feiyu02
2025-09-12 dc4f12f66685260ac357997680e5f3fe723c3c4a
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
41
42
43
44
45
46
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)
}