From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/clazz/GoodsSubClassLabelServiceImpl.java | 254 +++++++++++++++++++++++++------------------------- 1 files changed, 127 insertions(+), 127 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/clazz/GoodsSubClassLabelServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/clazz/GoodsSubClassLabelServiceImpl.java index 7e0dd85..63ec0d6 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/clazz/GoodsSubClassLabelServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/clazz/GoodsSubClassLabelServiceImpl.java @@ -1,127 +1,127 @@ -package com.yeshi.fanli.service.impl.clazz; - -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.yeshi.fanli.dao.mybatis.clazz.GoodsSubClassLabelMapMapper; -import com.yeshi.fanli.dao.mybatis.clazz.GoodsSubClassLabelMapper; -import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; -import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel; -import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap; -import com.yeshi.fanli.exception.goods.GoodsClassException; -import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.vo.goods.GoodsSubClassLabelVO; - -@Service -public class GoodsSubClassLabelServiceImpl implements GoodsSubClassLabelService { - - @Resource - private GoodsSubClassLabelMapper goodsSubClassLabelMapper; - - @Resource - private GoodsSubClassLabelMapMapper goodsSubClassLabelMapMapper; - - @Override - public void addSubClassLabel(GoodsSubClassLabel label) throws GoodsClassException { - - if (label == null || label.getGoodsClass() == null || StringUtil.isNullOrEmpty(label.getName())) - throw new GoodsClassException(1, "鏁版嵁涓嶅畬鏁�"); - GoodsSubClassLabel oldLabel = goodsSubClassLabelMapper.selectByClassIdAndName(label.getName(), - label.getGoodsClass().getId()); - if (oldLabel != null) - throw new GoodsClassException(2, "鍒嗙被鏍囩鍚嶇О宸茬粡瀛樺湪"); - label.setCreateTime(new Date()); - goodsSubClassLabelMapper.insertSelective(label); - } - - @Override - public void addSubClassLabelMap(GoodsSubClassLabelMap map) throws GoodsClassException { - if (map.getGoodsSubClass() == null || map.getLabel() == null) - throw new GoodsClassException(1, "鏁版嵁涓嶅畬鏁�"); - - GoodsSubClassLabelMap oldMap = goodsSubClassLabelMapMapper.selectByLabelIdAndSubClassId(map.getLabel().getId(), - map.getGoodsSubClass().getId()); - if (oldMap != null) - throw new GoodsClassException(2, "瀵瑰簲鍏崇郴宸茬粡瀛樺湪"); - // 閫氳繃subClassId鏌ヨ - - GoodsSubClassLabelMap omap = goodsSubClassLabelMapMapper.selectBySubClassId(map.getGoodsSubClass().getId()); - if (omap != null) - goodsSubClassLabelMapMapper.deleteByPrimaryKey(omap.getId()); - - map.setCreateTime(new Date()); - goodsSubClassLabelMapMapper.insertSelective(map); - } - - @Override - public List<GoodsSubClassLabel> listLabelByClassId(Long classId) { - - return goodsSubClassLabelMapper.listByClassId(classId); - } - - @Override - public List<GoodsSubClassLabelMap> listMapByLabelId(Long labelId) { - return goodsSubClassLabelMapMapper.listMapByLabelId(labelId); - } - - @Transactional - @Override - public void deleteLabel(Long labelId) { - - List<GoodsSubClassLabelMap> maplist = listMapByLabelId(labelId); - if (maplist != null) - for (GoodsSubClassLabelMap map : maplist) { - goodsSubClassLabelMapMapper.deleteByPrimaryKey(map.getId()); - } - goodsSubClassLabelMapper.deleteByPrimaryKey(labelId); - } - - @Override - public void updateSubClassLabel(GoodsSubClassLabel label) { - goodsSubClassLabelMapper.updateByPrimaryKeySelective(label); - } - - @Override - public GoodsSubClassLabelMap selectBySubClassId(Long subClassId) { - return goodsSubClassLabelMapMapper.selectBySubClassId(subClassId); - } - - @Override - @Cacheable(value = "classCache", key = "'listSubMapCache-'+#classId") - public List<GoodsSubClassLabelVO> listSubMapCache(Long classId) { - List<GoodsSubClassLabelVO> list = goodsSubClassLabelMapper.listSubMapByClassId(classId, - Calendar.getInstance().get(Calendar.MONTH) + 1); - if (list == null || list.size() == 0) { - return list; - } - - for (int i = 0; i < list.size(); i++) { - GoodsSubClassLabelVO labelVO = list.get(i); - List<GoodsSubClass> listSub = labelVO.getListSub(); - if (listSub == null || listSub.size() == 0) { - list.remove(labelVO); - i--; - continue; - } - - for (GoodsSubClass goodsSubClass : listSub) { - String pictureSecond = goodsSubClass.getPictureSecond(); - if (!StringUtil.isNullOrEmpty(pictureSecond)) { - goodsSubClass.setPicture(pictureSecond); - } - } - - labelVO.setListSub(listSub); - } - return list; - } - -} +package com.yeshi.fanli.service.impl.clazz; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.yeshi.fanli.dao.mybatis.clazz.GoodsSubClassLabelMapMapper; +import com.yeshi.fanli.dao.mybatis.clazz.GoodsSubClassLabelMapper; +import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; +import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel; +import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap; +import com.yeshi.fanli.exception.goods.GoodsClassException; +import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.vo.goods.GoodsSubClassLabelVO; + +@Service +public class GoodsSubClassLabelServiceImpl implements GoodsSubClassLabelService { + + @Resource + private GoodsSubClassLabelMapper goodsSubClassLabelMapper; + + @Resource + private GoodsSubClassLabelMapMapper goodsSubClassLabelMapMapper; + + @Override + public void addSubClassLabel(GoodsSubClassLabel label) throws GoodsClassException { + + if (label == null || label.getGoodsClass() == null || StringUtil.isNullOrEmpty(label.getName())) + throw new GoodsClassException(1, "鏁版嵁涓嶅畬鏁�"); + GoodsSubClassLabel oldLabel = goodsSubClassLabelMapper.selectByClassIdAndName(label.getName(), + label.getGoodsClass().getId()); + if (oldLabel != null) + throw new GoodsClassException(2, "鍒嗙被鏍囩鍚嶇О宸茬粡瀛樺湪"); + label.setCreateTime(new Date()); + goodsSubClassLabelMapper.insertSelective(label); + } + + @Override + public void addSubClassLabelMap(GoodsSubClassLabelMap map) throws GoodsClassException { + if (map.getGoodsSubClass() == null || map.getLabel() == null) + throw new GoodsClassException(1, "鏁版嵁涓嶅畬鏁�"); + + GoodsSubClassLabelMap oldMap = goodsSubClassLabelMapMapper.selectByLabelIdAndSubClassId(map.getLabel().getId(), + map.getGoodsSubClass().getId()); + if (oldMap != null) + throw new GoodsClassException(2, "瀵瑰簲鍏崇郴宸茬粡瀛樺湪"); + // 閫氳繃subClassId鏌ヨ + + GoodsSubClassLabelMap omap = goodsSubClassLabelMapMapper.selectBySubClassId(map.getGoodsSubClass().getId()); + if (omap != null) + goodsSubClassLabelMapMapper.deleteByPrimaryKey(omap.getId()); + + map.setCreateTime(new Date()); + goodsSubClassLabelMapMapper.insertSelective(map); + } + + @Override + public List<GoodsSubClassLabel> listLabelByClassId(Long classId) { + + return goodsSubClassLabelMapper.listByClassId(classId); + } + + @Override + public List<GoodsSubClassLabelMap> listMapByLabelId(Long labelId) { + return goodsSubClassLabelMapMapper.listMapByLabelId(labelId); + } + + @Transactional + @Override + public void deleteLabel(Long labelId) { + + List<GoodsSubClassLabelMap> maplist = listMapByLabelId(labelId); + if (maplist != null) + for (GoodsSubClassLabelMap map : maplist) { + goodsSubClassLabelMapMapper.deleteByPrimaryKey(map.getId()); + } + goodsSubClassLabelMapper.deleteByPrimaryKey(labelId); + } + + @Override + public void updateSubClassLabel(GoodsSubClassLabel label) { + goodsSubClassLabelMapper.updateByPrimaryKeySelective(label); + } + + @Override + public GoodsSubClassLabelMap selectBySubClassId(Long subClassId) { + return goodsSubClassLabelMapMapper.selectBySubClassId(subClassId); + } + + @Override + @Cacheable(value = "classCache", key = "'listSubMapCache-'+#classId") + public List<GoodsSubClassLabelVO> listSubMapCache(Long classId) { + List<GoodsSubClassLabelVO> list = goodsSubClassLabelMapper.listSubMapByClassId(classId, + Calendar.getInstance().get(Calendar.MONTH) + 1); + if (list == null || list.size() == 0) { + return list; + } + + for (int i = 0; i < list.size(); i++) { + GoodsSubClassLabelVO labelVO = list.get(i); + List<GoodsSubClass> listSub = labelVO.getListSub(); + if (listSub == null || listSub.size() == 0) { + list.remove(labelVO); + i--; + continue; + } + + for (GoodsSubClass goodsSubClass : listSub) { + String pictureSecond = goodsSubClass.getPictureSecond(); + if (!StringUtil.isNullOrEmpty(pictureSecond)) { + goodsSubClass.setPicture(pictureSecond); + } + } + + labelVO.setListSub(listSub); + } + return list; + } + +} -- Gitblit v1.8.0