From cd2eeb1b5b23e300a123959560e3e9d73ff1b796 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 31 Oct 2024 19:46:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E5=91=98=E6=9C=BA=E5=85=B7?= =?UTF-8?q?=E5=85=B3=E8=81=94=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeRepairController.java | 8 ++-- .../material/ma/mapper/TypeRepairMapper.java | 9 +++-- .../ma/service/ITypeRepairService.java | 6 +-- .../service/impl/TypeRepairServiceImpl.java | 19 ++++++---- .../mapper/material/ma/TypeRepairMapper.xml | 37 +++++++++++-------- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeRepairController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeRepairController.java index fb6286d2..2263a609 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeRepairController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeRepairController.java @@ -85,9 +85,9 @@ public class TypeRepairController extends BaseController @RequiresPermissions("ma:repair:add") @SysLog(title = "维修班机具配置", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增维修班机具配置") @PostMapping - public AjaxResult add(@RequestBody TypeRepair typeRepair) + public AjaxResult add(@RequestBody List typeRepairs) { - return toAjax(typeRepairService.insertTypeRepair(typeRepair)); + return toAjax(typeRepairService.insertTypeRepair(typeRepairs)); } /** @@ -124,8 +124,8 @@ public class TypeRepairController extends BaseController @RequiresPermissions("ma:repair:remove") @SysLog(title = "维修班机具配置", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除单个维修班机具配置") @DeleteMapping - public AjaxResult remove(@RequestBody TypeRepair typeRepair) + public AjaxResult remove(@RequestBody List typeRepairs) { - return toAjax(typeRepairService.deleteTypeRepairByUserIdAndTypeId(typeRepair)); + return toAjax(typeRepairService.deleteTypeRepairByUserIdAndTypeId(typeRepairs)); } } 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 ff7b9088..647e36f2 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 @@ -2,6 +2,7 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.TypeRepair; +import org.apache.ibatis.annotations.Param; /** * 维修班机具配置Mapper接口 @@ -34,10 +35,10 @@ public interface TypeRepairMapper { /** * 新增维修班机具配置 * - * @param typeRepair 维修班机具配置 + * @param typeRepairs 维修班机具配置 * @return 结果 */ - int insertTypeRepair(TypeRepair typeRepair); + int insertTypeRepair(@Param("list") List typeRepairs); /** * 修改维修班机具配置 @@ -65,8 +66,8 @@ public interface TypeRepairMapper { /** * 根据用户id和类型id删除配置记录 - * @param typeRepair + * @param typeRepairs * @return */ - int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair); + int deleteTypeRepairByUserIdAndTypeId(@Param("list") List typeRepairs); } 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 8c7382da..a43a02f8 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 @@ -34,10 +34,10 @@ public interface ITypeRepairService { /** * 新增维修班机具配置 * - * @param typeRepair 维修班机具配置 + * @param typeRepairs 维修班机具配置 * @return 结果 */ - public int insertTypeRepair(TypeRepair typeRepair); + public int insertTypeRepair(List typeRepairs); /** * 修改维修班机具配置 @@ -66,5 +66,5 @@ public interface ITypeRepairService { /** * 根据用户id和类型id删除配置信息 */ - int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair); + int deleteTypeRepairByUserIdAndTypeId(List typeRepairs); } 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 be717e8a..456a9298 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 @@ -7,6 +7,7 @@ import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.TypeRepairMapper; import com.bonus.material.ma.domain.TypeRepair; import com.bonus.material.ma.service.ITypeRepairService; +import org.springframework.util.CollectionUtils; /** * 维修班机具配置Service业务层处理 @@ -57,14 +58,18 @@ public class TypeRepairServiceImpl implements ITypeRepairService { /** * 新增维修班机具配置 * - * @param typeRepair 维修班机具配置 + * @param typeRepairs 维修班机具配置 * @return 结果 */ @Override - public int insertTypeRepair(TypeRepair typeRepair) + public int insertTypeRepair(List typeRepairs) { - typeRepair.setCreateTime(DateUtils.getNowDate()); - return typeRepairMapper.insertTypeRepair(typeRepair); + if (CollectionUtils.isEmpty(typeRepairs)) { + return 0; + } + typeRepairs.forEach(typeKeeper -> typeKeeper.setCreateTime(DateUtils.getNowDate())); + typeRepairMapper.deleteTypeRepairByUserIdAndTypeId(typeRepairs); + return typeRepairMapper.insertTypeRepair(typeRepairs); } /** @@ -107,10 +112,10 @@ public class TypeRepairServiceImpl implements ITypeRepairService { /** * 根据用户id和类型id删除配置信息 * - * @param typeRepair + * @param typeRepairs */ @Override - public int deleteTypeRepairByUserIdAndTypeId(TypeRepair typeRepair) { - return typeRepairMapper.deleteTypeRepairByUserIdAndTypeId(typeRepair); + public int deleteTypeRepairByUserIdAndTypeId(List typeRepairs) { + return typeRepairMapper.deleteTypeRepairByUserIdAndTypeId(typeRepairs); } } 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 926cbf2f..3a6dfafa 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 @@ -31,21 +31,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into ma_type_repair - - type_id, - user_id, - create_time, - update_time, - company_id, - - - #{typeId}, - #{userId}, - #{createTime}, - #{updateTime}, - #{companyId}, - + insert into ma_type_repair (type_id,user_id,create_time,update_time,company_id) + values + + ( + #{item.typeId}, + #{item.userId}, + #{item.createTime}, + #{item.updateTime}, + #{item.companyId} + ) + @@ -82,6 +78,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from ma_type_repair where user_id = #{userId} and type_id = #{typeId} + delete from ma_type_repair where + type_id in + + #{item.typeId} + + and + user_id in + + #{item.userId} + \ No newline at end of file