|
@@ -1,10 +1,11 @@
|
|
package shop.alien.second.service.impl;
|
|
package shop.alien.second.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import shop.alien.entity.second.SecondGoods;
|
|
import shop.alien.entity.second.SecondGoods;
|
|
import shop.alien.entity.store.StoreImg;
|
|
import shop.alien.entity.store.StoreImg;
|
|
@@ -17,6 +18,7 @@ import shop.alien.util.common.netease.TextCheckUtil;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 二手商品服务实现类
|
|
* 二手商品服务实现类
|
|
@@ -24,6 +26,8 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, SecondGoods> implements SecondGoodsService {
|
|
public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, SecondGoods> implements SecondGoodsService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SecondGoodsMapper secondGoodsMapper;
|
|
/**
|
|
/**
|
|
* 保存商品为草稿状态
|
|
* 保存商品为草稿状态
|
|
* @param goods 商品实体
|
|
* @param goods 商品实体
|
|
@@ -32,7 +36,13 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
@Override
|
|
@Override
|
|
public boolean saveAsDraft(SecondGoods goods) {
|
|
public boolean saveAsDraft(SecondGoods goods) {
|
|
// 设置商品状态为草稿
|
|
// 设置商品状态为草稿
|
|
|
|
+ goods.setUserId(1);
|
|
goods.setGoodsStatus(0); // TODO: 使用常量或枚举代替硬编码
|
|
goods.setGoodsStatus(0); // TODO: 使用常量或枚举代替硬编码
|
|
|
|
+ goods.setCreatedTime(new Date());
|
|
|
|
+ goods.setUpdatedTime(new Date());
|
|
|
|
+ goods.setDeleteFlag(0);
|
|
|
|
+ goods.setCreatedUserId(1);
|
|
|
|
+ goods.setUpdatedUserId(1);
|
|
return save(goods);
|
|
return save(goods);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -152,5 +162,27 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
// message.setUpdatedTime(new Date());
|
|
// message.setUpdatedTime(new Date());
|
|
// messageMapper.insert(message);
|
|
// messageMapper.insert(message);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<SecondGoods> getGoodsWithImages(IPage<SecondGoods> page, Integer categoryId, Integer status) {
|
|
|
|
+ // 调用 Mapper 层分页查询方法
|
|
|
|
+ IPage<SecondGoods> goodsPage = secondGoodsMapper.selectGoodsWithImages(page, categoryId, status);
|
|
|
|
+
|
|
|
|
+ if (CollectionUtil.isNotEmpty(goodsPage.getRecords())) {
|
|
|
|
+ List<Integer> goodsIds = goodsPage.getRecords().stream()
|
|
|
|
+ .map(SecondGoods::getId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+// // 批量获取图片信息
|
|
|
|
+// Map<Integer, List<String>> imagesMap = storeImgService.getImgsByGoodsIds(goodsIds);
|
|
|
|
+//
|
|
|
|
+// // 设置图片信息
|
|
|
|
+// for (SecondGoods goods : goodsPage.getRecords()) {
|
|
|
|
+// goods.setImgUrl(imagesMap.getOrDefault(goods.getId(), Collections.emptyList()));
|
|
|
|
+// }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return goodsPage;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|