From c33d5a6de26200e58ab9828670fc435d5212d702 Mon Sep 17 00:00:00 2001 From: "OUMYYE\\Administrator" Date: Tue, 23 Jan 2024 17:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AD=A6=E5=91=98=E5=85=B3?= =?UTF-8?q?=E8=81=94=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biutag/entity/system/PoliceDepart.java | 27 ++++++ .../biutag/entity/system/PolicePosition.java | 27 ++++++ .../com/biutag/entity/system/PoliceRole.java | 27 ++++++ .../mapper/system/PoliceDepartMapper.java | 15 +++ .../mapper/system/PolicePositionMapper.java | 18 ++++ .../mapper/system/PoliceRoleMapper.java | 15 +++ .../lan/service/IPoliceUserService.java | 82 +++++++++++++--- .../service/impl/PoliceUserServiceImpl.java | 93 +++++++++++++++++-- 8 files changed, 279 insertions(+), 25 deletions(-) create mode 100644 mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java create mode 100644 mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java create mode 100644 mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java create mode 100644 mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java create mode 100644 mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java create mode 100644 mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java diff --git a/mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java b/mailbox-common/src/main/java/com/biutag/entity/system/PoliceDepart.java new file mode 100644 index 0000000..3b4d5be --- /dev/null +++ b/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; + +} diff --git a/mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java b/mailbox-common/src/main/java/com/biutag/entity/system/PolicePosition.java new file mode 100644 index 0000000..5067bc2 --- /dev/null +++ b/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; + +} diff --git a/mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java b/mailbox-common/src/main/java/com/biutag/entity/system/PoliceRole.java new file mode 100644 index 0000000..fe068e2 --- /dev/null +++ b/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; + +} diff --git a/mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java b/mailbox-common/src/main/java/com/biutag/mapper/system/PoliceDepartMapper.java new file mode 100644 index 0000000..31dfd9a --- /dev/null +++ b/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 { + + +} diff --git a/mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java b/mailbox-common/src/main/java/com/biutag/mapper/system/PolicePositionMapper.java new file mode 100644 index 0000000..8e5bb80 --- /dev/null +++ b/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 { + + +} diff --git a/mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java b/mailbox-common/src/main/java/com/biutag/mapper/system/PoliceRoleMapper.java new file mode 100644 index 0000000..5b560b4 --- /dev/null +++ b/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 { + + +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java index 35c7ec5..52d9843 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/IPoliceUserService.java +++ b/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 + * @author */ PageResult list(PageValidate pageValidate, PoliceUserSearchValidate searchValidate); - - List all(PoliceUserSearchValidate searchValidate); + List searchPoliceUserList(String searchName); - List 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 departIds); + + + /** + * 批量写入警员岗位关联表 + * + * @param empNo 警警号 + * @param positionIds 部门ID组 + * @author + */ + void batchSavePositionByEmpNo(String empNo, List positionIds); + + /** + * 批量写入警员角色关联表 + * + * @param empNo 警警号 + * @param roleIds 角色组 + * @author + */ + void batchSaveRoleByEmpNo(String empNo, List 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); } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java index e0b9227..6d5e763 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/PoliceUserServiceImpl.java +++ b/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() .select(field) .eq("is_delete", 0) .eq("emp_no", createValidate.getEmpNo()) - .last("limit 1")), "账号已存在换一个吧!"); + .last("limit 1")), "警号已存在换一个吧!"); Assert.isNull(policeUserMapper.selectOne(new QueryWrapper() .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() .select(field) .eq("id", updateValidate.getId()) .eq("is_delete", 0) .last("limit 1")), "账号不存在了!"); - Assert.isNull(policeUserMapper.selectOne(new QueryWrapper() - .select(field) - .eq("is_delete", 0) - .eq("emp_no", updateValidate.getEmpNo()) - .ne("id", updateValidate.getId()) - .last("limit 1")), "警号已存在换一个吧!"); + Assert.isNull(policeUserMapper.selectOne(new QueryWrapper() .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() + .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 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 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 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().eq("emp_no", empNo)); + } + + @Override + public void batchDeleteDepartByEmpNo(String empNo) { + policeDepartMapper.delete(new QueryWrapper().eq("emp_no", empNo)); + } + + @Override + public void batchDeleteRoleByEmpNo(String empNo) { + policeRoleMapper.delete(new QueryWrapper().eq("emp_no", empNo)); + } + + + }