YearDictServiceImpl.java
1.48 KB
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
51
52
53
54
55
package com.zhongzhi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhongzhi.common.exception.HttpException;
import com.zhongzhi.model.YearDictDO;
import com.zhongzhi.dao.YearDictDAO;
import com.zhongzhi.service.YearDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 年份字典表 服务实现类
* </p>
*
* @author DengMin
* @since 2023-04-11
*/
@Service
public class YearDictServiceImpl extends ServiceImpl<YearDictDAO, YearDictDO> implements YearDictService {
public List<YearDictDO> queryYears() {
return this.baseMapper.selectList(null);
}
public void updateYear(YearDictDO yearDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<YearDictDO>()
.lambda()
.eq(YearDictDO::getYear,yearDictDO.getYear())
.ne(YearDictDO::getId,yearDictDO.getId()));
if (count > 0 ){
throw new HttpException(90001);
}
this.baseMapper.updateById(yearDictDO);
}
public void addYear(YearDictDO yearDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<YearDictDO>()
.lambda()
.eq(YearDictDO::getYear,yearDictDO.getYear()));
if (count > 0 ){
throw new HttpException(90001);
}
yearDictDO.setStatus("1");
this.baseMapper.insert(yearDictDO);
}
}