Compare commits
2 Commits
09a4b16316
...
0dc53b7794
Author | SHA1 | Date |
---|---|---|
|
0dc53b7794 | |
|
8f82279d43 |
|
@ -3,36 +3,33 @@ package com.dragon.car.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障码
|
||||
* @description : 故障码表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName ("fault_code")
|
||||
@TableName ("trouble_code")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FaultCode {
|
||||
|
||||
/**
|
||||
* 故障码编号
|
||||
*/
|
||||
|
||||
@TableId (type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 故障码
|
||||
*/
|
||||
private String code;
|
||||
private String name;
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
private Integer level;
|
||||
public FaultCode (String operationKey, String operationValue, String operationStatus) {
|
||||
this.code = operationKey;
|
||||
this.name = operationValue;
|
||||
this.status = operationStatus;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.dragon.car.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 车辆故障信息
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public/*
|
||||
指定车辆的故障信息
|
||||
*/
|
||||
class VehicleFault {
|
||||
private Integer id; // 故障ID
|
||||
private Integer vehicleId; // 车辆ID
|
||||
private Integer faultCodeId; // 故障代码ID
|
||||
private LocalDateTime occurTime; // 故障发生时间
|
||||
private Integer level; // 故障等级
|
||||
private Integer status; // 故障状态
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package com.dragon.car.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 车辆故障信息
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class VehicleFaultInfo {
|
||||
private Integer id;
|
||||
private Integer vehicleId;
|
||||
private Integer faultCodeId;
|
||||
private LocalDateTime occurTime;
|
||||
private Integer level;
|
||||
private Integer status;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.dragon.car.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障码初始化
|
||||
*/
|
||||
@Data
|
||||
public class VehicleInfo {
|
||||
/**
|
||||
* 车辆信息id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 板号
|
||||
*/
|
||||
private String plateNumber;
|
||||
|
||||
/**
|
||||
* 车辆模型
|
||||
*/
|
||||
private String vehicleModel;
|
||||
/**
|
||||
* 制造者
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.dragon.car.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障码请求
|
||||
*/
|
||||
@Data
|
||||
public class FaultCodeReq {
|
||||
private Integer id;
|
||||
private String code;
|
||||
private Integer level;
|
||||
private String description;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.dragon.car.domain.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障通知记录请求
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class FaultNotifyRecordReq {
|
||||
private Integer id;
|
||||
/**
|
||||
* 车辆故障信息 ID
|
||||
*/
|
||||
private Integer vehicleFaultInfoId;
|
||||
/**
|
||||
* 通知时间
|
||||
*/
|
||||
private LocalDateTime notifyTime;
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
private Integer notifyType;
|
||||
/**
|
||||
* 接收器
|
||||
*/
|
||||
private String receiver;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.dragon.car.domain.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhn
|
||||
* 故障码管理请求
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class ReqFault {
|
||||
private String id;
|
||||
//操作
|
||||
private String operation;
|
||||
//操作状态
|
||||
private String operationStatus;
|
||||
//操作key
|
||||
private String operationKey;
|
||||
//操作value
|
||||
private String operationValue;
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.dragon.car.domain.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description :
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class VehicleFaultInfoReq {
|
||||
private Integer id;
|
||||
private Integer vehicleId;
|
||||
private Integer faultCodeId;
|
||||
private LocalDateTime occurTime;
|
||||
private Integer level;
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package com.dragon.car.domain.req;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 车辆信息请求
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class VehicleInfoReq {
|
||||
private Integer id;
|
||||
private String plateNumber;
|
||||
private String vehicleModule;
|
||||
private String manufacturer;
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.dragon.car.domain.resp;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障码响应
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class FaultCodeResp {
|
||||
private Integer id;
|
||||
private String code;
|
||||
private Integer level;
|
||||
private String description;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.dragon.car.domain.resp;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障通知记录响应
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class FaultNotifyRecordResp {
|
||||
private Integer id;
|
||||
/**
|
||||
* 车辆故障信息 ID
|
||||
*/
|
||||
private Integer vehicleFaultInfoId;
|
||||
/**
|
||||
* 通知时间
|
||||
*/
|
||||
private LocalDateTime notifyTime;
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
private Integer notifyType;
|
||||
/**
|
||||
* 接收器
|
||||
*/
|
||||
private String receiver;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.dragon.car.domain.resp;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author zhn
|
||||
* 故障返回实体类
|
||||
**/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class RespFaultCode {
|
||||
private Integer id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String status;
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.dragon.car.domain.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 车辆故障信息回复
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName ("vehicleFaultInfoResp")
|
||||
public class VehicleFaultInfoResp {
|
||||
private Integer id;
|
||||
private Integer vehicleId;
|
||||
private Integer faultCodeId;
|
||||
private LocalDateTime occurTime;
|
||||
private Integer level;
|
||||
private Integer status;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.dragon.car.domain.resp;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 车辆信息响应
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class VehicleInfoResp {
|
||||
private Integer id;
|
||||
private String plateNumber;
|
||||
private String vehicleModule;
|
||||
private String manufacturer;
|
||||
}
|
|
@ -3,7 +3,6 @@ package com.dragon.car.service.controller;
|
|||
import com.dragon.car.domain.req.RequestCar;
|
||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||
import com.dragon.car.service.service.CarManageService;
|
||||
import com.dragon.car.service.service.FaultService;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -22,8 +21,7 @@ import java.util.List;
|
|||
public class CarController {
|
||||
@Autowired
|
||||
CarManageService carManageService;
|
||||
@Autowired
|
||||
FaultService faultService;
|
||||
|
||||
|
||||
/**
|
||||
* 车辆初始化
|
||||
|
@ -79,7 +77,7 @@ public class CarController {
|
|||
@PostMapping ("/faultCode")
|
||||
public Result<List<ResquestFaultCode>> faultCodeList () {
|
||||
|
||||
return faultService.faultCodeList ();
|
||||
return carManageService.faultCodeList ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package com.dragon.car.service.controller;
|
||||
|
||||
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||
import com.dragon.car.domain.req.ReqFault;
|
||||
import com.dragon.car.domain.resp.RespFaultCode;
|
||||
import com.dragon.car.service.service.FaultService;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障码管理控制
|
||||
|
@ -19,11 +20,28 @@ public class FaultController {
|
|||
@Autowired
|
||||
FaultService faultService;
|
||||
|
||||
// 按 ID 选择带有故障代码的车辆故障信息
|
||||
//故障码维护--查询
|
||||
@RequestMapping ("/query")
|
||||
public Result<List<RespFaultCode>> query (ReqFault reqFault) {
|
||||
return faultService.queryFaultCode ();
|
||||
}
|
||||
|
||||
@GetMapping ("/{id}")
|
||||
public Result<VehicleFaultInfoResp> getVehicleFaultInfoWithFaultCode (@PathVariable ("id") Integer id) {
|
||||
return faultService.getVehicleFaultInfoWithFaultCodeById (id);
|
||||
//故障码维护--新增
|
||||
@RequestMapping ("/insert")
|
||||
public Result insert (ReqFault reqFault) {
|
||||
return faultService.insertFaultCode (reqFault);
|
||||
}
|
||||
|
||||
//故障码维护--修改
|
||||
@RequestMapping ("/update")
|
||||
public Result update (ReqFault reqFault) {
|
||||
return faultService.updateFaultCode (reqFault);
|
||||
}
|
||||
|
||||
//故障码维护--删除
|
||||
@RequestMapping ("/delete")
|
||||
public Result delete (ReqFault reqFault) {
|
||||
return faultService.deleteFaultCode (reqFault);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package com.dragon.car.service.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dragon.car.domain.VehicleFaultInfo;
|
||||
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 故障码映射
|
||||
*/
|
||||
@Mapper
|
||||
public interface FaultCodeMapper extends BaseMapper<VehicleFaultInfo> {
|
||||
|
||||
@Select ("""
|
||||
SELECT vfi.*, fc.code, fc.description
|
||||
FROM vehicle_fault_info vfi
|
||||
INNER JOIN fault_code fc ON vfi.fault_code_id = fc.id
|
||||
WHERE vfi.id = #{id}
|
||||
""")
|
||||
VehicleFaultInfoResp selectVehicleFaultInfoWithFaultCodeById (@Param ("id") Integer id);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.dragon.car.service.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dragon.car.domain.FaultCode;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zhn
|
||||
* 故障映射
|
||||
**/
|
||||
@Mapper
|
||||
public interface FaultMapper extends BaseMapper<FaultCode> {
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.dragon.car.service.service;
|
||||
|
||||
import com.dragon.car.domain.req.RequestCar;
|
||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -45,4 +46,6 @@ public interface CarManageService {
|
|||
*/
|
||||
Result carDelect (RequestCar request);
|
||||
|
||||
Result<List<ResquestFaultCode>> faultCodeList ();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,31 +1,43 @@
|
|||
package com.dragon.car.service.service;
|
||||
|
||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||
import com.dragon.car.domain.req.ReqFault;
|
||||
import com.dragon.car.domain.resp.RespFaultCode;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆故障码管理
|
||||
*
|
||||
* @author : Administrator
|
||||
* @description :
|
||||
*/
|
||||
public interface FaultService {
|
||||
/**
|
||||
* 对故障码的管理查看
|
||||
* 故障管理-查询
|
||||
*
|
||||
* @return 故障码的返回结果集
|
||||
* @return RespFaultCode 故障返回实体类
|
||||
*/
|
||||
Result<List<ResquestFaultCode>> faultCodeList ();
|
||||
Result<List<RespFaultCode>> queryFaultCode ();
|
||||
|
||||
/**
|
||||
* 按照id码查车
|
||||
* 故障管理-新增
|
||||
*
|
||||
* @param id
|
||||
* @param reqFault 故障实体类
|
||||
*
|
||||
* @return List<VehicleFaultInfoResp>
|
||||
* @return 返回 0/1
|
||||
*/
|
||||
Result<VehicleFaultInfoResp> getVehicleFaultInfoWithFaultCodeById (Integer id);
|
||||
Result insertFaultCode (ReqFault reqFault);
|
||||
|
||||
/**
|
||||
* 故障管理-修改
|
||||
*
|
||||
* @param reqFault 故障实体类
|
||||
*
|
||||
* @return 返回 0/1
|
||||
*/
|
||||
Result updateFaultCode (ReqFault reqFault);
|
||||
|
||||
/**
|
||||
* 故障管理-删除
|
||||
*
|
||||
* @param reqFault 故障实体类
|
||||
*
|
||||
* @return 返回 0/1
|
||||
*/
|
||||
Result deleteFaultCode (ReqFault reqFault);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.dragon.car.service.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.dragon.car.domain.req.RequestCar;
|
||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||
import com.dragon.car.service.mapper.CarManageMapper;
|
||||
import com.dragon.car.service.service.CarManageService;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
|
@ -83,5 +84,13 @@ public class CarManageServiceImpl implements CarManageService {
|
|||
return Result.success (i > 0 ? "成功" : "失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<List<ResquestFaultCode>> faultCodeList () {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,47 +1,116 @@
|
|||
package com.dragon.car.service.service.impl;
|
||||
|
||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||
import com.dragon.car.service.mapper.FaultCodeMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.dragon.car.domain.FaultCode;
|
||||
import com.dragon.car.domain.req.ReqFault;
|
||||
import com.dragon.car.domain.resp.RespFaultCode;
|
||||
import com.dragon.car.service.mapper.FaultMapper;
|
||||
import com.dragon.car.service.service.FaultService;
|
||||
import com.dragon.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author : Administrator
|
||||
* @description : 车辆故障码维护
|
||||
*/
|
||||
* @author zhn
|
||||
* @description 故障管理业务层
|
||||
* <p>
|
||||
* 判断 reqFault 操作的 operation 属于啥 c添加 r查询 u修改 d删除
|
||||
* <p>
|
||||
* 判断 reqFault 操作状态的 operationStatus 对状态码是否启用 0/1
|
||||
* <p>
|
||||
* 判断 reqFault 操作键的 operation keu 状态码
|
||||
* <p>
|
||||
* 判断 reqFault 操作值的 operation value 自己看的值
|
||||
**/
|
||||
@Service
|
||||
public class FaultServiceImpl implements FaultService {
|
||||
@Autowired
|
||||
FaultCodeMapper faultCodeMapper;
|
||||
FaultMapper faultMapper;
|
||||
|
||||
/**
|
||||
* 对故障码的管理查看
|
||||
* 故障管理-查询
|
||||
*
|
||||
* @return 故障码的返回结果集
|
||||
* @return RespFaultCode 故障返回实体类
|
||||
*/
|
||||
@Override
|
||||
public Result<List<ResquestFaultCode>> faultCodeList () {
|
||||
|
||||
|
||||
return null;
|
||||
public Result<List<RespFaultCode>> queryFaultCode () {
|
||||
return Result.success (faultMapper
|
||||
.selectList (Wrappers.query ())
|
||||
.stream ()
|
||||
.map (a -> new RespFaultCode (a.getId (), a.getCode (), a.getName (), a.getStatus ())) // 使用map方法将A对象转换为B对象
|
||||
.toList ());
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照id码查车
|
||||
* 故障管理-新增
|
||||
*
|
||||
* @param id
|
||||
* @param reqFault 故障实体类
|
||||
*
|
||||
* @return List<VehicleFaultInfoResp>
|
||||
* @return 返回 0/1
|
||||
*/
|
||||
@Override
|
||||
public Result<VehicleFaultInfoResp> getVehicleFaultInfoWithFaultCodeById (Integer id) {
|
||||
VehicleFaultInfoResp vehicleFaultInfoResp = faultCodeMapper.selectVehicleFaultInfoWithFaultCodeById (id);
|
||||
public Result insertFaultCode (ReqFault reqFault) {
|
||||
return Optional.of (reqFault)
|
||||
.filter (fault -> "c".equals (fault.getOperation ()))
|
||||
.map (fault -> new FaultCode (fault.getOperationKey (), fault.getOperationValue (), fault.getOperationStatus ()))
|
||||
.map (code -> faultMapper.insert (code) > 0 ? Result.success ("insert 成功") : Result.error ("insert 失败"))
|
||||
.orElse (Result.error ("添加操作异常"));
|
||||
}
|
||||
|
||||
return Result.success (vehicleFaultInfoResp);
|
||||
/**
|
||||
* 故障管理-修改
|
||||
*
|
||||
* @param reqFault 故障实体类
|
||||
*
|
||||
* @return 返回 0/1
|
||||
*/
|
||||
@Override
|
||||
public Result updateFaultCode (ReqFault reqFault) {
|
||||
// 1. 判断操作状态是 "u",传输的 key 和 value 非空,状态非 null 非 ""
|
||||
if ("u".equals (reqFault.getOperation ())) {
|
||||
return Optional.of (reqFault)
|
||||
.filter (fault -> fault.getOperationKey () != null && !fault.getOperationKey ().isEmpty ())
|
||||
.filter (fault -> fault.getOperationValue () != null && !fault.getOperationValue ().isEmpty ())
|
||||
.map (fault -> Result.success ("update成功"))
|
||||
.orElse (Result.error ("操作状态为 'u',但 key 或 value 为空"));
|
||||
}
|
||||
return Result.error ("操作状态不为 'u'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 故障管理-删除
|
||||
*
|
||||
* @param reqFault 故障实体类
|
||||
*
|
||||
* @return 返回 0/1
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Result deleteFaultCode (ReqFault reqFault) {
|
||||
String operation = reqFault.getOperation ();
|
||||
String code = reqFault.getOperationKey ();
|
||||
String operationStatus = reqFault.getOperationStatus ();
|
||||
|
||||
return switch (operation) {
|
||||
case "d" -> {
|
||||
if (Objects.equals (operationStatus, "0")) {
|
||||
int deleteCount = faultMapper.delete (Wrappers.lambdaQuery (FaultCode.class).eq (FaultCode::getCode, code));
|
||||
yield deleteCount > 0 ? Result.success ("彻底删除成功") : Result.error ("彻底删除失败");
|
||||
}
|
||||
else if (Objects.equals (operationStatus, "1")) {
|
||||
int updateCount = faultMapper.update (new FaultCode (code, null, "0"), Wrappers.lambdaQuery (FaultCode.class).eq (FaultCode::getCode, code));
|
||||
yield updateCount > 0 ? Result.success ("逻辑删除成功") : Result.error ("逻辑删除失败");
|
||||
}
|
||||
else {
|
||||
yield Result.error ("操作状态不合法");
|
||||
}
|
||||
}
|
||||
default -> Result.error ("操作状态不为 'd'");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue