|
|
@@ -155,14 +155,13 @@ public class StoreCuisineController {
|
|
|
// 执行AI审核
|
|
|
if (StringUtils.isNotEmpty(textContent.toString()) || imageUrls.size() > 0) {
|
|
|
AiContentModerationUtil.AuditResult auditResult = aiContentModerationUtil.auditContent(textContent.toString(), imageUrls);
|
|
|
- boolean allPassed = (auditResult != null);
|
|
|
|
|
|
LambdaUpdateWrapper<StoreCuisine> auditUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
auditUpdateWrapper.eq(StoreCuisine::getId, savedCuisine.getId());
|
|
|
auditUpdateWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
|
auditUpdateWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
|
|
|
|
- if (allPassed) {
|
|
|
+ if (auditResult.isPassed()) {
|
|
|
// 审核通过 审核状态为1 上架状态为1 已上架
|
|
|
auditUpdateWrapper.set(StoreCuisine::getStatus, 1);
|
|
|
auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 1);
|
|
|
@@ -198,10 +197,118 @@ public class StoreCuisineController {
|
|
|
@PostMapping("/updateCuisineCombo")
|
|
|
public R<String> updateCuisineCombo(@RequestBody CuisineComboDto cuisineComboDto) {
|
|
|
log.info("StoreCuisineController.updateCuisineCombo?dto={}", cuisineComboDto);
|
|
|
- if (storeCuisineService.updateCuisineCombo(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)
|
|
|
+ LambdaUpdateWrapper<StoreCuisine> auditingWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ auditingWrapper.eq(StoreCuisine::getId, updatedCuisine.getId());
|
|
|
+ auditingWrapper.set(StoreCuisine::getStatus, 0);
|
|
|
+ auditingWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
|
+ auditingWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
|
+ storeCuisineMapper.update(null, auditingWrapper);
|
|
|
+
|
|
|
+ // 组装 AI 审核文本和图片
|
|
|
+ StringBuilder textContent = new StringBuilder();
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getName())) {
|
|
|
+ textContent.append(cuisineComboDto.getName()).append(" ");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getDetailContent())) {
|
|
|
+ textContent.append(cuisineComboDto.getDetailContent()).append(" ");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getDescription())) {
|
|
|
+ textContent.append(cuisineComboDto.getDescription()).append(" ");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getDishReview())) {
|
|
|
+ textContent.append(cuisineComboDto.getDishReview()).append(" ");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getExtraNote())) {
|
|
|
+ textContent.append(cuisineComboDto.getExtraNote()).append(" ");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getReserveRule())) {
|
|
|
+ textContent.append(cuisineComboDto.getReserveRule()).append(" ");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getUsageRule())) {
|
|
|
+ textContent.append(cuisineComboDto.getUsageRule()).append(" ");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> imageUrls = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getImages())) {
|
|
|
+ String[] urls = cuisineComboDto.getImages().split(",");
|
|
|
+ for (String url : urls) {
|
|
|
+ if (StringUtils.isNotEmpty(url.trim())) {
|
|
|
+ String trimmedUrl = url.trim();
|
|
|
+ imageUrls.add(trimmedUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(cuisineComboDto.getImageContent())) {
|
|
|
+ String[] urls = cuisineComboDto.getImageContent().split(",");
|
|
|
+ for (String url : urls) {
|
|
|
+ if (StringUtils.isNotEmpty(url.trim())) {
|
|
|
+ String trimmedUrl = url.trim();
|
|
|
+ imageUrls.add(trimmedUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行AI审核
|
|
|
+ if (StringUtils.isNotEmpty(textContent.toString()) || imageUrls.size() > 0) {
|
|
|
+ AiContentModerationUtil.AuditResult auditResult = aiContentModerationUtil.auditContent(textContent.toString(), imageUrls);
|
|
|
+// boolean allPassed = (auditResult != null);
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<StoreCuisine> auditUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ auditUpdateWrapper.eq(StoreCuisine::getId, updatedCuisine.getId());
|
|
|
+ auditUpdateWrapper.set(StoreCuisine::getRejectionReason, null);
|
|
|
+ auditUpdateWrapper.set(StoreCuisine::getAuditTime, new Date());
|
|
|
+
|
|
|
+ if (auditResult.isPassed()) {
|
|
|
+ // 审核通过 审核状态为1 上架状态为1 已上架
|
|
|
+ auditUpdateWrapper.set(StoreCuisine::getStatus, 1);
|
|
|
+ auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 1);
|
|
|
+ log.info("AI审核通过,ID: {}", updatedCuisine.getId());
|
|
|
+ } else {
|
|
|
+ // 审核拒绝 审核状态为2 上架状态为0 没有上下架状态
|
|
|
+ auditUpdateWrapper.set(StoreCuisine::getStatus, 2);
|
|
|
+ auditUpdateWrapper.set(StoreCuisine::getShelfStatus, 0);
|
|
|
+ log.info("AI审核拒绝,ID: {}", updatedCuisine.getId());
|
|
|
+ }
|
|
|
+ storeCuisineMapper.update(null, auditUpdateWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
return R.success("修改成功");
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("修改美食套餐或单品异常", e);
|
|
|
+ return R.fail("修改失败:" + e.getMessage());
|
|
|
}
|
|
|
- return R.fail("修改失败");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取所有美食单品名称,用于添加套餐")
|
|
|
@@ -325,7 +432,7 @@ public class StoreCuisineController {
|
|
|
if(null==origin){
|
|
|
queryWrapper.eq(StoreCuisine::getShelfStatus, 1);
|
|
|
}else if(origin == 0){
|
|
|
- queryWrapper.in(StoreCuisine::getShelfStatus, 1,2);
|
|
|
+ queryWrapper.in(StoreCuisine::getShelfStatus, 0,1,2);
|
|
|
}
|
|
|
else{
|
|
|
queryWrapper.eq(StoreCuisine::getShelfStatus, origin);
|
|
|
@@ -377,7 +484,7 @@ public class StoreCuisineController {
|
|
|
if(null==origin){
|
|
|
queryWrapper.eq(StorePrice::getShelfStatus, 1);
|
|
|
}else if(origin == 0){
|
|
|
- queryWrapper.in(StorePrice::getShelfStatus, 1,2);
|
|
|
+ queryWrapper.in(StorePrice::getShelfStatus, 0,1,2);
|
|
|
}
|
|
|
else{
|
|
|
queryWrapper.eq(StorePrice::getShelfStatus, origin);
|