refactor(controller):优化删除接口参数传递方式

- 将多个删除接口的@RequestParam参数改为@RequestBody接收- 新增多个Form类用于封装删除参数
- 统一删除接口路径,增强接口语义化
- 优化Mapper中删除条件的参数引用- 移除实体类中冗余的字段更新逻辑
- 实体类实现Serializable接口并添加序列化ID
- 简化Controller中注解导入语句
This commit is contained in:
2025-09-26 13:14:24 +08:00
parent e24fc6059e
commit 2528cc6c42
18 changed files with 121 additions and 59 deletions

View File

@@ -6,14 +6,7 @@ import javax.servlet.http.HttpServletResponse;
import com.fizz.business.service.IPdiSetupService; import com.fizz.business.service.IPdiSetupService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@@ -39,8 +32,8 @@ public class PdiSetupController extends BaseController
/** /**
* 查询生产计划的参数详情列表 * 查询生产计划的参数详情列表
*/ */
@GetMapping("/list") @PostMapping("/list")
public TableDataInfo list(PdiSetups pdiSetup) public TableDataInfo list(@RequestBody PdiSetups pdiSetup)
{ {
startPage(); startPage();
List<PdiSetups> list = pdiSetupService.selectPdiSetupList(pdiSetup); List<PdiSetups> list = pdiSetupService.selectPdiSetupList(pdiSetup);

View File

@@ -2,6 +2,8 @@ package com.fizz.business.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fizz.business.form.TensionDeleteForm;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -83,9 +85,11 @@ public class SetupTensionController extends BaseController
* 删除全线张力 * 删除全线张力
*/ */
@Log(title = "全线张力", businessType = BusinessType.DELETE) @Log(title = "全线张力", businessType = BusinessType.DELETE)
@DeleteMapping() @DeleteMapping("/tension") // 建议添加路径区分不同删除接口
public AjaxResult remove(@RequestParam Long[] thicks,@RequestParam Long[] yieldStrens) public AjaxResult removeTension(@RequestBody TensionDeleteForm form) {
{ return toAjax(setupTensionService.deleteSetupTensionByThicks(
return toAjax(setupTensionService.deleteSetupTensionByThicks(thicks, yieldStrens)); form.getThicks(),
form.getYieldStrens()
));
} }
} }

View File

@@ -2,6 +2,8 @@ package com.fizz.business.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fizz.business.form.TlDeleteForm;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -81,15 +83,14 @@ public class SetupTlController extends BaseController
return toAjax(setupTlService.updateSetupTl(setupTl)); return toAjax(setupTlService.updateSetupTl(setupTl));
} }
/** // 拉矫机参数删除接口
* 删除拉矫机参数
*/
@Log(title = "拉矫机参数", businessType = BusinessType.DELETE) @Log(title = "拉矫机参数", businessType = BusinessType.DELETE)
@DeleteMapping() @DeleteMapping("/tl") // 不同路径区分
public AjaxResult remove(@RequestParam String[] steelGrades, public AjaxResult removeTl(@RequestBody TlDeleteForm form) {
@RequestParam Long[] yieldStrens, return toAjax(setupTlService.deleteSetupTlBySteelGrades(
@RequestParam Long[] thicks) form.getSteelGrades(),
{ form.getYieldStrens(),
return toAjax(setupTlService.deleteSetupTlBySteelGrades(steelGrades, yieldStrens, thicks)); form.getThicks()
));
} }
} }

View File

@@ -2,6 +2,8 @@ package com.fizz.business.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fizz.business.form.TmBendforceDeleteForm;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -84,10 +86,11 @@ public class SetupTmBendforceController extends BaseController
* 删除光整机弯辊力 * 删除光整机弯辊力
*/ */
@Log(title = "光整机弯辊力", businessType = BusinessType.DELETE) @Log(title = "光整机弯辊力", businessType = BusinessType.DELETE)
@DeleteMapping() @DeleteMapping("/tm/bendforce")
public AjaxResult remove(@RequestParam Long[] widths, public AjaxResult removeTmBendforce(@RequestBody TmBendforceDeleteForm form) {
@RequestParam Long[] rollForces) return toAjax(setupTmBendforceService.deleteSetupTmBendforceByWidths(
{ form.getWidths(),
return toAjax(setupTmBendforceService.deleteSetupTmBendforceByWidths(widths,rollForces)); form.getRollForces()
));
} }
} }

View File

@@ -2,6 +2,8 @@ package com.fizz.business.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fizz.business.form.TmMeshDeleteForm;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -85,11 +87,12 @@ public class SetupTmMeshController extends BaseController
* 删除光整机插入量 * 删除光整机插入量
*/ */
@Log(title = "光整机插入量", businessType = BusinessType.DELETE) @Log(title = "光整机插入量", businessType = BusinessType.DELETE)
@DeleteMapping() @DeleteMapping("/tm/mesh")
public AjaxResult remove( @RequestParam String[] steelGrades, public AjaxResult removeTmMesh(@RequestBody TmMeshDeleteForm form) {
@RequestParam Long[] yieldStrens, return toAjax(setupTmMeshService.deleteSetupTmMeshBySteelGrades(
@RequestParam Long[] thicks) form.getSteelGrades(),
{ form.getYieldStrens(),
return toAjax(setupTmMeshService.deleteSetupTmMeshBySteelGrades(steelGrades, yieldStrens, thicks)); form.getThicks()
));
} }
} }

