109 lines
3.7 KiB
Java
109 lines
3.7 KiB
Java
package com.cdzy.ebikeoperate.controller;
|
|
|
|
import com.cdzy.common.model.JsonResult;
|
|
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeBikeQrcodeBatchDto;
|
|
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeBikeQrcodeDto;
|
|
import com.mybatisflex.core.paginate.Page;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import com.cdzy.ebikeoperate.model.pojo.EbikeBikeQrcode;
|
|
import com.cdzy.ebikeoperate.service.EbikeBikeQrcodeService;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 车辆二维码 控制层。
|
|
*
|
|
* @author dingchao
|
|
* @since 2025-03-25
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/ebikeBikeQrcode")
|
|
public class EbikeBikeQrcodeController {
|
|
|
|
@Autowired
|
|
private EbikeBikeQrcodeService ebikeBikeQrcodeService;
|
|
|
|
/**
|
|
* 添加车辆二维码。
|
|
*
|
|
* @param ebikeBikeQrcode 车辆二维码
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
*/
|
|
@PostMapping("save")
|
|
public JsonResult<?> save(@RequestBody EbikeBikeQrcode ebikeBikeQrcode) {
|
|
boolean r = ebikeBikeQrcodeService.save(ebikeBikeQrcode);
|
|
return r? JsonResult.success() : JsonResult.failed("添加车辆二维码失败");
|
|
}
|
|
|
|
/**
|
|
* 批量添加车辆二维码。
|
|
*
|
|
* @param ebikeBikeCodes 车辆二维码列表
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
*/
|
|
@PostMapping("batchSave")
|
|
public JsonResult<?> batchSave(@RequestBody ReqEbikeBikeQrcodeBatchDto ebikeBikeCodes) {
|
|
List<EbikeBikeQrcode> ebikeBikeQrcodeList = ebikeBikeCodes.getBikeCodes().stream().map(code -> {
|
|
EbikeBikeQrcode ebikeBikeQrcode = new EbikeBikeQrcode();
|
|
ebikeBikeQrcode.setComponentProId(ebikeBikeCodes.getComponentProId());
|
|
ebikeBikeQrcode.setBikeCode(code);
|
|
return ebikeBikeQrcode;
|
|
}).toList();
|
|
boolean r = ebikeBikeQrcodeService.saveBatch(ebikeBikeQrcodeList);
|
|
return r? JsonResult.success() : JsonResult.failed("添加车辆二维码失败");
|
|
}
|
|
|
|
/**
|
|
* 根据主键更新车辆二维码。
|
|
*
|
|
* @param ebikeBikeQrcode 车辆二维码
|
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
*/
|
|
@PostMapping("update")
|
|
public JsonResult<?> update(@RequestBody EbikeBikeQrcode ebikeBikeQrcode) {
|
|
boolean r = ebikeBikeQrcodeService.updateById(ebikeBikeQrcode);
|
|
return r? JsonResult.success() : JsonResult.failed("更新车辆二维码失败");
|
|
}
|
|
|
|
/**
|
|
* 批量更新车辆二维码。
|
|
*
|
|
* @param ebikeBikeQrcodes 车辆二维码列表
|
|
* @return
|
|
*/
|
|
@PostMapping("updateBatch")
|
|
public JsonResult<?> updateBatch(@RequestBody List<EbikeBikeQrcode> ebikeBikeQrcodes) {
|
|
boolean r = ebikeBikeQrcodeService.updateBatch(ebikeBikeQrcodes);
|
|
return r? JsonResult.success() : JsonResult.failed("更新车辆二维码失败");
|
|
}
|
|
|
|
|
|
/**
|
|
* 根据车辆二维码主键获取详细信息。
|
|
*
|
|
* @param id 车辆二维码主键
|
|
* @return 车辆二维码详情
|
|
*/
|
|
@GetMapping("getInfo")
|
|
public JsonResult<?> getInfo(@RequestParam(name = "id") String id) {
|
|
EbikeBikeQrcode r = ebikeBikeQrcodeService.getById(id);
|
|
if(r == null)
|
|
return JsonResult.failed("获取车辆二维码详细失败信息");
|
|
return JsonResult.success(r);
|
|
}
|
|
|
|
/**
|
|
* 分页查询车辆二维码。
|
|
*
|
|
* @param reqEbikeBikeQrcodeDto 分页查询条件
|
|
* @return 分页对象
|
|
*/
|
|
@PostMapping("list")
|
|
public JsonResult<?> list(@RequestBody ReqEbikeBikeQrcodeDto reqEbikeBikeQrcodeDto) {
|
|
Page<EbikeBikeQrcode> pageRecords = ebikeBikeQrcodeService.getPageRecords(reqEbikeBikeQrcodeDto);
|
|
return JsonResult.success(pageRecords);
|
|
}
|
|
|
|
}
|