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
|
// }
|
}
|
}
|