mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 12:48:59 +08:00
feat:商品提交
This commit is contained in:
parent
442521127c
commit
a4f985a7be
@ -14,6 +14,7 @@ public class GoodsFormDTO {
|
||||
private String name;
|
||||
private Long categoryId;
|
||||
private Long brandId;
|
||||
private Long originPrice;
|
||||
private Long price;
|
||||
private String picUrl;
|
||||
private List<String> subPicUrls;
|
||||
|
@ -16,6 +16,6 @@ public interface PmsConstants {
|
||||
|
||||
String PRODUCT_REDIS_BLOOM_FILTER = "product:redis:bloom:filter";
|
||||
|
||||
String TEMP_ID_PREFIX = "temp-";
|
||||
String TEMP_ID_PREFIX = "tid_";
|
||||
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ public class GoodsController {
|
||||
@ApiImplicitParam(name = "ids", value = "id集合,以英文逗号','分隔", required = true, paramType = "query", dataType = "String")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result delete(@PathVariable String ids) {
|
||||
iPmsSpuService.removeBySpuIds(Arrays.asList(ids.split(",")).stream().map(id -> Long.parseLong(id)).collect(Collectors.toList()));
|
||||
return Result.success();
|
||||
boolean result = iPmsSpuService.removeByGoodsIds(Arrays.asList(ids.split(",")).stream().map(id -> Long.parseLong(id)).collect(Collectors.toList()));
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择性修改商品")
|
||||
|
@ -16,7 +16,7 @@ public interface IPmsSpuService extends IService<PmsSpu> {
|
||||
|
||||
boolean addGoods(GoodsFormDTO goodsFormDTO);
|
||||
|
||||
boolean removeBySpuIds(List<Long> spuIds);
|
||||
boolean removeByGoodsIds(List<Long> spuIds);
|
||||
|
||||
boolean updateGoods(GoodsFormDTO goodsFormDTO);
|
||||
|
||||
|
@ -19,16 +19,13 @@ import com.youlai.mall.pms.pojo.entity.PmsSku;
|
||||
import com.youlai.mall.pms.pojo.entity.PmsSpu;
|
||||
import com.youlai.mall.pms.pojo.entity.PmsSpuAttributeValue;
|
||||
import com.youlai.mall.pms.pojo.vo.admin.GoodsDetailVO;
|
||||
import com.youlai.mall.pms.service.IPmsAttributeService;
|
||||
import com.youlai.mall.pms.service.IPmsSkuService;
|
||||
import com.youlai.mall.pms.service.IPmsSpuAttributeValueService;
|
||||
import com.youlai.mall.pms.service.IPmsSpuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.beanutils.BeanUtilsBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -41,7 +38,6 @@ import java.util.stream.Collectors;
|
||||
public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> implements IPmsSpuService {
|
||||
private final IPmsSkuService iPmsSkuService;
|
||||
private final IPmsSpuAttributeValueService iPmsSpuAttributeValueService;
|
||||
private final IPmsAttributeService attributeService;
|
||||
private final BloomRedisService bloomRedisService;
|
||||
|
||||
@Override
|
||||
@ -133,7 +129,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
// 新增/修改SKU
|
||||
List<PmsSku> pmsSkuList = skuList.stream().map(sku -> {
|
||||
// 临时规格ID转换
|
||||
String specIds = Arrays.asList(sku.getSpecIds().split("_")).stream()
|
||||
String specIds = Arrays.asList(sku.getSpecIds().split("\\|")).stream()
|
||||
.map(specId ->
|
||||
specId.startsWith(PmsConstants.TEMP_ID_PREFIX) ? specTempIdIdMap.get(specId) + "" : specId
|
||||
)
|
||||
@ -277,22 +273,21 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
|
||||
return goodsDetailVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removeBySpuIds(List<Long> spuIds) {
|
||||
Optional.ofNullable(spuIds).ifPresent(
|
||||
ids -> ids.forEach(spuId -> {
|
||||
// sku
|
||||
iPmsSkuService.remove(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, spuId));
|
||||
// 规格
|
||||
iPmsSpuAttributeValueService.remove(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getId, spuId));
|
||||
// 属性
|
||||
iPmsSpuAttributeValueService.remove(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getSpuId, spuId));
|
||||
// spu
|
||||
this.removeById(spuId);
|
||||
})
|
||||
);
|
||||
return true;
|
||||
public boolean removeByGoodsIds(List<Long> goodsIds) {
|
||||
boolean result = true;
|
||||
for (Long goodsId : goodsIds) {
|
||||
// sku
|
||||
iPmsSkuService.remove(new LambdaQueryWrapper<PmsSku>().eq(PmsSku::getSpuId, goodsId));
|
||||
// 规格
|
||||
iPmsSpuAttributeValueService.remove(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getId, goodsId));
|
||||
// 属性
|
||||
iPmsSpuAttributeValueService.remove(new LambdaQueryWrapper<PmsSpuAttributeValue>().eq(PmsSpuAttributeValue::getSpuId, goodsId));
|
||||
// spu
|
||||
result = this.removeById(goodsId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,8 @@
|
||||
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
|
||||
<result property="categoryName" column="categoryName" jdbcType="VARCHAR"/>
|
||||
<result property="brandName" column="brandName" jdbcType="VARCHAR"/>
|
||||
<collection property="skuList" ofType="com.youlai.mall.pms.pojo.entity.PmsSku" javaType="list">
|
||||
<!-- Mybatis Plus 分页有BUG -->
|
||||
<!--<collection property="skuList" ofType="com.youlai.mall.pms.pojo.entity.PmsSku" javaType="list">
|
||||
<id property="id" column="skuId" jdbcType="BIGINT"/>
|
||||
<result property="name" column="skuName" jdbcType="VARCHAR"/>
|
||||
<result property="sn" column="sn" jdbcType="VARCHAR"/>
|
||||
@ -30,7 +31,10 @@
|
||||
<result property="price" column="skuPrice" jdbcType="BIGINT"/>
|
||||
<result property="stock" column="stock" jdbcType="INTEGER"/>
|
||||
<result property="lockedStock" column="locked_stock" jdbcType="INTEGER"/>
|
||||
</collection>
|
||||
</collection>-->
|
||||
|
||||
|
||||
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
@ -42,7 +46,9 @@
|
||||
status,gmt_create,gmt_modified
|
||||
</sql>
|
||||
<select id="list" resultMap="BaseResultMap">
|
||||
SELECT t1.*,
|
||||
SELECT t1.name,
|
||||
t1.pic_url,
|
||||
|
||||
t3.NAME categoryName,
|
||||
t4.NAME brandName,
|
||||
t2.id skuId,
|
||||
|
Loading…
Reference in New Issue
Block a user