|
|
|
@ -45,6 +45,14 @@ public class PoliceUserServiceImpl implements IPoliceUserService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
RoleMapper roleMapper; |
|
|
|
RoleMapper roleMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
PolicePositionMapper policePositionMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
PoliceDepartMapper policeDepartMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
PoliceRoleMapper policeRoleMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
IPermService iPermService; |
|
|
|
IPermService iPermService; |
|
|
|
|
|
|
|
|
|
|
|
@ -303,12 +311,12 @@ public class PoliceUserServiceImpl implements IPoliceUserService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void add(PoliceUserCreateValidate createValidate) { |
|
|
|
public void add(PoliceUserCreateValidate createValidate) { |
|
|
|
String[] field = {"id", "username", "nickname"}; |
|
|
|
String[] field = {"id", "emp_no","username", "id_code"}; |
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
.select(field) |
|
|
|
.select(field) |
|
|
|
.eq("is_delete", 0) |
|
|
|
.eq("is_delete", 0) |
|
|
|
.eq("emp_no", createValidate.getEmpNo()) |
|
|
|
.eq("emp_no", createValidate.getEmpNo()) |
|
|
|
.last("limit 1")), "账号已存在换一个吧!"); |
|
|
|
.last("limit 1")), "警号已存在换一个吧!"); |
|
|
|
|
|
|
|
|
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
.select(field) |
|
|
|
.select(field) |
|
|
|
@ -326,8 +334,11 @@ public class PoliceUserServiceImpl implements IPoliceUserService { |
|
|
|
PoliceUser model = new PoliceUser(); |
|
|
|
PoliceUser model = new PoliceUser(); |
|
|
|
|
|
|
|
|
|
|
|
model.setRoleIds(ListUtils.listToStringByInt(createValidate.getRoleIds(), ",")); |
|
|
|
model.setRoleIds(ListUtils.listToStringByInt(createValidate.getRoleIds(), ",")); |
|
|
|
|
|
|
|
this.batchSaveRoleByEmpNo(createValidate.getEmpNo(),createValidate.getRoleIds()); |
|
|
|
model.setDeptIds(ListUtils.listToStringByInt(createValidate.getDeptIds(), ",")); |
|
|
|
model.setDeptIds(ListUtils.listToStringByInt(createValidate.getDeptIds(), ",")); |
|
|
|
|
|
|
|
this.batchSaveDepartByEmpNo(createValidate.getEmpNo(),createValidate.getDeptIds()); |
|
|
|
model.setPostIds(ListUtils.listToStringByInt(createValidate.getPostIds(), ",")); |
|
|
|
model.setPostIds(ListUtils.listToStringByInt(createValidate.getPostIds(), ",")); |
|
|
|
|
|
|
|
this.batchSavePositionByEmpNo(createValidate.getEmpNo(),createValidate.getPostIds()); |
|
|
|
model.setEmpNo(createValidate.getEmpNo()); |
|
|
|
model.setEmpNo(createValidate.getEmpNo()); |
|
|
|
model.setName(createValidate.getName()); |
|
|
|
model.setName(createValidate.getName()); |
|
|
|
model.setAvatar(avatar); |
|
|
|
model.setAvatar(avatar); |
|
|
|
@ -356,19 +367,14 @@ public class PoliceUserServiceImpl implements IPoliceUserService { |
|
|
|
throw new OperateException("您无权限编辑系统管理员!"); |
|
|
|
throw new OperateException("您无权限编辑系统管理员!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String[] field = {"id", "name", "emp_no"}; |
|
|
|
String[] field = {"id", "id_code", "emp_no, role_ids, post_ids, dept_ids"}; |
|
|
|
Assert.notNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
Assert.notNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
.select(field) |
|
|
|
.select(field) |
|
|
|
.eq("id", updateValidate.getId()) |
|
|
|
.eq("id", updateValidate.getId()) |
|
|
|
.eq("is_delete", 0) |
|
|
|
.eq("is_delete", 0) |
|
|
|
.last("limit 1")), "账号不存在了!"); |
|
|
|
.last("limit 1")), "账号不存在了!"); |
|
|
|
|
|
|
|
|
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
|
|
|
|
.select(field) |
|
|
|
|
|
|
|
.eq("is_delete", 0) |
|
|
|
|
|
|
|
.eq("emp_no", updateValidate.getEmpNo()) |
|
|
|
|
|
|
|
.ne("id", updateValidate.getId()) |
|
|
|
|
|
|
|
.last("limit 1")), "警号已存在换一个吧!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
.select(field) |
|
|
|
.select(field) |
|
|
|
@ -376,17 +382,33 @@ public class PoliceUserServiceImpl implements IPoliceUserService { |
|
|
|
.eq("id_code", updateValidate.getIdCode()) |
|
|
|
.eq("id_code", updateValidate.getIdCode()) |
|
|
|
.ne("id", updateValidate.getId()) |
|
|
|
.ne("id", updateValidate.getId()) |
|
|
|
.last("limit 1")), "身份证已存在换一个吧!"); |
|
|
|
.last("limit 1")), "身份证已存在换一个吧!"); |
|
|
|
|
|
|
|
PoliceUser policeUser =policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
|
|
|
|
.select(field) |
|
|
|
|
|
|
|
.eq("is_delete", 0) |
|
|
|
|
|
|
|
.eq("emp_no", updateValidate.getEmpNo()) |
|
|
|
|
|
|
|
.eq("id", updateValidate.getId()) |
|
|
|
|
|
|
|
.last("limit 1")); |
|
|
|
|
|
|
|
Assert.notNull(policeUser, "警号已存在换一个吧!"); |
|
|
|
PoliceUser model = new PoliceUser(); |
|
|
|
PoliceUser model = new PoliceUser(); |
|
|
|
model.setId(updateValidate.getId()); |
|
|
|
model.setId(updateValidate.getId()); |
|
|
|
if(StringUtils.isNotNull(updateValidate.getRoleIds())) { |
|
|
|
if(StringUtils.isNotNull(updateValidate.getRoleIds())) { |
|
|
|
model.setRoleIds(ListUtils.listToStringByInt(updateValidate.getRoleIds(), ",")); |
|
|
|
model.setRoleIds(ListUtils.listToStringByInt(updateValidate.getRoleIds(), ",")); |
|
|
|
|
|
|
|
if(!policeUser.getRoleIds().equals(model.getRoleIds())){ |
|
|
|
|
|
|
|
this.batchSaveRoleByEmpNo(updateValidate.getEmpNo(),updateValidate.getRoleIds()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotNull(updateValidate.getDeptIds())) { |
|
|
|
if(StringUtils.isNotNull(updateValidate.getDeptIds())) { |
|
|
|
model.setDeptIds(ListUtils.listToStringByInt(updateValidate.getDeptIds(), ",")); |
|
|
|
model.setDeptIds(ListUtils.listToStringByInt(updateValidate.getDeptIds(), ",")); |
|
|
|
|
|
|
|
if(!policeUser.getDeptIds().equals(model.getDeptIds())){ |
|
|
|
|
|
|
|
this.batchSaveDepartByEmpNo(updateValidate.getEmpNo(),updateValidate.getDeptIds()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.isNotNull(updateValidate.getPostIds())) { |
|
|
|
if(StringUtils.isNotNull(updateValidate.getPostIds())) { |
|
|
|
model.setPostIds(ListUtils.listToStringByInt(updateValidate.getPostIds(), ",")); |
|
|
|
model.setPostIds(ListUtils.listToStringByInt(updateValidate.getPostIds(), ",")); |
|
|
|
|
|
|
|
if(!policeUser.getPostIds().equals(model.getPostIds())){ |
|
|
|
|
|
|
|
this.batchSavePositionByEmpNo(updateValidate.getEmpNo(),updateValidate.getPostIds()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
model.setName(updateValidate.getName()); |
|
|
|
model.setName(updateValidate.getName()); |
|
|
|
@ -509,4 +531,55 @@ public class PoliceUserServiceImpl implements IPoliceUserService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchSaveDepartByEmpNo(String empNo, List<Integer> departIds) { |
|
|
|
|
|
|
|
this.batchDeleteDepartByEmpNo(empNo); |
|
|
|
|
|
|
|
for (Integer departId : departIds) { |
|
|
|
|
|
|
|
PoliceDepart model = new PoliceDepart(); |
|
|
|
|
|
|
|
model.setEmpNo(empNo); |
|
|
|
|
|
|
|
model.setDepartId(departId.toString()); |
|
|
|
|
|
|
|
policeDepartMapper.insert(model); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchSavePositionByEmpNo(String empNo, List<Integer> positionIds) { |
|
|
|
|
|
|
|
this.batchDeletePositionsByEmpNo(empNo); |
|
|
|
|
|
|
|
for (Integer positionId : positionIds) { |
|
|
|
|
|
|
|
PolicePosition model = new PolicePosition(); |
|
|
|
|
|
|
|
model.setEmpNo(empNo); |
|
|
|
|
|
|
|
model.setPositionId(positionId.toString()); |
|
|
|
|
|
|
|
policePositionMapper.insert(model); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchSaveRoleByEmpNo(String empNo, List<Integer> roleIds) { |
|
|
|
|
|
|
|
this.batchDeleteRoleByEmpNo(empNo); |
|
|
|
|
|
|
|
for (Integer roleId : roleIds) { |
|
|
|
|
|
|
|
PoliceRole model = new PoliceRole(); |
|
|
|
|
|
|
|
model.setEmpNo(empNo); |
|
|
|
|
|
|
|
model.setRoleId(roleId.toString()); |
|
|
|
|
|
|
|
policeRoleMapper.insert(model); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchDeletePositionsByEmpNo(String empNo) { |
|
|
|
|
|
|
|
policePositionMapper.delete(new QueryWrapper<PolicePosition>().eq("emp_no", empNo)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchDeleteDepartByEmpNo(String empNo) { |
|
|
|
|
|
|
|
policeDepartMapper.delete(new QueryWrapper<PoliceDepart>().eq("emp_no", empNo)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void batchDeleteRoleByEmpNo(String empNo) { |
|
|
|
|
|
|
|
policeRoleMapper.delete(new QueryWrapper<PoliceRole>().eq("emp_no", empNo)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|