库管员绑定删除

This commit is contained in:
sxu 2024-10-31 14:34:19 +08:00
parent 699c505ed8
commit 5025fd65f9
5 changed files with 70 additions and 39 deletions

View File

@ -72,6 +72,18 @@ public class TypeKeeperController extends BaseController {
return success(typeKeeperService.selectTypeKeeperByID(ID));
}
/**
* 新增库管员配置
*/
// @ApiOperation(value = "新增库管员配置")
// @PreventRepeatSubmit
// @RequiresPermissions("ma:keeper:add")
// @SysLog(title = "库管员配置", businessType = OperaType.INSERT, module = "物资管理->新增库管员配置")
// @PostMapping
// public AjaxResult add(@RequestBody TypeKeeper typeKeeper) {
// return toAjax(typeKeeperService.insertTypeKeeper(typeKeeper));
// }
/**
* 新增库管员配置
*/
@ -80,8 +92,8 @@ public class TypeKeeperController extends BaseController {
@RequiresPermissions("ma:keeper:add")
@SysLog(title = "库管员配置", businessType = OperaType.INSERT, module = "物资管理->新增库管员配置")
@PostMapping
public AjaxResult add(@RequestBody TypeKeeper typeKeeper) {
return toAjax(typeKeeperService.insertTypeKeeper(typeKeeper));
public AjaxResult add(@RequestBody List<TypeKeeper> typeKeepers) {
return toAjax(typeKeeperService.insertTypeKeeper(typeKeepers));
}
/**
@ -112,13 +124,23 @@ public class TypeKeeperController extends BaseController {
/**
* 删除单个库管员配置
*/
@ApiOperation(value = "删除单个库管员配置")
// @ApiOperation(value = "删除单个库管员配置")
// @PreventRepeatSubmit
// @RequiresPermissions("ma:keeper:remove")
// @SysLog(title = "库管员配置", businessType = OperaType.DELETE, logType = 1,module = "物资管理->删除单个库管员配置")
// @DeleteMapping
// public AjaxResult remove(@RequestBody TypeKeeper typeKeeper)
// {
// return toAjax(typeKeeperService.deleteTypeKeeperByUserIdAndTypeId(typeKeeper));
// }
@ApiOperation(value = "删除库管员配置")
@PreventRepeatSubmit
@RequiresPermissions("ma:keeper:remove")
@SysLog(title = "库管员配置", businessType = OperaType.DELETE, logType = 1,module = "物资管理->删除单个库管员配置")
@DeleteMapping
public AjaxResult remove(@RequestBody TypeKeeper typeKeeper)
public AjaxResult remove(@RequestBody List<TypeKeeper> typeKeepers)
{
return toAjax(typeKeeperService.deleteTypeKeeperByUserIdAndTypeId(typeKeeper));
return toAjax(typeKeeperService.deleteTypeKeeperByUserIdAndTypeId(typeKeepers));
}
}

View File

@ -38,10 +38,10 @@ public interface TypeKeeperMapper {
/**
* 新增库管员配置
*
* @param typeKeeper 库管员配置
* @param typeKeepers 库管员配置
* @return 结果
*/
int insertTypeKeeper(TypeKeeper typeKeeper);
int insertTypeKeeper(List<TypeKeeper> typeKeepers);
/**
* 修改库管员配置
@ -59,11 +59,6 @@ public interface TypeKeeperMapper {
*/
int deleteTypeKeeperByID(Long ID);
/**
* 根据用户ID和物资类型ID删除库管员配置
*/
int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper);
/**
* 批量删除库管员配置
*
@ -71,4 +66,9 @@ public interface TypeKeeperMapper {
* @return 结果
*/
int deleteTypeKeeperByIDs(Long[] IDs);
/**
* 根据用户ID和物资类型ID删除库管员配置
*/
int deleteTypeKeeperByUserIdAndTypeId(List<TypeKeeper> typeKeepers);
}

View File

@ -31,10 +31,10 @@ public interface ITypeKeeperService {
/**
* 新增库管员配置
*
* @param typeKeeper 库管员配置
* @param typeKeepers 库管员配置
* @return 结果
*/
int insertTypeKeeper(TypeKeeper typeKeeper);
int insertTypeKeeper(List<TypeKeeper> typeKeepers);
/**
* 修改库管员配置
@ -63,8 +63,8 @@ public interface ITypeKeeperService {
/**
* 根据用户ID和物资类型ID删除库管员配置信息
*
* @param typeKeeper
* @param typeKeepers
* @return
*/
int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper);
int deleteTypeKeeperByUserIdAndTypeId(List<TypeKeeper> typeKeepers);
}

View File

@ -54,13 +54,13 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService {
/**
* 新增库管员配置
*
* @param typeKeeper 库管员配置
* @param typeKeepers 库管员配置
* @return 结果
*/
@Override
public int insertTypeKeeper(TypeKeeper typeKeeper) {
typeKeeper.setCreateTime(DateUtils.getNowDate());
return typeKeeperMapper.insertTypeKeeper(typeKeeper);
public int insertTypeKeeper(List<TypeKeeper> typeKeepers) {
typeKeepers.forEach(typeKeeper -> typeKeeper.setCreateTime(DateUtils.getNowDate()));
return typeKeeperMapper.insertTypeKeeper(typeKeepers);
}
/**
@ -101,11 +101,11 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService {
/**
* 根据用户ID和物资类型ID删除库管员配置信息
*
* @param typeKeeper
* @param typeKeepers
* @return
*/
@Override
public int deleteTypeKeeperByUserIdAndTypeId(TypeKeeper typeKeeper) {
return typeKeeperMapper.deleteTypeKeeperByUserIdAndTypeId(typeKeeper);
public int deleteTypeKeeperByUserIdAndTypeId(List<TypeKeeper> typeKeepers) {
return typeKeeperMapper.deleteTypeKeeperByUserIdAndTypeId(typeKeepers);
}
}

View File

@ -37,21 +37,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertTypeKeeper" parameterType="com.bonus.material.ma.domain.TypeKeeper" useGeneratedKeys="true" keyProperty="ID">
insert into ma_type_keeper
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeId != null">type_id,</if>
<if test="userId != null">user_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeId != null">#{typeId},</if>
<if test="userId != null">#{userId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
insert into ma_type_keeper (type_id,user_id,create_time,update_time,company_id)
values
<foreach collection="typeKeepers" item="item" separator=",">
(
#{item.typeId},
#{item.userId},
#{item.createTime},
#{item.updateTime},
#{item.companyId}
)
</foreach>
</insert>
<update id="updateTypeKeeper" parameterType="com.bonus.material.ma.domain.TypeKeeper">
@ -90,6 +86,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<delete id="deleteTypeKeeperByUserIdAndTypeId">
delete from ma_type_keeper where user_id = #{userId} and type_id = #{typeId}
delete from ma_type_keeper where
type_id in
<foreach collection="typeKeepers" item="item" separator=",">
(
#{item.typeId}
)
</foreach>
and
user_id in
<foreach collection="typeKeepers" item="item" separator=",">
(
#{item.userId}
)
</foreach>
</delete>
</mapper>