feiyu02
2024-01-10 30a53b41f09d2eefd33513a409d472c2166ba1ea
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
47
48
49
50
package cn.flightfeather.supervision.lightshare.service.impl
 
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationrule
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule
import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationruleMapper
import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationsubruleMapper
import cn.flightfeather.supervision.lightshare.service.EvaluationsubruleService
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
 
@Service
class EvaluationsubruleServiceImpl (
        val evaluationsubruleMapper: EvaluationsubruleMapper,
        val evaluationruleMapper: EvaluationruleMapper
):EvaluationsubruleService {
 
    override fun findOne(id: String): Evaluationsubrule = evaluationsubruleMapper.selectByPrimaryKey(id)
 
    override fun findAll(): MutableList<Evaluationsubrule> = evaluationsubruleMapper.selectAll()
 
    override fun save(evaluationsubrule: Evaluationsubrule): Int = evaluationsubruleMapper.insert(evaluationsubrule)
 
    override fun update(evaluationsubrule: Evaluationsubrule): Int = evaluationsubruleMapper.updateByPrimaryKey(evaluationsubrule)
 
    override fun delete(id: String): Int = evaluationsubruleMapper.deleteByPrimaryKey(id)
 
    override fun findByRuleId(erguid: String): List<Evaluationsubrule> {
        val example = Example(Evaluationsubrule::class.java)
        val criteria = example.createCriteria()
        criteria.andEqualTo("erguid", erguid)
        example.orderBy("extension1").desc()
        return evaluationsubruleMapper.selectByExample(example)
    }
 
    override fun search(districtCode: String, sceneTypeId: String, version: String?): List<Evaluationsubrule> {
        val result = mutableListOf<Evaluationsubrule>()
        evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
            createCriteria().andEqualTo("districtcode", districtCode)
                    .andEqualTo("scensetypeid", sceneTypeId)
        }).takeIf { it.isNotEmpty() }?.get(0)?.let {rule ->
            evaluationsubruleMapper.selectByExample(Example(Evaluationsubrule::class.java).apply {
                createCriteria().andEqualTo("erguid", rule.guid)
            })
        }?.also {
            result.addAll(it)
        }
 
        return result
    }
}