package com.safeluck.aaej.app.controller
|
|
import com.safeluck.aaej.api.extensions.format
|
import com.safeluck.aaej.api.extensions.getBigDecimal
|
import com.safeluck.aaej.api.extensions.getInt
|
import com.safeluck.aaej.api.extensions.getString
|
import com.safeluck.aaej.app.config.DBAlias
|
import com.safeluck.aaej.app.po.FileCoach
|
import com.safeluck.aaej.app.po.MobileSession
|
import com.safeluck.aaej.app.po.PSchoolInfo
|
import com.safeluck.aaej.base.dbhelper.impl.DBProxy
|
import com.safeluck.aaej.base.dbhelper.impl.DbHelper
|
import com.safeluck.aaej.base.dbhelper.impl.DbKey
|
import com.safeluck.aaej.base.redis.ObjectMapper
|
import com.safeluck.aaej.base.utils.DefaultGson
|
import com.safeluck.aaej.base.vo.JsonResult
|
import com.safeluck.apis.push.PassThroughMessage
|
import com.safeluck.apis.push.PushMessage
|
import jline.ANSIBuffer
|
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.logging.LogFactory
|
import org.springframework.beans.BeanUtils
|
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.cache.annotation.Cacheable
|
import org.springframework.context.ApplicationEventPublisher
|
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RestController
|
import java.math.BigDecimal
|
import java.util.HashMap
|
|
@RestController
|
class HelloWorldController {
|
@Autowired
|
internal lateinit var dbHelper: DbHelper
|
@Autowired
|
internal lateinit var dbProxy: DBProxy
|
|
@Autowired
|
lateinit var applicationEventPublisher: ApplicationEventPublisher
|
|
|
// @Autowired
|
var objectMapper: ObjectMapper = ObjectMapper()
|
|
private val logger = LogFactory.getLog(this.javaClass)
|
@RequestMapping("/hello")
|
fun index(): Any {
|
|
val hashMap = HashMap<String,Any>()
|
hashMap.put("key1", "hello world111122")
|
hashMap.put("key2", "hello world222222221212")
|
hashMap.put("key2322",java.util.Date())
|
|
// logger.info(DefaultGson.get().toJson(JsonResult.build(hashMap)))
|
// logger.info(DefaultGson.get().toJson(JsonResult.failed("登录失败")))
|
// logger.info(DefaultGson.get().toJson(JsonResult.success()))
|
//
|
// dbProxy.executebKey(DBAlias.center){
|
//
|
// val row = dbHelper.findById(MobileSession::class.java,"2ab90db5-19ee-40b2-adc4-4db3fa26d64e")
|
// logger.info(objectMapper.writeValueAsString(row))
|
// val session = tokenService.getSession("2ab90db5-19ee-40b2-adc4-4db3fa26d64e")
|
// session!!.ayid = "11111"
|
// tokenService.updateSession(session)
|
// }
|
//
|
// var row = configService.getConfig2("123")
|
//
|
//
|
// val info = configService.getPPASIndex("41050001")
|
// logger.info(info)
|
|
// val message = PushMessage()
|
// message.body = "cehI测测测试"
|
// message.push_destination = PushMessage.TARGET_AAEJ;
|
// message.push_type= PushMessage.TYPE_STUDENT;
|
// message.push_id = "13118092488"
|
// message.url = "http://www.aaej.cn"
|
// applicationEventPublisher.publishEvent(message);
|
|
// applicationEventPublisher.publishEvent(PassThroughMessage());
|
|
return hashMap
|
}
|
@RequestMapping("/test")
|
fun test(): JsonResult<*> {
|
val p_school = dbHelper.findById(PSchoolInfo::class.java,BigDecimal("5000150100000000448"))
|
|
val json = ObjectMapper().writeValueAsString(p_school)
|
logger.info(json)
|
|
|
return JsonResult.build(p_school)
|
|
// return JsonResult.build(schoolService.getSchoolList(null,null,0,1,10,null))
|
}
|
|
fun execute(action:(s:String)->Unit)
|
{}
|
|
fun Image(action:()->Unit)
|
{
|
dbProxy.executebKey("image",action)
|
}
|
|
|
|
@RequestMapping("/test2")
|
fun test2(): JsonResult<*> {
|
|
val list = ArrayList<Map<Any?,Any?>>()
|
|
val result = list.first { it.getString("id") == "111" }
|
|
val list2 = list.map{
|
val map = HashMap<Any?,Any?>()
|
map.put("id",it.getString("id"))
|
map
|
}.forEach {
|
it["col_new"] = ""
|
}
|
|
|
return JsonResult.success()
|
}
|
|
@DbKey(DBAlias.Image)
|
fun executeInDb()
|
{
|
//在image执行sql
|
|
}
|
@Cacheable
|
fun executeWithCache()
|
{
|
//缓存函数返回数据 用redis
|
}
|
@Cacheable(cacheManager = "caffeineCacheManager")
|
fun executeWithCache2()
|
{
|
//缓存函数返回数据 用本地内存
|
}
|
|
|
}
|