|
@@ -2,16 +2,23 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.GoodsCategoryDao;
|
|
import com.ym.mec.biz.dal.dao.GoodsCategoryDao;
|
|
import com.ym.mec.biz.dal.dao.SubjectGoodsMapperDao;
|
|
import com.ym.mec.biz.dal.dao.SubjectGoodsMapperDao;
|
|
|
|
+import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
|
|
|
|
+import com.ym.mec.biz.dal.entity.Goods;
|
|
import com.ym.mec.biz.dal.entity.GoodsCategory;
|
|
import com.ym.mec.biz.dal.entity.GoodsCategory;
|
|
|
|
+import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
|
|
|
|
+import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
|
+import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
|
|
import com.ym.mec.biz.service.GoodsCategoryService;
|
|
import com.ym.mec.biz.service.GoodsCategoryService;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
|
+import com.ym.mec.util.collection.MapUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCategory> implements GoodsCategoryService {
|
|
public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCategory> implements GoodsCategoryService {
|
|
@@ -41,4 +48,38 @@ public class GoodsCategoryServiceImpl extends BaseServiceImpl<Integer, GoodsCate
|
|
List<Integer> subjectIds = goodsCategory.getSubjectIds();
|
|
List<Integer> subjectIds = goodsCategory.getSubjectIds();
|
|
subjectGoodsMapperDao.batchAdd(goodsCategory.getId(),subjectIds);
|
|
subjectGoodsMapperDao.batchAdd(goodsCategory.getId(),subjectIds);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PageInfo<SubjectGoodsDto> querySubjectGoods(GoodsCategoryQueryInfo queryInfo) {
|
|
|
|
+ PageInfo<SubjectGoodsDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
|
+
|
|
|
|
+ List<SubjectGoodsDto> dataList = null;
|
|
|
|
+ int count = subjectGoodsMapperDao.countSubjectGoods(params);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ pageInfo.setTotal(count);
|
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
|
+ dataList = subjectGoodsMapperDao.querySubjectGoods(params);
|
|
|
|
+ dataList.forEach(e->{
|
|
|
|
+ e.setInstrument(e.getGoodsList().stream().filter(goods -> goods.getType() == GoodsType.INSTRUMENT).collect(Collectors.toList()));
|
|
|
|
+ e.setAccessories(e.getGoodsList().stream().filter(goods -> goods.getType() == GoodsType.ACCESSORIES).collect(Collectors.toList()));
|
|
|
|
+ e.setGoodsList(null);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (count == 0) {
|
|
|
|
+ dataList = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
|
+ return pageInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateSubjectGoods(Long subjectGoodsMapperId, String goodsIds) {
|
|
|
|
+ SubjectGoodsMapper subjectGoodsMapper = new SubjectGoodsMapper();
|
|
|
|
+ subjectGoodsMapper.setId(subjectGoodsMapperId);
|
|
|
|
+ subjectGoodsMapper.setGoodsIdList(goodsIds);
|
|
|
|
+ subjectGoodsMapper.setUpdateTime(new Date());
|
|
|
|
+ subjectGoodsMapperDao.update(subjectGoodsMapper);
|
|
|
|
+ }
|
|
}
|
|
}
|