|
|
@@ -2,8 +2,10 @@ package com.cyksj.web.controller.manage.goods;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
@@ -82,7 +84,14 @@ public class CmsGoodsDonController {
|
|
|
// 新增商品
|
|
|
GoodsDon goods = new GoodsDon();
|
|
|
BeanUtil.copyProperties(spu, goods);
|
|
|
-
|
|
|
+ if (StrUtil.isNotEmpty(goods.getRecommendTitle())) {
|
|
|
+ if (StrUtil.isEmpty(spu.getRecommendGoods())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择推荐的对应平台");
|
|
|
+ }
|
|
|
+ String recommendGoods = spu.getRecommendGoods();
|
|
|
+ Set<Long> goodsIds = Jsons.parseSet(recommendGoods, Long.class);
|
|
|
+ goods.setRecommendGoods(Jsons.toJson(goodsIds));
|
|
|
+ }
|
|
|
goodsDonService.save(goods);
|
|
|
Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
|
|
|
redisService.del(keys.toArray(String[]::new));
|
|
|
@@ -101,6 +110,23 @@ public class CmsGoodsDonController {
|
|
|
if (spu.getSpecialType() == null) {
|
|
|
goods.setSpecialType(null);
|
|
|
}
|
|
|
+ if (StrUtil.isNotEmpty(goods.getRecommendTitle())) {
|
|
|
+ if (StrUtil.isEmpty(spu.getRecommendGoods())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择推荐的对应平台");
|
|
|
+ }
|
|
|
+ String recommendGoods = spu.getRecommendGoods();
|
|
|
+ Set<Long> goodsIds = Jsons.parseSet(recommendGoods, Long.class);
|
|
|
+ //去除自己
|
|
|
+ goodsIds.remove(spu.getId());
|
|
|
+ goods.setRecommendGoods(Jsons.toJson(goodsIds));
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(goods.getRecommendTitle())) {
|
|
|
+ goods.setRecommendTitle(null);
|
|
|
+ goods.setRecommendGoods(null);
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(goods.getVideo())) {
|
|
|
+ goods.setVideo(null);
|
|
|
+ }
|
|
|
goodsDonService.updateById(goods);
|
|
|
Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
|
|
|
redisService.del(keys.toArray(String[]::new));
|