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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package cn.flightfeather.supervision.lightshare.repository.impl
 
import cn.flightfeather.supervision.domain.entity.BaseInfo
import cn.flightfeather.supervision.domain.entity.Userinfo
import cn.flightfeather.supervision.domain.enumeration.DistrictType
import cn.flightfeather.supervision.domain.mapper.BaseInfoMapper
import cn.flightfeather.supervision.domain.mapper.UserinfoMapper
import cn.flightfeather.supervision.domain.repository.UserInfoRep
import cn.flightfeather.supervision.lightshare.vo.UserSearchCondition
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 UserInfoRepositoryImplTest() {
 
    @Autowired
    lateinit var userInfoRep: UserInfoRep
 
    @Autowired
    lateinit var userinfoMapper: UserinfoMapper
 
    @Autowired
    lateinit var baseInfoMapper: BaseInfoMapper
 
    @Test
    fun foo1() {
        val c = UserSearchCondition().apply {
//            provinceCode = "310000"
//            cityCode = "310100"
            districtName = "静安区"
//            townCode = "310106019"
            area
            mcName
            userTypeId = 3
            sceneTypes = listOf("1")
        }
        val r = userInfoRep.searchUser(c)
        println(r)
    }
 
    @Test
    fun foo2() {
        userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
            createCriteria().andEqualTo("usertype", "政府部门")
        }).forEach {
            val baseInfo = BaseInfo().apply {
                biGuid = it?.guid
                biName = it?.realname
                biProvinceCode = "310000"
                biProvinceName = "上海市"
                biCityCode = "310100"
                biCityName = "上海市"
                biDistrictCode = DistrictType.getCode(it?.extension1)
                biDistrictName = it?.extension1
                biRemark = it?.usertype
            }
            val b = baseInfoMapper.selectOne(BaseInfo().apply { biGuid = it?.guid })
            if (b == null) {
                baseInfoMapper.insert(baseInfo)
            } else {
                baseInfoMapper.updateByPrimaryKey(baseInfo)
            }
        }
    }
}