BusinessDictServiceImpl.java
1.87 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
56
57
58
package com.laowu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.laowu.common.exception.HttpException;
import com.laowu.mapper.BusinessDictMapper;
import com.laowu.model.BusinessDictDO;
import com.laowu.service.BusinessDictService;
import com.laowu.util.ConstantUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 经营范围 服务实现类
* </p>
*
* @author Tuyp
* @since 2023-02-20
*/
@Service
public class BusinessDictServiceImpl extends ServiceImpl<BusinessDictMapper, BusinessDictDO> implements BusinessDictService {
public String addBusiness(BusinessDictDO businessDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<BusinessDictDO>()
.lambda()
.eq(BusinessDictDO::getBusiness, businessDictDO.getBusiness()));
if (count > 0) {
throw new HttpException(60001);
}
this.baseMapper.insert(businessDictDO);
return ConstantUtils.ADD_SUCCESS;
}
public String updateBusiness(BusinessDictDO businessDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<BusinessDictDO>()
.lambda()
.eq(BusinessDictDO::getBusiness, businessDictDO.getBusiness())
.ne(BusinessDictDO::getBusiness, businessDictDO.getBusiness()));
if (count > 0) {
throw new HttpException(60001);
}
this.baseMapper.updateById(businessDictDO);
return ConstantUtils.ADD_SUCCESS;
}
public String deleteBusiness(BusinessDictDO businessDictDO) {
this.baseMapper.deleteById(businessDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
public List<BusinessDictDO> queryBusiness() {
return this.baseMapper.selectList(null);
}
}