mall + promotion:mock banner mock 接口

This commit is contained in:
YunaiV 2023-06-17 00:47:47 +08:00
parent 5b324f90a4
commit 07fe52939d
7 changed files with 116 additions and 40 deletions

View File

@ -4,22 +4,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* @author xia
*/
@Schema(description = "管理后台 - Banner Response VO")
@Data
@ToString(callSuper = true)
public class BannerRespVO extends BannerBaseVO {
@Schema(description = "banner编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "banner编号不能为空")
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED)
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -1,42 +1,42 @@
package cn.iocoder.yudao.module.promotion.controller.app.banner;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO;
import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO;
import cn.iocoder.yudao.module.promotion.service.banner.BannerService;
import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* @author: XIA
*/
@RestController
@RequestMapping("/market/banner")
@Tag(name = "用户APP- 首页Banner")
@RequestMapping("/promotion/banner")
@Tag(name = "用户 APP - 首页 Banner")
@Validated
public class AppBannerController {
@Resource
private BannerService bannerService;
// TODO @xia新建一个 AppBannerRespVO只返回必要的字段status 要过滤下然后 sort 下结果
@GetMapping("/list")
@Operation(summary = "获得banner列表")
@PreAuthorize("@ss.hasPermission('market:banner:query')")
public CommonResult<List<BannerRespVO>> getBannerList() {
List<BannerDO> list = bannerService.getBannerList();
return success(BannerConvert.INSTANCE.convertList(list));
@Operation(summary = "获得 banner 列表")
// todo @芋艿swagger 注解待补全
// TODO @芋艿可以增加缓存提升性能
// TODO @芋艿position = 1 首页position = 10 拼团活动页
public CommonResult<List<AppBannerRespVO>> getBannerList(@RequestParam("position") Integer position) {
List<AppBannerRespVO> bannerList = new ArrayList<>();
AppBannerRespVO banner1 = new AppBannerRespVO();
banner1.setUrl("https://www.example.com/link1");
banner1.setPicUrl("https://api.java.crmeb.net/crmebimage/public/content/2022/08/04/0f78716213f64bfa83f191d51a832cbf73f6axavoy.jpg");
bannerList.add(banner1);
AppBannerRespVO banner2 = new AppBannerRespVO();
banner2.setUrl("https://www.example.com/link2");
banner2.setPicUrl("https://api.java.crmeb.net/crmebimage/public/content/2023/01/11/be09e755268b43ee90b0db3a3e1b7132r7a6t2wvsm.jpg");
bannerList.add(banner2);
return success(bannerList);
}
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.promotion.controller.app.banner.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "用户 App - Banner Response VO")
@Data
public class AppBannerRespVO {
@Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "跳转链接不能为空")
private String url;
@Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "图片地址不能为空")
private String picUrl;
}

View File

