package cn.flightfeather.supervision.lightshare.service.Impl
|
|
import cn.flightfeather.supervision.domain.entity.BaseInfo
|
import cn.flightfeather.supervision.domain.mapper.BaseInfoMapper
|
import cn.flightfeather.supervision.domain.mapper.UserinfoMapper
|
import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator
|
import cn.flightfeather.supervision.lightshare.service.BaseInfoService
|
import cn.flightfeather.supervision.lightshare.vo.BaseInfoVo
|
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
|
import cn.flightfeather.supervision.lightshare.vo.DataHead
|
import cn.flightfeather.supervision.lightshare.vo.UserSearchCondition
|
import com.github.pagehelper.PageHelper
|
import org.springframework.stereotype.Service
|
import java.util.*
|
|
@Service
|
class BaseInfoServiceImpl(
|
private val baseInfoMapper: BaseInfoMapper,
|
private val userinfoMapper: UserinfoMapper,
|
) : BaseInfoService {
|
|
override fun findOne(id: String): BaseResponse<BaseInfo> {
|
val res = baseInfoMapper.selectByPrimaryKey(id) ?: return BaseResponse(false, "用户id不存在")
|
return BaseResponse(true, data = res)
|
}
|
|
override fun save(info: BaseInfo): BaseResponse<Int> {
|
if (info.biGuid == null) return BaseResponse(false, "用户主键不能为空")
|
baseInfoMapper.selectByPrimaryKey(info.biGuid)?.run { return BaseResponse(false, "用户基本信息不能重复创建") }
|
userinfoMapper.selectByPrimaryKey(info.biGuid) ?: return BaseResponse(false, "该用户id账号不存在")
|
info.biCreateTime = Date()
|
info.biUpdateTime = info.biCreateTime
|
val res = baseInfoMapper.insert(info)
|
return if (res == 1) {
|
BaseResponse(true, data = res)
|
} else {
|
BaseResponse(false, "插入数据库失败", data = res)
|
}
|
}
|
|
override fun update(info: BaseInfo): BaseResponse<Int> {
|
info.biUpdateTime = Date()
|
val res = baseInfoMapper.updateByPrimaryKeySelective(info)
|
return if (res == 1) {
|
BaseResponse(true, data = res)
|
} else {
|
BaseResponse(false, "更新数据库失败", data = res)
|
}
|
}
|
|
override fun searchUser(condition: UserSearchCondition, page: Int, perPage: Int,): BaseResponse<List<BaseInfoVo?>> {
|
val p = PageHelper.startPage<BaseInfoVo>(page, perPage)
|
baseInfoMapper.searchUser(condition)
|
return BaseResponse(true, head = DataHead(p.pageNum, p.pages, p.total), data = p.result)
|
}
|
}
|