11
zhouwei
2019-07-12 143f7be25ff19896e70ffc486999a64a3bc3b76f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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()
    {
        //缓存函数返回数据 用本地内存
    }
 
 
}