feiyu02
2024-11-21 90615ce702dde7f1d8fed373d8f3a96796ef1f2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cn.flightfeather.supervision.lightshare.service.impl
 
import cn.flightfeather.supervision.domain.ds1.entity.District
import cn.flightfeather.supervision.domain.ds1.mapper.DistrictMapper
import cn.flightfeather.supervision.lightshare.service.DistrictService
import cn.flightfeather.supervision.lightshare.vo.DistrictVo
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
 
@Service
class DistrictServiceImpl(val districtMapper: DistrictMapper) : DistrictService {
    //根据ID查询
    override fun findByID(id: String): DistrictVo  {
        val districtVo = DistrictVo()
        val district= districtMapper.selectByPrimaryKey(id.toInt())
        if (district != null)
            BeanUtils.copyProperties(district,districtVo)
        return districtVo
    }
 
    //查询全部
    override fun findAll(): MutableList<DistrictVo>  {
        val distrivtVoList = mutableListOf<DistrictVo>()
        val districtList = districtMapper.selectAll()
        if (!districtList.isEmpty()) {
            districtList.forEach {
                val districtVo = DistrictVo()
                BeanUtils.copyProperties(it,districtVo)
                distrivtVoList.add(districtVo)
            }
        }
        return distrivtVoList
    }
 
    override fun save(district: District): Int = districtMapper.insert(district)
 
    override fun update(district: District): Int = districtMapper.updateByPrimaryKey(district)
 
    override fun delete(id: String): Int = districtMapper.deleteByPrimaryKey(id.toInt())
}