电池批量绑定状态判断
This commit is contained in:
parent
7a84f80e84
commit
43d819b9f5
@ -51,11 +51,14 @@ public class EbikeBatteryInfoController {
|
||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||
*/
|
||||
@GetMapping("bind")
|
||||
public JsonResult<?> bind(@RequestParam("batteryId")Long batteryId){
|
||||
public JsonResult<?> bind(@RequestParam("batteryId") Long batteryId) {
|
||||
EbikeBatteryInfo batteryInfo = ebikeBatteryInfoService.getById(batteryId);
|
||||
if (batteryInfo == null) {
|
||||
throw new EbikeException("电池ID错误");
|
||||
}
|
||||
if (batteryInfo.getStatus() == BatteryStatus.BIND) {
|
||||
throw new EbikeException("该电池已绑定");
|
||||
}
|
||||
batteryInfo.setStatus(BatteryStatus.BIND);
|
||||
ebikeBatteryInfoService.updateById(batteryInfo);
|
||||
return JsonResult.success();
|
||||
@ -68,7 +71,14 @@ public class EbikeBatteryInfoController {
|
||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||
*/
|
||||
@GetMapping("batchBind")
|
||||
public JsonResult<?> batchBind(@RequestBody EbikeBatteryInfoIdVo ids){
|
||||
public JsonResult<?> batchBind(@RequestBody EbikeBatteryInfoIdVo ids) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BATTERY_INFO.BATTERY_ID.in(ids.getBatteryIds()))
|
||||
.where(EBIKE_BATTERY_INFO.STATUS.eq(BatteryStatus.BIND));
|
||||
long count = ebikeBatteryInfoService.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new EbikeException("选择电池集合中包含已绑定电池");
|
||||
}
|
||||
UpdateChain.of(EbikeBatteryInfo.class)
|
||||
.set(EbikeBatteryInfo::getStatus, BatteryStatus.BIND)
|
||||
.where(EbikeBatteryInfo::getBatteryId).in(ids.getBatteryIds());
|
||||
@ -81,7 +91,7 @@ public class EbikeBatteryInfoController {
|
||||
* @param batteryId 主键
|
||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||
*/
|
||||
@PostMapping("remove")
|
||||
@GetMapping("remove")
|
||||
public JsonResult<?> remove(@RequestParam(value = "batteryId") Long batteryId) {
|
||||
ebikeBatteryInfoService.removeById(batteryId);
|
||||
return JsonResult.success();
|
||||
@ -106,10 +116,10 @@ public class EbikeBatteryInfoController {
|
||||
* @return 分页对象
|
||||
*/
|
||||
@GetMapping("page")
|
||||
public JsonResult<?> page(PageParam pageParam,Integer status) {
|
||||
public JsonResult<?> page(PageParam pageParam, Integer status) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BATTERY_INFO.STATUS.eq(status, Objects.nonNull(status)));
|
||||
Page<EbikeBatteryInfo> page = ebikeBatteryInfoService.page(pageParam.getPage(),queryWrapper);
|
||||
Page<EbikeBatteryInfo> page = ebikeBatteryInfoService.page(pageParam.getPage(), queryWrapper);
|
||||
return JsonResult.success(page);
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +75,7 @@ public class EbikeEcuInfoController {
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有中控基本信息。
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user