package cn.flightfeather.supervision.lightshare.service.impl
|
|
import cn.flightfeather.supervision.domain.ds1.entity.Gittype
|
import cn.flightfeather.supervision.domain.ds1.mapper.GittypeMapper
|
import cn.flightfeather.supervision.lightshare.service.GittypeService
|
import cn.flightfeather.supervision.lightshare.vo.GittypeVo
|
import org.springframework.beans.BeanUtils
|
import org.springframework.stereotype.Service
|
import tk.mybatis.mapper.entity.Example
|
import tk.mybatis.mapper.util.StringUtil
|
|
@Service
|
class GittypeServiceImpl(val gittypeMapper: GittypeMapper):GittypeService {
|
|
//根据传入gittype条件查询
|
override fun search(gittype: Gittype): List<GittypeVo> {
|
val gittypeVos = mutableListOf<GittypeVo>()
|
val name = gittype.name ?: ""
|
val example = Example(Gittype::class.java)
|
val criteria = example.createCriteria()
|
if (StringUtil.isNotEmpty(gittype.type)) {
|
criteria.andEqualTo("type", gittype.type)
|
}
|
//like查询name
|
criteria.andLike("name", "%$name%")
|
val re = gittypeMapper.selectByExample(example)
|
if (re.isNotEmpty()) {
|
re.forEach {
|
val gittypeVo = GittypeVo()
|
BeanUtils.copyProperties(it, gittypeVo)
|
gittypeVos.add(gittypeVo)
|
}
|
}
|
return gittypeVos
|
}
|
|
override fun findOne(id: String): Gittype = gittypeMapper.selectByPrimaryKey(id)
|
|
override fun findAll(): MutableList<Gittype> = gittypeMapper.selectAll()
|
|
override fun save(gittype: Gittype): Int = gittypeMapper.insert(gittype)
|
|
override fun update(gittype: Gittype): Int = gittypeMapper.updateByPrimaryKey(gittype)
|
|
override fun delete(id: String): Int = gittypeMapper.deleteByPrimaryKey(id)
|
}
|