package cn.flightfeather.supervision.lightshare.service.Impl
|
|
import cn.flightfeather.supervision.domain.entity.RestaurantBaseInfo
|
import cn.flightfeather.supervision.domain.entity.VehicleBaseInfo
|
import cn.flightfeather.supervision.domain.mapper.BaseInfoMapper
|
import cn.flightfeather.supervision.domain.mapper.RestaurantBaseInfoMapper
|
import cn.flightfeather.supervision.domain.mapper.VehicleBaseInfoMapper
|
import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator
|
import cn.flightfeather.supervision.lightshare.service.UserSpecialInfoService
|
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
|
import org.springframework.stereotype.Service
|
|
@Service
|
class UserSpecialInfoServiceImpl(
|
private val baseInfoMapper: BaseInfoMapper,
|
private val restaurantBaseInfoMapper: RestaurantBaseInfoMapper,
|
private val vehicleBaseInfoMapper: VehicleBaseInfoMapper
|
) : UserSpecialInfoService {
|
|
override fun findOneRestaurant(id: String): BaseResponse<RestaurantBaseInfo> {
|
val res = restaurantBaseInfoMapper.selectByPrimaryKey(id) ?: return BaseResponse(false, "用户id不存在")
|
return BaseResponse(true, data = res)
|
}
|
|
override fun saveRestaurant(info: RestaurantBaseInfo): BaseResponse<Int> {
|
if (info.rbGuid == null) return BaseResponse(false, "必须指定主键为用户id")
|
baseInfoMapper.selectByPrimaryKey(info.rbGuid) ?: return BaseResponse(false, "创建餐饮信息之前请先创建用户基本信息")
|
restaurantBaseInfoMapper.selectByPrimaryKey(info.rbGuid)?.run { return BaseResponse(false, "餐饮信息已存在,无法重复新建") }
|
val res = restaurantBaseInfoMapper.insert(info)
|
return if (res == 1) {
|
BaseResponse(true, data = res)
|
} else {
|
BaseResponse(false, "插入数据库失败", data = res)
|
}
|
}
|
|
override fun updateRestaurant(info: RestaurantBaseInfo): BaseResponse<Int> {
|
val res = restaurantBaseInfoMapper.updateByPrimaryKeySelective(info)
|
return if (res == 1) {
|
BaseResponse(true, data = res)
|
} else {
|
BaseResponse(false, "更新数据库失败", data = res)
|
}
|
}
|
|
override fun findOneVehicleRepair(id: String): BaseResponse<VehicleBaseInfo> {
|
val res = vehicleBaseInfoMapper.selectByPrimaryKey(id) ?: return BaseResponse(false, "用户id不存在")
|
return BaseResponse(true, data = res)
|
}
|
|
override fun saveVehicleRepair(info: VehicleBaseInfo): BaseResponse<Int> {
|
if (info.vbGuid == null) return BaseResponse(false, "必须指定主键为用户id")
|
baseInfoMapper.selectByPrimaryKey(info.vbGuid) ?: return BaseResponse(false, "创建汽修信息之前请先创建用户基本信息")
|
vehicleBaseInfoMapper.selectByPrimaryKey(info.vbGuid)?.run { return BaseResponse(false, "汽修信息已存在,无法重复新建") }
|
val res = vehicleBaseInfoMapper.insert(info)
|
return if (res == 1) {
|
BaseResponse(true, data = res)
|
} else {
|
BaseResponse(false, "插入数据库失败", data = res)
|
}
|
}
|
|
override fun updateVehicleRepair(info: VehicleBaseInfo): BaseResponse<Int> {
|
val res = vehicleBaseInfoMapper.updateByPrimaryKeySelective(info)
|
return if (res == 1) {
|
BaseResponse(true, data = res)
|
} else {
|
BaseResponse(false, "更新数据库失败", data = res)
|
}
|
}
|
}
|