根据头盔编号判断头盔二维码是否存在。

This commit is contained in:
小朱 2025-05-20 16:40:09 +08:00
parent a262061d7b
commit f71e921037

View File

@ -4,6 +4,7 @@ import com.cdzy.common.model.JsonResult;
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeHelmetQrcodeBatchDto;
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeHelmetQrcodeDto;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.cdzy.ebikeoperate.model.pojo.EbikeHelmetQrcode;
@ -101,5 +102,22 @@ public class EbikeHelmetQrcodeController {
Page<EbikeHelmetQrcode> pageRecords = ebikeHelmetQrcodeService.getPageRecords(reqEbikeHelmetQrcodeDto);
return JsonResult.success(pageRecords);
}
/**
* 根据头盔编号判断头盔二维码是否存在
*
* @param helmetCode 头盔二维码
* @return JsonResult 包含查询结果的响应
*/
@GetMapping("/checkhelmetCodeExistence")
public JsonResult<?> checkhelmetCodeExistence(@RequestParam(name = "helmetCode") String helmetCode) {
try {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("helmet_code", helmetCode);
long count = ebikeHelmetQrcodeService.count(queryWrapper);
return JsonResult.success(count);
} catch (Exception e) {
// 记录异常信息
return JsonResult.failed("查询失败,请稍后再试");
}
}
}