|
@@ -0,0 +1,84 @@
|
|
|
|
+package com.gree.mall.contest.logic.goods;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.gree.mall.contest.bean.admin.AdminUserCom;
|
|
|
|
+import com.gree.mall.contest.exception.RemoteServiceException;
|
|
|
|
+import com.gree.mall.contest.logic.common.CommonLogic;
|
|
|
|
+import com.gree.mall.contest.plus.entity.GoodsTag;
|
|
|
|
+import com.gree.mall.contest.plus.service.GoodsTagService;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
+public class GoodsTagLogic {
|
|
|
|
+
|
|
|
|
+ private final GoodsTagService goodsTagService;
|
|
|
|
+ private final CommonLogic commonLogic;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * page查询商品标签
|
|
|
|
+ */
|
|
|
|
+ public IPage<GoodsTag> pageGoodsTag(HttpServletRequest request, Integer pageNum, Integer pageSize, Integer type) {
|
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
+ List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
|
|
+
|
|
|
|
+ return goodsTagService.lambdaQuery()
|
|
|
|
+ .in(CollectionUtil.isNotEmpty(companyWechatIds), GoodsTag::getCompanyWechatId, companyWechatIds)
|
|
|
|
+ .eq(type != null, GoodsTag::getType, type)
|
|
|
|
+ .page(new Page<>(pageNum, pageSize));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量编辑标签
|
|
|
|
+ */
|
|
|
|
+ public void updateGoodsTag(HttpServletRequest request, String tags,Integer type) {
|
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
+ String loginCompanyWechatId = adminUser.getLoginCompanyWechatId();
|
|
|
|
+ if (StringUtils.isEmpty(loginCompanyWechatId)) {
|
|
|
|
+ throw new RemoteServiceException("无编辑标签权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //清除旧标签
|
|
|
|
+ goodsTagService.lambdaUpdate()
|
|
|
|
+ .eq(GoodsTag::getCompanyWechatId, loginCompanyWechatId)
|
|
|
|
+ .eq(GoodsTag::getType, type)
|
|
|
|
+ .remove();
|
|
|
|
+
|
|
|
|
+ //添加新标签
|
|
|
|
+ if (StringUtils.isNotEmpty(tags)) {
|
|
|
|
+ List<String> tagList = Arrays.asList(tags.trim().split(","));
|
|
|
|
+
|
|
|
|
+ List<GoodsTag> saveTagList = new ArrayList<>();
|
|
|
|
+ for (String tagStr : tagList
|
|
|
|
+ ) {
|
|
|
|
+ GoodsTag goodsTag = new GoodsTag();
|
|
|
|
+ goodsTag.setGoodsTagName(tagStr);
|
|
|
|
+ goodsTag.setCreateBy(adminUser.getAdminUserId());
|
|
|
|
+ goodsTag.setCompanyWechatId(loginCompanyWechatId);
|
|
|
|
+ goodsTag.setCompanyName(adminUser.getLoginCompanyName());
|
|
|
|
+ goodsTag.setType(type);
|
|
|
|
+ saveTagList.add(goodsTag);
|
|
|
|
+ }
|
|
|
|
+ goodsTagService.saveBatch(saveTagList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|