| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | import cn.flightfeather.supervision.domain.ds1.entity.District |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Town |
| | | import cn.flightfeather.supervision.domain.ds1.mapper.DistrictMapper |
| | | import cn.flightfeather.supervision.domain.ds1.mapper.TownMapper |
| | | import cn.flightfeather.supervision.lightshare.service.TownService |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | |
| | | @Service |
| | | class TownServiceImpl(val townMapper: TownMapper) : TownService { |
| | | class TownServiceImpl(val townMapper: TownMapper, private val districtMapper: DistrictMapper) : TownService { |
| | | override fun findOne(id: String): Town = townMapper.selectByPrimaryKey(id) |
| | | |
| | | override fun findAll(): MutableList<Town> = townMapper.selectAll() |
| | |
| | | override fun update(town: Town): Int = townMapper.updateByPrimaryKey(town) |
| | | |
| | | override fun delete(id: String): Int = townMapper.deleteByPrimaryKey(id) |
| | | |
| | | override fun getByDistrict(districtCode: String): List<Town> { |
| | | var result = mutableListOf<Town>() |
| | | districtMapper.selectByExample(Example(District::class.java).apply { |
| | | createCriteria().andEqualTo("districtcode", districtCode) |
| | | })?.takeIf { it.isNotEmpty() }?.get(0)?.let { |
| | | result = townMapper.selectByExample(Example(Town::class.java).apply { |
| | | createCriteria().andEqualTo("districtid", it.districtid) |
| | | }) |
| | | } |
| | | return result |
| | | } |
| | | } |