mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
mall:完善商品分类的 APP 后端接口
This commit is contained in:
@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCateg
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.category.CategoryConvert;
|
||||
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -61,7 +61,7 @@ public class ProductCategoryController {
|
||||
@PreAuthorize("@ss.hasPermission('product:category:query')")
|
||||
public CommonResult<ProductCategoryRespVO> getProductCategory(@RequestParam("id") Long id) {
|
||||
ProductCategoryDO category = categoryService.getProductCategory(id);
|
||||
return success(CategoryConvert.INSTANCE.convert(category));
|
||||
return success(ProductCategoryConvert.INSTANCE.convert(category));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ -70,7 +70,7 @@ public class ProductCategoryController {
|
||||
public CommonResult<List<ProductCategoryRespVO>> getProductCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
|
||||
List<ProductCategoryDO> list = categoryService.getEnableProductCategoryList(treeListReqVO);
|
||||
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
||||
return success(CategoryConvert.INSTANCE.convertList(list));
|
||||
return success(ProductCategoryConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.product.controller.app.category;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryListRespVO;
|
||||
import cn.iocoder.yudao.module.product.convert.category.CategoryConvert;
|
||||
import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO;
|
||||
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -29,10 +29,10 @@ public class AppCategoryController {
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得商品分类列表")
|
||||
public CommonResult<List<AppCategoryListRespVO>> listByQuery() {
|
||||
public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() {
|
||||
List<ProductCategoryDO> list = categoryService.getEnableProductCategoryList();
|
||||
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
||||
return success(CategoryConvert.INSTANCE.convertList03(list));
|
||||
return success(ProductCategoryConvert.INSTANCE.convertList03(list));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "App - 商品分类 Response VO")
|
||||
public class AppCategoryListRespVO {
|
||||
@ApiModel(value = "用户 APP - 商品分类 Response VO")
|
||||
public class AppCategoryRespVO {
|
||||
|
||||
@ApiModelProperty(value = "分类编号", required = true, example = "2")
|
||||
private Long id;
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.convert.category;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryListRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@ -16,9 +16,9 @@ import java.util.List;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface CategoryConvert {
|
||||
public interface ProductCategoryConvert {
|
||||
|
||||
CategoryConvert INSTANCE = Mappers.getMapper(CategoryConvert.class);
|
||||
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
|
||||
|
||||
ProductCategoryDO convert(ProductCategoryCreateReqVO bean);
|
||||
|
||||
@ -28,5 +28,5 @@ public interface CategoryConvert {
|
||||
|
||||
List<ProductCategoryRespVO> convertList(List<ProductCategoryDO> list);
|
||||
|
||||
List<AppCategoryListRespVO> convertList03(List<ProductCategoryDO> list);
|
||||
List<AppCategoryRespVO> convertList03(List<ProductCategoryDO> list);
|
||||
}
|
@ -9,9 +9,9 @@ import lombok.*;
|
||||
/**
|
||||
* 商品分类 DO
|
||||
*
|
||||
* 商品分类一共两级:
|
||||
* 商品分类一共两类:
|
||||
* 1)一级分类:{@link #parentId} 等于 0
|
||||
* 2)二级分类:{@link #parentId} 等于父分类
|
||||
* 2)二级 + 三级分类:{@link #parentId} 不等于 0
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@ -46,7 +46,7 @@ public class ProductCategoryDO extends BaseDO {
|
||||
* 分类图片
|
||||
*
|
||||
* 一级分类:推荐 200 x 100 分辨率
|
||||
* 二级分类:推荐 100 x 100 分辨率
|
||||
* 二级 + 三级分类:推荐 100 x 100 分辨率
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.category.CategoryConvert;
|
||||
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -37,7 +37,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
||||
validateParentProductCategory(createReqVO.getParentId());
|
||||
|
||||
// 插入
|
||||
ProductCategoryDO category = CategoryConvert.INSTANCE.convert(createReqVO);
|
||||
ProductCategoryDO category = ProductCategoryConvert.INSTANCE.convert(createReqVO);
|
||||
productCategoryMapper.insert(category);
|
||||
// 返回
|
||||
return category.getId();
|
||||
@ -51,7 +51,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
||||
validateParentProductCategory(updateReqVO.getParentId());
|
||||
|
||||
// 更新
|
||||
ProductCategoryDO updateObj = CategoryConvert.INSTANCE.convert(updateReqVO);
|
||||
ProductCategoryDO updateObj = ProductCategoryConvert.INSTANCE.convert(updateReqVO);
|
||||
productCategoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user