DictDataServiceImpl.java
4.81 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package com.huaheng.pc.system.dict.service;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.system.dict.domain.DictData;
import com.huaheng.pc.system.dict.mapper.DictDataMapper;
import java.util.ArrayList;
import java.util.List;
/**
* 字典 业务层处理
*
* @author huaheng
*/
@Service
public class DictDataServiceImpl implements IDictDataService
{
@Autowired
private DictDataMapper dictDataMapper;
/**
* 根据条件分页查询字典数据
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
@Override
public List<DictData> selectDictDataList(DictData dictData)
{
if (dictData.getWarehouseCode() == null) {
dictData.setWarehouseCode(ShiroUtils.getWarehouseCode());
}
return dictDataMapper.selectDictDataList(dictData);
}
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public List<DictData> selectDictDataByType(String dictType)
{
return dictDataMapper.selectDictDataByType(ShiroUtils.getWarehouseCode(), dictType);
}
/**
* 根据字典类型和字典键值查询字典数据信息
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典标签
*/
@Override
public String selectDictLabel(String dictType, String dictValue)
{
return dictDataMapper.selectDictLabel(ShiroUtils.getWarehouseCode(), dictType, dictValue);
}
/**
* 根据字典数据ID查询信息
*
* @param id 字典数据ID
* @return 字典数据
*/
@Override
public DictData selectDictDataById(Integer id)
{
return dictDataMapper.selectDictDataById(ShiroUtils.getWarehouseCode(), id);
}
/**
* 通过字典ID删除字典数据信息
*
* @param id 字典数据ID
* @return 结果
*/
@Override
public int deleteDictDataById(Integer id)
{
return dictDataMapper.deleteDictDataById(ShiroUtils.getWarehouseCode(), id);
}
/**
* 批量删除字典数据
*
* @param ids 需要删除的数据
* @return 结果
*/
@Override
public int deleteDictDataByIds(String ids)
{
return dictDataMapper.deleteDictDataByIds(ShiroUtils.getWarehouseCode(), Convert.toStrArray(ids));
}
/**
* 新增保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public int insertDictData(DictData dictData)
{
if (dictData.getWarehouseCode() == null) {
dictData.setWarehouseCode(ShiroUtils.getWarehouseCode());
}
dictData.setCreateBy(ShiroUtils.getLoginName());
return dictDataMapper.insertDictData(dictData);
}
/**
* 修改保存字典数据信息
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public int updateDictData(DictData dictData)
{
dictData.setWarehouseCode(ShiroUtils.getWarehouseCode());
dictData.setUpdateBy(ShiroUtils.getLoginName());
return dictDataMapper.updateDictData(dictData);
}
/**
* 验证指定仓库id的code是否存在
* @param dictValue
* @param type
* @return
*/
@Override
public Boolean checkConfig(String type, String dictValue){
DictData dictData = new DictData();
dictData.setWarehouseCode(ShiroUtils.getWarehouseCode());
dictData.setDictType(type);
dictData.setDictValue(dictValue);
Integer id = dictDataMapper.checkConfig(dictData);
if (id == null) {
return false;
} else {
return true;
}
}
/**
* 根据warehouseId删除DictData
* @param warehouseCode
* @return
*/
@Override
public int deleteDictDataByWarehouseCode(String warehouseCode){
return dictDataMapper.deleteDictDataByWarehouseCode(warehouseCode);
}
@Override
public int insertDictDatas(List<DictData> dictDatas)
{
List<DictData> dictDataList=new ArrayList<>();
for(DictData dictData: dictDatas) {
if (dictData.getWarehouseCode() == null) {
dictData.setWarehouseCode(ShiroUtils.getWarehouseCode());
}
dictData.setCreateBy(ShiroUtils.getLoginName());
dictDataList.add(dictData);
}
return dictDataMapper.insertDictDatas(dictDataList);
}
@Override
public DictData selectModel(DictData dictData) {
return dictDataMapper.selectModel(dictData);
}
}