yujian
2019-06-12 c007868c62c7da5c9ce1bf0e77d9e5f8619826e4
fanli/src/main/java/com/yeshi/fanli/service/impl/clazz/GoodsSubClassLabelServiceImpl.java
@@ -5,16 +5,19 @@
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.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 {
@@ -87,8 +90,39 @@
   @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);
      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;
   }
}