167 lines
4.6 KiB
Java
Raw Normal View History

2025-09-15 15:48:54 +08:00
package com.cdzy.operations.controller;
import com.cdzy.common.model.request.PageParam;
import com.cdzy.common.model.response.JsonResult;
2025-10-16 10:15:43 +08:00
import com.cdzy.operations.model.dto.EbikeEcuInOverview;
2025-09-15 15:48:54 +08:00
import com.cdzy.operations.model.entity.EbikeEcuInfo;
2025-10-15 15:18:46 +08:00
import com.cdzy.operations.model.vo.EbikeEcuInfoBatchVo;
2025-09-15 15:48:54 +08:00
import com.cdzy.operations.model.vo.EbikeEcuInfoVo;
import com.cdzy.operations.service.EbikeEcuInfoService;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
2025-10-31 10:07:37 +08:00
import jakarta.validation.constraints.NotNull;
2025-09-15 15:48:54 +08:00
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
2025-10-30 10:46:28 +08:00
import java.io.IOException;
2025-09-15 15:48:54 +08:00
import java.util.List;
/**
* 中控基本信息 控制层
*
* @author attiya
* @since 2025-09-15
*/
@RestController
@RequestMapping("/ebikeEcuInfo")
@Validated
public class EbikeEcuInfoController {
@Resource
private EbikeEcuInfoService ebikeEcuInfoService;
/**
* 中控入库
*
* @param ebikeEcuInfo 中控基本信息
* @return {@code true} 添加成功{@code false} 添加失败
*/
@PostMapping("save")
public JsonResult<?> saveEcu(@Validated @RequestBody EbikeEcuInfoVo ebikeEcuInfo) {
ebikeEcuInfoService.saveEcu(ebikeEcuInfo);
return JsonResult.success();
}
2025-10-15 15:18:46 +08:00
/**
* 批量入库
*
* @param batchVo 中控信息
* @return {@code true} 添加成功{@code false} 添加失败
*/
@PostMapping("batchSave")
public JsonResult<?> batchSave(@Validated @RequestBody EbikeEcuInfoBatchVo batchVo) {
ebikeEcuInfoService.batchSave(batchVo);
return JsonResult.success();
}
2025-09-15 15:48:54 +08:00
/**
* 根据主键删除中控基本信息
*
* @param ecuId 主键
* @return {@code true} 删除成功{@code false} 删除失败
*/
@GetMapping("remove")
public JsonResult<?> remove(@RequestParam("ecuId") Long ecuId) {
ebikeEcuInfoService.removeById(ecuId);
return JsonResult.success();
}
/**
* 根据主键更新中控基本信息
*
* @param ebikeEcuInfo 中控基本信息
* @return {@code true} 更新成功{@code false} 更新失败
*/
@PostMapping("update")
public JsonResult<?> update(@RequestBody EbikeEcuInfo ebikeEcuInfo) {
ebikeEcuInfoService.updateById(ebikeEcuInfo);
return JsonResult.success();
}
2025-10-16 09:42:11 +08:00
2025-09-15 15:48:54 +08:00
/**
* 查询所有中控基本信息
*
* @return 所有数据
*/
@GetMapping("list")
public JsonResult<?> list() {
List<EbikeEcuInfo> list = ebikeEcuInfoService.list();
return JsonResult.success(list);
}
2025-10-16 10:15:43 +08:00
/**
* 中控总览
*
* @return 所有数据
*/
@GetMapping("overview")
public JsonResult<?> overview() {
List<EbikeEcuInOverview> list = ebikeEcuInfoService.overview();
return JsonResult.success(list);
}
2025-09-15 15:48:54 +08:00
/**
* 根据中控基本信息主键获取详细信息
*
* @param ecuId 中控基本信息主键
* @return 中控基本信息详情
*/
@GetMapping("getInfo")
public JsonResult<?> getInfo(@RequestParam("ecuId") Long ecuId) {
EbikeEcuInfo info = ebikeEcuInfoService.getById(ecuId);
return JsonResult.success(info);
}
/**
* 分页查询中控基本信息
*
* @param pageParam 分页对象
* @return 分页对象
*/
@GetMapping("page")
public JsonResult<?> page(PageParam pageParam) {
Page<EbikeEcuInfo> paged = ebikeEcuInfoService.page(pageParam.getPage());
return JsonResult.success(paged);
}
2025-10-30 10:46:28 +08:00
2025-10-30 16:38:04 +08:00
/**
* 校验SN或BikeCode
*
* @return 执行结构
*/
@GetMapping("checkSnOrBikeCode")
2025-10-31 10:07:37 +08:00
public JsonResult<?> checkSnOrBikeCode(String ecuSn,String bikeCode) {
2025-10-30 16:38:04 +08:00
boolean result = ebikeEcuInfoService.checkSnOrBikeCode(ecuSn,bikeCode);
return JsonResult.success(result);
}
2025-10-30 10:46:28 +08:00
/**
* 设备是否在线
*
* @return 执行结构
*/
@GetMapping("online")
public JsonResult<?> online(String ecuSn,String bikeCode) throws IOException {
boolean online = ebikeEcuInfoService.online(ecuSn,bikeCode);
return JsonResult.success(online);
}
/**
2025-10-31 10:07:37 +08:00
* 执行命令
2025-10-30 10:46:28 +08:00
*
* @return 执行结构
*/
2025-10-31 10:07:37 +08:00
@GetMapping("executeCommand")
public JsonResult<?> executeCommand(String ecuSn,String bikeCode,@NotNull(message = "命令编码不能为空") String commandCode) {
boolean findBike = ebikeEcuInfoService.executeCommand(ecuSn,bikeCode,commandCode);
2025-10-30 10:46:28 +08:00
return JsonResult.success(findBike);
}
2025-09-15 15:48:54 +08:00
}