@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityPageItemRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -26,11 +26,14 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppCombinationActivityController {
@GetMapping("/page")
@Operation(summary = "获得拼团活动分页")
public CommonResult<PageResult<AppCombinationActivityPageItemRespVO>> getCombinationActivityPage(PageParam pageParam) {
List<AppCombinationActivityPageItemRespVO> activityList = new ArrayList<>();
AppCombinationActivityPageItemRespVO activity1 = new AppCombinationActivityPageItemRespVO();
@GetMapping("/list")
@Operation(summary = "获得拼团活动列表", description = "用于小程序首页")
// TODO 芋艿增加 Spring Cache
// TODO 芋艿缺少 swagger 注解
public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityList(
@RequestParam(name = "count", defaultValue = "6") Integer count) {
List<AppCombinationActivityRespVO> activityList = new ArrayList<>();
AppCombinationActivityRespVO activity1 = new AppCombinationActivityRespVO();
activity1.setId(1L);
activity1.setName("618 大拼团");
activity1.setUserSize(3);
@ -40,7 +43,34 @@ public class AppCombinationActivityController {
activity1.setCombinationPrice(100);
activityList.add(activity1);
AppCombinationActivityPageItemRespVO activity2 = new AppCombinationActivityPageItemRespVO();
AppCombinationActivityRespVO activity2 = new AppCombinationActivityRespVO();
activity2.setId(2L);
activity2.setName("双十一拼团");
activity2.setUserSize(5);
activity2.setSpuId(4096L);
activity2.setPicUrl("商品图片地址");
activity2.setMarketPrice(100);
activity2.setCombinationPrice(200);
activityList.add(activity2);
return success(activityList);
}
@GetMapping("/page")
@Operation(summary = "获得拼团活动分页")
public CommonResult<PageResult<AppCombinationActivityRespVO>> getCombinationActivityPage(PageParam pageParam) {
List<AppCombinationActivityRespVO> activityList = new ArrayList<>();
AppCombinationActivityRespVO activity1 = new AppCombinationActivityRespVO();
activity1.setId(1L);
activity1.setName("618 大拼团");
activity1.setUserSize(3);
activity1.setSpuId(2048L);
activity1.setPicUrl("商品图片地址");
activity1.setMarketPrice(50);
activity1.setCombinationPrice(100);
activityList.add(activity1);
AppCombinationActivityRespVO activity2 = new AppCombinationActivityRespVO();
activity2.setId(2L);
activity2.setName("双十一拼团");
activity2.setUserSize(5);

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -27,6 +28,23 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppCombinationRecordController {
@GetMapping("/get-summary")
@Operation(summary = "获得拼团活动的概要信息", description = "用于小程序首页")
// TODO 芋艿增加 @Cache 缓存1 分钟过期
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationSummary() {
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
summary.setUserCount(1024);
summary.setAvatars(new ArrayList<>());
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLjFK35Wvia9lJKHoXfQuHhk0qZbvpPNxrAiaEKF7aL2k4I8kuqrdTWwliamdPHeyAA7DjAg725X2GIQ/132");
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTK1pXgdj5DvBMwrbe8v3tFibSWeQATEsAibt3fllD8XwJ460P2r6KS3WCQvDefuv1bVpDhNCle6CTCA/132");
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTL7KRGHBE62N0awFyBesmmxiaCicf1fJ7E7UCh6zA8GWlT1QC1zT01gG4OxI7BWDESkdPZ5o7tno4hA/132");
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/ouwtwJycbic2JrCoZjETict0klxd1uRuicRneKk00ewMcCClxVcVHQT91Sh9MJGtwibf1fOicD1WpwSP4icJM6eQq1AA/132");
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/RpUrhwens58qc99OcGs993xL4M5QPOe05ekqF9Eia440kRicAlicicIdQWicHBmy2bzLgHzHguWEzHHxnIgeictL7bLA/132");
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/S4tfqmxc8GZGsKc1K4mnhpvtG16gtMrLnTQfDibhr7jJich9LRI5RQKZDoqEjZM3azMib5nic7F4ZXKMEgYyLO08KA/132");
summary.getAvatars().add("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKXMYJOomfp7cebz3cIeb8sHk3GGSIJtWEgREe3j7J1WoAbTvIOicpcNdFkWAziatBSMod8b5RyS4CQ/132");
return success(summary);
}
@GetMapping("/get-head-list")
@Operation(summary = "获得最近 n 条拼团记录(团长发起的)")
// TODO @芋艿注解要补全

View File

@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 App - 拼团活动分页项 Response VO")
@Schema(description = "用户 App - 拼团活动 Response VO")
@Data
public class AppCombinationActivityPageItemRespVO {
public class AppCombinationActivityRespVO {
@Schema(description = "拼团活动编号", required = true, example = "1024")
private Long id;

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "用户 App - 拼团记录的简要概括 Response VO")
@Data
public class AppCombinationRecordSummaryRespVO {
@Schema(description = "拼团用户数量", required = true, example = "1024")
private Integer userCount;
@Schema(description = "拼团用户头像列表", required = true) // 只返回最近的 7
private List<String> avatars;
}