|
@@ -0,0 +1,192 @@
|
|
|
+package com.caimei365.manager.service.caimei.user.impl;
|
|
|
+
|
|
|
+import com.caimei.utils.StringUtils;
|
|
|
+import com.caimei365.manager.dao.user.CmShopLabelDao;
|
|
|
+import com.caimei365.manager.entity.PaginationVo;
|
|
|
+import com.caimei365.manager.entity.ResponseJson;
|
|
|
+import com.caimei365.manager.entity.caimei.CmShop;
|
|
|
+import com.caimei365.manager.entity.caimei.CmShopLabel;
|
|
|
+import com.caimei365.manager.entity.caimei.CmShopRelevance;
|
|
|
+import com.caimei365.manager.service.caimei.user.CmShopLabelService;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Description
|
|
|
+ *
|
|
|
+ * @author : Charles
|
|
|
+ * @date : 2023/3/15
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CmShopLabelServiceImpl implements CmShopLabelService {
|
|
|
+ @Resource private CmShopLabelDao cmShopLabelDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关联标签供应商列表
|
|
|
+ * @param cmShopRelevance 搜索条件
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 页面数据数
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<CmShopRelevance>> pageList(CmShopRelevance cmShopRelevance, Integer pageNum, Integer pageSize) {
|
|
|
+ List<CmShopRelevance> relevanceList = cmShopLabelDao.shopRelevanceList(cmShopRelevance);
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
+ PaginationVo<CmShopRelevance> pageList = new PaginationVo<>(relevanceList);
|
|
|
+ return ResponseJson.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商列表
|
|
|
+ *
|
|
|
+ * @param shopId 供应商id
|
|
|
+ * @param name 供应商名称
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 页面数据数
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<CmShop>> shopList(Integer shopId, String name, Integer pageNum, Integer pageSize) {
|
|
|
+ List<CmShop> shopList = cmShopLabelDao.shopList(shopId, name);
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ PaginationVo<CmShop> pageList = new PaginationVo<>(shopList);
|
|
|
+ return ResponseJson.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加供应商
|
|
|
+ *
|
|
|
+ * @param shopId 供应商id
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson insertShopRelevance(Integer shopId) {
|
|
|
+ CmShopRelevance cmShopRelevance = new CmShopRelevance();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 初始化数据
|
|
|
+ cmShopRelevance.setAddTime(dateFormat.format(new Date()));
|
|
|
+ cmShopRelevance.setShopId(shopId);
|
|
|
+ // 保存供应商信息
|
|
|
+ cmShopLabelDao.insertShopRelevance(cmShopRelevance);
|
|
|
+ return ResponseJson.success("添加供应商成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除关联标签的供应商
|
|
|
+ *
|
|
|
+ * @param relevanceId 供应商id
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson delShopRelevanceById(Integer relevanceId) {
|
|
|
+ // 删除供应商
|
|
|
+ cmShopLabelDao.upShopRelevance(relevanceId);
|
|
|
+ // 删除标签
|
|
|
+ cmShopLabelDao.upShopLabel(relevanceId);
|
|
|
+ return ResponseJson.success("删除供应商完成");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商关联标签列表
|
|
|
+ *
|
|
|
+ * @param relevanceId 供应商id
|
|
|
+ * @param keyword 标签名
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 页面数据数
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<CmShopLabel>> shopLabelList(Integer relevanceId, String keyword, Integer pageNum, Integer pageSize) {
|
|
|
+ List<CmShopLabel> labelList = cmShopLabelDao.shopLabelList(relevanceId, keyword);
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
+ PaginationVo<CmShopLabel> pageList = new PaginationVo<>(labelList);
|
|
|
+ return ResponseJson.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 标签列表
|
|
|
+ *
|
|
|
+ * @param keyword 标签名
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 页面数据数
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<CmShopLabel>> labelList(String keyword, Integer pageNum, Integer pageSize) {
|
|
|
+ List<CmShopLabel> labelList = cmShopLabelDao.labelList(keyword);
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
+ PaginationVo<CmShopLabel> pageList = new PaginationVo<>(labelList);
|
|
|
+ return ResponseJson.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关联标签
|
|
|
+ *
|
|
|
+ * @param relevanceId 供应商id
|
|
|
+ * @param keywordIds 标签id或id集合
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson insertLabel(Integer relevanceId, String keywordIds) {
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 多个时进行拆分
|
|
|
+ if (keywordIds.contains(",")) {
|
|
|
+ String[] split = keywordIds.split(",");
|
|
|
+ for (String str : split) {
|
|
|
+ list.add(Integer.parseInt(str));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list.add(Integer.parseInt(keywordIds));
|
|
|
+ }
|
|
|
+ // 关联标签
|
|
|
+ String format = dateFormat.format(new Date());
|
|
|
+ for (Integer i : list) {
|
|
|
+ CmShopLabel cmShopLabel = new CmShopLabel();
|
|
|
+ cmShopLabel.setRelevanceId(relevanceId);
|
|
|
+ cmShopLabel.setKeywordId(i);
|
|
|
+ cmShopLabel.setPickTime(format);
|
|
|
+ cmShopLabelDao.insertLabel(cmShopLabel);
|
|
|
+ }
|
|
|
+ return ResponseJson.success("关联成功", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加标签到标签库
|
|
|
+ *
|
|
|
+ * @param keyword 标签
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson insertSearch(String keyword) {
|
|
|
+ cmShopLabelDao.insertSearch(keyword);
|
|
|
+ return ResponseJson.success("添加成功", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除供应商关联标签
|
|
|
+ *
|
|
|
+ * @param labelIds id或id集合
|
|
|
+ * @return 返回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson upShopLabelList(String labelIds) {
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ if (labelIds.contains(",")) {
|
|
|
+ String[] split = labelIds.split(",");
|
|
|
+ for (String str : split) {
|
|
|
+ list.add(Integer.parseInt(str));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list.add(Integer.parseInt(labelIds));
|
|
|
+ }
|
|
|
+ cmShopLabelDao.upShopLabelList(list);
|
|
|
+ return ResponseJson.success("删除完成");
|
|
|
+ }
|
|
|
+}
|