Commit 6dca8e082b42495f38bd0569278b8368e6a03e6c
1 parent
0e3cdda0
商品调整
Showing
19 changed files
with
153 additions
and
52 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
| @@ -38,7 +38,7 @@ public class ProductSkuController { | @@ -38,7 +38,7 @@ public class ProductSkuController { | ||
| 38 | @PostMapping("/create") | 38 | @PostMapping("/create") |
| 39 | @ApiOperation("创建商品sku") | 39 | @ApiOperation("创建商品sku") |
| 40 | @PreAuthorize("@ss.hasPermission('product:sku:create')") | 40 | @PreAuthorize("@ss.hasPermission('product:sku:create')") |
| 41 | - public CommonResult<Integer> createSku(@Valid @RequestBody ProductSkuCreateReqVO createReqVO) { | 41 | + public CommonResult<Long> createSku(@Valid @RequestBody ProductSkuCreateReqVO createReqVO) { |
| 42 | return success(ProductSkuService.createSku(createReqVO)); | 42 | return success(ProductSkuService.createSku(createReqVO)); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -52,18 +52,18 @@ public class ProductSkuController { | @@ -52,18 +52,18 @@ public class ProductSkuController { | ||
| 52 | 52 | ||
| 53 | @DeleteMapping("/delete") | 53 | @DeleteMapping("/delete") |
| 54 | @ApiOperation("删除商品sku") | 54 | @ApiOperation("删除商品sku") |
| 55 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) | 55 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) |
| 56 | @PreAuthorize("@ss.hasPermission('product:sku:delete')") | 56 | @PreAuthorize("@ss.hasPermission('product:sku:delete')") |
| 57 | - public CommonResult<Boolean> deleteSku(@RequestParam("id") Integer id) { | 57 | + public CommonResult<Boolean> deleteSku(@RequestParam("id") Long id) { |
| 58 | ProductSkuService.deleteSku(id); | 58 | ProductSkuService.deleteSku(id); |
| 59 | return success(true); | 59 | return success(true); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | @GetMapping("/get") | 62 | @GetMapping("/get") |
| 63 | @ApiOperation("获得商品sku") | 63 | @ApiOperation("获得商品sku") |
| 64 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) | 64 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 65 | @PreAuthorize("@ss.hasPermission('product:sku:query')") | 65 | @PreAuthorize("@ss.hasPermission('product:sku:query')") |
| 66 | - public CommonResult<ProductSkuRespVO> getSku(@RequestParam("id") Integer id) { | 66 | + public CommonResult<ProductSkuRespVO> getSku(@RequestParam("id") Long id) { |
| 67 | ProductSkuDO sku = ProductSkuService.getSku(id); | 67 | ProductSkuDO sku = ProductSkuService.getSku(id); |
| 68 | return success(ProductSkuConvert.INSTANCE.convert(sku)); | 68 | return success(ProductSkuConvert.INSTANCE.convert(sku)); |
| 69 | } | 69 | } |
| @@ -72,7 +72,7 @@ public class ProductSkuController { | @@ -72,7 +72,7 @@ public class ProductSkuController { | ||
| 72 | @ApiOperation("获得商品sku列表") | 72 | @ApiOperation("获得商品sku列表") |
| 73 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | 73 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 74 | @PreAuthorize("@ss.hasPermission('product:sku:query')") | 74 | @PreAuthorize("@ss.hasPermission('product:sku:query')") |
| 75 | - public CommonResult<List<ProductSkuRespVO>> getSkuList(@RequestParam("ids") Collection<Integer> ids) { | 75 | + public CommonResult<List<ProductSkuRespVO>> getSkuList(@RequestParam("ids") Collection<Long> ids) { |
| 76 | List<ProductSkuDO> list = ProductSkuService.getSkuList(ids); | 76 | List<ProductSkuDO> list = ProductSkuService.getSkuList(ids); |
| 77 | return success(ProductSkuConvert.INSTANCE.convertList(list)); | 77 | return success(ProductSkuConvert.INSTANCE.convertList(list)); |
| 78 | } | 78 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
| @@ -16,8 +16,8 @@ public class ProductSkuBaseVO { | @@ -16,8 +16,8 @@ public class ProductSkuBaseVO { | ||
| 16 | @NotNull(message = "spu编号不能为空") | 16 | @NotNull(message = "spu编号不能为空") |
| 17 | private Long spuId; | 17 | private Long spuId; |
| 18 | 18 | ||
| 19 | - @ApiModelProperty(value = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]", required = true) | ||
| 20 | - @NotNull(message = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]不能为空") | 19 | + @ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true) |
| 20 | + @NotNull(message = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]不能为空") | ||
| 21 | private List<Property> properties; | 21 | private List<Property> properties; |
| 22 | 22 | ||
| 23 | @ApiModelProperty(value = "销售价格,单位:分", required = true) | 23 | @ApiModelProperty(value = "销售价格,单位:分", required = true) |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.java
| @@ -13,6 +13,6 @@ public class ProductSkuUpdateReqVO extends ProductSkuBaseVO { | @@ -13,6 +13,6 @@ public class ProductSkuUpdateReqVO extends ProductSkuBaseVO { | ||
| 13 | 13 | ||
| 14 | @ApiModelProperty(value = "主键", required = true) | 14 | @ApiModelProperty(value = "主键", required = true) |
| 15 | @NotNull(message = "主键不能为空") | 15 | @NotNull(message = "主键不能为空") |
| 16 | - private Integer id; | 16 | + private Long id; |
| 17 | 17 | ||
| 18 | } | 18 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| 1 | package cn.iocoder.yudao.module.product.controller.admin.spu; | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu; |
| 2 | 2 | ||
| 3 | +import nonapi.io.github.classgraph.utils.LogNode; | ||
| 3 | import org.springframework.web.bind.annotation.*; | 4 | import org.springframework.web.bind.annotation.*; |
| 4 | import javax.annotation.Resource; | 5 | import javax.annotation.Resource; |
| 5 | import org.springframework.validation.annotation.Validated; | 6 | import org.springframework.validation.annotation.Validated; |
| @@ -38,7 +39,7 @@ public class ProductSpuController { | @@ -38,7 +39,7 @@ public class ProductSpuController { | ||
| 38 | @PostMapping("/create") | 39 | @PostMapping("/create") |
| 39 | @ApiOperation("创建商品spu") | 40 | @ApiOperation("创建商品spu") |
| 40 | @PreAuthorize("@ss.hasPermission('product:spu:create')") | 41 | @PreAuthorize("@ss.hasPermission('product:spu:create')") |
| 41 | - public CommonResult<Integer> createSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { | 42 | + public CommonResult<Long> createSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { |
| 42 | return success(spuService.createSpu(createReqVO)); | 43 | return success(spuService.createSpu(createReqVO)); |
| 43 | } | 44 | } |
| 44 | 45 | ||
| @@ -52,27 +53,27 @@ public class ProductSpuController { | @@ -52,27 +53,27 @@ public class ProductSpuController { | ||
| 52 | 53 | ||
| 53 | @DeleteMapping("/delete") | 54 | @DeleteMapping("/delete") |
| 54 | @ApiOperation("删除商品spu") | 55 | @ApiOperation("删除商品spu") |
| 55 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) | 56 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) |
| 56 | @PreAuthorize("@ss.hasPermission('product:spu:delete')") | 57 | @PreAuthorize("@ss.hasPermission('product:spu:delete')") |
| 57 | - public CommonResult<Boolean> deleteSpu(@RequestParam("id") Integer id) { | 58 | + public CommonResult<Boolean> deleteSpu(@RequestParam("id") Long id) { |
| 58 | spuService.deleteSpu(id); | 59 | spuService.deleteSpu(id); |
| 59 | return success(true); | 60 | return success(true); |
| 60 | } | 61 | } |
| 61 | 62 | ||
| 62 | @GetMapping("/get") | 63 | @GetMapping("/get") |
| 63 | @ApiOperation("获得商品spu") | 64 | @ApiOperation("获得商品spu") |
| 64 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) | 65 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 65 | @PreAuthorize("@ss.hasPermission('product:spu:query')") | 66 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 66 | - public CommonResult<SpuRespVO> getSpu(@RequestParam("id") Integer id) { | 67 | + public CommonResult<SpuRespVO> getSpu(@RequestParam("id") Long id) { |
| 67 | ProductSpuDO spu = spuService.getSpu(id); | 68 | ProductSpuDO spu = spuService.getSpu(id); |
| 68 | return success(ProductSpuConvert.INSTANCE.convert(spu)); | 69 | return success(ProductSpuConvert.INSTANCE.convert(spu)); |
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | @GetMapping("/list") | 72 | @GetMapping("/list") |
| 72 | @ApiOperation("获得商品spu列表") | 73 | @ApiOperation("获得商品spu列表") |
| 73 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | 74 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = Long.class) |
| 74 | @PreAuthorize("@ss.hasPermission('product:spu:query')") | 75 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 75 | - public CommonResult<List<SpuRespVO>> getSpuList(@RequestParam("ids") Collection<Integer> ids) { | 76 | + public CommonResult<List<SpuRespVO>> getSpuList(@RequestParam("ids") Collection<Long> ids) { |
| 76 | List<ProductSpuDO> list = spuService.getSpuList(ids); | 77 | List<ProductSpuDO> list = spuService.getSpuList(ids); |
| 77 | return success(ProductSpuConvert.INSTANCE.convertList(list)); | 78 | return success(ProductSpuConvert.INSTANCE.convertList(list)); |
| 78 | } | 79 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
| 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | ||
| 3 | import lombok.*; | 4 | import lombok.*; |
| 4 | import java.util.*; | 5 | import java.util.*; |
| 5 | import io.swagger.annotations.*; | 6 | import io.swagger.annotations.*; |
| 7 | + | ||
| 8 | +import javax.validation.Valid; | ||
| 6 | import javax.validation.constraints.*; | 9 | import javax.validation.constraints.*; |
| 7 | 10 | ||
| 8 | @ApiModel("管理后台 - 商品spu创建 Request VO") | 11 | @ApiModel("管理后台 - 商品spu创建 Request VO") |
| @@ -11,4 +14,8 @@ import javax.validation.constraints.*; | @@ -11,4 +14,8 @@ import javax.validation.constraints.*; | ||
| 11 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
| 12 | public class ProductSpuCreateReqVO extends ProductSpuBaseVO { | 15 | public class ProductSpuCreateReqVO extends ProductSpuBaseVO { |
| 13 | 16 | ||
| 17 | + @ApiModelProperty(value = "sku组合") | ||
| 18 | + @Valid | ||
| 19 | + List<ProductSkuCreateReqVO> productSkuCreateReqVOS; | ||
| 20 | + | ||
| 14 | } | 21 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuUpdateReqVO.java
| 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; | 1 | package cn.iocoder.yudao.module.product.controller.admin.spu.vo; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | ||
| 3 | import lombok.*; | 4 | import lombok.*; |
| 4 | import java.util.*; | 5 | import java.util.*; |
| 5 | import io.swagger.annotations.*; | 6 | import io.swagger.annotations.*; |
| 7 | + | ||
| 8 | +import javax.validation.Valid; | ||
| 6 | import javax.validation.constraints.*; | 9 | import javax.validation.constraints.*; |
| 7 | 10 | ||
| 8 | @ApiModel("管理后台 - 商品spu更新 Request VO") | 11 | @ApiModel("管理后台 - 商品spu更新 Request VO") |
| @@ -13,6 +16,10 @@ public class SpuUpdateReqVO extends ProductSpuBaseVO { | @@ -13,6 +16,10 @@ public class SpuUpdateReqVO extends ProductSpuBaseVO { | ||
| 13 | 16 | ||
| 14 | @ApiModelProperty(value = "主键", required = true) | 17 | @ApiModelProperty(value = "主键", required = true) |
| 15 | @NotNull(message = "主键不能为空") | 18 | @NotNull(message = "主键不能为空") |
| 16 | - private Integer id; | 19 | + private Long id; |
| 20 | + | ||
| 21 | + @ApiModelProperty(value = "sku组合") | ||
| 22 | + @Valid | ||
| 23 | + List<ProductSkuCreateReqVO> productSkuCreateReqVOS; | ||
| 17 | 24 | ||
| 18 | } | 25 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java
| @@ -2,12 +2,16 @@ package cn.iocoder.yudao.module.product.convert.sku; | @@ -2,12 +2,16 @@ package cn.iocoder.yudao.module.product.convert.sku; | ||
| 2 | 2 | ||
| 3 | import java.util.*; | 3 | import java.util.*; |
| 4 | 4 | ||
| 5 | +import cn.hutool.json.JSONUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 7 | ||
| 7 | import org.mapstruct.Mapper; | 8 | import org.mapstruct.Mapper; |
| 9 | +import org.mapstruct.Mapping; | ||
| 10 | +import org.mapstruct.Named; | ||
| 8 | import org.mapstruct.factory.Mappers; | 11 | import org.mapstruct.factory.Mappers; |
| 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; | 12 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 10 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 13 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 14 | +import org.springframework.util.StringUtils; | ||
| 11 | 15 | ||
| 12 | /** | 16 | /** |
| 13 | * 商品sku Convert | 17 | * 商品sku Convert |
| @@ -19,16 +23,36 @@ public interface ProductSkuConvert { | @@ -19,16 +23,36 @@ public interface ProductSkuConvert { | ||
| 19 | 23 | ||
| 20 | ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); | 24 | ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); |
| 21 | 25 | ||
| 26 | + @Mapping(source = "properties", target = "properties", qualifiedByName = "translateStringFromList") | ||
| 22 | ProductSkuDO convert(ProductSkuCreateReqVO bean); | 27 | ProductSkuDO convert(ProductSkuCreateReqVO bean); |
| 23 | 28 | ||
| 29 | + @Mapping(source = "properties", target = "properties", qualifiedByName = "translateStringFromList") | ||
| 24 | ProductSkuDO convert(ProductSkuUpdateReqVO bean); | 30 | ProductSkuDO convert(ProductSkuUpdateReqVO bean); |
| 25 | 31 | ||
| 32 | + @Mapping(source = "properties", target = "properties", qualifiedByName = "tokenizeToBeanArray") | ||
| 26 | ProductSkuRespVO convert(ProductSkuDO bean); | 33 | ProductSkuRespVO convert(ProductSkuDO bean); |
| 27 | 34 | ||
| 35 | + @Mapping(source = "properties", target = "properties", qualifiedByName = "tokenizeToExcelBeanArray") | ||
| 36 | + ProductSkuExcelVO convertToExcelVO(ProductSkuDO bean); | ||
| 37 | + | ||
| 28 | List<ProductSkuRespVO> convertList(List<ProductSkuDO> list); | 38 | List<ProductSkuRespVO> convertList(List<ProductSkuDO> list); |
| 29 | 39 | ||
| 30 | PageResult<ProductSkuRespVO> convertPage(PageResult<ProductSkuDO> page); | 40 | PageResult<ProductSkuRespVO> convertPage(PageResult<ProductSkuDO> page); |
| 31 | 41 | ||
| 32 | List<ProductSkuExcelVO> convertList02(List<ProductSkuDO> list); | 42 | List<ProductSkuExcelVO> convertList02(List<ProductSkuDO> list); |
| 33 | 43 | ||
| 44 | + @Named("tokenizeToBeanArray") | ||
| 45 | + default List<ProductSkuBaseVO.Property> translatePropertyArrayFromString(String properties) { | ||
| 46 | + return JSONUtil.toList(properties, ProductSkuBaseVO.Property.class); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Named("tokenizeToExcelBeanArray") | ||
| 50 | + default List<ProductSkuExcelVO.Property> translateExcelPropertyArrayFromString(String properties) { | ||
| 51 | + return JSONUtil.toList(properties, ProductSkuExcelVO.Property.class); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Named("translateStringFromList") | ||
| 55 | + default String translatePropertyStringFromList(List<ProductSkuBaseVO.Property> properties) { | ||
| 56 | + return JSONUtil.toJsonStr(properties); | ||
| 57 | + } | ||
| 34 | } | 58 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| @@ -5,9 +5,12 @@ import java.util.*; | @@ -5,9 +5,12 @@ import java.util.*; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | ||
| 7 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 8 | +import org.mapstruct.Mapping; | ||
| 9 | +import org.mapstruct.Named; | ||
| 8 | import org.mapstruct.factory.Mappers; | 10 | import org.mapstruct.factory.Mappers; |
| 9 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | 11 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 12 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 13 | +import org.springframework.util.StringUtils; | ||
| 11 | 14 | ||
| 12 | /** | 15 | /** |
| 13 | * 商品spu Convert | 16 | * 商品spu Convert |
| @@ -19,16 +22,31 @@ public interface ProductSpuConvert { | @@ -19,16 +22,31 @@ public interface ProductSpuConvert { | ||
| 19 | 22 | ||
| 20 | ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); | 23 | ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); |
| 21 | 24 | ||
| 25 | + @Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList") | ||
| 22 | ProductSpuDO convert(ProductSpuCreateReqVO bean); | 26 | ProductSpuDO convert(ProductSpuCreateReqVO bean); |
| 23 | 27 | ||
| 28 | + @Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList") | ||
| 24 | ProductSpuDO convert(SpuUpdateReqVO bean); | 29 | ProductSpuDO convert(SpuUpdateReqVO bean); |
| 25 | 30 | ||
| 31 | + @Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "tokenizeToStringArray") | ||
| 26 | SpuRespVO convert(ProductSpuDO bean); | 32 | SpuRespVO convert(ProductSpuDO bean); |
| 27 | 33 | ||
| 34 | + @Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "tokenizeToStringArray") | ||
| 35 | + SpuExcelVO convertToExcelVO(ProductSpuDO bean); | ||
| 36 | + | ||
| 28 | List<SpuRespVO> convertList(List<ProductSpuDO> list); | 37 | List<SpuRespVO> convertList(List<ProductSpuDO> list); |
| 29 | 38 | ||
| 30 | PageResult<SpuRespVO> convertPage(PageResult<ProductSpuDO> page); | 39 | PageResult<SpuRespVO> convertPage(PageResult<ProductSpuDO> page); |
| 31 | 40 | ||
| 32 | List<SpuExcelVO> convertList02(List<ProductSpuDO> list); | 41 | List<SpuExcelVO> convertList02(List<ProductSpuDO> list); |
| 33 | 42 | ||
| 43 | + @Named("tokenizeToStringArray") | ||
| 44 | + default List<String> translatePicUrlsArrayFromString(String picUrls) { | ||
| 45 | + return Arrays.asList(StringUtils.tokenizeToStringArray(picUrls, ",")); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Named("translatePicUrlsFromStringList") | ||
| 49 | + default String translatePicUrlsFromList(List<String> picUrls) { | ||
| 50 | + return StringUtils.collectionToCommaDelimitedString(picUrls); | ||
| 51 | + } | ||
| 34 | } | 52 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java
| @@ -27,7 +27,7 @@ public class ProductSkuDO extends BaseDO { | @@ -27,7 +27,7 @@ public class ProductSkuDO extends BaseDO { | ||
| 27 | * 主键 | 27 | * 主键 |
| 28 | */ | 28 | */ |
| 29 | @TableId | 29 | @TableId |
| 30 | - private Integer id; | 30 | + private Long id; |
| 31 | /** | 31 | /** |
| 32 | * spu编号 | 32 | * spu编号 |
| 33 | */ | 33 | */ |
| @@ -36,7 +36,7 @@ public class ProductSkuDO extends BaseDO { | @@ -36,7 +36,7 @@ public class ProductSkuDO extends BaseDO { | ||
| 36 | * 规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }] | 36 | * 规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }] |
| 37 | */ | 37 | */ |
| 38 | // TODO franky:可以定义一个内部的 Property 类,然后 List<Property> | 38 | // TODO franky:可以定义一个内部的 Property 类,然后 List<Property> |
| 39 | - private List<Property> properties; | 39 | + private String properties; |
| 40 | /** | 40 | /** |
| 41 | * 销售价格,单位:分 | 41 | * 销售价格,单位:分 |
| 42 | */ | 42 | */ |
| @@ -62,11 +62,5 @@ public class ProductSkuDO extends BaseDO { | @@ -62,11 +62,5 @@ public class ProductSkuDO extends BaseDO { | ||
| 62 | */ | 62 | */ |
| 63 | private Integer status; | 63 | private Integer status; |
| 64 | 64 | ||
| 65 | - @Data | ||
| 66 | - public static class Property { | ||
| 67 | - private Integer propertyId; | ||
| 68 | - private Integer valueId; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | } | 65 | } |
| 72 | 66 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
| 1 | package cn.iocoder.yudao.module.product.dal.dataobject.spu; | 1 | package cn.iocoder.yudao.module.product.dal.dataobject.spu; |
| 2 | 2 | ||
| 3 | +import cn.hutool.log.Log; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import com.baomidou.mybatisplus.annotation.KeySequence; | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | import com.baomidou.mybatisplus.annotation.TableId; | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| @@ -27,7 +28,7 @@ public class ProductSpuDO extends BaseDO { | @@ -27,7 +28,7 @@ public class ProductSpuDO extends BaseDO { | ||
| 27 | * 主键 | 28 | * 主键 |
| 28 | */ | 29 | */ |
| 29 | @TableId | 30 | @TableId |
| 30 | - private Integer id; | 31 | + private Long id; |
| 31 | /** | 32 | /** |
| 32 | * 商品名称 | 33 | * 商品名称 |
| 33 | */ | 34 | */ |
| @@ -48,7 +49,7 @@ public class ProductSpuDO extends BaseDO { | @@ -48,7 +49,7 @@ public class ProductSpuDO extends BaseDO { | ||
| 48 | * 商品主图地址,* 数组,以逗号分隔,最多上传15张 | 49 | * 商品主图地址,* 数组,以逗号分隔,最多上传15张 |
| 49 | */ | 50 | */ |
| 50 | // TODO franky:List<String> | 51 | // TODO franky:List<String> |
| 51 | - private List<String> picUrls; | 52 | + private String picUrls; |
| 52 | /** | 53 | /** |
| 53 | * 排序字段 | 54 | * 排序字段 |
| 54 | */ | 55 | */ |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/CategoryService.java
| @@ -76,4 +76,10 @@ public interface CategoryService { | @@ -76,4 +76,10 @@ public interface CategoryService { | ||
| 76 | * @return 商品分类列表 | 76 | * @return 商品分类列表 |
| 77 | */ | 77 | */ |
| 78 | List<CategoryDO> getCategoryTreeList(CategoryTreeListReqVO treeListReqVO); | 78 | List<CategoryDO> getCategoryTreeList(CategoryTreeListReqVO treeListReqVO); |
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 验证选择的分类的合法性 | ||
| 82 | + * @param categoryId 分类id | ||
| 83 | + */ | ||
| 84 | + void validatedCategoryById(Long categoryId); | ||
| 79 | } | 85 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/CategoryServiceImpl.java
| @@ -65,6 +65,9 @@ public class CategoryServiceImpl implements CategoryService { | @@ -65,6 +65,9 @@ public class CategoryServiceImpl implements CategoryService { | ||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | private CategoryDO validateCategoryExists(Long id, ErrorCode errorCode) { | 67 | private CategoryDO validateCategoryExists(Long id, ErrorCode errorCode) { |
| 68 | + if (id == 0) { | ||
| 69 | + return new CategoryDO().setId(id); | ||
| 70 | + } | ||
| 68 | CategoryDO categoryDO = categoryMapper.selectById(id); | 71 | CategoryDO categoryDO = categoryMapper.selectById(id); |
| 69 | if (categoryDO == null) { | 72 | if (categoryDO == null) { |
| 70 | throw exception(errorCode); | 73 | throw exception(errorCode); |
| @@ -73,6 +76,11 @@ public class CategoryServiceImpl implements CategoryService { | @@ -73,6 +76,11 @@ public class CategoryServiceImpl implements CategoryService { | ||
| 73 | } | 76 | } |
| 74 | 77 | ||
| 75 | @Override | 78 | @Override |
| 79 | + public void validatedCategoryById(Long categoryId) { | ||
| 80 | + this.validateCategoryExists(categoryId, CATEGORY_NOT_EXISTS); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Override | ||
| 76 | public CategoryDO getCategory(Long id) { | 84 | public CategoryDO getCategory(Long id) { |
| 77 | return categoryMapper.selectById(id); | 85 | return categoryMapper.selectById(id); |
| 78 | } | 86 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java
| @@ -19,7 +19,7 @@ public interface ProductSkuService { | @@ -19,7 +19,7 @@ public interface ProductSkuService { | ||
| 19 | * @param createReqVO 创建信息 | 19 | * @param createReqVO 创建信息 |
| 20 | * @return 编号 | 20 | * @return 编号 |
| 21 | */ | 21 | */ |
| 22 | - Integer createSku(@Valid ProductSkuCreateReqVO createReqVO); | 22 | + Long createSku(@Valid ProductSkuCreateReqVO createReqVO); |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * 更新商品sku | 25 | * 更新商品sku |
| @@ -33,7 +33,7 @@ public interface ProductSkuService { | @@ -33,7 +33,7 @@ public interface ProductSkuService { | ||
| 33 | * | 33 | * |
| 34 | * @param id 编号 | 34 | * @param id 编号 |
| 35 | */ | 35 | */ |
| 36 | - void deleteSku(Integer id); | 36 | + void deleteSku(Long id); |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * 获得商品sku | 39 | * 获得商品sku |
| @@ -41,7 +41,7 @@ public interface ProductSkuService { | @@ -41,7 +41,7 @@ public interface ProductSkuService { | ||
| 41 | * @param id 编号 | 41 | * @param id 编号 |
| 42 | * @return 商品sku | 42 | * @return 商品sku |
| 43 | */ | 43 | */ |
| 44 | - ProductSkuDO getSku(Integer id); | 44 | + ProductSkuDO getSku(Long id); |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * 获得商品sku列表 | 47 | * 获得商品sku列表 |
| @@ -49,7 +49,7 @@ public interface ProductSkuService { | @@ -49,7 +49,7 @@ public interface ProductSkuService { | ||
| 49 | * @param ids 编号 | 49 | * @param ids 编号 |
| 50 | * @return 商品sku列表 | 50 | * @return 商品sku列表 |
| 51 | */ | 51 | */ |
| 52 | - List<ProductSkuDO> getSkuList(Collection<Integer> ids); | 52 | + List<ProductSkuDO> getSkuList(Collection<Long> ids); |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | * 获得商品sku分页 | 55 | * 获得商品sku分页 |
| @@ -67,4 +67,9 @@ public interface ProductSkuService { | @@ -67,4 +67,9 @@ public interface ProductSkuService { | ||
| 67 | */ | 67 | */ |
| 68 | List<ProductSkuDO> getSkuList(ProductSkuExportReqVO exportReqVO); | 68 | List<ProductSkuDO> getSkuList(ProductSkuExportReqVO exportReqVO); |
| 69 | 69 | ||
| 70 | + /** | ||
| 71 | + *对sku的组合的属性等进行合法性校验 | ||
| 72 | + * @param skuCreateReqList sku组合的集合 | ||
| 73 | + */ | ||
| 74 | + void validatedSkuReq(List<ProductSkuCreateReqVO> skuCreateReqList); | ||
| 70 | } | 75 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| @@ -5,6 +5,8 @@ import javax.annotation.Resource; | @@ -5,6 +5,8 @@ import javax.annotation.Resource; | ||
| 5 | import org.springframework.validation.annotation.Validated; | 5 | import org.springframework.validation.annotation.Validated; |
| 6 | 6 | ||
| 7 | import java.util.*; | 7 | import java.util.*; |
| 8 | +import java.util.stream.Collectors; | ||
| 9 | + | ||
| 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; | 10 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 9 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 12 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| @@ -28,7 +30,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -28,7 +30,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 28 | private ProductSkuMapper ProductSkuMapper; | 30 | private ProductSkuMapper ProductSkuMapper; |
| 29 | 31 | ||
| 30 | @Override | 32 | @Override |
| 31 | - public Integer createSku(ProductSkuCreateReqVO createReqVO) { | 33 | + public Long createSku(ProductSkuCreateReqVO createReqVO) { |
| 32 | // 插入 | 34 | // 插入 |
| 33 | ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); | 35 | ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); |
| 34 | ProductSkuMapper.insert(sku); | 36 | ProductSkuMapper.insert(sku); |
| @@ -46,26 +48,26 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -46,26 +48,26 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | @Override | 50 | @Override |
| 49 | - public void deleteSku(Integer id) { | 51 | + public void deleteSku(Long id) { |
| 50 | // 校验存在 | 52 | // 校验存在 |
| 51 | this.validateSkuExists(id); | 53 | this.validateSkuExists(id); |
| 52 | // 删除 | 54 | // 删除 |
| 53 | ProductSkuMapper.deleteById(id); | 55 | ProductSkuMapper.deleteById(id); |
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | - private void validateSkuExists(Integer id) { | 58 | + private void validateSkuExists(Long id) { |
| 57 | if (ProductSkuMapper.selectById(id) == null) { | 59 | if (ProductSkuMapper.selectById(id) == null) { |
| 58 | throw exception(SKU_NOT_EXISTS); | 60 | throw exception(SKU_NOT_EXISTS); |
| 59 | } | 61 | } |
| 60 | } | 62 | } |
| 61 | 63 | ||
| 62 | @Override | 64 | @Override |
| 63 | - public ProductSkuDO getSku(Integer id) { | 65 | + public ProductSkuDO getSku(Long id) { |
| 64 | return ProductSkuMapper.selectById(id); | 66 | return ProductSkuMapper.selectById(id); |
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | @Override | 69 | @Override |
| 68 | - public List<ProductSkuDO> getSkuList(Collection<Integer> ids) { | 70 | + public List<ProductSkuDO> getSkuList(Collection<Long> ids) { |
| 69 | return ProductSkuMapper.selectBatchIds(ids); | 71 | return ProductSkuMapper.selectBatchIds(ids); |
| 70 | } | 72 | } |
| 71 | 73 | ||
| @@ -79,4 +81,11 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -79,4 +81,11 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 79 | return ProductSkuMapper.selectList(exportReqVO); | 81 | return ProductSkuMapper.selectList(exportReqVO); |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 84 | + @Override | ||
| 85 | + public void validatedSkuReq(List<ProductSkuCreateReqVO> skuCreateReqList) { | ||
| 86 | + // 校验规格属性以及规格值是否存在 | ||
| 87 | + List<Integer> propertyIds = skuCreateReqList.stream().flatMap(p -> p.getProperties().stream()).map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList()); | ||
| 88 | + | ||
| 89 | + // 校验是否有重复的sku组合 | ||
| 90 | + } | ||
| 82 | } | 91 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| @@ -19,7 +19,7 @@ public interface ProductSpuService { | @@ -19,7 +19,7 @@ public interface ProductSpuService { | ||
| 19 | * @param createReqVO 创建信息 | 19 | * @param createReqVO 创建信息 |
| 20 | * @return 编号 | 20 | * @return 编号 |
| 21 | */ | 21 | */ |
| 22 | - Integer createSpu(@Valid ProductSpuCreateReqVO createReqVO); | 22 | + Long createSpu(@Valid ProductSpuCreateReqVO createReqVO); |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * 更新商品spu | 25 | * 更新商品spu |
| @@ -33,7 +33,7 @@ public interface ProductSpuService { | @@ -33,7 +33,7 @@ public interface ProductSpuService { | ||
| 33 | * | 33 | * |
| 34 | * @param id 编号 | 34 | * @param id 编号 |
| 35 | */ | 35 | */ |
| 36 | - void deleteSpu(Integer id); | 36 | + void deleteSpu(Long id); |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * 获得商品spu | 39 | * 获得商品spu |
| @@ -41,7 +41,7 @@ public interface ProductSpuService { | @@ -41,7 +41,7 @@ public interface ProductSpuService { | ||
| 41 | * @param id 编号 | 41 | * @param id 编号 |
| 42 | * @return 商品spu | 42 | * @return 商品spu |
| 43 | */ | 43 | */ |
| 44 | - ProductSpuDO getSpu(Integer id); | 44 | + ProductSpuDO getSpu(Long id); |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * 获得商品spu列表 | 47 | * 获得商品spu列表 |
| @@ -49,7 +49,7 @@ public interface ProductSpuService { | @@ -49,7 +49,7 @@ public interface ProductSpuService { | ||
| 49 | * @param ids 编号 | 49 | * @param ids 编号 |
| 50 | * @return 商品spu列表 | 50 | * @return 商品spu列表 |
| 51 | */ | 51 | */ |
| 52 | - List<ProductSpuDO> getSpuList(Collection<Integer> ids); | 52 | + List<ProductSpuDO> getSpuList(Collection<Long> ids); |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | * 获得商品spu分页 | 55 | * 获得商品spu分页 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| 1 | package cn.iocoder.yudao.module.product.service.spu; | 1 | package cn.iocoder.yudao.module.product.service.spu; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; | ||
| 4 | +import cn.iocoder.yudao.module.product.service.category.CategoryService; | ||
| 5 | +import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | ||
| 3 | import org.springframework.stereotype.Service; | 6 | import org.springframework.stereotype.Service; |
| 4 | import javax.annotation.Resource; | 7 | import javax.annotation.Resource; |
| 8 | +import javax.validation.Valid; | ||
| 9 | + | ||
| 10 | +import org.springframework.transaction.annotation.Transactional; | ||
| 5 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 6 | 12 | ||
| 7 | import java.util.*; | 13 | import java.util.*; |
| @@ -27,10 +33,25 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -27,10 +33,25 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 27 | @Resource | 33 | @Resource |
| 28 | private ProductSpuMapper ProductSpuMapper; | 34 | private ProductSpuMapper ProductSpuMapper; |
| 29 | 35 | ||
| 36 | + @Resource | ||
| 37 | + private CategoryService categoryService; | ||
| 38 | + | ||
| 39 | + @Resource | ||
| 40 | + private ProductSkuService productSkuService; | ||
| 41 | + | ||
| 30 | @Override | 42 | @Override |
| 31 | - public Integer createSpu(ProductSpuCreateReqVO createReqVO) { | 43 | + @Transactional |
| 44 | + public Long createSpu(ProductSpuCreateReqVO createReqVO) { | ||
| 45 | + // 校验分类 | ||
| 46 | + categoryService.validatedCategoryById(createReqVO.getCategoryId()); | ||
| 47 | + // 校验SKU | ||
| 48 | + List<ProductSkuCreateReqVO> skuCreateReqList = createReqVO.getProductSkuCreateReqVOS(); | ||
| 49 | + productSkuService.validatedSkuReq(skuCreateReqList); | ||
| 32 | // 插入 | 50 | // 插入 |
| 33 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); | 51 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); |
| 52 | + skuCreateReqList.forEach(p -> { | ||
| 53 | + p.setSpuId(spu.getId()); | ||
| 54 | + }); | ||
| 34 | ProductSpuMapper.insert(spu); | 55 | ProductSpuMapper.insert(spu); |
| 35 | // 返回 | 56 | // 返回 |
| 36 | return spu.getId(); | 57 | return spu.getId(); |
| @@ -46,26 +67,26 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -46,26 +67,26 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 46 | } | 67 | } |
| 47 | 68 | ||
| 48 | @Override | 69 | @Override |
| 49 | - public void deleteSpu(Integer id) { | 70 | + public void deleteSpu(Long id) { |
| 50 | // 校验存在 | 71 | // 校验存在 |
| 51 | this.validateSpuExists(id); | 72 | this.validateSpuExists(id); |
| 52 | // 删除 | 73 | // 删除 |
| 53 | ProductSpuMapper.deleteById(id); | 74 | ProductSpuMapper.deleteById(id); |
| 54 | } | 75 | } |
| 55 | 76 | ||
| 56 | - private void validateSpuExists(Integer id) { | 77 | + private void validateSpuExists(Long id) { |
| 57 | if (ProductSpuMapper.selectById(id) == null) { | 78 | if (ProductSpuMapper.selectById(id) == null) { |
| 58 | throw exception(SPU_NOT_EXISTS); | 79 | throw exception(SPU_NOT_EXISTS); |
| 59 | } | 80 | } |
| 60 | } | 81 | } |
| 61 | 82 | ||
| 62 | @Override | 83 | @Override |
| 63 | - public ProductSpuDO getSpu(Integer id) { | 84 | + public ProductSpuDO getSpu(Long id) { |
| 64 | return ProductSpuMapper.selectById(id); | 85 | return ProductSpuMapper.selectById(id); |
| 65 | } | 86 | } |
| 66 | 87 | ||
| 67 | @Override | 88 | @Override |
| 68 | - public List<ProductSpuDO> getSpuList(Collection<Integer> ids) { | 89 | + public List<ProductSpuDO> getSpuList(Collection<Long> ids) { |
| 69 | return ProductSpuMapper.selectBatchIds(ids); | 90 | return ProductSpuMapper.selectBatchIds(ids); |
| 70 | } | 91 | } |
| 71 | 92 |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java
| @@ -46,7 +46,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | @@ -46,7 +46,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | ||
| 46 | ProductSkuCreateReqVO reqVO = randomPojo(ProductSkuCreateReqVO.class); | 46 | ProductSkuCreateReqVO reqVO = randomPojo(ProductSkuCreateReqVO.class); |
| 47 | 47 | ||
| 48 | // 调用 | 48 | // 调用 |
| 49 | - Integer skuId = ProductSkuService.createSku(reqVO); | 49 | + Long skuId = ProductSkuService.createSku(reqVO); |
| 50 | // 断言 | 50 | // 断言 |
| 51 | assertNotNull(skuId); | 51 | assertNotNull(skuId); |
| 52 | // 校验记录的属性是否正确 | 52 | // 校验记录的属性是否正确 |
| @@ -86,7 +86,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | @@ -86,7 +86,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | ||
| 86 | ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); | 86 | ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); |
| 87 | ProductSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 | 87 | ProductSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 |
| 88 | // 准备参数 | 88 | // 准备参数 |
| 89 | - Integer id = dbSku.getId(); | 89 | + Long id = dbSku.getId(); |
| 90 | 90 | ||
| 91 | // 调用 | 91 | // 调用 |
| 92 | ProductSkuService.deleteSku(id); | 92 | ProductSkuService.deleteSku(id); |
| @@ -97,7 +97,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | @@ -97,7 +97,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { | ||
| 97 | @Test | 97 | @Test |
| 98 | public void testDeleteSku_notExists() { | 98 | public void testDeleteSku_notExists() { |
| 99 | // 准备参数 | 99 | // 准备参数 |
| 100 | - Integer id = 1; | 100 | + Long id = 1L; |
| 101 | 101 | ||
| 102 | // 调用, 并断言异常 | 102 | // 调用, 并断言异常 |
| 103 | assertServiceException(() -> ProductSkuService.deleteSku(id), SKU_NOT_EXISTS); | 103 | assertServiceException(() -> ProductSkuService.deleteSku(id), SKU_NOT_EXISTS); |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| @@ -46,7 +46,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -46,7 +46,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 46 | ProductSpuCreateReqVO reqVO = randomPojo(ProductSpuCreateReqVO.class); | 46 | ProductSpuCreateReqVO reqVO = randomPojo(ProductSpuCreateReqVO.class); |
| 47 | 47 | ||
| 48 | // 调用 | 48 | // 调用 |
| 49 | - Integer spuId = spuService.createSpu(reqVO); | 49 | + Long spuId = spuService.createSpu(reqVO); |
| 50 | // 断言 | 50 | // 断言 |
| 51 | assertNotNull(spuId); | 51 | assertNotNull(spuId); |
| 52 | // 校验记录的属性是否正确 | 52 | // 校验记录的属性是否正确 |
| @@ -86,7 +86,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -86,7 +86,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 86 | ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class); | 86 | ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class); |
| 87 | ProductSpuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 | 87 | ProductSpuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 |
| 88 | // 准备参数 | 88 | // 准备参数 |
| 89 | - Integer id = dbSpu.getId(); | 89 | + Long id = dbSpu.getId(); |
| 90 | 90 | ||
| 91 | // 调用 | 91 | // 调用 |
| 92 | spuService.deleteSpu(id); | 92 | spuService.deleteSpu(id); |
| @@ -97,7 +97,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -97,7 +97,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 97 | @Test | 97 | @Test |
| 98 | public void testDeleteSpu_notExists() { | 98 | public void testDeleteSpu_notExists() { |
| 99 | // 准备参数 | 99 | // 准备参数 |
| 100 | - Integer id = 1; | 100 | + Long id = 1L; |
| 101 | 101 | ||
| 102 | // 调用, 并断言异常 | 102 | // 调用, 并断言异常 |
| 103 | assertServiceException(() -> spuService.deleteSpu(id), SPU_NOT_EXISTS); | 103 | assertServiceException(() -> spuService.deleteSpu(id), SPU_NOT_EXISTS); |
yudao-ui-admin/src/views/mall/product/spu/index.vue
| @@ -95,7 +95,7 @@ | @@ -95,7 +95,7 @@ | ||
| 95 | <el-input v-model="form.categoryId" placeholder="请输入分类id" /> | 95 | <el-input v-model="form.categoryId" placeholder="请输入分类id" /> |
| 96 | </el-form-item> | 96 | </el-form-item> |
| 97 | <el-form-item label="商品主图地址" prop="picUrls"> | 97 | <el-form-item label="商品主图地址" prop="picUrls"> |
| 98 | - <el-input v-model="form.picUrls" placeholder="请输入商品主图地址" /> | 98 | + <ImageUpload v-model="form.picUrls" :limit="1"/> |
| 99 | </el-form-item> | 99 | </el-form-item> |
| 100 | <el-form-item label="排序字段" prop="sort"> | 100 | <el-form-item label="排序字段" prop="sort"> |
| 101 | <el-input v-model="form.sort" placeholder="请输入排序字段" /> | 101 | <el-input v-model="form.sort" placeholder="请输入排序字段" /> |