1. 车辆中有型号的不能删除

This commit is contained in:
邱贞招 2024-09-06 09:19:37 +08:00
parent 4cde481530
commit f354d03219
3 changed files with 24 additions and 10 deletions

View File

@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.service.IAsDeviceService;
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.GetMapping;
@ -34,6 +36,10 @@ public class EtModelController extends BaseController
@Autowired @Autowired
private IEtModelService etModelService; private IEtModelService etModelService;
@Autowired
private IAsDeviceService asDeviceService;
/** /**
* 查询车辆型号列表 * 查询车辆型号列表
*/ */
@ -99,6 +105,12 @@ public class EtModelController extends BaseController
@DeleteMapping("/{modelIds}") @DeleteMapping("/{modelIds}")
public AjaxResult remove(@PathVariable Long[] modelIds) public AjaxResult remove(@PathVariable Long[] modelIds)
{ {
for (Long modelId:modelIds) {
// 判断该型号下是否有存在车辆
if(asDeviceService.selectCountByModelId(modelId) > 0){
return AjaxResult.warn("该型号【"+modelId+"】下存在车辆,无法删除!");
}
}
return toAjax(etModelService.deleteEtModelByModelIds(modelIds)); return toAjax(etModelService.deleteEtModelByModelIds(modelIds));
} }
} }

View File

@ -79,10 +79,10 @@ public class EtParkingAreaController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody EtParkingArea etParkingArea) public AjaxResult add(@RequestBody EtParkingArea etParkingArea)
{ {
if (!etParkingAreaService.checkParkingNameUnique(etParkingArea)) // if (!etParkingAreaService.checkParkingNameUnique(etParkingArea))
{ // {
return error("新增停车区'" + etParkingArea.getParkingName() + "'失败,该停车区已存在"); // return error("新增停车区'" + etParkingArea.getParkingName() + "'失败,该停车区已存在");
} // }
return toAjax(etParkingAreaService.insertEtParkingArea(etParkingArea)); return toAjax(etParkingAreaService.insertEtParkingArea(etParkingArea));
} }
@ -94,10 +94,10 @@ public class EtParkingAreaController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody EtParkingArea etParkingArea) public AjaxResult edit(@RequestBody EtParkingArea etParkingArea)
{ {
if (!etParkingAreaService.checkParkingNameUnique(etParkingArea)) // if (!etParkingAreaService.checkParkingNameUnique(etParkingArea))
{ // {
return error("修改停车区'" + etParkingArea.getParkingName() + "'失败,该停车区已存在"); // return error("修改停车区'" + etParkingArea.getParkingName() + "'失败,该停车区已存在");
} // }
return toAjax(etParkingAreaService.updateEtParkingArea(etParkingArea)); return toAjax(etParkingAreaService.updateEtParkingArea(etParkingArea));
} }

View File

@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.full_endurance, m.low_battery_reminder, m.create_by, m.create_time, m.full_endurance, m.low_battery_reminder, m.create_by, m.create_time,
m.update_by, m.update_time, m.remark from et_model m m.update_by, m.update_time, m.remark from et_model m
left join sys_dept d on d.dept_id = m.operator left join sys_dept d on d.dept_id = m.operator
where 1 = 1 where del_flag != 2
<if test="model != null and model != ''"> and m.model = #{model}</if> <if test="model != null and model != ''"> and m.model = #{model}</if>
<if test="brand != null and brand != ''"> and m.brand = #{brand}</if> <if test="brand != null and brand != ''"> and m.brand = #{brand}</if>
<if test="operator != null and operator != ''"> and m.operator = #{operator}</if> <if test="operator != null and operator != ''"> and m.operator = #{operator}</if>
@ -107,7 +107,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteEtModelByModelIds" parameterType="String"> <delete id="deleteEtModelByModelIds" parameterType="String">
delete from et_model where model_id in UPDATE et_model
SET del_flag = 2
WHERE model_id IN
<foreach item="modelId" collection="array" open="(" separator="," close=")"> <foreach item="modelId" collection="array" open="(" separator="," close=")">
#{modelId} #{modelId}
</foreach> </foreach>