View File

@@ -2,6 +2,8 @@ package com.fizz.business.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fizz.business.form.TmRollforceDeleteForm;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -86,12 +88,13 @@ public class SetupTmRollforceController extends BaseController
* 删除光整机轧制力 * 删除光整机轧制力
*/ */
@Log(title = "光整机轧制力", businessType = BusinessType.DELETE) @Log(title = "光整机轧制力", businessType = BusinessType.DELETE)
@DeleteMapping() @DeleteMapping("/tm/rollforce")
public AjaxResult remove(@RequestParam String[] steelGrades, public AjaxResult removeTmRollforce(@RequestBody TmRollforceDeleteForm form) {
@RequestParam Long[] thicks, return toAjax(setupTmRollforceService.deleteSetupTmRollforceBySteelGrades(
@RequestParam Long[] yieldStrens, form.getSteelGrades(),
@RequestParam Long[] elongs) form.getThicks(),
{ form.getYieldStrens(),
return toAjax(setupTmRollforceService.deleteSetupTmRollforceBySteelGrades(steelGrades, thicks, yieldStrens, elongs)); form.getElongs()
));
} }
} }

View File

@@ -10,6 +10,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import java.io.Serializable;
/** /**
* 生产计划的参数详情对象 pdi_setup * 生产计划的参数详情对象 pdi_setup
* *
@@ -18,7 +20,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
*/ */
@Data @Data
@TableName("pdi_setup") @TableName("pdi_setup")
public class PdiSetups extends BaseEntity public class PdiSetups implements Serializable
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -0,0 +1,12 @@
package com.fizz.business.form;
import lombok.Data;
/**
* 全线张力删除参数封装类
*/
@Data
public class TensionDeleteForm {
private Long[] thicks;
private Long[] yieldStrens;
}

View File

@@ -0,0 +1,13 @@
package com.fizz.business.form;
import lombok.Data;
/**
* 拉矫机参数删除参数封装类
*/
@Data
public class TlDeleteForm {
private String[] steelGrades;
private Long[] yieldStrens;
private Long[] thicks;
}

View File

@@ -0,0 +1,12 @@
package com.fizz.business.form;
import lombok.Data;
/**
* 光整机弯辊力删除参数封装类
*/
@Data
public class TmBendforceDeleteForm {
private Long[] widths;
private Long[] rollForces;
}

View File

@@ -0,0 +1,13 @@
package com.fizz.business.form;
import lombok.Data;
/**
* 光整机插入量删除参数封装类
*/
@Data
public class TmMeshDeleteForm {
private String[] steelGrades;
private Long[] yieldStrens;
private Long[] thicks;
}

View File

@@ -0,0 +1,14 @@
package com.fizz.business.form;
import lombok.Data;
/**
* 光整机轧制力删除参数封装类
*/
@Data
public class TmRollforceDeleteForm {
private String[] steelGrades;
private Long[] thicks;
private Long[] yieldStrens;
private Long[] elongs;
}

View File

@@ -56,7 +56,6 @@ public class PdiSetupServiceImpl extends ServiceImpl<PdiSetupMapper, PdiSetups>
@Override @Override
public Boolean insertPdiSetup(PdiSetups pdiSetup) public Boolean insertPdiSetup(PdiSetups pdiSetup)
{ {
pdiSetup.setCreateTime(DateUtils.getNowDate());
return this.save(pdiSetup); return this.save(pdiSetup);
} }
@@ -69,7 +68,6 @@ public class PdiSetupServiceImpl extends ServiceImpl<PdiSetupMapper, PdiSetups>
@Override @Override
public Boolean updatePdiSetup(PdiSetups pdiSetup) public Boolean updatePdiSetup(PdiSetups pdiSetup)
{ {
pdiSetup.setUpdateTime(DateUtils.getNowDate());
return this.updateById(pdiSetup); return this.updateById(pdiSetup);
} }

View File

@@ -110,7 +110,6 @@
<update id="updateSetupTension" parameterType="SetupTension"> <update id="updateSetupTension" parameterType="SetupTension">
update setup_tension update setup_tension
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="yieldStren != null">yield_stren = #{yieldStren},</if>
<if test="value1 != null">value1 = #{value1},</if> <if test="value1 != null">value1 = #{value1},</if>
<if test="value2 != null">value2 = #{value2},</if> <if test="value2 != null">value2 = #{value2},</if>
<if test="value3 != null">value3 = #{value3},</if> <if test="value3 != null">value3 = #{value3},</if>
@@ -129,7 +128,7 @@
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
</trim> </trim>
where thick = #{thick} where thick = #{thick} and yield_stren = #{yieldStren}
</update> </update>
<delete id="deleteSetupTensionByThick" parameterType="Long"> <delete id="deleteSetupTensionByThick" parameterType="Long">
@@ -141,7 +140,7 @@
where where
<foreach item="item" index="index" collection="thicks" open="(" separator=") OR (" close=")"> <foreach item="item" index="index" collection="thicks" open="(" separator=") OR (" close=")">
thick = #{thicks[${index}]} thick = #{thicks[${index}]}
AND yield_stren = #{yieldStren[${index}]} AND yield_stren = #{yieldStrens[${index}]}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

View File

@@ -95,8 +95,6 @@
<update id="updateSetupTl" parameterType="SetupTl"> <update id="updateSetupTl" parameterType="SetupTl">
update setup_tl update setup_tl
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="yieldStren != null">yield_stren = #{yieldStren},</if>
<if test="thick != null">thick = #{thick},</if>
<if test="value1 != null">value1 = #{value1},</if> <if test="value1 != null">value1 = #{value1},</if>
<if test="value2 != null">value2 = #{value2},</if> <if test="value2 != null">value2 = #{value2},</if>
<if test="value3 != null">value3 = #{value3},</if> <if test="value3 != null">value3 = #{value3},</if>
@@ -110,7 +108,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
</trim> </trim>
where steel_grade = #{steelGrade} where steel_grade = #{steelGrade} and yield_stren = #{yieldStren} and thick = #{thick}
</update> </update>
<delete id="deleteSetupTlBySteelGrade" parameterType="String"> <delete id="deleteSetupTlBySteelGrade" parameterType="String">

View File

@@ -64,7 +64,6 @@
<update id="updateSetupTmBendforce" parameterType="SetupTmBendforce"> <update id="updateSetupTmBendforce" parameterType="SetupTmBendforce">
update setup_tm_bendforce update setup_tm_bendforce
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="rollForce != null">roll_force = #{rollForce},</if>
<if test="value1 != null">value1 = #{value1},</if> <if test="value1 != null">value1 = #{value1},</if>
<if test="value2 != null">value2 = #{value2},</if> <if test="value2 != null">value2 = #{value2},</if>
<if test="value3 != null">value3 = #{value3},</if> <if test="value3 != null">value3 = #{value3},</if>
@@ -72,7 +71,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
</trim> </trim>
where width = #{width} where width = #{width} and roll_force = #{rollForce}
</update> </update>
<delete id="deleteSetupTmBendforceByWidth" parameterType="Long"> <delete id="deleteSetupTmBendforceByWidth" parameterType="Long">

View File

@@ -92,8 +92,6 @@
<update id="updateSetupTmMesh" parameterType="SetupTmMesh"> <update id="updateSetupTmMesh" parameterType="SetupTmMesh">
update setup_tm_mesh update setup_tm_mesh
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="yieldStren != null">yield_stren = #{yieldStren},</if>
<if test="thick != null">thick = #{thick},</if>
<if test="value1 != null">value1 = #{value1},</if> <if test="value1 != null">value1 = #{value1},</if>
<if test="value2 != null">value2 = #{value2},</if> <if test="value2 != null">value2 = #{value2},</if>
<if test="value3 != null">value3 = #{value3},</if> <if test="value3 != null">value3 = #{value3},</if>
@@ -107,7 +105,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
</trim> </trim>
where steel_grade = #{steelGrade} where steel_grade = #{steelGrade} and yield_stren = #{yieldStren} and thick = #{thick}
</update> </update>
<delete id="deleteSetupTmMeshBySteelGrade" parameterType="String"> <delete id="deleteSetupTmMeshBySteelGrade" parameterType="String">

View File

@@ -95,9 +95,6 @@
<update id="updateSetupTmRollforce" parameterType="SetupTmRollforce"> <update id="updateSetupTmRollforce" parameterType="SetupTmRollforce">
update setup_tm_rollforce update setup_tm_rollforce
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="thick != null">thick = #{thick},</if>
<if test="yieldStren != null">yield_stren = #{yieldStren},</if>
<if test="elong != null">elong = #{elong},</if>
<if test="value1 != null">value1 = #{value1},</if> <if test="value1 != null">value1 = #{value1},</if>
<if test="value2 != null">value2 = #{value2},</if> <if test="value2 != null">value2 = #{value2},</if>
<if test="value3 != null">value3 = #{value3},</if> <if test="value3 != null">value3 = #{value3},</if>
@@ -111,7 +108,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
</trim> </trim>
where steel_grade = #{steelGrade} where steel_grade = #{steelGrade} and thick = #{thick} and yield_stren = #{yieldStren} and elong = #{elong}
</update> </update>
<delete id="deleteSetupTmRollforceBySteelGrade" parameterType="String"> <delete id="deleteSetupTmRollforceBySteelGrade" parameterType="String">