-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request !724 from niou233/feature/mall_product_org
- Loading branch information
Showing
11 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package cn.iocoder.yudao.module.product.controller.admin.favorite; | ||
|
||
import cn.hutool.core.collection.CollUtil; | ||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; | ||
import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; | ||
import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; | ||
import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; | ||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | ||
import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; | ||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.annotation.Resource; | ||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
|
||
@Tag(name = "管理后台 - 商品收藏") | ||
@RestController | ||
@RequestMapping("/product/favorite") | ||
@Validated | ||
public class ProductFavoriteController { | ||
|
||
@Resource | ||
private ProductFavoriteService productFavoriteService; | ||
|
||
@Resource | ||
private ProductSpuService productSpuService; | ||
|
||
@GetMapping("/page") | ||
@Operation(summary = "获得商品收藏分页") | ||
@PreAuthorize("@ss.hasPermission('product:favorite:query')") | ||
public CommonResult<PageResult<ProductFavoriteRespVO>> getFavoritePage(@Valid ProductFavoritePageReqVO pageVO) { | ||
PageResult<ProductFavoriteDO> favoritePage = productFavoriteService.getFavoritePage(pageVO); | ||
if (CollUtil.isEmpty(favoritePage.getList())) { | ||
return success(PageResult.empty()); | ||
} | ||
|
||
List<ProductSpuDO> list = productSpuService.getSpuList(convertSet(favoritePage.getList(), ProductFavoriteDO::getSpuId)); | ||
|
||
// 得到商品 spu 信息 | ||
List<ProductFavoriteRespVO> favorites = ProductFavoriteConvert.INSTANCE.convertList2admin(favoritePage.getList(), list); | ||
|
||
// 转换 VO 结果 | ||
PageResult<ProductFavoriteRespVO> pageResult = new PageResult<>(favoritePage.getTotal()); | ||
pageResult.setList(favorites); | ||
|
||
return success(pageResult); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...a/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* 商品收藏 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
*/ | ||
@Data | ||
public class ProductFavoriteBaseVO { | ||
|
||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5036") | ||
@NotNull(message = "用户编号不能为空") | ||
private Long userId; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...n/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; | ||
|
||
import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
@Schema(description = "管理后台 - 商品收藏分页 Request VO") | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
public class ProductFavoritePageReqVO extends PageParam { | ||
|
||
@Schema(description = "用户编号", example = "5036") | ||
private Long userId; | ||
} |
17 changes: 17 additions & 0 deletions
17
...va/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
import lombok.ToString; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
@Schema(description = "管理后台 - 商品收藏的单个 Response VO") | ||
@Data | ||
@ToString(callSuper = true) | ||
public class ProductFavoriteReqVO extends ProductFavoriteBaseVO { | ||
|
||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32734") | ||
@NotNull(message = "商品 SPU 编号不能为空") | ||
private Long spuId; | ||
} |
18 changes: 18 additions & 0 deletions
18
...a/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; | ||
|
||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
import lombok.ToString; | ||
|
||
@Schema(description = "管理后台 - 商品收藏 Response VO") | ||
@Data | ||
@ToString(callSuper = true) | ||
public class ProductFavoriteRespVO extends ProductSpuRespVO { | ||
|
||
@Schema(description = "userId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | ||
private Long userId; | ||
|
||
@Schema(description = "spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") | ||
private Long spuId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDetailDO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cn.iocoder.yudao.module.product.dal.dataobject.favorite; | ||
|
||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | ||
import lombok.Data; | ||
|
||
/** | ||
* 商品收藏 DO | ||
* | ||
* @author 芋道源码 | ||
*/ | ||
@Data | ||
public class ProductFavoriteDetailDO extends ProductFavoriteDO { | ||
|
||
ProductSpuDO spuDO; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters