mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	mall + promotion:
1、增加 article mock 接口
This commit is contained in:
		| @@ -0,0 +1,39 @@ | |||||||
|  | package cn.iocoder.yudao.module.promotion.controller.app.article; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||||
|  | import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; | ||||||
|  | import io.swagger.v3.oas.annotations.Operation; | ||||||
|  | import io.swagger.v3.oas.annotations.tags.Tag; | ||||||
|  | import org.springframework.validation.annotation.Validated; | ||||||
|  | import org.springframework.web.bind.annotation.RequestMapping; | ||||||
|  | import org.springframework.web.bind.annotation.RestController; | ||||||
|  |  | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.List; | ||||||
|  | import java.util.Random; | ||||||
|  |  | ||||||
|  | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||||
|  |  | ||||||
|  | @Tag(name = "用户 APP - 文章分类") | ||||||
|  | @RestController | ||||||
|  | @RequestMapping("/promotion/article-category") | ||||||
|  | @Validated | ||||||
|  | public class AppArticleCategoryController { | ||||||
|  |  | ||||||
|  |     @RequestMapping("/list") | ||||||
|  |     @Operation(summary = "获得文章分类列表") | ||||||
|  |     // TODO @芋艿:swagger 注解 | ||||||
|  |     public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() { | ||||||
|  |         List<AppArticleCategoryRespVO> appArticleRespVOList = new ArrayList<>(); | ||||||
|  |         Random random = new Random(); | ||||||
|  |         for (int i = 0; i < 10; i++) { | ||||||
|  |             AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO(); | ||||||
|  |             appArticleRespVO.setId((long) (i + 1)); | ||||||
|  |             appArticleRespVO.setName("分类 - " + i); | ||||||
|  |             appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); | ||||||
|  |             appArticleRespVOList.add(appArticleRespVO); | ||||||
|  |         } | ||||||
|  |         return success(appArticleRespVOList); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,90 @@ | |||||||
|  | package cn.iocoder.yudao.module.promotion.controller.app.article; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
|  | import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | ||||||
|  | import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; | ||||||
|  | import io.swagger.v3.oas.annotations.tags.Tag; | ||||||
|  | import org.springframework.validation.annotation.Validated; | ||||||
|  | import org.springframework.web.bind.annotation.RequestMapping; | ||||||
|  | import org.springframework.web.bind.annotation.RequestParam; | ||||||
|  | import org.springframework.web.bind.annotation.RestController; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.List; | ||||||
|  | import java.util.Random; | ||||||
|  |  | ||||||
|  | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||||
|  |  | ||||||
|  | @Tag(name = "用户 APP - 文章") | ||||||
|  | @RestController | ||||||
|  | @RequestMapping("/promotion/article") | ||||||
|  | @Validated | ||||||
|  | public class AppArticleController { | ||||||
|  |  | ||||||
|  |     @RequestMapping("/list") | ||||||
|  |     // TODO @芋艿:swagger 注解 | ||||||
|  |     public CommonResult<List<AppArticleRespVO>> getArticleList(@RequestParam(value = "recommendHot", required = false) Boolean recommendHot, | ||||||
|  |                                                                @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { | ||||||
|  |         List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>(); | ||||||
|  |         Random random = new Random(); | ||||||
|  |         for (int i = 0; i < 10; i++) { | ||||||
|  |             AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); | ||||||
|  |             appArticleRespVO.setId((long) (i + 1)); | ||||||
|  |             appArticleRespVO.setTitle("芋道源码 - " + i + "模块"); | ||||||
|  |             appArticleRespVO.setAuthor("芋道源码"); | ||||||
|  |             appArticleRespVO.setCategoryId((long) random.nextInt(10000)); | ||||||
|  |             appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); | ||||||
|  |             appArticleRespVO.setIntroduction("我是简介"); | ||||||
|  |             appArticleRespVO.setDescription("我是详细"); | ||||||
|  |             appArticleRespVO.setCreateTime(LocalDateTime.now()); | ||||||
|  |             appArticleRespVO.setBrowseCount(random.nextInt(10000)); | ||||||
|  |             appArticleRespVO.setSpuId((long) random.nextInt(10000)); | ||||||
|  |             appArticleRespVOList.add(appArticleRespVO); | ||||||
|  |         } | ||||||
|  |         return success(appArticleRespVOList); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @RequestMapping("/page") | ||||||
|  |     // TODO @芋艿:swagger 注解 | ||||||
|  |     public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) { | ||||||
|  |         List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>(); | ||||||
|  |         Random random = new Random(); | ||||||
|  |         for (int i = 0; i < 10; i++) { | ||||||
|  |             AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); | ||||||
|  |             appArticleRespVO.setId((long) (i + 1)); | ||||||
|  |             appArticleRespVO.setTitle("芋道源码 - " + i + "模块"); | ||||||
|  |             appArticleRespVO.setAuthor("芋道源码"); | ||||||
|  |             appArticleRespVO.setCategoryId((long) random.nextInt(10000)); | ||||||
|  |             appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); | ||||||
|  |             appArticleRespVO.setIntroduction("我是简介"); | ||||||
|  |             appArticleRespVO.setDescription("我是详细"); | ||||||
|  |             appArticleRespVO.setCreateTime(LocalDateTime.now()); | ||||||
|  |             appArticleRespVO.setBrowseCount(random.nextInt(10000)); | ||||||
|  |             appArticleRespVO.setSpuId((long) random.nextInt(10000)); | ||||||
|  |             appArticleRespVOList.add(appArticleRespVO); | ||||||
|  |         } | ||||||
|  |         return success(new PageResult<>(appArticleRespVOList, 10L)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @RequestMapping("/get") | ||||||
|  |     // TODO @芋艿:swagger 注解 | ||||||
|  |     public CommonResult<AppArticleRespVO> getArticlePage(@RequestParam("id") Long id) { | ||||||
|  |         Random random = new Random(); | ||||||
|  |         AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); | ||||||
|  |         appArticleRespVO.setId((long) (1)); | ||||||
|  |         appArticleRespVO.setTitle("芋道源码 - " + 0 + "模块"); | ||||||
|  |         appArticleRespVO.setAuthor("芋道源码"); | ||||||
|  |         appArticleRespVO.setCategoryId((long) random.nextInt(10000)); | ||||||
|  |         appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (0 + 1) + ".png"); | ||||||
|  |         appArticleRespVO.setIntroduction("我是简介"); | ||||||
|  |         appArticleRespVO.setDescription("我是详细"); | ||||||
|  |         appArticleRespVO.setCreateTime(LocalDateTime.now()); | ||||||
|  |         appArticleRespVO.setBrowseCount(random.nextInt(10000)); | ||||||
|  |         appArticleRespVO.setSpuId((long) random.nextInt(10000)); | ||||||
|  |         appArticleRespVO.setSpuId(633L); | ||||||
|  |         return success(appArticleRespVO); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,14 @@ | |||||||
|  | package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||||
|  | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | @Schema(description = "应用 App - 文章的分页 Request VO") | ||||||
|  | @Data | ||||||
|  | public class AppArticlePageReqVO extends PageParam { | ||||||
|  |  | ||||||
|  |     @Schema(description = "分类编号", example = "2048") | ||||||
|  |     private Long categoryId; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,49 @@ | |||||||
|  | package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; | ||||||
|  |  | ||||||
|  | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  |  | ||||||
|  | @Schema(description = "应用 App - 文章 Response VO") | ||||||
|  | @Data | ||||||
|  | public class AppArticleRespVO { | ||||||
|  |  | ||||||
|  |     @Schema(description = "文章编号", required = true, example = "1") | ||||||
|  |     private Long id; | ||||||
|  |  | ||||||
|  |     @Schema(description = "文章标题", required = true, example = "芋道源码 - 促销模块") | ||||||
|  |     private String title; | ||||||
|  |  | ||||||
|  |     @Schema(description = "文章作者", required = true, example = "芋道源码") | ||||||
|  |     private String author; | ||||||
|  |  | ||||||
|  |     @Schema(description = "分类编号", required = true, example = "2048") | ||||||
|  |     private Long categoryId; | ||||||
|  |  | ||||||
|  |     @Schema(description = "图文封面", required = true, example = "https://www.iocoder.cn/1.png") | ||||||
|  |     private String picUrl; | ||||||
|  |  | ||||||
|  |     @Schema(description = "文章简介", required = true, example = "我是简介") | ||||||
|  |     private String introduction; | ||||||
|  |  | ||||||
|  |     @Schema(description = "文章内容", required = true, example = "我是详细") | ||||||
|  |     private String description; | ||||||
|  |  | ||||||
|  |     @Schema(description = "发布时间", required = true) | ||||||
|  |     private LocalDateTime createTime; | ||||||
|  |  | ||||||
|  |     @Schema(description = "浏览量", required = true, example = "1024") | ||||||
|  |     private Integer browseCount; | ||||||
|  |  | ||||||
|  |     @Schema(description = "关联的商品 SPU 编号", example = "1024") | ||||||
|  |     private Long spuId; | ||||||
|  |  | ||||||
|  | // TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回; | ||||||
|  | //    @Schema(description = "是否热卖推荐", required = true, example = "true") | ||||||
|  | //    private Boolean recommendHot; | ||||||
|  | // | ||||||
|  | //    @Schema(description = "是否 Banner 推荐", required = true, example = "true") | ||||||
|  | //    private Boolean recommendBanner; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,26 @@ | |||||||
|  | package cn.iocoder.yudao.module.promotion.controller.app.article.vo.category; | ||||||
|  |  | ||||||
|  | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | @Schema(description = "应用 App - 文章分类 Response VO") | ||||||
|  | @Data | ||||||
|  | public class AppArticleCategoryRespVO { | ||||||
|  |  | ||||||
|  |     @Schema(description = "分类编号", required = true, example = "1") | ||||||
|  |     private Long id; | ||||||
|  |  | ||||||
|  |     @Schema(description = "分类名称", required = true, example = "技术") | ||||||
|  |     private String name; | ||||||
|  |  | ||||||
|  |     @Schema(description = "分类图标", required = true, example = "https://www.iocoder.cn/1.png") | ||||||
|  |     private String picUrl; | ||||||
|  |  | ||||||
|  |     // TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回; | ||||||
|  | //    @Schema(description = "状态", required = true, example = "1") | ||||||
|  | //    private Integer status; | ||||||
|  | // | ||||||
|  | //    @Schema(description = "排序", required = true, example = "1024") | ||||||
|  | //    private Integer sort; | ||||||
|  |  | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV