From 16e4db25c9051c9a8452a4812ee363268dfacd76 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Wed, 16 Oct 2024 18:45:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86--=E5=BA=93=E7=AE=A1=E5=91=98=E3=80=81=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E5=91=98=E7=9A=84=E7=BB=91=E5=AE=9A=E5=8F=8A=E8=A7=A3?= =?UTF-8?q?=E7=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/material/ma/MaTypeConfigDto.java | 28 +++++++ .../ma/controller/MaTypeConfigController.java | 84 +++++++++++++++++-- .../bonus/material/ma/domain/TypeKeeper.java | 5 ++ .../bonus/material/ma/domain/TypeRepair.java | 6 ++ .../material/ma/mapper/TypeKeeperMapper.java | 10 +++ .../material/ma/mapper/TypeRepairMapper.java | 7 ++ .../ma/service/ITypeKeeperService.java | 8 ++ .../ma/service/ITypeRepairService.java | 5 ++ .../service/impl/TypeKeeperServiceImpl.java | 13 ++- .../service/impl/TypeRepairServiceImpl.java | 14 +++- .../mapper/material/ma/TypeKeeperMapper.xml | 10 +++ .../mapper/material/ma/TypeRepairMapper.xml | 4 + 12 files changed, 185 insertions(+), 9 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/MaTypeConfigDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/MaTypeConfigDto.java index 66766743..4919a6cf 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/MaTypeConfigDto.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/MaTypeConfigDto.java @@ -1,8 +1,11 @@ package com.bonus.material.ma; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; +import javax.validation.constraints.NotNull; + /** * @author : 阮世耀 * @version : 1.0 @@ -14,10 +17,35 @@ import lombok.ToString; @ToString public class MaTypeConfigDto implements java.io.Serializable { + /** + * 配置id + */ private Long id; + /** + * 物资类型id + */ + @NotNull(message = "物资类型id不能为空") private Long typeId; + /** + * 左侧Tree层级用户id + */ + @NotNull(message = "用户id不能为空") private Long userId; + /** + * 绑定标识 1:绑定, 2:解绑 + */ + @ApiModelProperty(value = "绑定标识 1:绑定, 2:解绑") + @NotNull(message = "绑定标识不能为空") + private Integer bindFlag; + + /** + * 绑定角色类型: 1:库管员,2:维修员 + */ + @ApiModelProperty(value = "绑定角色类型: 1:库管员,2:维修员") + @NotNull(message = "绑定角色类型不能为空") + private Integer bindRoleType; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java index 72fdd1b4..c7fdfeb8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MaTypeConfigController.java @@ -3,7 +3,7 @@ package com.bonus.material.ma.controller; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.common.security.annotation.PreventRepeatSubmit; import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.material.ma.MaTypeConfigDto; import com.bonus.material.ma.domain.Type; @@ -13,17 +13,18 @@ import com.bonus.material.ma.service.ITypeKeeperService; import com.bonus.material.ma.service.ITypeRepairService; import com.bonus.material.ma.service.ITypeService; import com.bonus.material.ma.vo.MaTypeConfigVo; -import com.bonus.material.ma.vo.MaTypeListVo; import com.google.common.collect.ImmutableList; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; import java.util.*; -import java.util.stream.Collectors; /** * @author : 阮世耀 @@ -53,6 +54,78 @@ public class MaTypeConfigController extends BaseController { @Resource private ITypeService typeService; + + @ApiOperation(value = "配置物资类型绑定信息") + @PreventRepeatSubmit + @RequiresPermissions("ma:typeConfig:edit") + @PostMapping("/updateMaTypeBindInfo") + public AjaxResult updateMaTypeBindInfo(@Valid @NotNull MaTypeConfigDto maTypeConfigDto) { + // -------------------- 数据校验开始 --------------------- + + // 1.判断绑定标识是否为空 + if (maTypeConfigDto.getBindFlag() == null) { + return error("绑定标识不能为空"); + } + + // 2.判断绑定角色类型是否为空 + if (maTypeConfigDto.getBindRoleType() == null) { + return error("绑定角色类型不能为空"); + } + + // 3.判断用户id是否为空 + if (maTypeConfigDto.getUserId() == null) { + return error("用户id不能为空"); + } + + // ---------------- 数据校验结束 --------------------- + int result; + switch (maTypeConfigDto.getBindFlag()) { + case 1: + result = handleBind(maTypeConfigDto.getBindFlag(), maTypeConfigDto.getTypeId(), maTypeConfigDto.getUserId()); + return result == 1 ? AjaxResult.success("绑定成功") : error("绑定失败"); + case 2: + result = handleUnBind(maTypeConfigDto.getBindFlag(), maTypeConfigDto.getTypeId(), maTypeConfigDto.getUserId()); + return result == 1 ? AjaxResult.success("解绑成功") : error("解绑失败"); + default: + // 处理其他情况或抛出异常 + return error("输入值不合法 bindFlag: " + maTypeConfigDto.getBindFlag()); + } + } + + private int handleBind(int bindRoleType, Long typeId, Long userId) { + switch (bindRoleType) { + case 1: + // 处理 bindFlag 为 1:绑定 且 bindRoleType 为 1:库管员 的情况 + // TODO: 实现具体逻辑 + return typeKeeperService.insertTypeKeeper(new TypeKeeper(typeId, userId)); + case 2: + // 处理 bindFlag 为 1:绑定 且 bindRoleType 为 2:维修员 的情况 + // TODO: 实现具体逻辑 + return typeRepairService.insertTypeRepair(new TypeRepair(typeId, userId)); + default: + // 处理其他情况或抛出异常 + throw new IllegalArgumentException("Unsupported bindRoleType: " + bindRoleType); + } + } + + private int handleUnBind(int bindRoleType, Long typeId, Long userId) { + switch (bindRoleType) { + case 1: + // 处理 bindFlag 为 2:解绑 且 bindRoleType 为 1:库管员 的情况 + // TODO: 实现具体逻辑 + return typeKeeperService.deleteTypeKeeperByUserIdAndTypeId(new TypeKeeper(typeId, userId)); + case 2: + // 处理 bindFlag 为 2:解绑 且 bindRoleType 为 2:维修员 的情况 + // TODO: 实现具体逻辑 + return typeRepairService.deleteTypeRepairByUserIdAndTypeId(new TypeRepair(typeId, userId)); + default: + // 处理其他情况或抛出异常 + throw new IllegalArgumentException("Unsupported bindRoleType: " + bindRoleType); + } + } + + + /** * 查询物资类型配置右侧列表 */ @@ -111,11 +184,10 @@ public class MaTypeConfigController extends BaseController { } } - return success(filteredList); // ------------------- 数据过滤结束 --------------------- - - + // 返回前端 + return success(filteredList); // -------------------- 数据处理结束 --------------------- } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java index 660b4187..b16a3bfc 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeKeeper.java @@ -41,5 +41,10 @@ public class TypeKeeper extends BaseEntity { @ApiModelProperty(value = "数据所属组织") private String companyId; + public TypeKeeper(Long typeId, Long userId) { + this.typeId = typeId; + this.userId = userId; + } + public TypeKeeper() {} } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeRepair.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeRepair.java index e1b61f4c..7b0b44dc 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeRepair.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/TypeRepair.java @@ -38,5 +38,11 @@ public class TypeRepair extends BaseEntity { @ApiModelProperty(value = "数据所属组织") private Long companyId; + public TypeRepair() {} + + public TypeRepair(Long typeId, Long userId) { + this.typeId = typeId; + this.userId = userId; + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java index f7501bb5..c5c195a9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeKeeperMapper.java @@ -17,6 +17,11 @@ public interface TypeKeeperMapper { */ TypeKeeper selectTypeKeeperByID(Long ID); + /** + * 根据用户ID和物资类型ID查询库管员配置 + */ + TypeKeeper selectTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper); + /** * 查询库管员配置列表 * @@ -54,6 +59,11 @@ public interface TypeKeeperMapper { */ int deleteTypeKeeperByID(Long ID); + /** + * 根据用户ID和物资类型ID删除库管员配置 + */ + int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper); + /** * 批量删除库管员配置 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeRepairMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeRepairMapper.java index 6e2de569..ff7b9088 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeRepairMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeRepairMapper.java @@ -62,4 +62,11 @@ public interface TypeRepairMapper { * @return 结果 */ int deleteTypeRepairByIDs(Long[] IDs); + + /** + * 根据用户id和类型id删除配置记录 + * @param typeRepair + * @return + */ + int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java index 000627e7..6a129bda 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeKeeperService.java @@ -59,4 +59,12 @@ public interface ITypeKeeperService { * @return 结果 */ int deleteTypeKeeperByID(Long ID); + + /** + * 根据用户ID和物资类型ID删除库管员配置信息 + * + * @param typeKeeper + * @return + */ + int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeRepairService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeRepairService.java index ffb23427..442c3708 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeRepairService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeRepairService.java @@ -55,6 +55,11 @@ public interface ITypeRepairService { */ public int deleteTypeRepairByIDs(Long[] IDs); + /** + * 根据用户id和类型id删除配置信息 + */ + int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair); + /** * 删除维修班机具配置信息 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java index c7343f4e..dc6b184b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeKeeperServiceImpl.java @@ -87,7 +87,7 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService { } /** - * 删除库管员配置信息 + * 根据主键id删除库管员配置信息 * * @param ID 库管员配置主键 * @return 结果 @@ -97,4 +97,15 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService { { return typeKeeperMapper.deleteTypeKeeperByID(ID); } + + /** + * 根据用户ID和物资类型ID删除库管员配置信息 + * + * @param typeKeeper + * @return + */ + @Override + public int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper) { + return typeKeeperMapper.deleteTypeKeeperByUserIdAndTypeId(typeKeeper); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeRepairServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeRepairServiceImpl.java index f3b84b3b..4597b8da 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeRepairServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeRepairServiceImpl.java @@ -15,8 +15,8 @@ import com.bonus.material.ma.service.ITypeRepairService; * @date 2024-09-27 */ @Service -public class TypeRepairServiceImpl implements ITypeRepairService -{ +public class TypeRepairServiceImpl implements ITypeRepairService { + @Autowired private TypeRepairMapper typeRepairMapper; @@ -92,6 +92,16 @@ public class TypeRepairServiceImpl implements ITypeRepairService return typeRepairMapper.deleteTypeRepairByIDs(IDs); } + /** + * 根据用户id和类型id删除配置信息 + * + * @param typeRepair + */ + @Override + public int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair) { + return typeRepairMapper.deleteTypeRepairByUserIdAndTypeId(typeRepair); + } + /** * 删除维修班机具配置信息 * diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml index 7ae19e3c..7e3a918f 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeKeeperMapper.xml @@ -29,6 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where ID = #{ID} + + insert into ma_type_keeper @@ -82,4 +88,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and tk.company_id = #{companyId} + + + delete from ma_type_keeper where user_id = #{userId} and type_id = #{typeId} + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeRepairMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeRepairMapper.xml index de02fc41..289aed11 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeRepairMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeRepairMapper.xml @@ -80,4 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ma_type m ON m.type_id = mtk.type_id left join sys_user su on mtk.user_id = su.user_id + + + delete from ma_type_repair where user_id = #{userId} and type_id = #{typeId} + \ No newline at end of file