物资配置管理--库管员、维修员的绑定及解绑
This commit is contained in:
parent
d8f69259ec
commit
16e4db25c9
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
// -------------------- 数据处理结束 ---------------------
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
/**
|
||||
* 批量删除库管员配置
|
||||
*
|
||||
|
|
|
|||
|
|
@ -62,4 +62,11 @@ public interface TypeRepairMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteTypeRepairByIDs(Long[] IDs);
|
||||
|
||||
/**
|
||||
* 根据用户id和类型id删除配置记录
|
||||
* @param typeRepair
|
||||
* @return
|
||||
*/
|
||||
int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,12 @@ public interface ITypeKeeperService {
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteTypeKeeperByID(Long ID);
|
||||
|
||||
/**
|
||||
* 根据用户ID和物资类型ID删除库管员配置信息
|
||||
*
|
||||
* @param typeKeeper
|
||||
* @return
|
||||
*/
|
||||
int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ public interface ITypeRepairService {
|
|||
*/
|
||||
public int deleteTypeRepairByIDs(Long[] IDs);
|
||||
|
||||
/**
|
||||
* 根据用户id和类型id删除配置信息
|
||||
*/
|
||||
int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair);
|
||||
|
||||
/**
|
||||
* 删除维修班机具配置信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除维修班机具配置信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectTypeKeeperVo"/>
|
||||
where ID = #{ID}
|
||||
</select>
|
||||
|
||||
<select id="selectTypeKeeperByUserIdAndTypeId" parameterType="Long" resultMap="TypeKeeperResult">
|
||||
<include refid="selectTypeKeeperVo"/>
|
||||
where type_id = #{typeId} and user_id = #{userId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertTypeKeeper" parameterType="com.bonus.material.ma.domain.TypeKeeper" useGeneratedKeys="true" keyProperty="ID">
|
||||
insert into ma_type_keeper
|
||||
|
|
@ -82,4 +88,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="companyId != null "> and tk.company_id = #{companyId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<delete id="deleteTypeKeeperByUserIdAndTypeId">
|
||||
delete from ma_type_keeper where user_id = #{userId} and type_id = #{typeId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -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
|
||||
</select>
|
||||
|
||||
<delete id="deleteTypeRepairByUserIdAndTypeId">
|
||||
delete from ma_type_repair where user_id = #{userId} and type_id = #{typeId}
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue