Commit 7c3015a67a6255c0e420f4ad397949e6c462aa1e

Authored by YunaiV
1 parent b368a54b

code review banner 模块的代码

yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/BannerController.java
... ... @@ -15,12 +15,10 @@ import org.springframework.web.bind.annotation.*;
15 15  
16 16 import javax.annotation.Resource;
17 17 import javax.validation.Valid;
18   -import java.util.Collection;
19   -import java.util.List;
20 18  
21 19 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
22 20  
23   -@Api(tags = "管理后台 - Banner管理")
  21 +@Api(tags = "管理后台 - Banner 管理")
24 22 @RestController
25 23 @RequestMapping("/market/banner")
26 24 @Validated
... ... @@ -30,14 +28,14 @@ public class BannerController {
30 28 private BannerService bannerService;
31 29  
32 30 @PostMapping("/create")
33   - @ApiOperation("创建banner")
  31 + @ApiOperation("创建 Banner")
34 32 @PreAuthorize("@ss.hasPermission('market:banner:create')")
35 33 public CommonResult<Long> createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) {
36 34 return success(bannerService.createBanner(createReqVO));
37 35 }
38 36  
39 37 @PutMapping("/update")
40   - @ApiOperation("更新banner")
  38 + @ApiOperation("更新 Banner")
