feiyu02
2026-01-19 53ce8de426561e7a43847afda23b5e24e6f76c4e
src/main/kotlin/cn/flightfeather/supervision/domain/repository/UserConfigRep.kt
@@ -1,10 +1,13 @@
package cn.flightfeather.supervision.domain.repository
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.domain.entity.BaseInfo
import cn.flightfeather.supervision.domain.entity.UserConfig
import cn.flightfeather.supervision.domain.entity.UserSetting
import cn.flightfeather.supervision.domain.entity.Userinfo
import cn.flightfeather.supervision.domain.mapper.BaseInfoMapper
import cn.flightfeather.supervision.domain.mapper.UserConfigMapper
import cn.flightfeather.supervision.domain.mapper.UserSettingMapper
import cn.flightfeather.supervision.domain.mapper.UserinfoMapper
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
@@ -14,6 +17,7 @@
    private val userConfigMapper: UserConfigMapper,
    private val userinfoMapper: UserinfoMapper,
    private val baseInfoMapper: BaseInfoMapper,
    private val userSettingMapper: UserSettingMapper,
) {
    fun select(configId: Int): UserConfig? {
@@ -79,4 +83,18 @@
        return userConfigMapper.selectByPrimaryKey(configId)
    }
    fun getUserSetting(userId: String): UserSetting? {
        val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: throw BizException("该用户不存在")
        val baseInfo = baseInfoMapper.selectByPrimaryKey(userId)
        val userSetting = UserSetting().apply {
            userTypeId = userInfo.usertypeid?.toInt()
            provinceName = baseInfo?.biProvinceName
            cityName = baseInfo?.biCityName
            districtName = baseInfo?.biDistrictName ?: userInfo.extension1
            sceneTypeId = userInfo.extension2?.toInt()
        }
        val res = userSettingMapper.select(userSetting)
        return if (res.isNotEmpty()) res[0] else null
    }
}