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