From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelClassServiceImpl.java | 554 +++++++++++++++++++++++++++--------------------------- 1 files changed, 277 insertions(+), 277 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelClassServiceImpl.java index 243c6d1..6d023f2 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelClassServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelClassServiceImpl.java @@ -1,277 +1,277 @@ -package com.yeshi.fanli.service.impl.lable; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -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.lable.LabelClassMapper; -import com.yeshi.fanli.entity.bus.clazz.GoodsClass; -import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; -import com.yeshi.fanli.entity.bus.lable.Label; -import com.yeshi.fanli.entity.bus.lable.LabelClass; -import com.yeshi.fanli.exception.goods.quality.LabelClassException; -import com.yeshi.fanli.service.inter.lable.LabelClassService; -import com.yeshi.fanli.service.inter.lable.LabelService; - -@Service -public class LabelClassServiceImpl implements LabelClassService { - - - @Resource - private LabelService labelService; - - @Resource - private LabelClassMapper labelClassMapper; - - - - @Override - public int insert(LabelClass record) throws LabelClassException{ - return labelClassMapper.insert(record); - } - - - @Override - public int updateByPrimaryKey(LabelClass record) throws LabelClassException{ - return labelClassMapper.updateByPrimaryKey(record); - } - - @Override - public int updateByPrimaryKeySelective(LabelClass record) throws LabelClassException{ - return labelClassMapper.updateByPrimaryKeySelective(record); - } - - @Override - public int deleteByPrimaryKey(Long id) throws LabelClassException{ - return labelClassMapper.deleteByPrimaryKey(id); - } - - - @Override - public LabelClass selectByPrimaryKey(Long id) throws LabelClassException { - return labelClassMapper.selectByPrimaryKey(id); - } - - @Override - public List<LabelClass> getByClassId(Long classId) throws LabelClassException { - return labelClassMapper.getByClassId(classId); - } - - @Override - public List<LabelClass> getBySubClassId(Long classId) throws LabelClassException { - return labelClassMapper.getBySubClassId(classId); - } - - - @Override - public List<LabelClass> queryByClassId(int start, int count, Long classId) throws LabelClassException { - return labelClassMapper.queryByClassId(start, count, classId); - } - - @Override - public int getCountQueryByClassId(Long classId) throws LabelClassException { - return labelClassMapper.getCountQueryByClassId(classId); - } - - @Override - public List<LabelClass> queryBySubClassId(int start, int count, Long classId) throws LabelClassException { - return labelClassMapper.queryBySubClassId(start, count, classId); - } - - @Override - @Cacheable(value = "labelCache",key="'queryBySubClassIdCache-'+#start+'-'+#classId") - public List<LabelClass> queryBySubClassIdCache(int start, int count, Long classId) throws LabelClassException { - return queryBySubClassId(start, count, classId); - } - - @Override - public List<Long> getRelationLabIds(int start, int count, Long classId) throws LabelClassException { - - /* 1銆佹牴鎹爣绛炬煡璇㈠晢鍝� */ - List<Long> listLabId = null; - - List<LabelClass> labelClassList = queryBySubClassIdCache(start, count, classId); - - if (labelClassList != null && labelClassList.size() > 0) { - listLabId = new ArrayList<Long>(); - for (LabelClass labelClass : labelClassList) { - Label label = labelClass.getLabel(); - listLabId.add(label.getId()); - } - } - - return listLabId; - - } - - - @Override - public int getCountQueryBySubClassId(Long subClassId) throws LabelClassException { - return labelClassMapper.getCountQueryBySubClassId(subClassId); - } - - - - @Override - @Transactional - public void addBatchClass(GoodsClass goodsClass,List<Long> labIdList) throws Exception { - - long recordId = goodsClass.getId(); - - if (labIdList == null || labIdList.size() == 0) { - // 娓呯┖鍏宠仈鏍囩 - labelClassMapper.deleteByClassId(recordId); - return; - } - - // 鍒犻櫎鏍囩 - List<Long> subList = new ArrayList<Long>(); - - // 鏌ヨ鐜版湁鍏宠仈鏍囩 - List<LabelClass> hasList = labelClassMapper.getByClassId(recordId); - - - // 宸插瓨鍦紝鍒欓亶鍘嗗摢浜涢渶瑕佸垹闄� - if (hasList != null && hasList.size() > 0) { - - for (LabelClass lClass: hasList) { - - Long lablClassID = lClass.getId(); - - Label label = lClass.getLabel(); - - if (label != null) { - - Long labid = label.getId(); - if (labIdList.contains(labid)) { - // 鍖呭惈锛屽垯浠庨泦鍚堜腑鍒犻櫎 labid - labIdList.remove(labid); - } else { - // 褰撳墠浼犻�掍腑涓嶅寘鍚� 閭d箞闇�瑕佸垹闄� lablClassID - subList.add(lablClassID); - } - } - } - } - - if (subList != null && subList.size() > 0) { - for (Long id: subList) { - labelClassMapper.deleteByPrimaryKey(id); - } - } - - if (labIdList != null && labIdList.size() > 0) { - - // 鍘婚噸澶� - HashSet<Long> h = new HashSet<Long>(labIdList); - labIdList.clear(); - labIdList.addAll(h); - - for (Long labId: labIdList) { - // 鏌ヨ鏁版嵁搴� 鏍囩鏄惁瀛樺湪 - Label label = labelService.selectByPrimaryKey(labId); - if (label == null) { - continue; - } - - LabelClass labelClass = new LabelClass(); - - labelClass.setLabel(label); - labelClass.setGoodClass(goodsClass); - labelClass.setCreatetime(new Date()); - labelClassMapper.insertSelective(labelClass); - } - } - - } - - - @Override - @Transactional - public void addBatchSubClass(GoodsSubClass goodsSubClass,List<Long> labIdList) throws Exception { - - long recordId = goodsSubClass.getId(); - // 鍒犻櫎鏍囩 - List<Long> subList = new ArrayList<Long>(); - - // 鏌ヨ鐜版湁鍏宠仈鏍囩 - List<LabelClass> hasList = labelClassMapper.getBySubClassId(recordId); - - - // 宸插瓨鍦紝鍒欓亶鍘嗗摢浜涢渶瑕佸垹闄� - if (hasList != null && hasList.size() > 0) { - - for (LabelClass lClass: hasList) { - Long lablClassID = lClass.getId(); - Label label = lClass.getLabel(); - if (label != null) { - Long id = label.getId(); - - - if (labIdList.contains(id)) { - // 鍖呭惈锛屽垯浠庨泦鍚堜腑鍒犻櫎 labid - labIdList.remove(id); - - } else { - // 褰撳墠浼犻�掍腑涓嶅寘鍚� 閭d箞闇�瑕佸垹闄� lablClassID - subList.add(lablClassID); - } - } - } - } - - /* 鍒犻櫎鏍囩 */ - if (subList != null && subList.size() > 0) { - for (Long id: subList) { - labelClassMapper.deleteByPrimaryKey(id); - } - } - - /* 娣诲姞鏂板鏍囩 */ - if (labIdList != null && labIdList.size() > 0) { - - // 鍘婚噸澶� - HashSet<Long> h = new HashSet<Long>(labIdList); - labIdList.clear(); - labIdList.addAll(h); - - - for (Long labId: labIdList) { - - Label label = labelService.selectByPrimaryKey(labId); - if (label == null) { - continue; - } - - LabelClass labelClass = new LabelClass(); - - labelClass.setLabel(label); - labelClass.setCreatetime(new Date()); - labelClass.setGoodsSubClass(goodsSubClass); - labelClassMapper.insertSelective(labelClass); - } - } - - - } - - - @Override - public int deleteByClassId(Long recordId) throws Exception { - return labelClassMapper.deleteByClassId(recordId); - } - - @Override - public int deleteBySubClassId(Long recordId) throws Exception { - return labelClassMapper.deleteBySubClassId(recordId); - } - -} - +package com.yeshi.fanli.service.impl.lable; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +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.lable.LabelClassMapper; +import com.yeshi.fanli.entity.bus.clazz.GoodsClass; +import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; +import com.yeshi.fanli.entity.bus.lable.Label; +import com.yeshi.fanli.entity.bus.lable.LabelClass; +import com.yeshi.fanli.exception.goods.quality.LabelClassException; +import com.yeshi.fanli.service.inter.lable.LabelClassService; +import com.yeshi.fanli.service.inter.lable.LabelService; + +@Service +public class LabelClassServiceImpl implements LabelClassService { + + + @Resource + private LabelService labelService; + + @Resource + private LabelClassMapper labelClassMapper; + + + + @Override + public int insert(LabelClass record) throws LabelClassException{ + return labelClassMapper.insert(record); + } + + + @Override + public int updateByPrimaryKey(LabelClass record) throws LabelClassException{ + return labelClassMapper.updateByPrimaryKey(record); + } + + @Override + public int updateByPrimaryKeySelective(LabelClass record) throws LabelClassException{ + return labelClassMapper.updateByPrimaryKeySelective(record); + } + + @Override + public int deleteByPrimaryKey(Long id) throws LabelClassException{ + return labelClassMapper.deleteByPrimaryKey(id); + } + + + @Override + public LabelClass selectByPrimaryKey(Long id) throws LabelClassException { + return labelClassMapper.selectByPrimaryKey(id); + } + + @Override + public List<LabelClass> getByClassId(Long classId) throws LabelClassException { + return labelClassMapper.getByClassId(classId); + } + + @Override + public List<LabelClass> getBySubClassId(Long classId) throws LabelClassException { + return labelClassMapper.getBySubClassId(classId); + } + + + @Override + public List<LabelClass> queryByClassId(int start, int count, Long classId) throws LabelClassException { + return labelClassMapper.queryByClassId(start, count, classId); + } + + @Override + public int getCountQueryByClassId(Long classId) throws LabelClassException { + return labelClassMapper.getCountQueryByClassId(classId); + } + + @Override + public List<LabelClass> queryBySubClassId(int start, int count, Long classId) throws LabelClassException { + return labelClassMapper.queryBySubClassId(start, count, classId); + } + + @Override + @Cacheable(value = "labelCache",key="'queryBySubClassIdCache-'+#start+'-'+#classId") + public List<LabelClass> queryBySubClassIdCache(int start, int count, Long classId) throws LabelClassException { + return queryBySubClassId(start, count, classId); + } + + @Override + public List<Long> getRelationLabIds(int start, int count, Long classId) throws LabelClassException { + + /* 1銆佹牴鎹爣绛炬煡璇㈠晢鍝� */ + List<Long> listLabId = null; + + List<LabelClass> labelClassList = queryBySubClassIdCache(start, count, classId); + + if (labelClassList != null && labelClassList.size() > 0) { + listLabId = new ArrayList<Long>(); + for (LabelClass labelClass : labelClassList) { + Label label = labelClass.getLabel(); + listLabId.add(label.getId()); + } + } + + return listLabId; + + } + + + @Override + public int getCountQueryBySubClassId(Long subClassId) throws LabelClassException { + return labelClassMapper.getCountQueryBySubClassId(subClassId); + } + + + + @Override + @Transactional(rollbackFor=Exception.class) + public void addBatchClass(GoodsClass goodsClass,List<Long> labIdList) throws Exception { + + long recordId = goodsClass.getId(); + + if (labIdList == null || labIdList.size() == 0) { + // 娓呯┖鍏宠仈鏍囩 + labelClassMapper.deleteByClassId(recordId); + return; + } + + // 鍒犻櫎鏍囩 + List<Long> subList = new ArrayList<Long>(); + + // 鏌ヨ鐜版湁鍏宠仈鏍囩 + List<LabelClass> hasList = labelClassMapper.getByClassId(recordId); + + + // 宸插瓨鍦紝鍒欓亶鍘嗗摢浜涢渶瑕佸垹闄� + if (hasList != null && hasList.size() > 0) { + + for (LabelClass lClass: hasList) { + + Long lablClassID = lClass.getId(); + + Label label = lClass.getLabel(); + + if (label != null) { + + Long labid = label.getId(); + if (labIdList.contains(labid)) { + // 鍖呭惈锛屽垯浠庨泦鍚堜腑鍒犻櫎 labid + labIdList.remove(labid); + } else { + // 褰撳墠浼犻�掍腑涓嶅寘鍚� 閭d箞闇�瑕佸垹闄� lablClassID + subList.add(lablClassID); + } + } + } + } + + if (subList != null && subList.size() > 0) { + for (Long id: subList) { + labelClassMapper.deleteByPrimaryKey(id); + } + } + + if (labIdList != null && labIdList.size() > 0) { + + // 鍘婚噸澶� + HashSet<Long> h = new HashSet<Long>(labIdList); + labIdList.clear(); + labIdList.addAll(h); + + for (Long labId: labIdList) { + // 鏌ヨ鏁版嵁搴� 鏍囩鏄惁瀛樺湪 + Label label = labelService.selectByPrimaryKey(labId); + if (label == null) { + continue; + } + + LabelClass labelClass = new LabelClass(); + + labelClass.setLabel(label); + labelClass.setGoodClass(goodsClass); + labelClass.setCreatetime(new Date()); + labelClassMapper.insertSelective(labelClass); + } + } + + } + + + @Override + @Transactional(rollbackFor=Exception.class) + public void addBatchSubClass(GoodsSubClass goodsSubClass,List<Long> labIdList) throws Exception { + + long recordId = goodsSubClass.getId(); + // 鍒犻櫎鏍囩 + List<Long> subList = new ArrayList<Long>(); + + // 鏌ヨ鐜版湁鍏宠仈鏍囩 + List<LabelClass> hasList = labelClassMapper.getBySubClassId(recordId); + + + // 宸插瓨鍦紝鍒欓亶鍘嗗摢浜涢渶瑕佸垹闄� + if (hasList != null && hasList.size() > 0) { + + for (LabelClass lClass: hasList) { + Long lablClassID = lClass.getId(); + Label label = lClass.getLabel(); + if (label != null) { + Long id = label.getId(); + + + if (labIdList.contains(id)) { + // 鍖呭惈锛屽垯浠庨泦鍚堜腑鍒犻櫎 labid + labIdList.remove(id); + + } else { + // 褰撳墠浼犻�掍腑涓嶅寘鍚� 閭d箞闇�瑕佸垹闄� lablClassID + subList.add(lablClassID); + } + } + } + } + + /* 鍒犻櫎鏍囩 */ + if (subList != null && subList.size() > 0) { + for (Long id: subList) { + labelClassMapper.deleteByPrimaryKey(id); + } + } + + /* 娣诲姞鏂板鏍囩 */ + if (labIdList != null && labIdList.size() > 0) { + + // 鍘婚噸澶� + HashSet<Long> h = new HashSet<Long>(labIdList); + labIdList.clear(); + labIdList.addAll(h); + + + for (Long labId: labIdList) { + + Label label = labelService.selectByPrimaryKey(labId); + if (label == null) { + continue; + } + + LabelClass labelClass = new LabelClass(); + + labelClass.setLabel(label); + labelClass.setCreatetime(new Date()); + labelClass.setGoodsSubClass(goodsSubClass); + labelClassMapper.insertSelective(labelClass); + } + } + + + } + + + @Override + public int deleteByClassId(Long recordId) throws Exception { + return labelClassMapper.deleteByClassId(recordId); + } + + @Override + public int deleteBySubClassId(Long recordId) throws Exception { + return labelClassMapper.deleteBySubClassId(recordId); + } + +} + -- Gitblit v1.8.0