55 lines
1.9 KiB
Java
Raw Normal View History

2025-04-14 09:35:36 +08:00
package com.cdzy.ebikemaintenance.controller;
import com.cdzy.common.model.JsonResult;
import com.cdzy.common.model.PageParam;
import com.cdzy.ebikemaintenance.model.pojo.EbikeBikeInfo;
import com.cdzy.ebikemaintenance.service.EbikeBikeInfoService;
import com.cdzy.ebikemaintenance.service.EbikeSystemInfoService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
/**
* 运营车辆控制层
* @author attiya
* @since 2025-03-21
*/
@RestController
@RequestMapping("/operation")
@Validated
public class EbikeOperationController {
@Resource
EbikeBikeInfoService bikeInfoService;
@Resource
private EbikeSystemInfoService ebikeSystemInfoService;
/**
* 运营车辆列表
* @return 运营车辆列表
*/
@GetMapping("page")
public JsonResult<?> page(PageParam pageParam) {
QueryWrapper queryWrapper = QueryWrapper.create()
.where(EBIKE_BIKE_INFO.STATE.eq(1));
Page<EbikeBikeInfo> page = bikeInfoService.page(pageParam.getPage(), queryWrapper);
//汉化状态
page.getRecords().forEach(ebikeBikeInfo -> {
String bike_state = ebikeBikeInfo.getState();
if (bike_state == null || bike_state.isEmpty()) {
bike_state = "0";
}
bike_state = ebikeSystemInfoService.getEbikeCarStatusName(Integer.valueOf(bike_state));
ebikeBikeInfo.setState(bike_state);
});
return JsonResult.success(page);
}
}