feiyu02
2026-01-21 fe031e01cc1737c2f05a133fde7c36c7a2a7b4b4
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,19 @@
        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.selectBestConfig(userSetting)
//        return if (res.isNotEmpty()) res[0] else null
        return res
    }
}