feiyu02
2025-08-14 f373bbf83d9d2a7e5f96118d7dcd658c9fea8bc8
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
package cn.flightfeather.supervision.domain.ds1.repository
 
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.Scense
import cn.flightfeather.supervision.domain.ds1.entity.Userinfo
import cn.flightfeather.supervision.domain.ds1.mapper.UserinfoMapper
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
 
/**
 * 飞羽监管用户信息数据库相关操作
 */
@Repository
class UserInfoSVRep(
    private val userinfoMapper: UserinfoMapper,
    private val sceneRep: SceneRep,
) {
 
    /**
     * 查找用户
     */
    fun findUser(sceneIdList: List<String?>): List<Userinfo?> {
        if (sceneIdList.isEmpty()) return emptyList()
        return userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
            createCriteria().andIn("dGuid", sceneIdList)
        })
    }
 
    fun findUser(sceneId: String?): Userinfo? {
        return try {
            userinfoMapper.selectOne(Userinfo().apply { dGuid = sceneId })
        } catch (e: Exception) {
            null
        }
    }
 
    /**
     * 模糊搜索用户
     * @param areaVo 查询区域范围
     * @param keyword 搜索关键字,匹配账户[Userinfo.acountname]和昵称[Userinfo.realname]
     * @param userType 用户类型,默认企业[Constant.UserType.ENTERPRISE]
     */
    fun searchUser(
        areaVo: AreaVo, keyword: String,
        userType: Constant.UserType = Constant.UserType.ENTERPRISE,
    ): List<Userinfo?> {
        return userinfoMapper.searchUser(areaVo, keyword, userType.value)
//        val userList = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
//            createCriteria().orLike("realname", "%${keyword}%")
//                .orLike("acountname", "%${keyword}%")
//        })
//        val sceneList = sceneRep.findSceneList(Scense().apply {
//            provincecode = areaVo.provincecode
//            citycode = areaVo.citycode
//            districtcode = areaVo.districtcode
//            towncode = areaVo.towncode
//            typeid = areaVo.scensetypeid?.toByteOrNull()
//            extension1 = if (areaVo.online == true) "1" else "0"
//        })
//        return userList.filter { u ->
//            val scene = sceneList.find { s ->
//                return@find s?.guid == u.dGuid
//            }
//            return@filter scene != null
//        }
    }
}