前端:H5 首页增加 Banner 列表
This commit is contained in:
@@ -8,8 +8,8 @@ import cn.iocoder.mall.promotion.api.dto.BannerAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerPageDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.application.convert.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.BannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.BannerVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminBannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -32,9 +32,9 @@ public class AdminsBannerController {
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<BannerPageVO> page(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
public CommonResult<AdminBannerPageVO> page(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
CommonResult<BannerPageBO> result = bannerService.getBannerPage(new BannerPageDTO().setTitle(title).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return BannerConvert.INSTANCE.convert(result);
|
||||
}
|
||||
@@ -48,11 +48,11 @@ public class AdminsBannerController {
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", required = true, example = "活动很牛逼"),
|
||||
})
|
||||
public CommonResult<BannerVO> add(@RequestParam("title") String title,
|
||||
@RequestParam("url") String url,
|
||||
@RequestParam("picUrl") String picUrl,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
public CommonResult<AdminsBannerVO> add(@RequestParam("title") String title,
|
||||
@RequestParam("url") String url,
|
||||
@RequestParam("picUrl") String picUrl,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
BannerAddDTO bannerAddDTO = new BannerAddDTO().setTitle(title).setUrl(url).setPicUrl(picUrl)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return BannerConvert.INSTANCE.convert2(bannerService.addBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerAddDTO));
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.iocoder.mall.promotion.application.controller.users;
|
||||
|
||||
import cn.iocoder.common.framework.constant.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.BannerService;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.application.convert.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersBannerVO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("users/banner")
|
||||
@Api("Banner 模块")
|
||||
public class UsersProductCategoryController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private BannerService bannerService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得所有 Banner 列表")
|
||||
public CommonResult<List<UsersBannerVO>> list() {
|
||||
// 查询 Banner 列表
|
||||
List<BannerBO> result = bannerService.getBannerListByStatus(CommonStatusEnum.ENABLE.getValue()).getData();
|
||||
// 排序,按照 sort 升序
|
||||
result.sort(Comparator.comparing(BannerBO::getSort));
|
||||
// 返回
|
||||
return CommonResult.success(BannerConvert.INSTANCE.convertList(result));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,24 +3,30 @@ package cn.iocoder.mall.promotion.application.convert;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.BannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.BannerVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminBannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersBannerVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BannerConvert {
|
||||
|
||||
BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
BannerVO convert(BannerBO bannerBO);
|
||||
AdminsBannerVO convert(BannerBO bannerBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<BannerVO> convert2(CommonResult<BannerBO> result);
|
||||
CommonResult<AdminsBannerVO> convert2(CommonResult<BannerBO> result);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<BannerPageVO> convert(CommonResult<BannerPageBO> result);
|
||||
CommonResult<AdminBannerPageVO> convert(CommonResult<BannerPageBO> result);
|
||||
|
||||
@Mappings({})
|
||||
List<UsersBannerVO> convertList(List<BannerBO> banners);
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.promotion.application.vo;
|
||||
package cn.iocoder.mall.promotion.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -6,18 +6,18 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("Banner 分页 VO")
|
||||
public class BannerPageVO {
|
||||
public class AdminBannerPageVO {
|
||||
|
||||
@ApiModelProperty(value = "Banner 数组")
|
||||
private List<BannerVO> list;
|
||||
private List<AdminsBannerVO> list;
|
||||
@ApiModelProperty(value = "Banner 总数")
|
||||
private Integer total;
|
||||
|
||||
public List<BannerVO> getList() {
|
||||
public List<AdminsBannerVO> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public BannerPageVO setList(List<BannerVO> list) {
|
||||
public AdminBannerPageVO setList(List<AdminsBannerVO> list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class BannerPageVO {
|
||||
return total;
|
||||
}
|
||||
|
||||
public BannerPageVO setTotal(Integer total) {
|
||||
public AdminBannerPageVO setTotal(Integer total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.promotion.application.vo;
|
||||
package cn.iocoder.mall.promotion.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("Banner VO")
|
||||
public class BannerVO {
|
||||
public class AdminsBannerVO {
|
||||
|
||||
@ApiModelProperty(value = "Banner 编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@@ -29,7 +29,7 @@ public class BannerVO {
|
||||
return id;
|
||||
}
|
||||
|
||||
public BannerVO setId(Integer id) {
|
||||
public AdminsBannerVO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class BannerVO {
|
||||
return title;
|
||||
}
|
||||
|
||||
public BannerVO setTitle(String title) {
|
||||
public AdminsBannerVO setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class BannerVO {
|
||||
return url;
|
||||
}
|
||||
|
||||
public BannerVO setUrl(String url) {
|
||||
public AdminsBannerVO setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class BannerVO {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public BannerVO setSort(Integer sort) {
|
||||
public AdminsBannerVO setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class BannerVO {
|
||||
return status;
|
||||
}
|
||||
|
||||
public BannerVO setStatus(Integer status) {
|
||||
public AdminsBannerVO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class BannerVO {
|
||||
return memo;
|
||||
}
|
||||
|
||||
public BannerVO setMemo(String memo) {
|
||||
public AdminsBannerVO setMemo(String memo) {
|
||||
this.memo = memo;
|
||||
return this;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class BannerVO {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public BannerVO setCreateTime(Date createTime) {
|
||||
public AdminsBannerVO setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class BannerVO {
|
||||
return picUrl;
|
||||
}
|
||||
|
||||
public BannerVO setPicUrl(String picUrl) {
|
||||
public AdminsBannerVO setPicUrl(String picUrl) {
|
||||
this.picUrl = picUrl;
|
||||
return this;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.iocoder.mall.promotion.application.vo.users;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel("Banner VO")
|
||||
public class UsersBannerVO {
|
||||
|
||||
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com")
|
||||
private String url;
|
||||
@ApiModelProperty(value = "图片链接", required = true, example = "http://www.iocoder.cn/01.jpg")
|
||||
private String picUrl;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public UsersBannerVO setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPicUrl() {
|
||||
return picUrl;
|
||||
}
|
||||
|
||||
public UsersBannerVO setPicUrl(String picUrl) {
|
||||
this.picUrl = picUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user