41 39 @PreAuthorize("@ss.hasPermission('market:banner:update')")
42 40 public CommonResult<Boolean> updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) {
43 41 bannerService.updateBanner(updateReqVO);
... ... @@ -45,7 +43,7 @@ public class BannerController {
45 43 }
46 44  
47 45 @DeleteMapping("/delete")
48   - @ApiOperation("删除banner")
  46 + @ApiOperation("删除 Banner")
49 47 @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
50 48 @PreAuthorize("@ss.hasPermission('market:banner:delete')")
51 49 public CommonResult<Boolean> deleteBanner(@RequestParam("id") Long id) {
... ... @@ -54,7 +52,7 @@ public class BannerController {
54 52 }
55 53  
56 54 @GetMapping("/get")
57   - @ApiOperation("获得banner")
  55 + @ApiOperation("获得 Banner")
58 56 @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
59 57 @PreAuthorize("@ss.hasPermission('market:banner:query')")
60 58 public CommonResult<BannerRespVO> getBanner(@RequestParam("id") Long id) {
... ... @@ -62,30 +60,12 @@ public class BannerController {
62 60 return success(BannerConvert.INSTANCE.convert(banner));
63 61 }
64 62  
65   - @GetMapping("/list")
66   - @ApiOperation("获得banner列表")
67   - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
68   - @PreAuthorize("@ss.hasPermission('market:banner:query')")
69   - public CommonResult<List<BannerRespVO>> getBannerList(@RequestParam("ids") Collection<Long> ids) {
70   - List<BannerDO> list = bannerService.getBannerList(ids);
71   - return success(BannerConvert.INSTANCE.convertList(list));
72   - }
73   -
74 63 @GetMapping("/page")
75   - @ApiOperation("获得Banner分页")
  64 + @ApiOperation("获得 Banner 分页")
76 65 @PreAuthorize("@ss.hasPermission('market:banner:query')")
77 66 public CommonResult<PageResult<BannerRespVO>> getBannerPage(@Valid BannerPageReqVO pageVO) {
78 67 PageResult<BannerDO> pageResult = bannerService.getBannerPage(pageVO);
79 68 return success(BannerConvert.INSTANCE.convertPage(pageResult));
80 69 }
81 70  
82   -
83   - @GetMapping("/update-status")
84   - @ApiOperation("Banner上下架")
85   - @PreAuthorize("@ss.hasPermission('market:banner:update')")
86   - public CommonResult<Boolean> updateBannerStatus(@Valid @RequestBody BannerUpdateStatusReqVO reqVO) {
87   - bannerService.updateBannerStatus(reqVO);
88   - return success(true);
89   - }
90   -
91 71 }
... ...
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerBaseVO.java
... ... @@ -8,8 +8,8 @@ import lombok.Data;
8 8 import javax.validation.constraints.NotNull;
9 9  
10 10 /**
11   -* Banner Base VO,提供给添加、修改、详细的子 VO 使用
12   -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  11 + * Banner Base VO,提供给添加、修改、详细的子 VO 使用
  12 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
13 13 * @author xia
14 14 */
15 15 @Data
... ... @@ -21,24 +21,16 @@ public class BannerBaseVO {
21 21  
22 22 @ApiModelProperty(value = "跳转链接", required = true)
23 23 @NotNull(message = "跳转链接不能为空")
24   - /**
25   - * 跳转链接
26   - */
27 24 private String url;
28 25  
29 26 @ApiModelProperty(value = "图片地址", required = true)
30 27 @NotNull(message = "图片地址不能为空")
31   - /**
32   - * 图片链接
33   - */
34 28 private String picUrl;
35 29  
36   -
37 30 @ApiModelProperty(value = "排序", required = true)
38 31 @NotNull(message = "排序不能为空")
39 32 private Integer sort;
40 33  
41   -
42 34 @ApiModelProperty(value = "状态", required = true)
43 35 @NotNull(message = "状态不能为空")
44 36 @InEnum(CommonStatusEnum.class)
... ...
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateReqVO.java
1 1 package cn.iocoder.yudao.module.market.controller.admin.banner.vo;
2 2  
3   -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4   -import cn.iocoder.yudao.framework.common.validation.InEnum;
5 3 import io.swagger.annotations.ApiModel;
6 4 import io.swagger.annotations.ApiModelProperty;
7 5 import lombok.Data;
... ... @@ -19,9 +17,8 @@ import javax.validation.constraints.NotNull;
19 17 @ToString(callSuper = true)
20 18 public class BannerUpdateReqVO extends BannerBaseVO {
21 19  
22   - @ApiModelProperty(value = "banner编号", required = true)
23   - @NotNull(message = "banner编号不能为空")
  20 + @ApiModelProperty(value = "banner 编号", required = true)
  21 + @NotNull(message = "banner 编号不能为空")
24 22 private Long id;
25 23  
26   -
27 24 }
... ...
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateStatusReqVO.java deleted
1   -package cn.iocoder.yudao.module.market.controller.admin.banner.vo;
2   -
3   -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4   -import cn.iocoder.yudao.framework.common.validation.InEnum;
5   -import io.swagger.annotations.ApiModelProperty;
6   -import lombok.Data;
7   -
8   -import javax.validation.constraints.NotNull;
9   -
10   -/**
11   - * @Copyright: 南京淘点网络科技有限公司
12   - * @author: wangxia
13   - */
14   -@Data
15   -public class BannerUpdateStatusReqVO {
16   -
17   - @ApiModelProperty(value = "banner编号", required = true)
18   - @NotNull(message = "banner编号不能为空")
19   - private Long id;
20   -
21   - @ApiModelProperty(value = "状态", required = true)
22   - @NotNull(message = "状态不能为空")
23   - @InEnum(CommonStatusEnum.class)
24   - private Integer status;
25   -}
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/app/banner/AppBannerController.java
... ... @@ -27,9 +27,11 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
27 27 @Validated
28 28 public class AppBannerController {
29 29  
  30 + // TODO @xia:使用 @Resource 哈
30 31 @Autowired
31 32 private BannerService bannerService;
32 33  
  34 + // TODO @xia:新建一个 AppBannerRespVO,只返回必要的字段。status 要过滤下。然后 sort 下结果
33 35 @GetMapping("/list")
34 36 @ApiOperation("获得banner列表")
35 37 @PreAuthorize("@ss.hasPermission('market:banner:query')")
... ...
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerService.java
... ... @@ -4,22 +4,20 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO;
5 5 import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO;
6 6 import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO;
7   -import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateStatusReqVO;
8 7 import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO;
9 8  
10 9 import javax.validation.Valid;
11   -import java.util.Collection;
12 10 import java.util.List;
13 11  
14 12 /**
15   - * 首页Banner Service 接口
  13 + * 首页 Banner Service 接口
16 14 *
17 15 * @author xia
18 16 */
19 17 public interface BannerService {
20 18  
21 19 /**
22   - * 创建Banner
  20 + * 创建 Banner
23 21 *
24 22 * @param createReqVO 创建信息
25 23 * @return 编号
... ... @@ -27,21 +25,21 @@ public interface BannerService {
27 25 Long createBanner(@Valid BannerCreateReqVO createReqVO);
28 26  
29 27 /**
30   - * 更新Banner
  28 + * 更新 Banner
31 29 *
32 30 * @param updateReqVO 更新信息
33 31 */
34 32 void updateBanner(@Valid BannerUpdateReqVO updateReqVO);
35 33  
36 34 /**
37   - * 删除Banner
  35 + * 删除 Banner
38 36 *
39 37 * @param id 编号
40 38 */
41 39 void deleteBanner(Long id);
42 40  
43 41 /**
44   - * 获得Banner
  42 + * 获得 Banner
45 43 *
46 44 * @param id 编号
47 45 * @return Banner
... ... @@ -49,26 +47,17 @@ public interface BannerService {
49 47 BannerDO getBanner(Long id);
50 48  
51 49 /**
52   - * 获得Banner列表
53   - *
54   - * @param ids 编号
55   - * @return Banner列表
56   - */
57   - List<BannerDO> getBannerList(Collection<Long> ids);
58   -
59   - /**
60   - * 获得所有Banner列表
  50 + * 获得所有 Banner列表
61 51 * @return Banner列表
62 52 */
63 53 List<BannerDO> getBannerList();
64 54  
65 55 /**
66   - * 获得Banner分页
  56 + * 获得 Banner 分页
67 57 *
68 58 * @param pageReqVO 分页查询
69 59 * @return Banner分页
70 60 */
71 61 PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO);
72 62  
73   - void updateBannerStatus(BannerUpdateStatusReqVO reqVO);
74 63 }
... ...
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerServiceImpl.java
... ... @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO;
5 5 import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO;
6 6 import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO;
7   -import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateStatusReqVO;
8 7 import cn.iocoder.yudao.module.market.convert.banner.BannerConvert;
9 8 import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO;
10 9 import cn.iocoder.yudao.module.market.dal.mysql.banner.BannerMapper;
... ... @@ -12,11 +11,10 @@ import org.springframework.stereotype.Service;
12 11 import org.springframework.validation.annotation.Validated;
13 12  
14 13 import javax.annotation.Resource;
15   -import java.util.Collection;
16 14 import java.util.List;
17 15  
18 16 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
19   -import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*;
  17 +import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.BANNER_NOT_EXISTS;
20 18  
21 19 /**
22 20 * 首页banner 实现类
... ... @@ -68,11 +66,6 @@ public class BannerServiceImpl implements BannerService {
68 66 }
69 67  
70 68 @Override
71   - public List<BannerDO> getBannerList(Collection<Long> ids) {
72   - return bannerMapper.selectBatchIds(ids);
73   - }
74   -
75   - @Override
76 69 public List<BannerDO> getBannerList() {
77 70 return bannerMapper.selectList();
78 71 }
... ... @@ -82,13 +75,4 @@ public class BannerServiceImpl implements BannerService {
82 75 return bannerMapper.selectPage(pageReqVO);
83 76 }
84 77  
85   - @Override
86   - public void updateBannerStatus(BannerUpdateStatusReqVO updateStatusReqVO) {
87   - // 校验是否可以更新
88   - this.validateBannerExists(updateStatusReqVO.getId());
89   - // 更新状态
90   - BannerDO updateObj = BannerConvert.INSTANCE.convert(updateStatusReqVO);
91   - bannerMapper.updateById(updateObj);
92   - }
93   -
94 78 }
... ...
yudao-ui-admin/src/views/mall/market/banner/index.vue
... ... @@ -29,12 +29,6 @@
29 29 v-hasPermi="['market:banner:create']">新增
30 30 </el-button>
31 31 </el-col>
32   -<!-- <el-col :span="1.5">-->
33   -<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"-->
34   -<!-- :loading="exportLoading"-->
35   -<!-- v-hasPermi="['market:banner:export']">导出-->
36   -<!-- </el-button>-->
37   -<!-- </el-col>-->
38 32 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
39 33 </el-row>
40 34  
... ... @@ -258,23 +252,6 @@ export default {
258 252 this.$modal.msgSuccess("删除成功");
259 253 }).catch(() => {
260 254 });
261   - },
262   - /** 导出按钮操作 */
263   - handleExport() {
264   - // 处理查询参数
265   - let params = {...this.queryParams};
266   - params.pageNo = undefined;
267   - params.pageSize = undefined;
268   - this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
269   - // 执行导出
270   - this.$modal.confirm('是否确认导出所有Banner数据项?').then(() => {
271   - this.exportLoading = true;
272   - return exportBannerExcel(params);
273   - }).then(response => {
274   - this.$download.excel(response, "Banner.xls");
275   - this.exportLoading = false;
276   - }).catch(() => {
277   - });
278 255 }
279 256 }
280 257 };
... ...