83 lines
2.3 KiB
Java

package com.cdzy.operations.controller;
import com.cdzy.common.model.request.PageParam;
import com.cdzy.common.model.response.JsonResult;
import com.cdzy.operations.model.entity.EbikeBikeQr;
import com.cdzy.operations.model.vo.EbikeBikeQrVo;
import com.cdzy.operations.service.EbikeBikeQrService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.util.StringUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static com.cdzy.operations.model.entity.table.EbikeBikeQrTableDef.EBIKE_BIKE_QR;
/**
* 车辆二维码 控制层。
*
* @author attiya
* @since 2025-10-16
*/
@RestController
@RequestMapping("/ebikeBikeQr")
public class EbikeBikeQrController {
@Resource
private EbikeBikeQrService ebikeBikeQrService;
/**
* 生成车辆二维码。
*
* @param qrVo 生成二维码参数
* @return {@code true} 添加成功,{@code false} 添加失败
*/
@PostMapping("addEbikeQr")
public JsonResult<?> addEbikeQr(@RequestBody EbikeBikeQrVo qrVo) throws Exception {
ebikeBikeQrService.addEbikeQr(qrVo);
return JsonResult.success();
}
/**
* 根据主键删除。
*
* @param bikeQrId 主键
* @return {@code true} 删除成功,{@code false} 删除失败
*/
@GetMapping("remove")
public JsonResult<?> remove(Long bikeQrId) {
ebikeBikeQrService.removeById(bikeQrId);
return JsonResult.success();
}
/**
* 查询所有。
*
* @return 所有数据
*/
@GetMapping("list")
public JsonResult<?> list() {
List<EbikeBikeQr> list = ebikeBikeQrService.list();
return JsonResult.success(list);
}
/**
* 分页查询。
*
* @param pageParam 分页对象
* @param bikeQrCode 二维码编号
* @return 分页对象
*/
@GetMapping("page")
public JsonResult<?> page(PageParam pageParam, String bikeQrCode) {
QueryWrapper queryWrapper = QueryWrapper.create()
.where(EBIKE_BIKE_QR.BIKE_QR_CODE.eq(bikeQrCode, StringUtil.hasText(bikeQrCode)));
Page<EbikeBikeQr> page = ebikeBikeQrService.page(pageParam.getPage(), queryWrapper);
return JsonResult.success(page);
}
}