设置单个参数必传 不能为空

This commit is contained in:
小朱 2025-05-26 15:38:33 +08:00
parent c9129438ae
commit 18ab5ec446
3 changed files with 55 additions and 6 deletions

View File

@ -10,7 +10,10 @@ import com.cdzy.ebikeoperate.model.pojo.EbikeHelmetEnterRecords;
import com.cdzy.ebikeoperate.service.EbikeBikeQrcodeService; import com.cdzy.ebikeoperate.service.EbikeBikeQrcodeService;
import com.cdzy.ebikeoperate.service.EbikeComponentService; import com.cdzy.ebikeoperate.service.EbikeComponentService;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import jakarta.validation.constraints.Null;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map; import java.util.Map;
@ -44,7 +47,7 @@ public class EbikeComponentController {
* @return * @return
*/ */
@GetMapping("/invalidateDevicePart") @GetMapping("/invalidateDevicePart")
public JsonResult<?> invalidateDevicePart(@RequestParam(name="componentEnterRecordId")String componentEnterRecordId) { public JsonResult<?> invalidateDevicePart(@RequestParam(name="componentEnterRecordId")@NotNull String componentEnterRecordId) {
return ebikeComponentService.invalidateDevicePart(componentEnterRecordId); return ebikeComponentService.invalidateDevicePart(componentEnterRecordId);
} }
/** /**
@ -53,7 +56,7 @@ public class EbikeComponentController {
* @return * @return
*/ */
@GetMapping("/cancelDevicePart") @GetMapping("/cancelDevicePart")
public JsonResult<?> cancelDevicePart(@RequestParam(name = "componentEnterRecordId") String componentEnterRecordId) { public JsonResult<?> cancelDevicePart(@RequestParam(name = "componentEnterRecordId")@NotNull String componentEnterRecordId) {
return ebikeComponentService.cancelDevicePart(componentEnterRecordId); return ebikeComponentService.cancelDevicePart(componentEnterRecordId);
} }
@ -73,7 +76,7 @@ public class EbikeComponentController {
* @return * @return
*/ */
@GetMapping("/cancelOutDevicePart") @GetMapping("/cancelOutDevicePart")
public JsonResult<?> cancelOutDevicePart(@RequestParam(name = "componentOutRecordId") String componentOutRecordId) { public JsonResult<?> cancelOutDevicePart(@RequestParam(name = "componentOutRecordId")@NotNull String componentOutRecordId) {
return ebikeComponentService.cancelOutDevicePart(componentOutRecordId); return ebikeComponentService.cancelOutDevicePart(componentOutRecordId);
} }
/** /**
@ -82,7 +85,7 @@ public class EbikeComponentController {
* @return * @return
*/ */
@GetMapping("/invalidateOutDevicePart") @GetMapping("/invalidateOutDevicePart")
public JsonResult<?> invalidateOutDevicePart(@RequestParam(name="componentOutRecordId")String componentOutRecordId) { public JsonResult<?> invalidateOutDevicePart(@RequestParam(name="componentOutRecordId")@NotNull String componentOutRecordId) {
return ebikeComponentService.invalidateOutDevicePart(componentOutRecordId); return ebikeComponentService.invalidateOutDevicePart(componentOutRecordId);
} }
@ -116,8 +119,7 @@ public class EbikeComponentController {
* @return ResComponentOutRecordInfoDto * @return ResComponentOutRecordInfoDto
*/ */
@GetMapping("/getComponentOutRecordInfo") @GetMapping("/getComponentOutRecordInfo")
public JsonResult<?> getComponentOutRecordInfo(@RequestParam(name="componentOutRecordId") String componentOutRecordId) { public JsonResult<?> getComponentOutRecordInfo(@RequestParam(name="componentOutRecordId") @NotNull String componentOutRecordId) {
return ebikeComponentService.getComponentOutRecordInfo(componentOutRecordId); return ebikeComponentService.getComponentOutRecordInfo(componentOutRecordId);
} }
} }

View File

@ -2,9 +2,11 @@ package com.cdzy.ebikeoperate.model.dto.response;
import com.cdzy.ebikeoperate.model.pojo.*; import com.cdzy.ebikeoperate.model.pojo.*;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import lombok.Data;
import java.util.List; import java.util.List;
@Data
public class ResComponentOutRecordInfoDto { public class ResComponentOutRecordInfoDto {
/** /**

View File

@ -14,6 +14,7 @@ import com.ebike.feign.model.rsp.StaffFeign;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -674,6 +675,50 @@ public class EbikeComponentServiceImpl implements EbikeComponentService {
public JsonResult<?> getComponentOutRecordInfo(String componentOutRecordId) { public JsonResult<?> getComponentOutRecordInfo(String componentOutRecordId) {
QueryWrapper query = new QueryWrapper(); QueryWrapper query = new QueryWrapper();
ResComponentOutRecordInfoDto resComponentOutRecordInfoDto = new ResComponentOutRecordInfoDto(); ResComponentOutRecordInfoDto resComponentOutRecordInfoDto = new ResComponentOutRecordInfoDto();
query.eq("component_out_record_id", componentOutRecordId);
EbikeComponentOutRecords ebikeComponentOutRecords = ebikeComponentOutRecordsMapper.selectOneByQuery(query);
BeanUtils.copyProperties(ebikeComponentOutRecords, resComponentOutRecordInfoDto);
String componentType = ebikeComponentOutRecords.getComponentType();
ComponentType componentTypeEnum = ComponentType.fromCode(componentType);
switch (componentTypeEnum) {
case BATTERY: // 电池
List<EbikeBatteryOutRecords> ebikeBatteryOutRecords = ebikeBatteryOutRecordsMapper.selectListWithRelationsByQuery(query);
resComponentOutRecordInfoDto.setEbikeBatteryOutRecords(ebikeBatteryOutRecords);
break;
case HELMET: // 头盔
List<EbikeHelmetOutRecords> ebikeHelmetOutRecords = ebikeHelmetOutRecordsMapper.selectListWithRelationsByQuery(query);
resComponentOutRecordInfoDto.setEbikeHelmetOutRecords(ebikeHelmetOutRecords);
break;
case ECU: // 中控
List<EbikeEcuOutRecords> ebikeEcuOutRecords = ebikeEcuOutRecordsMapper.selectListWithRelationsByQuery(query);
resComponentOutRecordInfoDto.setEbikeEcuOutRecords(ebikeEcuOutRecords);
break;
}
//查询是否存在规划记录
EbikeComponentEnterRecords ebikeComponentEnterRecords = ebikeComponentEnterRecordsMapper.selectOneByQuery(query);
if(ebikeComponentEnterRecords!=null){
String componentEnterRecordId = ebikeComponentEnterRecords.getComponentEnterRecordId();
query = new QueryWrapper();
query.eq("component_enter_record_id", componentEnterRecordId);
String componentEnterType = ebikeComponentEnterRecords.getComponentType();
ComponentType componentTypeEnumEnter = ComponentType.fromCode(componentEnterType);
switch (componentTypeEnumEnter) {
case BATTERY: // 电池
List<EbikeBatteryEnterRecords> ebikeBatteryEnterRecords = ebikeBatteryEnterRecordsMapper.selectListWithRelationsByQuery(query);
resComponentOutRecordInfoDto.setEbikeBatteryEnterRecords(ebikeBatteryEnterRecords);
break;
case HELMET: // 头盔
List<EbikeHelmetEnterRecords> ebikeHelmetEnterRecords = ebikeHelmetEnterRecordsMapper.selectListWithRelationsByQuery(query);
resComponentOutRecordInfoDto.setEbikeHelmetEnterRecords(ebikeHelmetEnterRecords);
break;
case ECU: // 中控
List<EbikeEcuEnterRecords> ebikeEcuEnterRecords = ebikeEcuEnterRecordsMapper.selectListWithRelationsByQuery(query);
resComponentOutRecordInfoDto.setEbikeEcuEnterRecords(ebikeEcuEnterRecords);
break;
}
}
return JsonResult.success(resComponentOutRecordInfoDto); return JsonResult.success(resComponentOutRecordInfoDto);
} }
public StaffFeign getStaffFeignInfo() { public StaffFeign getStaffFeignInfo() {