feiyu02
2024-08-15 196bb14112448857a885e32dc4149e308e00b01a
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
package cn.flightfeather.supervision.lightshare.service.Impl
 
import cn.flightfeather.supervision.domain.entity.UserInfoWx
import cn.flightfeather.supervision.domain.mapper.PersonalInfoMapper
import cn.flightfeather.supervision.domain.mapper.UserInfoWxMapper
import cn.flightfeather.supervision.lightshare.service.WxUserService
import org.junit.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.test.context.junit4.SpringRunner
import tk.mybatis.mapper.entity.Example
 
@RunWith(SpringRunner::class)
@ExtendWith(SpringExtension::class)
@SpringBootTest
class WxUserServiceImplTest {
 
    @Autowired
    lateinit var wxUserService: WxUserService
 
    @Autowired
    lateinit var personalInfoMapper: PersonalInfoMapper
 
    @Autowired
    lateinit var userInfoWxMapper: UserInfoWxMapper
 
    @Test
    fun subscribeResult() {
        val msg = "{\"ToUserName\":\"gh_c60faa57000f\",\"FromUserName\":\"otZkc5cC55BtV2AFZdXMvBw0oJo8\",\"CreateTime\":1667377808,\"MsgType\":\"event\",\"Event\":\"subscribe_msg_popup_event\",\"List\":[{\"PopupScene\":\"0\",\"SubscribeStatusString\":\"accept\",\"TemplateId\":\"6JQFOJ12yBvKfRg_duSdwKiH5_J3LpICmz3Li-L1Cr8\"},{\"PopupScene\":\"0\",\"SubscribeStatusString\":\"accept\",\"TemplateId\":\"zPNMzF5WsshniJyl83DD-lDZtNvx7JyqLbKgqDl0qvU\"},{\"PopupScene\":\"0\",\"SubscribeStatusString\":\"accept\",\"TemplateId\":\"dqREi7vAd03OOirTgBGcm5aCihZJKBjVpiA8Kbu4B8w\"}]}"
        wxUserService.subscribeResult(msg)
    }
 
    @Test
    fun refreshPersonalInfo() {
        personalInfoMapper.selectAll().forEach {
            val uList = userInfoWxMapper.selectByExample(Example(UserInfoWx::class.java).apply {
                createCriteria().andEqualTo("piGuid", it?.piGuid)
            })
            if (uList.isNotEmpty()) {
                val u = uList[0]
                it?.piWxId = u.uiOpenId
                it?.piSceneId = u.uiGuid
                personalInfoMapper.updateByPrimaryKeySelective(it)
            }
        }
    }
}