public Result<ProdBatch> add(@RequestBody ProdBatch prodBatch, HttpServletRequest request) { Result<ProdBatch> result = new Result<ProdBatch>(); try { QueryWrapper<ProdBatch> queryWrapper = new QueryWrapper<ProdBatch>(); queryWrapper.eq("is_delete", 0); queryWrapper.and(wrapper -> wrapper.eq("batch_name", prodBatch.getBatchName()).or().eq("batch_code", prodBatch.getBatchCode())); queryWrapper.eq("company_id", prodBatch.getCompanyId()); queryWrapper.eq("plat_id", prodBatch.getPlatId()); queryWrapper.orderByDesc("create_date"); List<ProdBatch> prodBatchList = prodBatchService.list(queryWrapper); if (prodBatchList != null && prodBatchList.size() > 0) { result.setSuccess(false); result.setMessage("产品批次名称或产品批次编号重复"); return result; } prodBatch.setCreateDate(new Date()); prodBatch.setModifiedDate(new Date()); prodBatchService.save(prodBatch); result.success("添加成功!"); } catch (Exception e) { e.printStackTrace(); log.info(e.getMessage()); result.error500("操作失败"); } return result; }
切记不能丢了and
打印出来的sql为