Commit 846405d8b1c057383a5d728a7c3de5a427a89afc

Authored by YunaiV
1 parent 7036a665

mall + promotion:

1、增加 article mock 接口
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.app.article;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO;
  5 +import io.swagger.v3.oas.annotations.Operation;
  6 +import io.swagger.v3.oas.annotations.tags.Tag;
  7 +import org.springframework.validation.annotation.Validated;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +import java.util.Random;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  16 +
  17 +@Tag(name = "用户 APP - 文章分类")
  18 +@RestController
  19 +@RequestMapping("/promotion/article-category")
  20 +@Validated
  21 +public class AppArticleCategoryController {
  22 +
  23 + @RequestMapping("/list")
  24 + @Operation(summary = "获得文章分类列表")
  25 + // TODO @芋艿:swagger 注解
  26 + public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() {
  27 + List<AppArticleCategoryRespVO> appArticleRespVOList = new ArrayList<>();
  28 + Random random = new Random();
  29 + for (int i = 0; i < 10; i++) {
  30 + AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO();
  31 + appArticleRespVO.setId((long) (i + 1));
  32 + appArticleRespVO.setName("分类 - " + i);
  33 + appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
  34 + appArticleRespVOList.add(appArticleRespVO);
  35 + }
  36 + return success(appArticleRespVOList);
  37 + }
  38 +
  39 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.app.article;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
  6 +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO;
  7 +import io.swagger.v3.oas.annotations.tags.Tag;
  8 +import org.springframework.validation.annotation.Validated;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import java.time.LocalDateTime;
  14 +import java.util.ArrayList;
  15 +import java.util.List;
  16 +import java.util.Random;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  19 +
  20 +@Tag(name = "用户 APP - 文章")
  21 +@RestController
  22 +@RequestMapping("/promotion/article")
  23 +@Validated
  24 +public class AppArticleController {
  25 +
  26 + @RequestMapping("/list")
  27 + // TODO @芋艿:swagger 注解
  28 + public CommonResult<List<AppArticleRespVO>> getArticleList(@RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
  29 + @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
  30 + List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>();
  31 + Random random = new Random();
  32 + for (int i = 0; i < 10; i++) {
  33 + AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
  34 + appArticleRespVO.setId((long) (i + 1));
  35 + appArticleRespVO.setTitle("芋道源码 - " + i + "模块");
  36 + appArticleRespVO.setAuthor("芋道源码");
  37 + appArticleRespVO.setCategoryId((long) random.nextInt(10000));
  38 + appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
  39 + appArticleRespVO.setIntroduction("我是简介");
  40 + appArticleRespVO.setDescription("我是详细");
  41 + appArticleRespVO.setCreateTime(LocalDateTime.now());
  42 + appArticleRespVO.setBrowseCount(random.nextInt(10000));
  43 + appArticleRespVO.setSpuId((long) random.nextInt(10000));
  44 + appArticleRespVOList.add(appArticleRespVO);
  45 + }
  46 + return success(appArticleRespVOList);
  47 + }
  48 +
  49 + @RequestMapping("/page")
  50 + // TODO @芋艿:swagger 注解
  51 + public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) {
  52 + List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>();
  53 + Random random = new Random();
  54 + for (int i = 0; i < 10; i++) {
  55 + AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
  56 + appArticleRespVO.setId((long) (i + 1));
  57 + appArticleRespVO.setTitle("芋道源码 - " + i + "模块");
  58 + appArticleRespVO.setAuthor("芋道源码");
  59 + appArticleRespVO.setCategoryId((long) random.nextInt(10000));
  60 + appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
  61 + appArticleRespVO.setIntroduction("我是简介");
  62 + appArticleRespVO.setDescription("我是详细");
  63 + appArticleRespVO.setCreateTime(LocalDateTime.now());
  64 + appArticleRespVO.setBrowseCount(random.nextInt(10000));
  65 + appArticleRespVO.setSpuId((long) random.nextInt(10000));
  66 + appArticleRespVOList.add(appArticleRespVO);
  67 + }
  68 + return success(new PageResult<>(appArticleRespVOList, 10L));
  69 + }
  70 +
  71 + @RequestMapping("/get")
  72 + // TODO @芋艿:swagger 注解
  73 + public CommonResult<AppArticleRespVO> getArticlePage(@RequestParam("id") Long id) {
  74 + Random random = new Random();
  75 + AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
  76 + appArticleRespVO.setId((long) (1));
  77 + appArticleRespVO.setTitle("芋道源码 - " + 0 + "模块");
  78 + appArticleRespVO.setAuthor("芋道源码");
  79 + appArticleRespVO.setCategoryId((long) random.nextInt(10000));
  80 + appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (0 + 1) + ".png");
  81 + appArticleRespVO.setIntroduction("我是简介");
  82 + appArticleRespVO.setDescription("我是详细");
  83 + appArticleRespVO.setCreateTime(LocalDateTime.now());
  84 + appArticleRespVO.setBrowseCount(random.nextInt(10000));
  85 + appArticleRespVO.setSpuId((long) random.nextInt(10000));
  86 + appArticleRespVO.setSpuId(633L);
  87 + return success(appArticleRespVO);
  88 + }
  89 +
  90 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +
  7 +@Schema(description = "应用 App - 文章的分页 Request VO")
  8 +@Data
  9 +public class AppArticlePageReqVO extends PageParam {
  10 +
  11 + @Schema(description = "分类编号", example = "2048")
  12 + private Long categoryId;
  13 +
  14 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import java.time.LocalDateTime;
  7 +
  8 +@Schema(description = "应用 App - 文章 Response VO")
  9 +@Data
  10 +public class AppArticleRespVO {
  11 +
  12 + @Schema(description = "文章编号", required = true, example = "1")
  13 + private Long id;
  14 +
  15 + @Schema(description = "文章标题", required = true, example = "芋道源码 - 促销模块")
  16 + private String title;
  17 +
  18 + @Schema(description = "文章作者", required = true, example = "芋道源码")
  19 + private String author;
  20 +
  21 + @Schema(description = "分类编号", required = true, example = "2048")
  22 + private Long categoryId;
  23 +
  24 + @Schema(description = "图文封面", required = true, example = "https://www.iocoder.cn/1.png")
  25 + private String picUrl;
  26 +
  27 + @Schema(description = "文章简介", required = true, example = "我是简介")
  28 + private String introduction;
  29 +
  30 + @Schema(description = "文章内容", required = true, example = "我是详细")
  31 + private String description;
  32 +
  33 + @Schema(description = "发布时间", required = true)
  34 + private LocalDateTime createTime;
  35 +
  36 + @Schema(description = "浏览量", required = true, example = "1024")
  37 + private Integer browseCount;
  38 +
  39 + @Schema(description = "关联的商品 SPU 编号", example = "1024")
  40 + private Long spuId;
  41 +
  42 +// TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回;
  43 +// @Schema(description = "是否热卖推荐", required = true, example = "true")
  44 +// private Boolean recommendHot;
  45 +//
  46 +// @Schema(description = "是否 Banner 推荐", required = true, example = "true")
  47 +// private Boolean recommendBanner;
  48 +
  49 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.promotion.controller.app.article.vo.category;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +@Schema(description = "应用 App - 文章分类 Response VO")
  7 +@Data
  8 +public class AppArticleCategoryRespVO {
  9 +
  10 + @Schema(description = "分类编号", required = true, example = "1")
  11 + private Long id;
  12 +
  13 + @Schema(description = "分类名称", required = true, example = "技术")
  14 + private String name;
  15 +
  16 + @Schema(description = "分类图标", required = true, example = "https://www.iocoder.cn/1.png")
  17 + private String picUrl;
  18 +
  19 + // TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回;
  20 +// @Schema(description = "状态", required = true, example = "1")
  21 +// private Integer status;
  22 +//
  23 +// @Schema(description = "排序", required = true, example = "1024")
  24 +// private Integer sort;
  25 +
  26 +}
... ...