From 7c3015a67a6255c0e420f4ad397949e6c462aa1e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 31 May 2022 19:25:24 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20banner=20=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/banner/BannerController.java | 32 ++++--------------- .../admin/banner/vo/BannerBaseVO.java | 12 ++----- .../admin/banner/vo/BannerUpdateReqVO.java | 7 ++-- .../banner/vo/BannerUpdateStatusReqVO.java | 25 --------------- .../app/banner/AppBannerController.java | 2 ++ .../market/service/banner/BannerService.java | 25 ++++----------- .../service/banner/BannerServiceImpl.java | 18 +---------- .../src/views/mall/market/banner/index.vue | 23 ------------- 8 files changed, 20 insertions(+), 124 deletions(-) delete mode 100644 yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateStatusReqVO.java diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/BannerController.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/BannerController.java index f5154d6c1..932ead7de 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/BannerController.java +++ b/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.*; import javax.annotation.Resource; import javax.validation.Valid; -import java.util.Collection; -import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Api(tags = "管理后台 - Banner管理") +@Api(tags = "管理后台 - Banner 管理") @RestController @RequestMapping("/market/banner") @Validated @@ -30,14 +28,14 @@ public class BannerController { private BannerService bannerService; @PostMapping("/create") - @ApiOperation("创建banner") + @ApiOperation("创建 Banner") @PreAuthorize("@ss.hasPermission('market:banner:create')") public CommonResult createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) { return success(bannerService.createBanner(createReqVO)); } @PutMapping("/update") - @ApiOperation("更新banner") + @ApiOperation("更新 Banner") @PreAuthorize("@ss.hasPermission('market:banner:update')") public CommonResult updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) { bannerService.updateBanner(updateReqVO); @@ -45,7 +43,7 @@ public class BannerController { } @DeleteMapping("/delete") - @ApiOperation("删除banner") + @ApiOperation("删除 Banner") @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('market:banner:delete')") public CommonResult deleteBanner(@RequestParam("id") Long id) { @@ -54,7 +52,7 @@ public class BannerController { } @GetMapping("/get") - @ApiOperation("获得banner") + @ApiOperation("获得 Banner") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('market:banner:query')") public CommonResult getBanner(@RequestParam("id") Long id) { @@ -62,30 +60,12 @@ public class BannerController { return success(BannerConvert.INSTANCE.convert(banner)); } - @GetMapping("/list") - @ApiOperation("获得banner列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) - @PreAuthorize("@ss.hasPermission('market:banner:query')") - public CommonResult> getBannerList(@RequestParam("ids") Collection ids) { - List list = bannerService.getBannerList(ids); - return success(BannerConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") - @ApiOperation("获得Banner分页") + @ApiOperation("获得 Banner 分页") @PreAuthorize("@ss.hasPermission('market:banner:query')") public CommonResult> getBannerPage(@Valid BannerPageReqVO pageVO) { PageResult pageResult = bannerService.getBannerPage(pageVO); return success(BannerConvert.INSTANCE.convertPage(pageResult)); } - - @GetMapping("/update-status") - @ApiOperation("Banner上下架") - @PreAuthorize("@ss.hasPermission('market:banner:update')") - public CommonResult updateBannerStatus(@Valid @RequestBody BannerUpdateStatusReqVO reqVO) { - bannerService.updateBannerStatus(reqVO); - return success(true); - } - } diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerBaseVO.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerBaseVO.java index cfdbb8b5e..f5f37dbbc 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerBaseVO.java +++ b/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; import javax.validation.constraints.NotNull; /** -* Banner Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + * Banner Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 * @author xia */ @Data @@ -21,24 +21,16 @@ public class BannerBaseVO { @ApiModelProperty(value = "跳转链接", required = true) @NotNull(message = "跳转链接不能为空") - /** - * 跳转链接 - */ private String url; @ApiModelProperty(value = "图片地址", required = true) @NotNull(message = "图片地址不能为空") - /** - * 图片链接 - */ private String picUrl; - @ApiModelProperty(value = "排序", required = true) @NotNull(message = "排序不能为空") private Integer sort; - @ApiModelProperty(value = "状态", required = true) @NotNull(message = "状态不能为空") @InEnum(CommonStatusEnum.class) diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateReqVO.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateReqVO.java index 774b0c5e9..1f2d7ce80 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateReqVO.java @@ -1,7 +1,5 @@ package cn.iocoder.yudao.module.market.controller.admin.banner.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -19,9 +17,8 @@ import javax.validation.constraints.NotNull; @ToString(callSuper = true) public class BannerUpdateReqVO extends BannerBaseVO { - @ApiModelProperty(value = "banner编号", required = true) - @NotNull(message = "banner编号不能为空") + @ApiModelProperty(value = "banner 编号", required = true) + @NotNull(message = "banner 编号不能为空") private Long id; - } diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateStatusReqVO.java deleted file mode 100644 index 74919cebe..000000000 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateStatusReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.market.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * @Copyright: 南京淘点网络科技有限公司 - * @author: wangxia - */ -@Data -public class BannerUpdateStatusReqVO { - - @ApiModelProperty(value = "banner编号", required = true) - @NotNull(message = "banner编号不能为空") - private Long id; - - @ApiModelProperty(value = "状态", required = true) - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; -} diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/app/banner/AppBannerController.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/app/banner/AppBannerController.java index 783179e85..3d9d58eb8 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/app/banner/AppBannerController.java +++ b/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; @Validated public class AppBannerController { + // TODO @xia:使用 @Resource 哈 @Autowired private BannerService bannerService; + // TODO @xia:新建一个 AppBannerRespVO,只返回必要的字段。status 要过滤下。然后 sort 下结果 @GetMapping("/list") @ApiOperation("获得banner列表") @PreAuthorize("@ss.hasPermission('market:banner:query')") diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerService.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerService.java index f69898187..67debdc3d 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerService.java +++ b/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; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateStatusReqVO; import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; import javax.validation.Valid; -import java.util.Collection; import java.util.List; /** - * 首页Banner Service 接口 + * 首页 Banner Service 接口 * * @author xia */ public interface BannerService { /** - * 创建Banner + * 创建 Banner * * @param createReqVO 创建信息 * @return 编号 @@ -27,21 +25,21 @@ public interface BannerService { Long createBanner(@Valid BannerCreateReqVO createReqVO); /** - * 更新Banner + * 更新 Banner * * @param updateReqVO 更新信息 */ void updateBanner(@Valid BannerUpdateReqVO updateReqVO); /** - * 删除Banner + * 删除 Banner * * @param id 编号 */ void deleteBanner(Long id); /** - * 获得Banner + * 获得 Banner * * @param id 编号 * @return Banner @@ -49,26 +47,17 @@ public interface BannerService { BannerDO getBanner(Long id); /** - * 获得Banner列表 - * - * @param ids 编号 - * @return Banner列表 - */ - List getBannerList(Collection ids); - - /** - * 获得所有Banner列表 + * 获得所有 Banner列表 * @return Banner列表 */ List getBannerList(); /** - * 获得Banner分页 + * 获得 Banner 分页 * * @param pageReqVO 分页查询 * @return Banner分页 */ PageResult getBannerPage(BannerPageReqVO pageReqVO); - void updateBannerStatus(BannerUpdateStatusReqVO reqVO); } diff --git a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerServiceImpl.java b/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerServiceImpl.java index d2b25c0a7..04784ff66 100644 --- a/yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerServiceImpl.java +++ b/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; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO; import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateStatusReqVO; import cn.iocoder.yudao.module.market.convert.banner.BannerConvert; import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; import cn.iocoder.yudao.module.market.dal.mysql.banner.BannerMapper; @@ -12,11 +11,10 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.BANNER_NOT_EXISTS; /** * 首页banner 实现类 @@ -67,11 +65,6 @@ public class BannerServiceImpl implements BannerService { return bannerMapper.selectById(id); } - @Override - public List getBannerList(Collection ids) { - return bannerMapper.selectBatchIds(ids); - } - @Override public List getBannerList() { return bannerMapper.selectList(); @@ -82,13 +75,4 @@ public class BannerServiceImpl implements BannerService { return bannerMapper.selectPage(pageReqVO); } - @Override - public void updateBannerStatus(BannerUpdateStatusReqVO updateStatusReqVO) { - // 校验是否可以更新 - this.validateBannerExists(updateStatusReqVO.getId()); - // 更新状态 - BannerDO updateObj = BannerConvert.INSTANCE.convert(updateStatusReqVO); - bannerMapper.updateById(updateObj); - } - } diff --git a/yudao-ui-admin/src/views/mall/market/banner/index.vue b/yudao-ui-admin/src/views/mall/market/banner/index.vue index be2e4b213..448f9124b 100644 --- a/yudao-ui-admin/src/views/mall/market/banner/index.vue +++ b/yudao-ui-admin/src/views/mall/market/banner/index.vue @@ -29,12 +29,6 @@ v-hasPermi="['market:banner:create']">新增 - - - - - - @@ -258,23 +252,6 @@ export default { this.$modal.msgSuccess("删除成功"); }).catch(() => { }); - }, - /** 导出按钮操作 */ - handleExport() { - // 处理查询参数 - let params = {...this.queryParams}; - params.pageNo = undefined; - params.pageSize = undefined; - this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); - // 执行导出 - this.$modal.confirm('是否确认导出所有Banner数据项?').then(() => { - this.exportLoading = true; - return exportBannerExcel(params); - }).then(response => { - this.$download.excel(response, "Banner.xls"); - this.exportLoading = false; - }).catch(() => { - }); } } };