Browse Source

增加警员关联表

dev-zsy
OUMYYE\Administrator 2 years ago
parent
commit
c33d5a6de2
  1. 27
      mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java
  2. 27
      mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java
  3. 27
      mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java
  4. 15
      mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java
  5. 18
      mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java
  6. 15
      mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java
  7. 82
      mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java
  8. 93
      mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java

27
mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java

@ -0,0 +1,27 @@
package com.biutag.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("警员部门关联表")
public class PoliceDepart implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("警号")
private String empNo;
@ApiModelProperty("部门id")
private String departId;
}

27
mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java

@ -0,0 +1,27 @@
package com.biutag.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("警员角色关联表")
public class PolicePosition implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("警号")
private String empNo;
@ApiModelProperty("岗位id")
private String positionId;
}

27
mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java

@ -0,0 +1,27 @@
package com.biutag.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("警员角色关联表")
public class PoliceRole implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("警号")
private String empNo;
@ApiModelProperty("角色id")
private String roleId;
}

15
mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java

@ -0,0 +1,15 @@
package com.biutag.mapper.system;
import com.biutag.core.basics.IBaseMapper;
import com.biutag.entity.system.PoliceDepart;
import com.biutag.entity.system.PolicePosition;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统岗位Mapper
*/
@Mapper
public interface PoliceDepartMapper extends IBaseMapper<PoliceDepart> {
}

18
mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java

@ -0,0 +1,18 @@
package com.biutag.mapper.system;
import com.biutag.core.basics.IBaseMapper;
import com.biutag.entity.system.Dept;
import com.biutag.entity.system.PolicePosition;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 系统岗位Mapper
*/
@Mapper
public interface PolicePositionMapper extends IBaseMapper<PolicePosition> {
}

15
mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java

@ -0,0 +1,15 @@
package com.biutag.mapper.system;
import com.biutag.core.basics.IBaseMapper;
import com.biutag.entity.system.PoliceDepart;
import com.biutag.entity.system.PoliceRole;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统岗位Mapper
*/
@Mapper
public interface PoliceRoleMapper extends IBaseMapper<PoliceRole> {
}

82
mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java

@ -21,79 +21,131 @@ public interface IPoliceUserService {
/**
* 当前管理员
*
* @author
* @return SystemSelfVo
* @author
*/
PoliceUserSelvesVo self(Integer adminId);
/**
* 管理员详情
*
* @author
* @param id 主键参数
* @return PoliceUserDetailVo
* @author
*/
PoliceUserDetailVo detail(Integer id);
/**
* 管理员列表
*
* @author
* @param pageValidate 分页参数
* @param pageValidate 分页参数
* @param searchValidate 搜索参数
* @return PageResult<PoliceUserListedVo>
* @author
*/
PageResult<PoliceUserListedVo> list(PageValidate pageValidate, PoliceUserSearchValidate searchValidate);
List<PoliceUser> all(PoliceUserSearchValidate searchValidate);
List<PoliceUser> searchPoliceUserList(String searchName);
List<PoliceUser> searchPoliceUserList(String searchName);
/**
* 管理员新增
*
* @author
* @param createValidate 参数
* @author
*/
void add(PoliceUserCreateValidate createValidate);
/**
* 管理员编辑
*
* @author
* @param updateValidate 参数
* @param adminId 管理员ID
* @param adminId 管理员ID
* @author
*/
void edit(PoliceUserUpdateValidate updateValidate, Integer adminId);
/**
* 当前管理员更新
*
* @author
* @param upInfoValidate 参数
* @param adminId 管理员ID
* @param adminId 管理员ID
* @author
*/
void upInfo(PoliceUserUpInfoValidate upInfoValidate, Integer adminId);
/**
* 管理员删除
*
* @author
* @param id 主键参数
* @param id 主键参数
* @param adminId 管理员ID
* @author
*/
void del(Integer id, Integer adminId);
/**
* 管理员状态切换
*
* @author
* @param id 主键参数
* @author
*/
void disable(Integer id, Integer adminId);
/**
* 批量写入警员部门关联表
*
* @param empNo 警警号
* @param departIds 部门ID组
* @author
*/
void batchSaveDepartByEmpNo(String empNo, List<Integer> departIds);
/**
* 批量写入警员岗位关联表
*
* @param empNo 警警号
* @param positionIds 部门ID组
* @author
*/
void batchSavePositionByEmpNo(String empNo, List<Integer> positionIds);
/**
* 批量写入警员角色关联表
*
* @param empNo 警警号
* @param roleIds 角色组
* @author
*/
void batchSaveRoleByEmpNo(String empNo, List<Integer> roleIds);
/**
* 根据角色ID批量删除角色
*
* @param empNo 角色ID
* @author
*/
void batchDeletePositionsByEmpNo(String empNo);
/**
* 根据角色ID批量删除角色
*
* @param empNo 角色ID
* @author
*/
void batchDeleteDepartByEmpNo(String empNo);
/**
* 根据角色ID批量删除角色
*
* @param empNo 角色ID
* @author
*/
void batchDeleteRoleByEmpNo(String empNo);
}

93
mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java

@ -45,6 +45,14 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
@Resource
RoleMapper roleMapper;
@Resource
PolicePositionMapper policePositionMapper;
@Resource
PoliceDepartMapper policeDepartMapper;
@Resource
PoliceRoleMapper policeRoleMapper;
@Resource
IPermService iPermService;
@ -303,12 +311,12 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
*/
@Override
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>()
.select(field)
.eq("is_delete", 0)
.eq("emp_no", createValidate.getEmpNo())
.last("limit 1")), "号已存在换一个吧!");
.last("limit 1")), "号已存在换一个吧!");
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>()
.select(field)
@ -326,8 +334,11 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
PoliceUser model = new PoliceUser();
model.setRoleIds(ListUtils.listToStringByInt(createValidate.getRoleIds(), ","));
this.batchSaveRoleByEmpNo(createValidate.getEmpNo(),createValidate.getRoleIds());
model.setDeptIds(ListUtils.listToStringByInt(createValidate.getDeptIds(), ","));
this.batchSaveDepartByEmpNo(createValidate.getEmpNo(),createValidate.getDeptIds());
model.setPostIds(ListUtils.listToStringByInt(createValidate.getPostIds(), ","));
this.batchSavePositionByEmpNo(createValidate.getEmpNo(),createValidate.getPostIds());
model.setEmpNo(createValidate.getEmpNo());
model.setName(createValidate.getName());
model.setAvatar(avatar);
@ -356,19 +367,14 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
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>()
.select(field)
.eq("id", updateValidate.getId())
.eq("is_delete", 0)
.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>()
.select(field)
@ -376,17 +382,33 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
.eq("id_code", updateValidate.getIdCode())
.ne("id", updateValidate.getId())
.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();
model.setId(updateValidate.getId());
if(StringUtils.isNotNull(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())) {
model.setDeptIds(ListUtils.listToStringByInt(updateValidate.getDeptIds(), ","));
if(!policeUser.getDeptIds().equals(model.getDeptIds())){
this.batchSaveDepartByEmpNo(updateValidate.getEmpNo(),updateValidate.getDeptIds());
}
}
if(StringUtils.isNotNull(updateValidate.getPostIds())) {
model.setPostIds(ListUtils.listToStringByInt(updateValidate.getPostIds(), ","));
if(!policeUser.getPostIds().equals(model.getPostIds())){
this.batchSavePositionByEmpNo(updateValidate.getEmpNo(),updateValidate.getPostIds());
}
}
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));
}
}

Loading…
Cancel
Save