|
|
@@ -170,30 +170,6 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
170
|
170
|
return result > 0;
|
|
171
|
171
|
}
|
|
172
|
172
|
|
|
173
|
|
- /**
|
|
174
|
|
- * 校验部门名称是否唯一(全局未删除范围内唯一)
|
|
175
|
|
- *
|
|
176
|
|
- * @param dept 部门信息
|
|
177
|
|
- * @return 结果
|
|
178
|
|
- */
|
|
179
|
|
- @Override
|
|
180
|
|
- public boolean checkDeptNameUnique(SysDept dept)
|
|
181
|
|
- {
|
|
182
|
|
- if (dept == null || StringUtils.isEmpty(dept.getDeptName()))
|
|
183
|
|
- {
|
|
184
|
|
- return UserConstants.UNIQUE;
|
|
185
|
|
- }
|
|
186
|
|
- String deptName = dept.getDeptName().trim();
|
|
187
|
|
- dept.setDeptName(deptName);
|
|
188
|
|
- Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
|
189
|
|
- SysDept info = deptMapper.checkDeptNameUnique(deptName, dept.getParentId());
|
|
190
|
|
- if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
|
|
191
|
|
- {
|
|
192
|
|
- return UserConstants.NOT_UNIQUE;
|
|
193
|
|
- }
|
|
194
|
|
- return UserConstants.UNIQUE;
|
|
195
|
|
- }
|
|
196
|
|
-
|
|
197
|
173
|
/**
|
|
198
|
174
|
* 校验部门是否有数据权限
|
|
199
|
175
|
*
|
|
|
@@ -223,9 +199,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
223
|
199
|
@Override
|
|
224
|
200
|
public int insertDept(SysDept dept)
|
|
225
|
201
|
{
|
|
226
|
|
- if (!checkDeptNameUnique(dept))
|
|
|
202
|
+ if (dept != null && StringUtils.isNotEmpty(dept.getDeptName()))
|
|
227
|
203
|
{
|
|
228
|
|
- throw new ServiceException("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
|
|
204
|
+ dept.setDeptName(dept.getDeptName().trim());
|
|
229
|
205
|
}
|
|
230
|
206
|
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
|
231
|
207
|
// 如果父节点不为正常状态,则不允许新增子节点
|
|
|
@@ -246,9 +222,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
246
|
222
|
@Override
|
|
247
|
223
|
public int updateDept(SysDept dept)
|
|
248
|
224
|
{
|
|
249
|
|
- if (!checkDeptNameUnique(dept))
|
|
|
225
|
+ if (dept != null && StringUtils.isNotEmpty(dept.getDeptName()))
|
|
250
|
226
|
{
|
|
251
|
|
- throw new ServiceException("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
|
|
227
|
+ dept.setDeptName(dept.getDeptName().trim());
|
|
252
|
228
|
}
|
|
253
|
229
|
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
|
254
|
230
|
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|