|
@@ -98,9 +98,51 @@ public class StoreCuisineController {
|
|
|
return R.fail("新增失败:数据保存异常");
|
|
return R.fail("新增失败:数据保存异常");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ log.info("新增成功,返回ID: {}", savedCuisine.getId());
|
|
|
|
|
+ return R.data(savedCuisine, "新增成功");
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("新增美食套餐或单品异常", e);
|
|
|
|
|
+ return R.fail("新增失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("修改美食套餐或单品")
|
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
|
+ @PostMapping("/updateCuisineCombo")
|
|
|
|
|
+ public R<String> updateCuisineCombo(@RequestBody CuisineComboDto cuisineComboDto) {
|
|
|
|
|
+ log.info("StoreCuisineController.updateCuisineCombo?dto={}", cuisineComboDto);
|
|
|
|
|
+
|
|
|
|
|
+ // 参数验证
|
|
|
|
|
+ if (cuisineComboDto == null) {
|
|
|
|
|
+ log.error("修改美食套餐或单品失败:参数不能为空");
|
|
|
|
|
+ return R.fail("参数不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验ID不能为空
|
|
|
|
|
+ if (cuisineComboDto.getId() == null) {
|
|
|
|
|
+ log.error("修改美食套餐或单品失败:ID不能为空");
|
|
|
|
|
+ return R.fail("ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 更新数据
|
|
|
|
|
+ boolean updateResult = storeCuisineService.updateCuisineCombo(cuisineComboDto);
|
|
|
|
|
+ if (!updateResult) {
|
|
|
|
|
+ log.error("修改美食套餐或单品失败:更新操作返回false");
|
|
|
|
|
+ return R.fail("修改失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询更新后的记录
|
|
|
|
|
+ StoreCuisine updatedCuisine = storeCuisineService.getById(cuisineComboDto.getId());
|
|
|
|
|
+ if (updatedCuisine == null) {
|
|
|
|
|
+ log.error("修改美食套餐或单品失败:更新后查询不到数据,ID={}", cuisineComboDto.getId());
|
|
|
|
|
+ return R.fail("修改失败:数据更新异常");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 将状态置为"审核中"(0)
|
|
// 将状态置为"审核中"(0)
|
|
|
LambdaUpdateWrapper<StoreCuisine> auditingWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<StoreCuisine> auditingWrapper = new LambdaUpdateWrapper<>();
|
|
|
- auditingWrapper.eq(StoreCuisine::getId, savedCuisine.getId());
|
|
|
|
|
|
|
+ auditingWrapper.eq(StoreCuisine::getId, updatedCuisine.getId());
|
|
|
auditingWrapper.set(StoreCuisine::getStatus, 0);
|
|
auditingWrapper.set(StoreCuisine::getStatus, 0);
|
|
|
auditingWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
auditingWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
|
auditingWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
auditingWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
@@ -158,7 +200,7 @@ public class StoreCuisineController {
|
|
|
boolean allPassed = (auditResult != null);
|
|
boolean allPassed = (auditResult != null);
|
|
|
|
|
|
|
|
LambdaUpdateWrapper<StoreCuisine> auditUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<StoreCuisine> auditUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- auditUpdateWrapper.eq(StoreCuisine::getId, savedCuisine.getId());
|
|
|
|
|
|
|
+ auditUpdateWrapper.eq(StoreCuisine::getId, updatedCuisine.getId());
|
|
|
auditUpdateWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
auditUpdateWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
|
auditUpdateWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
auditUpdateWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
|
|
|
|
|
@@ -166,42 +208,22 @@ public class StoreCuisineController {
|
|
|
// 审核通过 审核状态为1 上架状态为1 已上架
|
|
// 审核通过 审核状态为1 上架状态为1 已上架
|
|
|
auditUpdateWrapper.set(StoreCuisine::getStatus, 1);
|
|
auditUpdateWrapper.set(StoreCuisine::getStatus, 1);
|
|
|
auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 1);
|
|
auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 1);
|
|
|
- log.info("AI审核通过,ID: {}", savedCuisine.getId());
|
|
|
|
|
|
|
+ log.info("AI审核通过,ID: {}", updatedCuisine.getId());
|
|
|
} else {
|
|
} else {
|
|
|
// 审核拒绝 审核状态为2 上架状态为0 没有上下架状态
|
|
// 审核拒绝 审核状态为2 上架状态为0 没有上下架状态
|
|
|
auditUpdateWrapper.set(StoreCuisine::getStatus, 2);
|
|
auditUpdateWrapper.set(StoreCuisine::getStatus, 2);
|
|
|
auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 0);
|
|
auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 0);
|
|
|
- log.info("AI审核拒绝,ID: {}", savedCuisine.getId());
|
|
|
|
|
|
|
+ log.info("AI审核拒绝,ID: {}", updatedCuisine.getId());
|
|
|
}
|
|
}
|
|
|
storeCuisineMapper.update(null, auditUpdateWrapper);
|
|
storeCuisineMapper.update(null, auditUpdateWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 重新查询一次,返回最新的数据
|
|
|
|
|
- StoreCuisine finalCuisine = storeCuisineService.getById(savedCuisine.getId());
|
|
|
|
|
- if (finalCuisine != null) {
|
|
|
|
|
- log.info("新增成功,返回ID: {}", finalCuisine.getId());
|
|
|
|
|
- return R.data(finalCuisine, "新增成功");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 如果查询失败,返回保存后的对象(至少包含ID)
|
|
|
|
|
- log.warn("新增成功但最终查询失败,返回保存后的对象,ID: {}", savedCuisine.getId());
|
|
|
|
|
- return R.data(savedCuisine, "新增成功");
|
|
|
|
|
|
|
+ return R.success("修改成功");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("新增美食套餐或单品异常", e);
|
|
|
|
|
- return R.fail("新增失败:" + e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @ApiOperation("修改美食套餐或单品")
|
|
|
|
|
- @ApiOperationSupport(order = 2)
|
|
|
|
|
- @PostMapping("/updateCuisineCombo")
|
|
|
|
|
- public R<String> updateCuisineCombo(@RequestBody CuisineComboDto cuisineComboDto) {
|
|
|
|
|
- log.info("StoreCuisineController.updateCuisineCombo?dto={}", cuisineComboDto);
|
|
|
|
|
- if (storeCuisineService.updateCuisineCombo(cuisineComboDto)) {
|
|
|
|
|
- return R.success("修改成功");
|
|
|
|
|
|
|
+ log.error("修改美食套餐或单品异常", e);
|
|
|
|
|
+ return R.fail("修改失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
- return R.fail("修改失败");
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("获取所有美食单品名称,用于添加套餐")
|
|
@ApiOperation("获取所有美食单品名称,用于添加套餐")
|