前端:H5 首页增加 Banner 列表
This commit is contained in:
parent
23acc40d8d
commit
1fd9ab2a18
10
mobile-web/src/api/promotion.js
Normal file
10
mobile-web/src/api/promotion.js
Normal file
@ -0,0 +1,10 @@
|
||||
import request from "../config/request";
|
||||
|
||||
// Banner
|
||||
|
||||
export function getBannerList() {
|
||||
return request({
|
||||
url: 'promotion-api/users/banner/list',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
@ -1,13 +1,5 @@
|
||||
import request from "../config/request";
|
||||
|
||||
|
||||
export function GetUserIndex() {
|
||||
return request({
|
||||
url: '/User/GetUserIndex',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function GetFavorite(data){
|
||||
return request({
|
||||
url: '/User/GetFavorite',
|
||||
@ -108,4 +100,3 @@ export function doPassportMobileSendRegisterCode(mobile) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
<script>
|
||||
|
||||
// TODO 芋艿,准备废弃。
|
||||
|
||||
export default {
|
||||
name:'imageAd',
|
||||
components:{
|
||||
|
@ -1,8 +1,12 @@
|
||||
<template>
|
||||
<div :style="'background-color:'+((page.BackgroundColor==undefined||page.BackgroundColor=='')?'#fff':page.BackgroundColor)">
|
||||
<div :style="'height:'+topheight+'px'" ></div>
|
||||
<van-swipe :autoplay="3000" indicator-color="white" height="160">
|
||||
<van-swipe-item v-for="(banner, index) in banners" :key="index" >
|
||||
<img :src="banner.picUrl" height="100%" width="100%">
|
||||
</van-swipe-item>
|
||||
</van-swipe>
|
||||
<div v-for="(item,index) in page.Sections" :key="index">
|
||||
<imageAd v-if="item.Code=='ImageAd'" :data="item.ParameterDictionary"></imageAd>
|
||||
|
||||
<imageText v-if="item.Code=='ImageText'" :data="item.ParameterDictionary"></imageText>
|
||||
|
||||
@ -38,6 +42,7 @@ import imageAd from "../../components/page/imageAd.vue";
|
||||
import imageText from "../../components/page/imageText.vue";
|
||||
import product from "../../components/page/product.vue";
|
||||
import { GetPage } from "../../api/page.js";
|
||||
import { getBannerList } from '../../api/promotion.js';
|
||||
|
||||
export default {
|
||||
name:"page",
|
||||
@ -57,6 +62,7 @@ export default {
|
||||
return{
|
||||
topheight:0,
|
||||
page:{},
|
||||
banners: [], // Banner 列表
|
||||
}
|
||||
},
|
||||
created:function(){
|
||||
@ -64,6 +70,13 @@ export default {
|
||||
this.page=response;
|
||||
});
|
||||
},
|
||||
mounted: function() {
|
||||
// 加载 Banner
|
||||
let response = getBannerList();
|
||||
response.then(data => {
|
||||
this.banners = data;
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
settopheight:function(value){
|
||||
this.topheight=value;
|
||||
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController("productCategoryController_users")
|
||||
@RestController
|
||||
@RequestMapping("users/category")
|
||||
@Api("商品分类")
|
||||
public class UsersProductCategoryController {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -7,8 +7,12 @@ 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 java.util.List;
|
||||
|
||||
public interface BannerService {
|
||||
|
||||
CommonResult<List<BannerBO>> getBannerListByStatus(Integer status);
|
||||
|
||||
CommonResult<BannerPageBO> getBannerPage(BannerPageDTO bannerPageDTO);
|
||||
|
||||
CommonResult<BannerBO> addBanner(Integer adminId, BannerAddDTO bannerAddDTO);
|
||||
|
@ -11,6 +11,8 @@ public interface BannerMapper {
|
||||
|
||||
BannerDO selectById(@Param("id") Integer id);
|
||||
|
||||
List<BannerDO> selectListByStatus(@Param("status") Integer status);
|
||||
|
||||
List<BannerDO> selectListByTitleLike(@Param("title") String title,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示
|
||||
@com.alibaba.dubbo.config.annotation.Service(validation = "true")
|
||||
@ -27,6 +28,12 @@ public class BannerServiceImpl implements BannerService {
|
||||
@Autowired
|
||||
private BannerMapper bannerMapper;
|
||||
|
||||
@Override
|
||||
public CommonResult<List<BannerBO>> getBannerListByStatus(Integer status) {
|
||||
List<BannerDO> banners = bannerMapper.selectListByStatus(status);
|
||||
return CommonResult.success(BannerConvert.INSTANCE.convertToBO(banners));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<BannerPageBO> getBannerPage(BannerPageDTO bannerPageDTO) {
|
||||
BannerPageBO bannerPageBO = new BannerPageBO();
|
||||
|
@ -32,6 +32,18 @@
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListByStatus" parameterType="Integer" resultType="BannerDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM banner
|
||||
<where>
|
||||
<if test="status != null">
|
||||
status = #{status}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListByTitleLike" resultType="BannerDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
|
Loading…
Reference in New Issue
Block a user