故障类型的编写

dev.vehicleGateway
15285 2024-09-25 20:32:18 +08:00
parent 2ed82cdd80
commit 5cd6840e2a
5 changed files with 62 additions and 13 deletions

View File

@ -29,10 +29,10 @@ public class SysCarFault extends BaseEntity {
@Schema(defaultValue = "车辆故障编码",type = "String",description = "车辆故障编码")
private String faultCode;
/**
*
* ID
*/
@Schema(defaultValue = "车辆故障类型",type = "String",description = "车辆故障类型")
private String faultType;
@Schema(defaultValue = "车辆故障类型ID",type = "Integer",description = "车辆故障类型ID")
private Integer faultTypeId;
/**
* VIN
*/

View File

@ -6,9 +6,9 @@ import com.muyu.fault.common.FaultType;
import com.muyu.fault.service.FaultTypeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/type")
@ -22,8 +22,41 @@ public class FaultTypeController {
* @return
*/
@RequestMapping(value = "faultTypeList",method = RequestMethod.GET)
public Result faultTypeList(){
LambdaQueryWrapper<FaultType> queryWrapper = new LambdaQueryWrapper<>();
return Result.success(faultTypeService.list(queryWrapper));
public Result<List<FaultType>> faultTypeList(@RequestBody FaultType faultType){
return Result.success(faultTypeService.faultTypeList(faultType));
}
/**
*
* @param faultType
* @return
*/
@RequestMapping(value = "insertType",method = RequestMethod.POST)
public Result insertType(@RequestBody FaultType faultType){
return Result.success(faultTypeService.save(faultType));
}
/**
*
* @param faultType
* @return
*/
@RequestMapping(value = "updateType",method = RequestMethod.POST)
public Result updtaeType(@RequestBody FaultType faultType){
return Result.success(faultTypeService.updateById(faultType));
}
/**
*
* @param faultTypeId
* @return
*/
@RequestMapping(value = "deleteType/{faultTypeId}",method = RequestMethod.DELETE)
public Result deleteType(@PathVariable(name = "faultTypeId") Long faultTypeId){
return Result.success(faultTypeService.removeById(faultTypeId));
}
}

View File

@ -3,5 +3,8 @@ package com.muyu.fault.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.fault.common.FaultType;
import java.util.List;
public interface FaultTypeService extends IService<FaultType> {
List<FaultType> faultTypeList(FaultType faultType);
}

View File

@ -1,11 +1,26 @@
package com.muyu.fault.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.fault.common.FaultType;
import com.muyu.fault.mapper.FaultTypeMapper;
import com.muyu.fault.service.FaultTypeService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class FaultTypeServiceImpl extends ServiceImpl<FaultTypeMapper, FaultType> implements FaultTypeService {
@Override
public List<FaultType> faultTypeList(FaultType faultType) {
LambdaQueryWrapper<FaultType> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultType.getFaultTypeName())) {
queryWrapper.like(FaultType::getFaultTypeName,faultType.getFaultTypeName());
}
if (StringUtils.isNotEmpty(faultType.getFaultTypeDescription())) {
queryWrapper.like(FaultType::getFaultTypeDescription,faultType.getFaultTypeDescription());
}
return this.list(queryWrapper);
}
}

View File

@ -42,12 +42,10 @@ public class SysCarFaultServiceImpl
public List<SysCarFault> selectSysCarFaultList(SysCarFault sysCarFault)
{
LambdaQueryWrapper<SysCarFault> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotEmpty(sysCarFault.getFaultType()),
SysCarFault::getFaultType, sysCarFault.getFaultType());
queryWrapper.eq(StringUtils.isNotEmpty(String.valueOf(sysCarFault.getFaultTypeId())),
SysCarFault::getFaultTypeId, sysCarFault.getFaultTypeId());
queryWrapper.eq(StringUtils.isNotEmpty(sysCarFault.getState()),
SysCarFault::getState, sysCarFault.getState());
queryWrapper.eq(StringUtils.isNotEmpty(sysCarFault.getFaultType()),
SysCarFault::getFaultType, sysCarFault.getFaultType());
queryWrapper.like(StringUtils.isNotEmpty(sysCarFault.getCarVin()),
SysCarFault::getCarVin, sysCarFault.getCarVin());
queryWrapper.eq(StringUtils.isNotEmpty(sysCarFault.getFaultWarn()),