新增接口根据车辆编号修改车辆状态
This commit is contained in:
parent
70e2416f13
commit
0452652273
@ -813,5 +813,18 @@ public class EbikeBikeInfoController {
|
||||
|
||||
return JsonResult.success(inventoryBikeListDtoPage);
|
||||
}
|
||||
/**
|
||||
* 修改车辆状态
|
||||
*
|
||||
* @param request 车辆状态修改请求参数
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("updateVehicleStatus")
|
||||
public JsonResult<?> updateVehicleStatus(@RequestBody ReqVehicleStatusUpdateDto request) {
|
||||
// 调用服务层方法,执行车辆状态修改操作
|
||||
return ebikeBikeInfoService.updateVehicleStatus(request);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.cdzy.ebikemaintenance.model.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class ReqVehicleStatusUpdateDto {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 车辆编号
|
||||
*/
|
||||
private String bikeCode;
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.ebikemaintenance.service;
|
||||
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.ebikemaintenance.model.dto.request.*;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.*;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.ResEbikeBikeComDto;
|
||||
@ -269,4 +270,12 @@ public interface EbikeBikeInfoService extends IService<EbikeBikeInfo> {
|
||||
* @return
|
||||
*/
|
||||
Page<ResInventoryBikeListDto> getOperationalBikeList(ReqEbikeCheckinDto queryParam);
|
||||
|
||||
/**
|
||||
* 修改车辆状态
|
||||
*
|
||||
* @param queryParam 车辆状态修改请求参数
|
||||
* @return
|
||||
*/
|
||||
JsonResult<?> updateVehicleStatus(ReqVehicleStatusUpdateDto queryParam);
|
||||
}
|
||||
|
||||
@ -1308,4 +1308,32 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
Page<ResInventoryBikeListDto> page = Page.of(queryParam.getPageParam().getPage().getPageNumber(), queryParam.getPageParam().getPageSize());
|
||||
return ebikeBikeInfoMapper.paginateAs(page, query, ResInventoryBikeListDto.class);
|
||||
}
|
||||
|
||||
public JsonResult<?> updateVehicleStatus(ReqVehicleStatusUpdateDto queryParam) {
|
||||
String bikeCode = queryParam.getBikeCode();
|
||||
// 根据 bikeCode 查找 bikeId
|
||||
QueryWrapper query = QueryWrapper.create();
|
||||
query.eq("bike_code",bikeCode);
|
||||
EbikeBikeInfo ebikeBikeInfo = ebikeBikeInfoMapper.selectOneByQuery(query);
|
||||
|
||||
if (ebikeBikeInfo.getBikeId() == null) {
|
||||
return JsonResult.failed("未找到该车辆的ID");
|
||||
}
|
||||
|
||||
// 创建更新请求 DTO,设置 bikeId 和新的状态
|
||||
EbikeBikeInfo updateDto = new EbikeBikeInfo();
|
||||
updateDto.setBikeId(ebikeBikeInfo.getBikeId());
|
||||
updateDto.setState(queryParam.getState());
|
||||
updateDto.setUpdatedAt(LocalDateTime.now()); // 设置更新时间
|
||||
|
||||
// 调用服务层方法,执行车辆状态更新
|
||||
int update = ebikeBikeInfoMapper.update(updateDto);
|
||||
|
||||
if(update>0){
|
||||
return JsonResult.success("车辆状态修改成功");
|
||||
} else {
|
||||
return JsonResult.failed("车辆状态修改失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user