FieldDictServiceImpl.java
2.08 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
59
60
61
62
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.field.QueryFieldsDTO;
import com.subsidy.model.FieldDictDO;
import com.subsidy.mapper.FieldDictMapper;
import com.subsidy.service.FieldDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import org.springframework.stereotype.Service;
/**
* <p>
* 行业字典表 服务实现类
* </p>
*
* @author Tuyp
* @since 2024-01-11
*/
@Service
public class FieldDictServiceImpl extends ServiceImpl<FieldDictMapper, FieldDictDO> implements FieldDictService {
public String addField(FieldDictDO fieldDictDO) {
Integer count = this.baseMapper.selectCount(new QueryWrapper<FieldDictDO>()
.lambda()
.eq(FieldDictDO::getFieldName, fieldDictDO.getFieldName()));
if (count > 0) {
throw new HttpException(11001);
}
this.baseMapper.insert(fieldDictDO);
return ConstantUtils.ADD_SUCCESS;
}
public String updateField(FieldDictDO fieldDictDO) {
Integer count = this.baseMapper.selectCount(new QueryWrapper<FieldDictDO>()
.lambda()
.eq(FieldDictDO::getFieldName, fieldDictDO.getFieldName())
.ne(FieldDictDO::getId, fieldDictDO.getId()));
if (count > 0) {
throw new HttpException(11001);
}
this.baseMapper.updateById(fieldDictDO);
return ConstantUtils.SET_SUCCESS;
}
public String deleteField(FieldDictDO fieldDictDO){
this.baseMapper.deleteById(fieldDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
public IPage queryFields(QueryFieldsDTO queryFieldsDTO){
Page pager = new Page(queryFieldsDTO.getPageNum(), queryFieldsDTO.getPageSize());
return this.baseMapper.queryFields(pager,queryFieldsDTO.getFieldName());
}
}