Commit 0e3cdda08d505abe315ce953d1b8b3e1588068a4
Merge remote-tracking branch 'origin/feature/1.8.0-uniapp' into feature/1.8.0-uniapp
Showing
48 changed files
with
1250 additions
and
339 deletions
sql/mall.sql
| ... | ... | @@ -253,3 +253,35 @@ create table product_sku |
| 253 | 253 | collate utf8mb4_general_ci; |
| 254 | 254 | |
| 255 | 255 | |
| 256 | +---Market-Banner管理SQL | |
| 257 | +drop table if exists market_banner; | |
| 258 | +CREATE TABLE `market_banner` ( | |
| 259 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Banner编号', | |
| 260 | + `title` varchar(64) NOT NULL DEFAULT '' COMMENT 'Banner标题', | |
| 261 | + `pic_url` varchar(255) NOT NULL COMMENT '图片URL', | |
| 262 | + `status` tinyint(4) NOT NULL DEFAULT '-1' COMMENT '活动状态', | |
| 263 | + `url` varchar(255) NOT NULL COMMENT '跳转地址', | |
| 264 | + `creator` varchar(64) DEFAULT '' COMMENT '创建者', | |
| 265 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 266 | + `updater` varchar(64) DEFAULT '' COMMENT '更新者', | |
| 267 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 268 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 269 | + `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号', | |
| 270 | + `sort` tinyint(4) DEFAULT NULL COMMENT '排序', | |
| 271 | + `memo` varchar(255) DEFAULT NULL COMMENT '描述', | |
| 272 | + PRIMARY KEY (`id`) USING BTREE | |
| 273 | +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='Banner管理'; | |
| 274 | +-- 菜单 SQL | |
| 275 | +INSERT INTO `system_menu`(`id`,`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | |
| 276 | +VALUES (2002, 'Banner管理', '', 2, 1, 2000, 'brand', '', 'mall/market/banner/index', 0); | |
| 277 | +-- 按钮父菜单ID | |
| 278 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 279 | +-- 按钮 SQL | |
| 280 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | |
| 281 | +VALUES ('Banner查询', 'market:banner:query', 3, 1, @parentId, '', '', '', 0); | |
| 282 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | |
| 283 | +VALUES ('Banner创建', 'market:banner:create', 3, 2, @parentId, '', '', '', 0); | |
| 284 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | |
| 285 | +VALUES ('Banner更新', 'market:banner:update', 3, 3, @parentId, '', '', '', 0); | |
| 286 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) | |
| 287 | +VALUES ('Banner删除', 'market:banner:delete', 3, 4, @parentId, '', '', '', 0); | ... | ... |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/CommonStatusEnum.java
| 1 | 1 | package cn.iocoder.yudao.framework.common.enums; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 3 | 4 | import lombok.AllArgsConstructor; |
| 4 | 5 | import lombok.Getter; |
| 5 | 6 | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 6 | 9 | /** |
| 7 | 10 | * 通用状态枚举 |
| 8 | 11 | * |
| ... | ... | @@ -10,11 +13,14 @@ import lombok.Getter; |
| 10 | 13 | */ |
| 11 | 14 | @Getter |
| 12 | 15 | @AllArgsConstructor |
| 13 | -public enum CommonStatusEnum { | |
| 16 | +public enum CommonStatusEnum implements IntArrayValuable { | |
| 14 | 17 | |
| 15 | 18 | ENABLE(0, "开启"), |
| 16 | 19 | DISABLE(1, "关闭"); |
| 17 | 20 | |
| 21 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CommonStatusEnum::getStatus).toArray(); | |
| 22 | + | |
| 23 | + | |
| 18 | 24 | /** |
| 19 | 25 | * 状态值 |
| 20 | 26 | */ |
| ... | ... | @@ -24,4 +30,9 @@ public enum CommonStatusEnum { |
| 24 | 30 | */ |
| 25 | 31 | private final String name; |
| 26 | 32 | |
| 33 | + @Override | |
| 34 | + public int[] array() { | |
| 35 | + return ARRAYS; | |
| 36 | + } | |
| 37 | + | |
| 27 | 38 | } | ... | ... |
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/ErrorCodeConstants.java
| ... | ... | @@ -12,4 +12,7 @@ public interface ErrorCodeConstants { |
| 12 | 12 | |
| 13 | 13 | // ========== 促销活动相关 1003001000============ |
| 14 | 14 | ErrorCode ACTIVITY_NOT_EXISTS = new ErrorCode(1003001000, "促销活动不存在"); |
| 15 | + | |
| 16 | + // ========== banner相关 1003002000============ | |
| 17 | + ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1003002000, "Banner不存在"); | |
| 15 | 18 | } | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityCreateReqVO.java
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/BannerController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.controller.admin.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.market.convert.banner.BannerConvert; | |
| 7 | +import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; | |
| 8 | +import cn.iocoder.yudao.module.market.service.banner.BannerService; | |
| 9 | +import io.swagger.annotations.Api; | |
| 10 | +import io.swagger.annotations.ApiImplicitParam; | |
| 11 | +import io.swagger.annotations.ApiOperation; | |
| 12 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.*; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import javax.validation.Valid; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 20 | + | |
| 21 | +@Api(tags = "管理后台 - Banner 管理") | |
| 22 | +@RestController | |
| 23 | +@RequestMapping("/market/banner") | |
| 24 | +@Validated | |
| 25 | +public class BannerController { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private BannerService bannerService; | |
| 29 | + | |
| 30 | + @PostMapping("/create") | |
| 31 | + @ApiOperation("创建 Banner") | |
| 32 | + @PreAuthorize("@ss.hasPermission('market:banner:create')") | |
| 33 | + public CommonResult<Long> createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) { | |
| 34 | + return success(bannerService.createBanner(createReqVO)); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @PutMapping("/update") | |
| 38 | + @ApiOperation("更新 Banner") | |
| 39 | + @PreAuthorize("@ss.hasPermission('market:banner:update')") | |
| 40 | + public CommonResult<Boolean> updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) { | |
| 41 | + bannerService.updateBanner(updateReqVO); | |
| 42 | + return success(true); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @DeleteMapping("/delete") | |
| 46 | + @ApiOperation("删除 Banner") | |
| 47 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | |
| 48 | + @PreAuthorize("@ss.hasPermission('market:banner:delete')") | |
| 49 | + public CommonResult<Boolean> deleteBanner(@RequestParam("id") Long id) { | |
| 50 | + bannerService.deleteBanner(id); | |
| 51 | + return success(true); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @GetMapping("/get") | |
| 55 | + @ApiOperation("获得 Banner") | |
| 56 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 57 | + @PreAuthorize("@ss.hasPermission('market:banner:query')") | |
| 58 | + public CommonResult<BannerRespVO> getBanner(@RequestParam("id") Long id) { | |
| 59 | + BannerDO banner = bannerService.getBanner(id); | |
| 60 | + return success(BannerConvert.INSTANCE.convert(banner)); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/page") | |
| 64 | + @ApiOperation("获得 Banner 分页") | |
| 65 | + @PreAuthorize("@ss.hasPermission('market:banner:query')") | |
| 66 | + public CommonResult<PageResult<BannerRespVO>> getBannerPage(@Valid BannerPageReqVO pageVO) { | |
| 67 | + PageResult<BannerDO> pageResult = bannerService.getBannerPage(pageVO); | |
| 68 | + return success(BannerConvert.INSTANCE.convertPage(pageResult)); | |
| 69 | + } | |
| 70 | + | |
| 71 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerBaseVO.java
0 → 100644
| 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 | + * Banner Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 12 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 13 | + * @author xia | |
| 14 | + */ | |
| 15 | +@Data | |
| 16 | +public class BannerBaseVO { | |
| 17 | + | |
| 18 | + @ApiModelProperty(value = "标题", required = true) | |
| 19 | + @NotNull(message = "标题不能为空") | |
| 20 | + private String title; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "跳转链接", required = true) | |
| 23 | + @NotNull(message = "跳转链接不能为空") | |
| 24 | + private String url; | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "图片地址", required = true) | |
| 27 | + @NotNull(message = "图片地址不能为空") | |
| 28 | + private String picUrl; | |
| 29 | + | |
| 30 | + @ApiModelProperty(value = "排序", required = true) | |
| 31 | + @NotNull(message = "排序不能为空") | |
| 32 | + private Integer sort; | |
| 33 | + | |
| 34 | + @ApiModelProperty(value = "状态", required = true) | |
| 35 | + @NotNull(message = "状态不能为空") | |
| 36 | + @InEnum(CommonStatusEnum.class) | |
| 37 | + private Integer status; | |
| 38 | + | |
| 39 | + @ApiModelProperty(value = "备注") | |
| 40 | + private String memo; | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.controller.admin.banner.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import java.util.Date; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * @author xia | |
| 13 | + */ | |
| 14 | +@ApiModel("管理后台 - Banner 创建 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class BannerCreateReqVO extends BannerBaseVO { | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerPageReqVO.java
0 → 100644
| 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.pojo.PageParam; | |
| 5 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 6 | +import io.swagger.annotations.ApiModel; | |
| 7 | +import io.swagger.annotations.ApiModelProperty; | |
| 8 | +import lombok.Data; | |
| 9 | +import lombok.EqualsAndHashCode; | |
| 10 | +import lombok.ToString; | |
| 11 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 12 | + | |
| 13 | +import java.util.Date; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * @author xia | |
| 19 | + */ | |
| 20 | +@ApiModel("管理后台 - Banner 分页 Request VO") | |
| 21 | +@Data | |
| 22 | +@EqualsAndHashCode(callSuper = true) | |
| 23 | +@ToString(callSuper = true) | |
| 24 | +public class BannerPageReqVO extends PageParam { | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "标题") | |
| 27 | + private String title; | |
| 28 | + | |
| 29 | + | |
| 30 | + @ApiModelProperty(value = "状态") | |
| 31 | + @InEnum(CommonStatusEnum.class) | |
| 32 | + private Integer status; | |
| 33 | + | |
| 34 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 35 | + @ApiModelProperty(value = "开始创建时间") | |
| 36 | + private Date beginCreateTime; | |
| 37 | + | |
| 38 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 39 | + @ApiModelProperty(value = "结束创建时间") | |
| 40 | + private Date endCreateTime; | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.controller.admin.banner.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | +import java.util.Date; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * @author xia | |
| 13 | + */ | |
| 14 | +@ApiModel("管理后台 - Banner Response VO") | |
| 15 | +@Data | |
| 16 | +@ToString(callSuper = true) | |
| 17 | +public class BannerRespVO extends BannerBaseVO { | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "banner编号", required = true) | |
| 20 | + @NotNull(message = "banner编号不能为空") | |
| 21 | + private Long id; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "创建时间", required = true) | |
| 24 | + private Date createTime; | |
| 25 | + | |
| 26 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/banner/vo/BannerUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.controller.admin.banner.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * @author xia | |
| 13 | + */ | |
| 14 | +@ApiModel("管理后台 - Banner更新 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class BannerUpdateReqVO extends BannerBaseVO { | |
| 19 | + | |
| 20 | + @ApiModelProperty(value = "banner 编号", required = true) | |
| 21 | + @NotNull(message = "banner 编号不能为空") | |
| 22 | + private Long id; | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/app/banner/AppBannerController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.controller.app.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerRespVO; | |
| 5 | +import cn.iocoder.yudao.module.market.convert.banner.BannerConvert; | |
| 6 | +import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; | |
| 7 | +import cn.iocoder.yudao.module.market.service.banner.BannerService; | |
| 8 | +import io.swagger.annotations.Api; | |
| 9 | +import io.swagger.annotations.ApiOperation; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RestController; | |
| 16 | + | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * @author: XIA | |
| 23 | + */ | |
| 24 | +@RestController | |
| 25 | +@RequestMapping("/market/banner") | |
| 26 | +@Api(tags = "用户APP- 首页Banner") | |
| 27 | +@Validated | |
| 28 | +public class AppBannerController { | |
| 29 | + | |
| 30 | + // TODO @xia:使用 @Resource 哈 | |
| 31 | + @Autowired | |
| 32 | + private BannerService bannerService; | |
| 33 | + | |
| 34 | + // TODO @xia:新建一个 AppBannerRespVO,只返回必要的字段。status 要过滤下。然后 sort 下结果 | |
| 35 | + @GetMapping("/list") | |
| 36 | + @ApiOperation("获得banner列表") | |
| 37 | + @PreAuthorize("@ss.hasPermission('market:banner:query')") | |
| 38 | + public CommonResult<List<BannerRespVO>> getBannerList() { | |
| 39 | + List<BannerDO> list = bannerService.getBannerList(); | |
| 40 | + return success(BannerConvert.INSTANCE.convertList(list)); | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/banner/BannerConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.convert.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerRespVO; | |
| 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 | +import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; | |
| 9 | +import org.mapstruct.Mapper; | |
| 10 | +import org.mapstruct.factory.Mappers; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Banner Convert | |
| 16 | + * | |
| 17 | + * @author xia | |
| 18 | + */ | |
| 19 | +@Mapper | |
| 20 | +public interface BannerConvert { | |
| 21 | + | |
| 22 | + BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class); | |
| 23 | + | |
| 24 | + | |
| 25 | + List<BannerRespVO> convertList(List<BannerDO> list); | |
| 26 | + | |
| 27 | + PageResult<BannerRespVO> convertPage(PageResult<BannerDO> pageResult); | |
| 28 | + | |
| 29 | + BannerRespVO convert(BannerDO banner); | |
| 30 | + | |
| 31 | + BannerDO convert(BannerCreateReqVO createReqVO); | |
| 32 | + | |
| 33 | + BannerDO convert(BannerUpdateReqVO updateReqVO); | |
| 34 | + | |
| 35 | + BannerDO convert(BannerUpdateStatusReqVO updateStatusReqVO); | |
| 36 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/banner/BannerDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.dal.dataobject.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 5 | +import lombok.*; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * banner DO | |
| 9 | + * | |
| 10 | + * @author xia | |
| 11 | + */ | |
| 12 | +@TableName("market_banner") | |
| 13 | +@Data | |
| 14 | +@EqualsAndHashCode(callSuper = true) | |
| 15 | +@ToString(callSuper = true) | |
| 16 | +@Builder | |
| 17 | +@NoArgsConstructor | |
| 18 | +@AllArgsConstructor | |
| 19 | +public class BannerDO extends BaseDO { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 编号 | |
| 23 | + */ | |
| 24 | + private Long id; | |
| 25 | + /** | |
| 26 | + * 标题 | |
| 27 | + */ | |
| 28 | + private String title; | |
| 29 | + /** | |
| 30 | + * 跳转链接 | |
| 31 | + */ | |
| 32 | + private String url; | |
| 33 | + /** | |
| 34 | + * 图片链接 | |
| 35 | + */ | |
| 36 | + private String picUrl; | |
| 37 | + /** | |
| 38 | + * 排序 | |
| 39 | + */ | |
| 40 | + private Integer sort; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 状态 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | |
| 44 | + */ | |
| 45 | + private Integer status; | |
| 46 | + /** | |
| 47 | + * 备注 | |
| 48 | + */ | |
| 49 | + private String memo; | |
| 50 | + | |
| 51 | + // TODO 芋艿 点击次数。&& 其他数据相关 | |
| 52 | + | |
| 53 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/banner/BannerMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.dal.mysql.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Banner Mapper | |
| 12 | + * | |
| 13 | + * @author xia | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface BannerMapper extends BaseMapperX<BannerDO> { | |
| 17 | + | |
| 18 | + default PageResult<BannerDO> selectPage(BannerPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<BannerDO>() | |
| 20 | + .likeIfPresent(BannerDO::getTitle, reqVO.getTitle()) | |
| 21 | + .eqIfPresent(BannerDO::getStatus, reqVO.getStatus()) | |
| 22 | + .betweenIfPresent(BannerDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 23 | + .betweenIfPresent(BannerDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 24 | + .orderByDesc(BannerDO::getSort)); | |
| 25 | + } | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.service.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; | |
| 8 | + | |
| 9 | +import javax.validation.Valid; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 首页 Banner Service 接口 | |
| 14 | + * | |
| 15 | + * @author xia | |
| 16 | + */ | |
| 17 | +public interface BannerService { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 创建 Banner | |
| 21 | + * | |
| 22 | + * @param createReqVO 创建信息 | |
| 23 | + * @return 编号 | |
| 24 | + */ | |
| 25 | + Long createBanner(@Valid BannerCreateReqVO createReqVO); | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 更新 Banner | |
| 29 | + * | |
| 30 | + * @param updateReqVO 更新信息 | |
| 31 | + */ | |
| 32 | + void updateBanner(@Valid BannerUpdateReqVO updateReqVO); | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 删除 Banner | |
| 36 | + * | |
| 37 | + * @param id 编号 | |
| 38 | + */ | |
| 39 | + void deleteBanner(Long id); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 获得 Banner | |
| 43 | + * | |
| 44 | + * @param id 编号 | |
| 45 | + * @return Banner | |
| 46 | + */ | |
| 47 | + BannerDO getBanner(Long id); | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 获得所有 Banner列表 | |
| 51 | + * @return Banner列表 | |
| 52 | + */ | |
| 53 | + List<BannerDO> getBannerList(); | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 获得 Banner 分页 | |
| 57 | + * | |
| 58 | + * @param pageReqVO 分页查询 | |
| 59 | + * @return Banner分页 | |
| 60 | + */ | |
| 61 | + PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO); | |
| 62 | + | |
| 63 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/banner/BannerServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.service.banner; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.market.controller.admin.banner.vo.BannerUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.market.convert.banner.BannerConvert; | |
| 8 | +import cn.iocoder.yudao.module.market.dal.dataobject.banner.BannerDO; | |
| 9 | +import cn.iocoder.yudao.module.market.dal.mysql.banner.BannerMapper; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 17 | +import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.BANNER_NOT_EXISTS; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * 首页banner 实现类 | |
| 21 | + * | |
| 22 | + * @author xia | |
| 23 | + */ | |
| 24 | +@Service | |
| 25 | +@Validated | |
| 26 | +public class BannerServiceImpl implements BannerService { | |
| 27 | + | |
| 28 | + @Resource | |
| 29 | + private BannerMapper bannerMapper; | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public Long createBanner(BannerCreateReqVO createReqVO) { | |
| 33 | + // 插入 | |
| 34 | + BannerDO banner = BannerConvert.INSTANCE.convert(createReqVO); | |
| 35 | + bannerMapper.insert(banner); | |
| 36 | + // 返回 | |
| 37 | + return banner.getId(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public void updateBanner(BannerUpdateReqVO updateReqVO) { | |
| 42 | + // 校验存在 | |
| 43 | + this.validateBannerExists(updateReqVO.getId()); | |
| 44 | + // 更新 | |
| 45 | + BannerDO updateObj = BannerConvert.INSTANCE.convert(updateReqVO); | |
| 46 | + bannerMapper.updateById(updateObj); | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + public void deleteBanner(Long id) { | |
| 51 | + // 校验存在 | |
| 52 | + this.validateBannerExists(id); | |
| 53 | + // 删除 | |
| 54 | + bannerMapper.deleteById(id); | |
| 55 | + } | |
| 56 | + | |
| 57 | + private void validateBannerExists(Long id) { | |
| 58 | + if (bannerMapper.selectById(id) == null) { | |
| 59 | + throw exception(BANNER_NOT_EXISTS); | |
| 60 | + } | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public BannerDO getBanner(Long id) { | |
| 65 | + return bannerMapper.selectById(id); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public List<BannerDO> getBannerList() { | |
| 70 | + return bannerMapper.selectList(); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @Override | |
| 74 | + public PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO) { | |
| 75 | + return bannerMapper.selectPage(pageReqVO); | |
| 76 | + } | |
| 77 | + | |
| 78 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/SkuController.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
| ... | ... | @@ -22,31 +22,31 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 22 | 22 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; |
| 23 | 23 | |
| 24 | 24 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 25 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; | |
| 26 | -import cn.iocoder.yudao.module.product.convert.sku.SkuConvert; | |
| 27 | -import cn.iocoder.yudao.module.product.service.sku.SkuService; | |
| 25 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 26 | +import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 27 | +import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | |
| 28 | 28 | |
| 29 | 29 | @Api(tags = "管理后台 - 商品sku") |
| 30 | 30 | @RestController |
| 31 | 31 | @RequestMapping("/product/sku") |
| 32 | 32 | @Validated |
| 33 | -public class SkuController { | |
| 33 | +public class ProductSkuController { | |
| 34 | 34 | |
| 35 | 35 | @Resource |
| 36 | - private SkuService skuService; | |
| 36 | + private ProductSkuService ProductSkuService; | |
| 37 | 37 | |
| 38 | 38 | @PostMapping("/create") |
| 39 | 39 | @ApiOperation("创建商品sku") |
| 40 | 40 | @PreAuthorize("@ss.hasPermission('product:sku:create')") |
| 41 | - public CommonResult<Integer> createSku(@Valid @RequestBody SkuCreateReqVO createReqVO) { | |
| 42 | - return success(skuService.createSku(createReqVO)); | |
| 41 | + public CommonResult<Integer> createSku(@Valid @RequestBody ProductSkuCreateReqVO createReqVO) { | |
| 42 | + return success(ProductSkuService.createSku(createReqVO)); | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | @PutMapping("/update") |
| 46 | 46 | @ApiOperation("更新商品sku") |
| 47 | 47 | @PreAuthorize("@ss.hasPermission('product:sku:update')") |
| 48 | - public CommonResult<Boolean> updateSku(@Valid @RequestBody SkuUpdateReqVO updateReqVO) { | |
| 49 | - skuService.updateSku(updateReqVO); | |
| 48 | + public CommonResult<Boolean> updateSku(@Valid @RequestBody ProductSkuUpdateReqVO updateReqVO) { | |
| 49 | + ProductSkuService.updateSku(updateReqVO); | |
| 50 | 50 | return success(true); |
| 51 | 51 | } |
| 52 | 52 | |
| ... | ... | @@ -55,7 +55,7 @@ public class SkuController { |
| 55 | 55 | @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) |
| 56 | 56 | @PreAuthorize("@ss.hasPermission('product:sku:delete')") |
| 57 | 57 | public CommonResult<Boolean> deleteSku(@RequestParam("id") Integer id) { |
| 58 | - skuService.deleteSku(id); | |
| 58 | + ProductSkuService.deleteSku(id); | |
| 59 | 59 | return success(true); |
| 60 | 60 | } |
| 61 | 61 | |
| ... | ... | @@ -63,38 +63,38 @@ public class SkuController { |
| 63 | 63 | @ApiOperation("获得商品sku") |
| 64 | 64 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) |
| 65 | 65 | @PreAuthorize("@ss.hasPermission('product:sku:query')") |
| 66 | - public CommonResult<SkuRespVO> getSku(@RequestParam("id") Integer id) { | |
| 67 | - SkuDO sku = skuService.getSku(id); | |
| 68 | - return success(SkuConvert.INSTANCE.convert(sku)); | |
| 66 | + public CommonResult<ProductSkuRespVO> getSku(@RequestParam("id") Integer id) { | |
| 67 | + ProductSkuDO sku = ProductSkuService.getSku(id); | |
| 68 | + return success(ProductSkuConvert.INSTANCE.convert(sku)); | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | @GetMapping("/list") |
| 72 | 72 | @ApiOperation("获得商品sku列表") |
| 73 | 73 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 74 | 74 | @PreAuthorize("@ss.hasPermission('product:sku:query')") |
| 75 | - public CommonResult<List<SkuRespVO>> getSkuList(@RequestParam("ids") Collection<Integer> ids) { | |
| 76 | - List<SkuDO> list = skuService.getSkuList(ids); | |
| 77 | - return success(SkuConvert.INSTANCE.convertList(list)); | |
| 75 | + public CommonResult<List<ProductSkuRespVO>> getSkuList(@RequestParam("ids") Collection<Integer> ids) { | |
| 76 | + List<ProductSkuDO> list = ProductSkuService.getSkuList(ids); | |
| 77 | + return success(ProductSkuConvert.INSTANCE.convertList(list)); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | @GetMapping("/page") |
| 81 | 81 | @ApiOperation("获得商品sku分页") |
| 82 | 82 | @PreAuthorize("@ss.hasPermission('product:sku:query')") |
| 83 | - public CommonResult<PageResult<SkuRespVO>> getSkuPage(@Valid SkuPageReqVO pageVO) { | |
| 84 | - PageResult<SkuDO> pageResult = skuService.getSkuPage(pageVO); | |
| 85 | - return success(SkuConvert.INSTANCE.convertPage(pageResult)); | |
| 83 | + public CommonResult<PageResult<ProductSkuRespVO>> getSkuPage(@Valid ProductSkuPageReqVO pageVO) { | |
| 84 | + PageResult<ProductSkuDO> pageResult = ProductSkuService.getSkuPage(pageVO); | |
| 85 | + return success(ProductSkuConvert.INSTANCE.convertPage(pageResult)); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | @GetMapping("/export-excel") |
| 89 | 89 | @ApiOperation("导出商品sku Excel") |
| 90 | 90 | @PreAuthorize("@ss.hasPermission('product:sku:export')") |
| 91 | 91 | @OperateLog(type = EXPORT) |
| 92 | - public void exportSkuExcel(@Valid SkuExportReqVO exportReqVO, | |
| 92 | + public void exportSkuExcel(@Valid ProductSkuExportReqVO exportReqVO, | |
| 93 | 93 | HttpServletResponse response) throws IOException { |
| 94 | - List<SkuDO> list = skuService.getSkuList(exportReqVO); | |
| 94 | + List<ProductSkuDO> list = ProductSkuService.getSkuList(exportReqVO); | |
| 95 | 95 | // 导出 Excel |
| 96 | - List<SkuExcelVO> datas = SkuConvert.INSTANCE.convertList02(list); | |
| 97 | - ExcelUtils.write(response, "商品sku.xls", "数据", SkuExcelVO.class, datas); | |
| 96 | + List<ProductSkuExcelVO> datas = ProductSkuConvert.INSTANCE.convertList02(list); | |
| 97 | + ExcelUtils.write(response, "商品sku.xls", "数据", ProductSkuExcelVO.class, datas); | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuBaseVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
| ... | ... | @@ -10,7 +10,7 @@ import javax.validation.constraints.*; |
| 10 | 10 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 11 | 11 | */ |
| 12 | 12 | @Data |
| 13 | -public class SkuBaseVO { | |
| 13 | +public class ProductSkuBaseVO { | |
| 14 | 14 | |
| 15 | 15 | @ApiModelProperty(value = "spu编号", required = true) |
| 16 | 16 | @NotNull(message = "spu编号不能为空") |
| ... | ... | @@ -18,7 +18,7 @@ public class SkuBaseVO { |
| 18 | 18 | |
| 19 | 19 | @ApiModelProperty(value = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]", required = true) |
| 20 | 20 | @NotNull(message = "规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]不能为空") |
| 21 | - private String properties; | |
| 21 | + private List<Property> properties; | |
| 22 | 22 | |
| 23 | 23 | @ApiModelProperty(value = "销售价格,单位:分", required = true) |
| 24 | 24 | @NotNull(message = "销售价格,单位:分不能为空") |
| ... | ... | @@ -43,4 +43,10 @@ public class SkuBaseVO { |
| 43 | 43 | @ApiModelProperty(value = "状态: 0-正常 1-禁用") |
| 44 | 44 | private Integer status; |
| 45 | 45 | |
| 46 | + @Data | |
| 47 | + public static class Property { | |
| 48 | + private Integer propertyId; | |
| 49 | + private Integer valueId; | |
| 50 | + } | |
| 51 | + | |
| 46 | 52 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuCreateReqVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateReqVO.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuExcelVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java
| ... | ... | @@ -12,7 +12,7 @@ import com.alibaba.excel.annotation.ExcelProperty; |
| 12 | 12 | * @author 芋道源码 |
| 13 | 13 | */ |
| 14 | 14 | @Data |
| 15 | -public class SkuExcelVO { | |
| 15 | +public class ProductSkuExcelVO { | |
| 16 | 16 | |
| 17 | 17 | @ExcelProperty("主键") |
| 18 | 18 | private Integer id; |
| ... | ... | @@ -21,7 +21,7 @@ public class SkuExcelVO { |
| 21 | 21 | private Long spuId; |
| 22 | 22 | |
| 23 | 23 | @ExcelProperty("规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]") |
| 24 | - private String properties; | |
| 24 | + private List<Property> properties; | |
| 25 | 25 | |
| 26 | 26 | @ExcelProperty("销售价格,单位:分") |
| 27 | 27 | private Integer price; |
| ... | ... | @@ -44,4 +44,9 @@ public class SkuExcelVO { |
| 44 | 44 | @ExcelProperty("创建时间") |
| 45 | 45 | private Date createTime; |
| 46 | 46 | |
| 47 | + @Data | |
| 48 | + public static class Property { | |
| 49 | + private Integer propertyId; | |
| 50 | + private Integer valueId; | |
| 51 | + } | |
| 47 | 52 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuExportReqVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExportReqVO.java
| ... | ... | @@ -10,7 +10,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 10 | 10 | |
| 11 | 11 | @ApiModel(value = "管理后台 - 商品sku Excel 导出 Request VO", description = "参数和 SkuPageReqVO 是一致的") |
| 12 | 12 | @Data |
| 13 | -public class SkuExportReqVO { | |
| 13 | +public class ProductSkuExportReqVO { | |
| 14 | 14 | |
| 15 | 15 | @ApiModelProperty(value = "spu编号") |
| 16 | 16 | private Long spuId; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuPageReqVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuPageReqVO.java
| ... | ... | @@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 12 | 12 | @Data |
| 13 | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | 14 | @ToString(callSuper = true) |
| 15 | -public class SkuPageReqVO extends PageParam { | |
| 15 | +public class ProductSkuPageReqVO extends PageParam { | |
| 16 | 16 | |
| 17 | 17 | @ApiModelProperty(value = "spu编号") |
| 18 | 18 | private Long spuId; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuRespVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java
| ... | ... | @@ -8,7 +8,7 @@ import io.swagger.annotations.*; |
| 8 | 8 | @Data |
| 9 | 9 | @EqualsAndHashCode(callSuper = true) |
| 10 | 10 | @ToString(callSuper = true) |
| 11 | -public class SkuRespVO extends SkuBaseVO { | |
| 11 | +public class ProductSkuRespVO extends ProductSkuBaseVO { | |
| 12 | 12 | |
| 13 | 13 | @ApiModelProperty(value = "主键", required = true) |
| 14 | 14 | private Integer id; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/SkuUpdateReqVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuUpdateReqVO.java
| ... | ... | @@ -9,7 +9,7 @@ import javax.validation.constraints.*; |
| 9 | 9 | @Data |
| 10 | 10 | @EqualsAndHashCode(callSuper = true) |
| 11 | 11 | @ToString(callSuper = true) |
| 12 | -public class SkuUpdateReqVO extends SkuBaseVO { | |
| 12 | +public class ProductSkuUpdateReqVO extends ProductSkuBaseVO { | |
| 13 | 13 | |
| 14 | 14 | @ApiModelProperty(value = "主键", required = true) |
| 15 | 15 | @NotNull(message = "主键不能为空") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/SpuController.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| ... | ... | @@ -22,23 +22,23 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 22 | 22 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; |
| 23 | 23 | |
| 24 | 24 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 25 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; | |
| 26 | -import cn.iocoder.yudao.module.product.convert.spu.SpuConvert; | |
| 27 | -import cn.iocoder.yudao.module.product.service.spu.SpuService; | |
| 25 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 26 | +import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | |
| 27 | +import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; | |
| 28 | 28 | |
| 29 | 29 | @Api(tags = "管理后台 - 商品spu") |
| 30 | 30 | @RestController |
| 31 | 31 | @RequestMapping("/product/spu") |
| 32 | 32 | @Validated |
| 33 | -public class SpuController { | |
| 33 | +public class ProductSpuController { | |
| 34 | 34 | |
| 35 | 35 | @Resource |
| 36 | - private SpuService spuService; | |
| 36 | + private ProductSpuService spuService; | |
| 37 | 37 | |
| 38 | 38 | @PostMapping("/create") |
| 39 | 39 | @ApiOperation("创建商品spu") |
| 40 | 40 | @PreAuthorize("@ss.hasPermission('product:spu:create')") |
| 41 | - public CommonResult<Integer> createSpu(@Valid @RequestBody SpuCreateReqVO createReqVO) { | |
| 41 | + public CommonResult<Integer> createSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { | |
| 42 | 42 | return success(spuService.createSpu(createReqVO)); |
| 43 | 43 | } |
| 44 | 44 | |
| ... | ... | @@ -64,8 +64,8 @@ public class SpuController { |
| 64 | 64 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) |
| 65 | 65 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 66 | 66 | public CommonResult<SpuRespVO> getSpu(@RequestParam("id") Integer id) { |
| 67 | - SpuDO spu = spuService.getSpu(id); | |
| 68 | - return success(SpuConvert.INSTANCE.convert(spu)); | |
| 67 | + ProductSpuDO spu = spuService.getSpu(id); | |
| 68 | + return success(ProductSpuConvert.INSTANCE.convert(spu)); | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | @GetMapping("/list") |
| ... | ... | @@ -73,16 +73,16 @@ public class SpuController { |
| 73 | 73 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 74 | 74 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 75 | 75 | public CommonResult<List<SpuRespVO>> getSpuList(@RequestParam("ids") Collection<Integer> ids) { |
| 76 | - List<SpuDO> list = spuService.getSpuList(ids); | |
| 77 | - return success(SpuConvert.INSTANCE.convertList(list)); | |
| 76 | + List<ProductSpuDO> list = spuService.getSpuList(ids); | |
| 77 | + return success(ProductSpuConvert.INSTANCE.convertList(list)); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | @GetMapping("/page") |
| 81 | 81 | @ApiOperation("获得商品spu分页") |
| 82 | 82 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 83 | 83 | public CommonResult<PageResult<SpuRespVO>> getSpuPage(@Valid SpuPageReqVO pageVO) { |
| 84 | - PageResult<SpuDO> pageResult = spuService.getSpuPage(pageVO); | |
| 85 | - return success(SpuConvert.INSTANCE.convertPage(pageResult)); | |
| 84 | + PageResult<ProductSpuDO> pageResult = spuService.getSpuPage(pageVO); | |
| 85 | + return success(ProductSpuConvert.INSTANCE.convertPage(pageResult)); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | @GetMapping("/export-excel") |
| ... | ... | @@ -91,9 +91,9 @@ public class SpuController { |
| 91 | 91 | @OperateLog(type = EXPORT) |
| 92 | 92 | public void exportSpuExcel(@Valid SpuExportReqVO exportReqVO, |
| 93 | 93 | HttpServletResponse response) throws IOException { |
| 94 | - List<SpuDO> list = spuService.getSpuList(exportReqVO); | |
| 94 | + List<ProductSpuDO> list = spuService.getSpuList(exportReqVO); | |
| 95 | 95 | // 导出 Excel |
| 96 | - List<SpuExcelVO> datas = SpuConvert.INSTANCE.convertList02(list); | |
| 96 | + List<SpuExcelVO> datas = ProductSpuConvert.INSTANCE.convertList02(list); | |
| 97 | 97 | ExcelUtils.write(response, "商品spu.xls", "数据", SpuExcelVO.class, datas); |
| 98 | 98 | } |
| 99 | 99 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuBaseVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
| ... | ... | @@ -10,7 +10,7 @@ import javax.validation.constraints.*; |
| 10 | 10 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 11 | 11 | */ |
| 12 | 12 | @Data |
| 13 | -public class SpuBaseVO { | |
| 13 | +public class ProductSpuBaseVO { | |
| 14 | 14 | |
| 15 | 15 | @ApiModelProperty(value = "商品名称") |
| 16 | 16 | private String name; |
| ... | ... | @@ -29,7 +29,7 @@ public class SpuBaseVO { |
| 29 | 29 | |
| 30 | 30 | @ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true) |
| 31 | 31 | @NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空") |
| 32 | - private String picUrls; | |
| 32 | + private List<String> picUrls; | |
| 33 | 33 | |
| 34 | 34 | @ApiModelProperty(value = "排序字段", required = true) |
| 35 | 35 | @NotNull(message = "排序字段不能为空") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuCreateReqVO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuExcelVO.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuExportReqVO.java
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java
| ... | ... | @@ -8,7 +8,7 @@ import io.swagger.annotations.*; |
| 8 | 8 | @Data |
| 9 | 9 | @EqualsAndHashCode(callSuper = true) |
| 10 | 10 | @ToString(callSuper = true) |
| 11 | -public class SpuRespVO extends SpuBaseVO { | |
| 11 | +public class SpuRespVO extends ProductSpuBaseVO { | |
| 12 | 12 | |
| 13 | 13 | @ApiModelProperty(value = "主键", required = true) |
| 14 | 14 | private Integer id; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuUpdateReqVO.java
| ... | ... | @@ -9,7 +9,7 @@ import javax.validation.constraints.*; |
| 9 | 9 | @Data |
| 10 | 10 | @EqualsAndHashCode(callSuper = true) |
| 11 | 11 | @ToString(callSuper = true) |
| 12 | -public class SpuUpdateReqVO extends SpuBaseVO { | |
| 12 | +public class SpuUpdateReqVO extends ProductSpuBaseVO { | |
| 13 | 13 | |
| 14 | 14 | @ApiModelProperty(value = "主键", required = true) |
| 15 | 15 | @NotNull(message = "主键不能为空") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/SkuConvert.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java
| ... | ... | @@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import org.mapstruct.Mapper; |
| 8 | 8 | import org.mapstruct.factory.Mappers; |
| 9 | 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 10 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; | |
| 10 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * 商品sku Convert |
| ... | ... | @@ -15,20 +15,20 @@ import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | 17 | @Mapper |
| 18 | -public interface SkuConvert { | |
| 18 | +public interface ProductSkuConvert { | |
| 19 | 19 | |
| 20 | - SkuConvert INSTANCE = Mappers.getMapper(SkuConvert.class); | |
| 20 | + ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); | |
| 21 | 21 | |
| 22 | - SkuDO convert(SkuCreateReqVO bean); | |
| 22 | + ProductSkuDO convert(ProductSkuCreateReqVO bean); | |
| 23 | 23 | |
| 24 | - SkuDO convert(SkuUpdateReqVO bean); | |
| 24 | + ProductSkuDO convert(ProductSkuUpdateReqVO bean); | |
| 25 | 25 | |
| 26 | - SkuRespVO convert(SkuDO bean); | |
| 26 | + ProductSkuRespVO convert(ProductSkuDO bean); | |
| 27 | 27 | |
| 28 | - List<SkuRespVO> convertList(List<SkuDO> list); | |
| 28 | + List<ProductSkuRespVO> convertList(List<ProductSkuDO> list); | |
| 29 | 29 | |
| 30 | - PageResult<SkuRespVO> convertPage(PageResult<SkuDO> page); | |
| 30 | + PageResult<ProductSkuRespVO> convertPage(PageResult<ProductSkuDO> page); | |
| 31 | 31 | |
| 32 | - List<SkuExcelVO> convertList02(List<SkuDO> list); | |
| 32 | + List<ProductSkuExcelVO> convertList02(List<ProductSkuDO> list); | |
| 33 | 33 | |
| 34 | 34 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/SpuConvert.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| ... | ... | @@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import org.mapstruct.Mapper; |
| 8 | 8 | import org.mapstruct.factory.Mappers; |
| 9 | 9 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 10 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; | |
| 10 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * 商品spu Convert |
| ... | ... | @@ -15,20 +15,20 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | 17 | @Mapper |
| 18 | -public interface SpuConvert { | |
| 18 | +public interface ProductSpuConvert { | |
| 19 | 19 | |
| 20 | - SpuConvert INSTANCE = Mappers.getMapper(SpuConvert.class); | |
| 20 | + ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); | |
| 21 | 21 | |
| 22 | - SpuDO convert(SpuCreateReqVO bean); | |
| 22 | + ProductSpuDO convert(ProductSpuCreateReqVO bean); | |
| 23 | 23 | |
| 24 | - SpuDO convert(SpuUpdateReqVO bean); | |
| 24 | + ProductSpuDO convert(SpuUpdateReqVO bean); | |
| 25 | 25 | |
| 26 | - SpuRespVO convert(SpuDO bean); | |
| 26 | + SpuRespVO convert(ProductSpuDO bean); | |
| 27 | 27 | |
| 28 | - List<SpuRespVO> convertList(List<SpuDO> list); | |
| 28 | + List<SpuRespVO> convertList(List<ProductSpuDO> list); | |
| 29 | 29 | |
| 30 | - PageResult<SpuRespVO> convertPage(PageResult<SpuDO> page); | |
| 30 | + PageResult<SpuRespVO> convertPage(PageResult<ProductSpuDO> page); | |
| 31 | 31 | |
| 32 | - List<SpuExcelVO> convertList02(List<SpuDO> list); | |
| 32 | + List<SpuExcelVO> convertList02(List<ProductSpuDO> list); | |
| 33 | 33 | |
| 34 | 34 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/SkuDO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java
| ... | ... | @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | 7 | import lombok.*; |
| 8 | 8 | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 9 | 11 | /** |
| 10 | 12 | * 商品sku DO |
| 11 | 13 | * |
| ... | ... | @@ -19,7 +21,7 @@ import lombok.*; |
| 19 | 21 | @Builder |
| 20 | 22 | @NoArgsConstructor |
| 21 | 23 | @AllArgsConstructor |
| 22 | -public class SkuDO extends BaseDO { | |
| 24 | +public class ProductSkuDO extends BaseDO { | |
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | * 主键 |
| ... | ... | @@ -34,7 +36,7 @@ public class SkuDO extends BaseDO { |
| 34 | 36 | * 规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }] |
| 35 | 37 | */ |
| 36 | 38 | // TODO franky:可以定义一个内部的 Property 类,然后 List<Property> |
| 37 | - private String properties; | |
| 39 | + private List<Property> properties; | |
| 38 | 40 | /** |
| 39 | 41 | * 销售价格,单位:分 |
| 40 | 42 | */ |
| ... | ... | @@ -60,4 +62,11 @@ public class SkuDO extends BaseDO { |
| 60 | 62 | */ |
| 61 | 63 | private Integer status; |
| 62 | 64 | |
| 65 | + @Data | |
| 66 | + public static class Property { | |
| 67 | + private Integer propertyId; | |
| 68 | + private Integer valueId; | |
| 69 | + } | |
| 70 | + | |
| 63 | 71 | } |
| 72 | + | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/SpuDO.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
| ... | ... | @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | 7 | import lombok.*; |
| 8 | 8 | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 9 | 11 | /** |
| 10 | 12 | * 商品spu DO |
| 11 | 13 | * |
| ... | ... | @@ -19,7 +21,7 @@ import lombok.*; |
| 19 | 21 | @Builder |
| 20 | 22 | @NoArgsConstructor |
| 21 | 23 | @AllArgsConstructor |
| 22 | -public class SpuDO extends BaseDO { | |
| 24 | +public class ProductSpuDO extends BaseDO { | |
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | * 主键 |
| ... | ... | @@ -46,7 +48,7 @@ public class SpuDO extends BaseDO { |
| 46 | 48 | * 商品主图地址,* 数组,以逗号分隔,最多上传15张 |
| 47 | 49 | */ |
| 48 | 50 | // TODO franky:List<String> |
| 49 | - private String picUrls; | |
| 51 | + private List<String> picUrls; | |
| 50 | 52 | /** |
| 51 | 53 | * 排序字段 |
| 52 | 54 | */ | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.dal.mysql.sku; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 商品sku Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> { | |
| 19 | + | |
| 20 | + default PageResult<ProductSkuDO> selectPage(ProductSkuPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<ProductSkuDO>() | |
| 22 | + .eqIfPresent(ProductSkuDO::getSpuId, reqVO.getSpuId()) | |
| 23 | + .eqIfPresent(ProductSkuDO::getProperties, reqVO.getProperties()) | |
| 24 | + .eqIfPresent(ProductSkuDO::getPrice, reqVO.getPrice()) | |
| 25 | + .eqIfPresent(ProductSkuDO::getOriginalPrice, reqVO.getOriginalPrice()) | |
| 26 | + .eqIfPresent(ProductSkuDO::getCostPrice, reqVO.getCostPrice()) | |
| 27 | + .eqIfPresent(ProductSkuDO::getBarCode, reqVO.getBarCode()) | |
| 28 | + .eqIfPresent(ProductSkuDO::getPicUrl, reqVO.getPicUrl()) | |
| 29 | + .eqIfPresent(ProductSkuDO::getStatus, reqVO.getStatus()) | |
| 30 | + .betweenIfPresent(ProductSkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 31 | + .orderByDesc(ProductSkuDO::getId)); | |
| 32 | + } | |
| 33 | + | |
| 34 | + default List<ProductSkuDO> selectList(ProductSkuExportReqVO reqVO) { | |
| 35 | + return selectList(new LambdaQueryWrapperX<ProductSkuDO>() | |
| 36 | + .eqIfPresent(ProductSkuDO::getSpuId, reqVO.getSpuId()) | |
| 37 | + .eqIfPresent(ProductSkuDO::getProperties, reqVO.getProperties()) | |
| 38 | + .eqIfPresent(ProductSkuDO::getPrice, reqVO.getPrice()) | |
| 39 | + .eqIfPresent(ProductSkuDO::getOriginalPrice, reqVO.getOriginalPrice()) | |
| 40 | + .eqIfPresent(ProductSkuDO::getCostPrice, reqVO.getCostPrice()) | |
| 41 | + .eqIfPresent(ProductSkuDO::getBarCode, reqVO.getBarCode()) | |
| 42 | + .eqIfPresent(ProductSkuDO::getPicUrl, reqVO.getPicUrl()) | |
| 43 | + .eqIfPresent(ProductSkuDO::getStatus, reqVO.getStatus()) | |
| 44 | + .betweenIfPresent(ProductSkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 45 | + .orderByDesc(ProductSkuDO::getId)); | |
| 46 | + } | |
| 47 | + | |
| 48 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/SkuMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.product.dal.mysql.sku; | |
| 2 | - | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; | |
| 9 | -import org.apache.ibatis.annotations.Mapper; | |
| 10 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 商品sku Mapper | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@Mapper | |
| 18 | -public interface SkuMapper extends BaseMapperX<SkuDO> { | |
| 19 | - | |
| 20 | - default PageResult<SkuDO> selectPage(SkuPageReqVO reqVO) { | |
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<SkuDO>() | |
| 22 | - .eqIfPresent(SkuDO::getSpuId, reqVO.getSpuId()) | |
| 23 | - .eqIfPresent(SkuDO::getProperties, reqVO.getProperties()) | |
| 24 | - .eqIfPresent(SkuDO::getPrice, reqVO.getPrice()) | |
| 25 | - .eqIfPresent(SkuDO::getOriginalPrice, reqVO.getOriginalPrice()) | |
| 26 | - .eqIfPresent(SkuDO::getCostPrice, reqVO.getCostPrice()) | |
| 27 | - .eqIfPresent(SkuDO::getBarCode, reqVO.getBarCode()) | |
| 28 | - .eqIfPresent(SkuDO::getPicUrl, reqVO.getPicUrl()) | |
| 29 | - .eqIfPresent(SkuDO::getStatus, reqVO.getStatus()) | |
| 30 | - .betweenIfPresent(SkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 31 | - .orderByDesc(SkuDO::getId)); | |
| 32 | - } | |
| 33 | - | |
| 34 | - default List<SkuDO> selectList(SkuExportReqVO reqVO) { | |
| 35 | - return selectList(new LambdaQueryWrapperX<SkuDO>() | |
| 36 | - .eqIfPresent(SkuDO::getSpuId, reqVO.getSpuId()) | |
| 37 | - .eqIfPresent(SkuDO::getProperties, reqVO.getProperties()) | |
| 38 | - .eqIfPresent(SkuDO::getPrice, reqVO.getPrice()) | |
| 39 | - .eqIfPresent(SkuDO::getOriginalPrice, reqVO.getOriginalPrice()) | |
| 40 | - .eqIfPresent(SkuDO::getCostPrice, reqVO.getCostPrice()) | |
| 41 | - .eqIfPresent(SkuDO::getBarCode, reqVO.getBarCode()) | |
| 42 | - .eqIfPresent(SkuDO::getPicUrl, reqVO.getPicUrl()) | |
| 43 | - .eqIfPresent(SkuDO::getStatus, reqVO.getStatus()) | |
| 44 | - .betweenIfPresent(SkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 45 | - .orderByDesc(SkuDO::getId)); | |
| 46 | - } | |
| 47 | - | |
| 48 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.dal.mysql.spu; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 商品spu Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { | |
| 19 | + | |
| 20 | + default PageResult<ProductSpuDO> selectPage(SpuPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<ProductSpuDO>() | |
| 22 | + .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) | |
| 23 | + .eqIfPresent(ProductSpuDO::getSellPoint, reqVO.getSellPoint()) | |
| 24 | + .eqIfPresent(ProductSpuDO::getDescription, reqVO.getDescription()) | |
| 25 | + .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) | |
| 26 | + .eqIfPresent(ProductSpuDO::getPicUrls, reqVO.getPicUrls()) | |
| 27 | + .eqIfPresent(ProductSpuDO::getSort, reqVO.getSort()) | |
| 28 | + .eqIfPresent(ProductSpuDO::getLikeCount, reqVO.getLikeCount()) | |
| 29 | + .eqIfPresent(ProductSpuDO::getPrice, reqVO.getPrice()) | |
| 30 | + .eqIfPresent(ProductSpuDO::getQuantity, reqVO.getQuantity()) | |
| 31 | + .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) | |
| 32 | + .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 33 | + .orderByDesc(ProductSpuDO::getId)); | |
| 34 | + } | |
| 35 | + | |
| 36 | + default List<ProductSpuDO> selectList(SpuExportReqVO reqVO) { | |
| 37 | + return selectList(new LambdaQueryWrapperX<ProductSpuDO>() | |
| 38 | + .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) | |
| 39 | + .eqIfPresent(ProductSpuDO::getSellPoint, reqVO.getSellPoint()) | |
| 40 | + .eqIfPresent(ProductSpuDO::getDescription, reqVO.getDescription()) | |
| 41 | + .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) | |
| 42 | + .eqIfPresent(ProductSpuDO::getPicUrls, reqVO.getPicUrls()) | |
| 43 | + .eqIfPresent(ProductSpuDO::getSort, reqVO.getSort()) | |
| 44 | + .eqIfPresent(ProductSpuDO::getLikeCount, reqVO.getLikeCount()) | |
| 45 | + .eqIfPresent(ProductSpuDO::getPrice, reqVO.getPrice()) | |
| 46 | + .eqIfPresent(ProductSpuDO::getQuantity, reqVO.getQuantity()) | |
| 47 | + .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) | |
| 48 | + .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 49 | + .orderByDesc(ProductSpuDO::getId)); | |
| 50 | + } | |
| 51 | + | |
| 52 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/SpuMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.product.dal.mysql.spu; | |
| 2 | - | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; | |
| 9 | -import org.apache.ibatis.annotations.Mapper; | |
| 10 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 商品spu Mapper | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@Mapper | |
| 18 | -public interface SpuMapper extends BaseMapperX<SpuDO> { | |
| 19 | - | |
| 20 | - default PageResult<SpuDO> selectPage(SpuPageReqVO reqVO) { | |
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<SpuDO>() | |
| 22 | - .likeIfPresent(SpuDO::getName, reqVO.getName()) | |
| 23 | - .eqIfPresent(SpuDO::getSellPoint, reqVO.getSellPoint()) | |
| 24 | - .eqIfPresent(SpuDO::getDescription, reqVO.getDescription()) | |
| 25 | - .eqIfPresent(SpuDO::getCategoryId, reqVO.getCategoryId()) | |
| 26 | - .eqIfPresent(SpuDO::getPicUrls, reqVO.getPicUrls()) | |
| 27 | - .eqIfPresent(SpuDO::getSort, reqVO.getSort()) | |
| 28 | - .eqIfPresent(SpuDO::getLikeCount, reqVO.getLikeCount()) | |
| 29 | - .eqIfPresent(SpuDO::getPrice, reqVO.getPrice()) | |
| 30 | - .eqIfPresent(SpuDO::getQuantity, reqVO.getQuantity()) | |
| 31 | - .eqIfPresent(SpuDO::getStatus, reqVO.getStatus()) | |
| 32 | - .betweenIfPresent(SpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 33 | - .orderByDesc(SpuDO::getId)); | |
| 34 | - } | |
| 35 | - | |
| 36 | - default List<SpuDO> selectList(SpuExportReqVO reqVO) { | |
| 37 | - return selectList(new LambdaQueryWrapperX<SpuDO>() | |
| 38 | - .likeIfPresent(SpuDO::getName, reqVO.getName()) | |
| 39 | - .eqIfPresent(SpuDO::getSellPoint, reqVO.getSellPoint()) | |
| 40 | - .eqIfPresent(SpuDO::getDescription, reqVO.getDescription()) | |
| 41 | - .eqIfPresent(SpuDO::getCategoryId, reqVO.getCategoryId()) | |
| 42 | - .eqIfPresent(SpuDO::getPicUrls, reqVO.getPicUrls()) | |
| 43 | - .eqIfPresent(SpuDO::getSort, reqVO.getSort()) | |
| 44 | - .eqIfPresent(SpuDO::getLikeCount, reqVO.getLikeCount()) | |
| 45 | - .eqIfPresent(SpuDO::getPrice, reqVO.getPrice()) | |
| 46 | - .eqIfPresent(SpuDO::getQuantity, reqVO.getQuantity()) | |
| 47 | - .eqIfPresent(SpuDO::getStatus, reqVO.getStatus()) | |
| 48 | - .betweenIfPresent(SpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 49 | - .orderByDesc(SpuDO::getId)); | |
| 50 | - } | |
| 51 | - | |
| 52 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/SkuService.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.service.sku; |
| 3 | 3 | import java.util.*; |
| 4 | 4 | import javax.validation.*; |
| 5 | 5 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 6 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; | |
| 6 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | |
| 9 | 9 | /** |
| ... | ... | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | 11 | * |
| 12 | 12 | * @author 芋道源码 |
| 13 | 13 | */ |
| 14 | -public interface SkuService { | |
| 14 | +public interface ProductSkuService { | |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * 创建商品sku |
| ... | ... | @@ -19,14 +19,14 @@ public interface SkuService { |
| 19 | 19 | * @param createReqVO 创建信息 |
| 20 | 20 | * @return 编号 |
| 21 | 21 | */ |
| 22 | - Integer createSku(@Valid SkuCreateReqVO createReqVO); | |
| 22 | + Integer createSku(@Valid ProductSkuCreateReqVO createReqVO); | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * 更新商品sku |
| 26 | 26 | * |
| 27 | 27 | * @param updateReqVO 更新信息 |
| 28 | 28 | */ |
| 29 | - void updateSku(@Valid SkuUpdateReqVO updateReqVO); | |
| 29 | + void updateSku(@Valid ProductSkuUpdateReqVO updateReqVO); | |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * 删除商品sku |
| ... | ... | @@ -41,7 +41,7 @@ public interface SkuService { |
| 41 | 41 | * @param id 编号 |
| 42 | 42 | * @return 商品sku |
| 43 | 43 | */ |
| 44 | - SkuDO getSku(Integer id); | |
| 44 | + ProductSkuDO getSku(Integer id); | |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * 获得商品sku列表 |
| ... | ... | @@ -49,7 +49,7 @@ public interface SkuService { |
| 49 | 49 | * @param ids 编号 |
| 50 | 50 | * @return 商品sku列表 |
| 51 | 51 | */ |
| 52 | - List<SkuDO> getSkuList(Collection<Integer> ids); | |
| 52 | + List<ProductSkuDO> getSkuList(Collection<Integer> ids); | |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * 获得商品sku分页 |
| ... | ... | @@ -57,7 +57,7 @@ public interface SkuService { |
| 57 | 57 | * @param pageReqVO 分页查询 |
| 58 | 58 | * @return 商品sku分页 |
| 59 | 59 | */ |
| 60 | - PageResult<SkuDO> getSkuPage(SkuPageReqVO pageReqVO); | |
| 60 | + PageResult<ProductSkuDO> getSkuPage(ProductSkuPageReqVO pageReqVO); | |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * 获得商品sku列表, 用于 Excel 导出 |
| ... | ... | @@ -65,6 +65,6 @@ public interface SkuService { |
| 65 | 65 | * @param exportReqVO 查询条件 |
| 66 | 66 | * @return 商品sku列表 |
| 67 | 67 | */ |
| 68 | - List<SkuDO> getSkuList(SkuExportReqVO exportReqVO); | |
| 68 | + List<ProductSkuDO> getSkuList(ProductSkuExportReqVO exportReqVO); | |
| 69 | 69 | |
| 70 | 70 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImpl.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| ... | ... | @@ -6,11 +6,11 @@ import org.springframework.validation.annotation.Validated; |
| 6 | 6 | |
| 7 | 7 | import java.util.*; |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 9 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; | |
| 9 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 10 | 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | 11 | |
| 12 | -import cn.iocoder.yudao.module.product.convert.sku.SkuConvert; | |
| 13 | -import cn.iocoder.yudao.module.product.dal.mysql.sku.SkuMapper; | |
| 12 | +import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; | |
| 14 | 14 | |
| 15 | 15 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 16 | 16 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -22,27 +22,27 @@ import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| 22 | 22 | */ |
| 23 | 23 | @Service |
| 24 | 24 | @Validated |
| 25 | -public class SkuServiceImpl implements SkuService { | |
| 25 | +public class ProductSkuServiceImpl implements ProductSkuService { | |
| 26 | 26 | |
| 27 | 27 | @Resource |
| 28 | - private SkuMapper skuMapper; | |
| 28 | + private ProductSkuMapper ProductSkuMapper; | |
| 29 | 29 | |
| 30 | 30 | @Override |
| 31 | - public Integer createSku(SkuCreateReqVO createReqVO) { | |
| 31 | + public Integer createSku(ProductSkuCreateReqVO createReqVO) { | |
| 32 | 32 | // 插入 |
| 33 | - SkuDO sku = SkuConvert.INSTANCE.convert(createReqVO); | |
| 34 | - skuMapper.insert(sku); | |
| 33 | + ProductSkuDO sku = ProductSkuConvert.INSTANCE.convert(createReqVO); | |
| 34 | + ProductSkuMapper.insert(sku); | |
| 35 | 35 | // 返回 |
| 36 | 36 | return sku.getId(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | @Override |
| 40 | - public void updateSku(SkuUpdateReqVO updateReqVO) { | |
| 40 | + public void updateSku(ProductSkuUpdateReqVO updateReqVO) { | |
| 41 | 41 | // 校验存在 |
| 42 | 42 | this.validateSkuExists(updateReqVO.getId()); |
| 43 | 43 | // 更新 |
| 44 | - SkuDO updateObj = SkuConvert.INSTANCE.convert(updateReqVO); | |
| 45 | - skuMapper.updateById(updateObj); | |
| 44 | + ProductSkuDO updateObj = ProductSkuConvert.INSTANCE.convert(updateReqVO); | |
| 45 | + ProductSkuMapper.updateById(updateObj); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | @Override |
| ... | ... | @@ -50,33 +50,33 @@ public class SkuServiceImpl implements SkuService { |
| 50 | 50 | // 校验存在 |
| 51 | 51 | this.validateSkuExists(id); |
| 52 | 52 | // 删除 |
| 53 | - skuMapper.deleteById(id); | |
| 53 | + ProductSkuMapper.deleteById(id); | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | private void validateSkuExists(Integer id) { |
| 57 | - if (skuMapper.selectById(id) == null) { | |
| 57 | + if (ProductSkuMapper.selectById(id) == null) { | |
| 58 | 58 | throw exception(SKU_NOT_EXISTS); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | @Override |
| 63 | - public SkuDO getSku(Integer id) { | |
| 64 | - return skuMapper.selectById(id); | |
| 63 | + public ProductSkuDO getSku(Integer id) { | |
| 64 | + return ProductSkuMapper.selectById(id); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | @Override |
| 68 | - public List<SkuDO> getSkuList(Collection<Integer> ids) { | |
| 69 | - return skuMapper.selectBatchIds(ids); | |
| 68 | + public List<ProductSkuDO> getSkuList(Collection<Integer> ids) { | |
| 69 | + return ProductSkuMapper.selectBatchIds(ids); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | @Override |
| 73 | - public PageResult<SkuDO> getSkuPage(SkuPageReqVO pageReqVO) { | |
| 74 | - return skuMapper.selectPage(pageReqVO); | |
| 73 | + public PageResult<ProductSkuDO> getSkuPage(ProductSkuPageReqVO pageReqVO) { | |
| 74 | + return ProductSkuMapper.selectPage(pageReqVO); | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | @Override |
| 78 | - public List<SkuDO> getSkuList(SkuExportReqVO exportReqVO) { | |
| 79 | - return skuMapper.selectList(exportReqVO); | |
| 78 | + public List<ProductSkuDO> getSkuList(ProductSkuExportReqVO exportReqVO) { | |
| 79 | + return ProductSkuMapper.selectList(exportReqVO); | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/SpuService.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.service.spu; |
| 3 | 3 | import java.util.*; |
| 4 | 4 | import javax.validation.*; |
| 5 | 5 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 6 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; | |
| 6 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | |
| 9 | 9 | /** |
| ... | ... | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | 11 | * |
| 12 | 12 | * @author 芋道源码 |
| 13 | 13 | */ |
| 14 | -public interface SpuService { | |
| 14 | +public interface ProductSpuService { | |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * 创建商品spu |
| ... | ... | @@ -19,7 +19,7 @@ public interface SpuService { |
| 19 | 19 | * @param createReqVO 创建信息 |
| 20 | 20 | * @return 编号 |
| 21 | 21 | */ |
| 22 | - Integer createSpu(@Valid SpuCreateReqVO createReqVO); | |
| 22 | + Integer createSpu(@Valid ProductSpuCreateReqVO createReqVO); | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * 更新商品spu |
| ... | ... | @@ -41,7 +41,7 @@ public interface SpuService { |
| 41 | 41 | * @param id 编号 |
| 42 | 42 | * @return 商品spu |
| 43 | 43 | */ |
| 44 | - SpuDO getSpu(Integer id); | |
| 44 | + ProductSpuDO getSpu(Integer id); | |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * 获得商品spu列表 |
| ... | ... | @@ -49,7 +49,7 @@ public interface SpuService { |
| 49 | 49 | * @param ids 编号 |
| 50 | 50 | * @return 商品spu列表 |
| 51 | 51 | */ |
| 52 | - List<SpuDO> getSpuList(Collection<Integer> ids); | |
| 52 | + List<ProductSpuDO> getSpuList(Collection<Integer> ids); | |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * 获得商品spu分页 |
| ... | ... | @@ -57,7 +57,7 @@ public interface SpuService { |
| 57 | 57 | * @param pageReqVO 分页查询 |
| 58 | 58 | * @return 商品spu分页 |
| 59 | 59 | */ |
| 60 | - PageResult<SpuDO> getSpuPage(SpuPageReqVO pageReqVO); | |
| 60 | + PageResult<ProductSpuDO> getSpuPage(SpuPageReqVO pageReqVO); | |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * 获得商品spu列表, 用于 Excel 导出 |
| ... | ... | @@ -65,6 +65,6 @@ public interface SpuService { |
| 65 | 65 | * @param exportReqVO 查询条件 |
| 66 | 66 | * @return 商品spu列表 |
| 67 | 67 | */ |
| 68 | - List<SpuDO> getSpuList(SpuExportReqVO exportReqVO); | |
| 68 | + List<ProductSpuDO> getSpuList(SpuExportReqVO exportReqVO); | |
| 69 | 69 | |
| 70 | 70 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/SpuServiceImpl.java renamed to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| ... | ... | @@ -6,11 +6,11 @@ import org.springframework.validation.annotation.Validated; |
| 6 | 6 | |
| 7 | 7 | import java.util.*; |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 9 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; | |
| 9 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 10 | 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | 11 | |
| 12 | -import cn.iocoder.yudao.module.product.convert.spu.SpuConvert; | |
| 13 | -import cn.iocoder.yudao.module.product.dal.mysql.spu.SpuMapper; | |
| 12 | +import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; | |
| 14 | 14 | |
| 15 | 15 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 16 | 16 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -22,16 +22,16 @@ import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| 22 | 22 | */ |
| 23 | 23 | @Service |
| 24 | 24 | @Validated |
| 25 | -public class SpuServiceImpl implements SpuService { | |
| 25 | +public class ProductSpuServiceImpl implements ProductSpuService { | |
| 26 | 26 | |
| 27 | 27 | @Resource |
| 28 | - private SpuMapper spuMapper; | |
| 28 | + private ProductSpuMapper ProductSpuMapper; | |
| 29 | 29 | |
| 30 | 30 | @Override |
| 31 | - public Integer createSpu(SpuCreateReqVO createReqVO) { | |
| 31 | + public Integer createSpu(ProductSpuCreateReqVO createReqVO) { | |
| 32 | 32 | // 插入 |
| 33 | - SpuDO spu = SpuConvert.INSTANCE.convert(createReqVO); | |
| 34 | - spuMapper.insert(spu); | |
| 33 | + ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); | |
| 34 | + ProductSpuMapper.insert(spu); | |
| 35 | 35 | // 返回 |
| 36 | 36 | return spu.getId(); |
| 37 | 37 | } |
| ... | ... | @@ -41,8 +41,8 @@ public class SpuServiceImpl implements SpuService { |
| 41 | 41 | // 校验存在 |
| 42 | 42 | this.validateSpuExists(updateReqVO.getId()); |
| 43 | 43 | // 更新 |
| 44 | - SpuDO updateObj = SpuConvert.INSTANCE.convert(updateReqVO); | |
| 45 | - spuMapper.updateById(updateObj); | |
| 44 | + ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); | |
| 45 | + ProductSpuMapper.updateById(updateObj); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | @Override |
| ... | ... | @@ -50,33 +50,33 @@ public class SpuServiceImpl implements SpuService { |
| 50 | 50 | // 校验存在 |
| 51 | 51 | this.validateSpuExists(id); |
| 52 | 52 | // 删除 |
| 53 | - spuMapper.deleteById(id); | |
| 53 | + ProductSpuMapper.deleteById(id); | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | private void validateSpuExists(Integer id) { |
| 57 | - if (spuMapper.selectById(id) == null) { | |
| 57 | + if (ProductSpuMapper.selectById(id) == null) { | |
| 58 | 58 | throw exception(SPU_NOT_EXISTS); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | @Override |
| 63 | - public SpuDO getSpu(Integer id) { | |
| 64 | - return spuMapper.selectById(id); | |
| 63 | + public ProductSpuDO getSpu(Integer id) { | |
| 64 | + return ProductSpuMapper.selectById(id); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | @Override |
| 68 | - public List<SpuDO> getSpuList(Collection<Integer> ids) { | |
| 69 | - return spuMapper.selectBatchIds(ids); | |
| 68 | + public List<ProductSpuDO> getSpuList(Collection<Integer> ids) { | |
| 69 | + return ProductSpuMapper.selectBatchIds(ids); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | @Override |
| 73 | - public PageResult<SpuDO> getSpuPage(SpuPageReqVO pageReqVO) { | |
| 74 | - return spuMapper.selectPage(pageReqVO); | |
| 73 | + public PageResult<ProductSpuDO> getSpuPage(SpuPageReqVO pageReqVO) { | |
| 74 | + return ProductSpuMapper.selectPage(pageReqVO); | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | @Override |
| 78 | - public List<SpuDO> getSpuList(SpuExportReqVO exportReqVO) { | |
| 79 | - return spuMapper.selectList(exportReqVO); | |
| 78 | + public List<ProductSpuDO> getSpuList(SpuExportReqVO exportReqVO) { | |
| 79 | + return ProductSpuMapper.selectList(exportReqVO); | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java
| ... | ... | @@ -9,8 +9,8 @@ import javax.annotation.Resource; |
| 9 | 9 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 10 | 10 | |
| 11 | 11 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; |
| 12 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.SkuDO; | |
| 13 | -import cn.iocoder.yudao.module.product.dal.mysql.sku.SkuMapper; | |
| 12 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; | |
| 14 | 14 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 15 | 15 | |
| 16 | 16 | import javax.annotation.Resource; |
| ... | ... | @@ -27,71 +27,71 @@ import static org.junit.jupiter.api.Assertions.*; |
| 27 | 27 | import static org.mockito.Mockito.*; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | -* {@link SkuServiceImpl} 的单元测试类 | |
| 30 | +* {@link ProductSkuServiceImpl} 的单元测试类 | |
| 31 | 31 | * |
| 32 | 32 | * @author 芋道源码 |
| 33 | 33 | */ |
| 34 | -@Import(SkuServiceImpl.class) | |
| 34 | +@Import(ProductSkuServiceImpl.class) | |
| 35 | 35 | public class SkuServiceImplTest extends BaseDbUnitTest { |
| 36 | 36 | |
| 37 | 37 | @Resource |
| 38 | - private SkuServiceImpl skuService; | |
| 38 | + private ProductSkuServiceImpl ProductSkuService; | |
| 39 | 39 | |
| 40 | 40 | @Resource |
| 41 | - private SkuMapper skuMapper; | |
| 41 | + private ProductSkuMapper ProductSkuMapper; | |
| 42 | 42 | |
| 43 | 43 | @Test |
| 44 | 44 | public void testCreateSku_success() { |
| 45 | 45 | // 准备参数 |
| 46 | - SkuCreateReqVO reqVO = randomPojo(SkuCreateReqVO.class); | |
| 46 | + ProductSkuCreateReqVO reqVO = randomPojo(ProductSkuCreateReqVO.class); | |
| 47 | 47 | |
| 48 | 48 | // 调用 |
| 49 | - Integer skuId = skuService.createSku(reqVO); | |
| 49 | + Integer skuId = ProductSkuService.createSku(reqVO); | |
| 50 | 50 | // 断言 |
| 51 | 51 | assertNotNull(skuId); |
| 52 | 52 | // 校验记录的属性是否正确 |
| 53 | - SkuDO sku = skuMapper.selectById(skuId); | |
| 53 | + ProductSkuDO sku = ProductSkuMapper.selectById(skuId); | |
| 54 | 54 | assertPojoEquals(reqVO, sku); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | @Test |
| 58 | 58 | public void testUpdateSku_success() { |
| 59 | 59 | // mock 数据 |
| 60 | - SkuDO dbSku = randomPojo(SkuDO.class); | |
| 61 | - skuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 | |
| 60 | + ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); | |
| 61 | + ProductSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 | |
| 62 | 62 | // 准备参数 |
| 63 | - SkuUpdateReqVO reqVO = randomPojo(SkuUpdateReqVO.class, o -> { | |
| 63 | + ProductSkuUpdateReqVO reqVO = randomPojo(ProductSkuUpdateReqVO.class, o -> { | |
| 64 | 64 | o.setId(dbSku.getId()); // 设置更新的 ID |
| 65 | 65 | }); |
| 66 | 66 | |
| 67 | 67 | // 调用 |
| 68 | - skuService.updateSku(reqVO); | |
| 68 | + ProductSkuService.updateSku(reqVO); | |
| 69 | 69 | // 校验是否更新正确 |
| 70 | - SkuDO sku = skuMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 70 | + ProductSkuDO sku = ProductSkuMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 71 | 71 | assertPojoEquals(reqVO, sku); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | @Test |
| 75 | 75 | public void testUpdateSku_notExists() { |
| 76 | 76 | // 准备参数 |
| 77 | - SkuUpdateReqVO reqVO = randomPojo(SkuUpdateReqVO.class); | |
| 77 | + ProductSkuUpdateReqVO reqVO = randomPojo(ProductSkuUpdateReqVO.class); | |
| 78 | 78 | |
| 79 | 79 | // 调用, 并断言异常 |
| 80 | - assertServiceException(() -> skuService.updateSku(reqVO), SKU_NOT_EXISTS); | |
| 80 | + assertServiceException(() -> ProductSkuService.updateSku(reqVO), SKU_NOT_EXISTS); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | @Test |
| 84 | 84 | public void testDeleteSku_success() { |
| 85 | 85 | // mock 数据 |
| 86 | - SkuDO dbSku = randomPojo(SkuDO.class); | |
| 87 | - skuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 | |
| 86 | + ProductSkuDO dbSku = randomPojo(ProductSkuDO.class); | |
| 87 | + ProductSkuMapper.insert(dbSku);// @Sql: 先插入出一条存在的数据 | |
| 88 | 88 | // 准备参数 |
| 89 | 89 | Integer id = dbSku.getId(); |
| 90 | 90 | |
| 91 | 91 | // 调用 |
| 92 | - skuService.deleteSku(id); | |
| 92 | + ProductSkuService.deleteSku(id); | |
| 93 | 93 | // 校验数据不存在了 |
| 94 | - assertNull(skuMapper.selectById(id)); | |
| 94 | + assertNull(ProductSkuMapper.selectById(id)); | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | @Test |
| ... | ... | @@ -100,14 +100,14 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 100 | 100 | Integer id = 1; |
| 101 | 101 | |
| 102 | 102 | // 调用, 并断言异常 |
| 103 | - assertServiceException(() -> skuService.deleteSku(id), SKU_NOT_EXISTS); | |
| 103 | + assertServiceException(() -> ProductSkuService.deleteSku(id), SKU_NOT_EXISTS); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | @Test |
| 107 | 107 | @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 |
| 108 | 108 | public void testGetSkuPage() { |
| 109 | 109 | // mock 数据 |
| 110 | - SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到 | |
| 110 | + ProductSkuDO dbSku = randomPojo(ProductSkuDO.class, o -> { // 等会查询到 | |
| 111 | 111 | o.setSpuId(null); |
| 112 | 112 | o.setProperties(null); |
| 113 | 113 | o.setPrice(null); |
| ... | ... | @@ -118,27 +118,27 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 118 | 118 | o.setStatus(null); |
| 119 | 119 | o.setCreateTime(null); |
| 120 | 120 | }); |
| 121 | - skuMapper.insert(dbSku); | |
| 121 | + ProductSkuMapper.insert(dbSku); | |
| 122 | 122 | // 测试 spuId 不匹配 |
| 123 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); | |
| 123 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); | |
| 124 | 124 | // 测试 properties 不匹配 |
| 125 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); | |
| 125 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); | |
| 126 | 126 | // 测试 price 不匹配 |
| 127 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); | |
| 127 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); | |
| 128 | 128 | // 测试 originalPrice 不匹配 |
| 129 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setOriginalPrice(null))); | |
| 129 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setOriginalPrice(null))); | |
| 130 | 130 | // 测试 costPrice 不匹配 |
| 131 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCostPrice(null))); | |
| 131 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCostPrice(null))); | |
| 132 | 132 | // 测试 barCode 不匹配 |
| 133 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); | |
| 133 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); | |
| 134 | 134 | // 测试 picUrl 不匹配 |
| 135 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); | |
| 135 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); | |
| 136 | 136 | // 测试 status 不匹配 |
| 137 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null))); | |
| 137 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null))); | |
| 138 | 138 | // 测试 createTime 不匹配 |
| 139 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); | |
| 139 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); | |
| 140 | 140 | // 准备参数 |
| 141 | - SkuPageReqVO reqVO = new SkuPageReqVO(); | |
| 141 | + ProductSkuPageReqVO reqVO = new ProductSkuPageReqVO(); | |
| 142 | 142 | reqVO.setSpuId(null); |
| 143 | 143 | reqVO.setProperties(null); |
| 144 | 144 | reqVO.setPrice(null); |
| ... | ... | @@ -151,7 +151,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 151 | 151 | reqVO.setEndCreateTime(null); |
| 152 | 152 | |
| 153 | 153 | // 调用 |
| 154 | - PageResult<SkuDO> pageResult = skuService.getSkuPage(reqVO); | |
| 154 | + PageResult<ProductSkuDO> pageResult = ProductSkuService.getSkuPage(reqVO); | |
| 155 | 155 | // 断言 |
| 156 | 156 | assertEquals(1, pageResult.getTotal()); |
| 157 | 157 | assertEquals(1, pageResult.getList().size()); |
| ... | ... | @@ -162,7 +162,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 162 | 162 | @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 |
| 163 | 163 | public void testGetSkuList() { |
| 164 | 164 | // mock 数据 |
| 165 | - SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到 | |
| 165 | + ProductSkuDO dbSku = randomPojo(ProductSkuDO.class, o -> { // 等会查询到 | |
| 166 | 166 | o.setSpuId(null); |
| 167 | 167 | o.setProperties(null); |
| 168 | 168 | o.setPrice(null); |
| ... | ... | @@ -173,27 +173,27 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 173 | 173 | o.setStatus(null); |
| 174 | 174 | o.setCreateTime(null); |
| 175 | 175 | }); |
| 176 | - skuMapper.insert(dbSku); | |
| 176 | + ProductSkuMapper.insert(dbSku); | |
| 177 | 177 | // 测试 spuId 不匹配 |
| 178 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); | |
| 178 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); | |
| 179 | 179 | // 测试 properties 不匹配 |
| 180 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); | |
| 180 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); | |
| 181 | 181 | // 测试 price 不匹配 |
| 182 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); | |
| 182 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); | |
| 183 | 183 | // 测试 originalPrice 不匹配 |
| 184 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setOriginalPrice(null))); | |
| 184 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setOriginalPrice(null))); | |
| 185 | 185 | // 测试 costPrice 不匹配 |
| 186 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCostPrice(null))); | |
| 186 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCostPrice(null))); | |
| 187 | 187 | // 测试 barCode 不匹配 |
| 188 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); | |
| 188 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); | |
| 189 | 189 | // 测试 picUrl 不匹配 |
| 190 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); | |
| 190 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); | |
| 191 | 191 | // 测试 status 不匹配 |
| 192 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null))); | |
| 192 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null))); | |
| 193 | 193 | // 测试 createTime 不匹配 |
| 194 | - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); | |
| 194 | + ProductSkuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); | |
| 195 | 195 | // 准备参数 |
| 196 | - SkuExportReqVO reqVO = new SkuExportReqVO(); | |
| 196 | + ProductSkuExportReqVO reqVO = new ProductSkuExportReqVO(); | |
| 197 | 197 | reqVO.setSpuId(null); |
| 198 | 198 | reqVO.setProperties(null); |
| 199 | 199 | reqVO.setPrice(null); |
| ... | ... | @@ -206,7 +206,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { |
| 206 | 206 | reqVO.setEndCreateTime(null); |
| 207 | 207 | |
| 208 | 208 | // 调用 |
| 209 | - List<SkuDO> list = skuService.getSkuList(reqVO); | |
| 209 | + List<ProductSkuDO> list = ProductSkuService.getSkuList(reqVO); | |
| 210 | 210 | // 断言 |
| 211 | 211 | assertEquals(1, list.size()); |
| 212 | 212 | assertPojoEquals(dbSku, list.get(0)); | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/SpuServiceImplTest.java renamed to yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| ... | ... | @@ -9,8 +9,8 @@ import javax.annotation.Resource; |
| 9 | 9 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 10 | 10 | |
| 11 | 11 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 12 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.SpuDO; | |
| 13 | -import cn.iocoder.yudao.module.product.dal.mysql.spu.SpuMapper; | |
| 12 | +import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; | |
| 14 | 14 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 15 | 15 | |
| 16 | 16 | import javax.annotation.Resource; |
| ... | ... | @@ -27,38 +27,38 @@ import static org.junit.jupiter.api.Assertions.*; |
| 27 | 27 | import static org.mockito.Mockito.*; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | -* {@link SpuServiceImpl} 的单元测试类 | |
| 30 | +* {@link ProductSpuServiceImpl} 的单元测试类 | |
| 31 | 31 | * |
| 32 | 32 | * @author 芋道源码 |
| 33 | 33 | */ |
| 34 | -@Import(SpuServiceImpl.class) | |
| 35 | -public class SpuServiceImplTest extends BaseDbUnitTest { | |
| 34 | +@Import(ProductSpuServiceImpl.class) | |
| 35 | +public class ProductSpuServiceImplTest extends BaseDbUnitTest { | |
| 36 | 36 | |
| 37 | 37 | @Resource |
| 38 | - private SpuServiceImpl spuService; | |
| 38 | + private ProductSpuServiceImpl spuService; | |
| 39 | 39 | |
| 40 | 40 | @Resource |
| 41 | - private SpuMapper spuMapper; | |
| 41 | + private ProductSpuMapper ProductSpuMapper; | |
| 42 | 42 | |
| 43 | 43 | @Test |
| 44 | 44 | public void testCreateSpu_success() { |
| 45 | 45 | // 准备参数 |
| 46 | - SpuCreateReqVO reqVO = randomPojo(SpuCreateReqVO.class); | |
| 46 | + ProductSpuCreateReqVO reqVO = randomPojo(ProductSpuCreateReqVO.class); | |
| 47 | 47 | |
| 48 | 48 | // 调用 |
| 49 | 49 | Integer spuId = spuService.createSpu(reqVO); |
| 50 | 50 | // 断言 |
| 51 | 51 | assertNotNull(spuId); |
| 52 | 52 | // 校验记录的属性是否正确 |
| 53 | - SpuDO spu = spuMapper.selectById(spuId); | |
| 53 | + ProductSpuDO spu = ProductSpuMapper.selectById(spuId); | |
| 54 | 54 | assertPojoEquals(reqVO, spu); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | @Test |
| 58 | 58 | public void testUpdateSpu_success() { |
| 59 | 59 | // mock 数据 |
| 60 | - SpuDO dbSpu = randomPojo(SpuDO.class); | |
| 61 | - spuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 | |
| 60 | + ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class); | |
| 61 | + ProductSpuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 | |
| 62 | 62 | // 准备参数 |
| 63 | 63 | SpuUpdateReqVO reqVO = randomPojo(SpuUpdateReqVO.class, o -> { |
| 64 | 64 | o.setId(dbSpu.getId()); // 设置更新的 ID |
| ... | ... | @@ -67,7 +67,7 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 67 | 67 | // 调用 |
| 68 | 68 | spuService.updateSpu(reqVO); |
| 69 | 69 | // 校验是否更新正确 |
| 70 | - SpuDO spu = spuMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 70 | + ProductSpuDO spu = ProductSpuMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 71 | 71 | assertPojoEquals(reqVO, spu); |
| 72 | 72 | } |
| 73 | 73 | |
| ... | ... | @@ -83,15 +83,15 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 83 | 83 | @Test |
| 84 | 84 | public void testDeleteSpu_success() { |
| 85 | 85 | // mock 数据 |
| 86 | - SpuDO dbSpu = randomPojo(SpuDO.class); | |
| 87 | - spuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 | |
| 86 | + ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class); | |
| 87 | + ProductSpuMapper.insert(dbSpu);// @Sql: 先插入出一条存在的数据 | |
| 88 | 88 | // 准备参数 |
| 89 | 89 | Integer id = dbSpu.getId(); |
| 90 | 90 | |
| 91 | 91 | // 调用 |
| 92 | 92 | spuService.deleteSpu(id); |
| 93 | 93 | // 校验数据不存在了 |
| 94 | - assertNull(spuMapper.selectById(id)); | |
| 94 | + assertNull(ProductSpuMapper.selectById(id)); | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | @Test |
| ... | ... | @@ -107,7 +107,7 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 107 | 107 | @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 |
| 108 | 108 | public void testGetSpuPage() { |
| 109 | 109 | // mock 数据 |
| 110 | - SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到 | |
| 110 | + ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class, o -> { // 等会查询到 | |
| 111 | 111 | o.setName(null); |
| 112 | 112 | o.setSellPoint(null); |
| 113 | 113 | o.setDescription(null); |
| ... | ... | @@ -120,29 +120,29 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 120 | 120 | o.setStatus(null); |
| 121 | 121 | o.setCreateTime(null); |
| 122 | 122 | }); |
| 123 | - spuMapper.insert(dbSpu); | |
| 123 | + ProductSpuMapper.insert(dbSpu); | |
| 124 | 124 | // 测试 name 不匹配 |
| 125 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); | |
| 125 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); | |
| 126 | 126 | // 测试 sellPoint 不匹配 |
| 127 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); | |
| 127 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); | |
| 128 | 128 | // 测试 description 不匹配 |
| 129 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); | |
| 129 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); | |
| 130 | 130 | // 测试 categoryId 不匹配 |
| 131 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null))); | |
| 131 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null))); | |
| 132 | 132 | // 测试 picUrls 不匹配 |
| 133 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); | |
| 133 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); | |
| 134 | 134 | // 测试 sort 不匹配 |
| 135 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSort(null))); | |
| 135 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSort(null))); | |
| 136 | 136 | // 测试 likeCount 不匹配 |
| 137 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setLikeCount(null))); | |
| 137 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setLikeCount(null))); | |
| 138 | 138 | // 测试 price 不匹配 |
| 139 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); | |
| 139 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); | |
| 140 | 140 | // 测试 quantity 不匹配 |
| 141 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null))); | |
| 141 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null))); | |
| 142 | 142 | // 测试 status 不匹配 |
| 143 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setStatus(null))); | |
| 143 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setStatus(null))); | |
| 144 | 144 | // 测试 createTime 不匹配 |
| 145 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); | |
| 145 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); | |
| 146 | 146 | // 准备参数 |
| 147 | 147 | SpuPageReqVO reqVO = new SpuPageReqVO(); |
| 148 | 148 | reqVO.setName(null); |
| ... | ... | @@ -159,7 +159,7 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 159 | 159 | reqVO.setEndCreateTime(null); |
| 160 | 160 | |
| 161 | 161 | // 调用 |
| 162 | - PageResult<SpuDO> pageResult = spuService.getSpuPage(reqVO); | |
| 162 | + PageResult<ProductSpuDO> pageResult = spuService.getSpuPage(reqVO); | |
| 163 | 163 | // 断言 |
| 164 | 164 | assertEquals(1, pageResult.getTotal()); |
| 165 | 165 | assertEquals(1, pageResult.getList().size()); |
| ... | ... | @@ -170,7 +170,7 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 170 | 170 | @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 |
| 171 | 171 | public void testGetSpuList() { |
| 172 | 172 | // mock 数据 |
| 173 | - SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到 | |
| 173 | + ProductSpuDO dbSpu = randomPojo(ProductSpuDO.class, o -> { // 等会查询到 | |
| 174 | 174 | o.setName(null); |
| 175 | 175 | o.setSellPoint(null); |
| 176 | 176 | o.setDescription(null); |
| ... | ... | @@ -183,29 +183,29 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 183 | 183 | o.setStatus(null); |
| 184 | 184 | o.setCreateTime(null); |
| 185 | 185 | }); |
| 186 | - spuMapper.insert(dbSpu); | |
| 186 | + ProductSpuMapper.insert(dbSpu); | |
| 187 | 187 | // 测试 name 不匹配 |
| 188 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); | |
| 188 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); | |
| 189 | 189 | // 测试 sellPoint 不匹配 |
| 190 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); | |
| 190 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); | |
| 191 | 191 | // 测试 description 不匹配 |
| 192 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); | |
| 192 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); | |
| 193 | 193 | // 测试 categoryId 不匹配 |
| 194 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null))); | |
| 194 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null))); | |
| 195 | 195 | // 测试 picUrls 不匹配 |
| 196 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); | |
| 196 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); | |
| 197 | 197 | // 测试 sort 不匹配 |
| 198 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSort(null))); | |
| 198 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSort(null))); | |
| 199 | 199 | // 测试 likeCount 不匹配 |
| 200 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setLikeCount(null))); | |
| 200 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setLikeCount(null))); | |
| 201 | 201 | // 测试 price 不匹配 |
| 202 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); | |
| 202 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); | |
| 203 | 203 | // 测试 quantity 不匹配 |
| 204 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null))); | |
| 204 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null))); | |
| 205 | 205 | // 测试 status 不匹配 |
| 206 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setStatus(null))); | |
| 206 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setStatus(null))); | |
| 207 | 207 | // 测试 createTime 不匹配 |
| 208 | - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); | |
| 208 | + ProductSpuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); | |
| 209 | 209 | // 准备参数 |
| 210 | 210 | SpuExportReqVO reqVO = new SpuExportReqVO(); |
| 211 | 211 | reqVO.setName(null); |
| ... | ... | @@ -222,7 +222,7 @@ public class SpuServiceImplTest extends BaseDbUnitTest { |
| 222 | 222 | reqVO.setEndCreateTime(null); |
| 223 | 223 | |
| 224 | 224 | // 调用 |
| 225 | - List<SpuDO> list = spuService.getSpuList(reqVO); | |
| 225 | + List<ProductSpuDO> list = spuService.getSpuList(reqVO); | |
| 226 | 226 | // 断言 |
| 227 | 227 | assertEquals(1, list.size()); |
| 228 | 228 | assertPojoEquals(dbSpu, list.get(0)); | ... | ... |
yudao-ui-admin/src/api/mall/market/banner.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | + | |
| 3 | +// 创建Banner | |
| 4 | +export function createBanner(data) { | |
| 5 | + return request({ | |
| 6 | + url: '/market/banner/create', | |
| 7 | + method: 'post', | |
| 8 | + data: data | |
| 9 | + }) | |
| 10 | +} | |
| 11 | + | |
| 12 | +// 更新Banner | |
| 13 | +export function updateBanner(data) { | |
| 14 | + return request({ | |
| 15 | + url: '/market/banner/update', | |
| 16 | + method: 'put', | |
| 17 | + data: data | |
| 18 | + }) | |
| 19 | +} | |
| 20 | + | |
| 21 | +// 删除Banner | |
| 22 | +export function deleteBanner(id) { | |
| 23 | + return request({ | |
| 24 | + url: '/market/banner/delete?id=' + id, | |
| 25 | + method: 'delete' | |
| 26 | + }) | |
| 27 | +} | |
| 28 | + | |
| 29 | +// 获得Banner | |
| 30 | +export function getBanner(id) { | |
| 31 | + return request({ | |
| 32 | + url: '/market/banner/get?id=' + id, | |
| 33 | + method: 'get' | |
| 34 | + }) | |
| 35 | +} | |
| 36 | + | |
| 37 | +// 获得Banner分页 | |
| 38 | +export function getBannerPage(query) { | |
| 39 | + return request({ | |
| 40 | + url: '/market/banner/page', | |
| 41 | + method: 'get', | |
| 42 | + params: query | |
| 43 | + }) | |
| 44 | +} | |
| 45 | + | |
| 46 | +// 导出Banner Excel | |
| 47 | +export function exportBannerExcel(query) { | |
| 48 | + return request({ | |
| 49 | + url: '/market/banner/export-excel', | |
| 50 | + method: 'get', | |
| 51 | + params: query, | |
| 52 | + responseType: 'blob' | |
| 53 | + }) | |
| 54 | +} | ... | ... |
yudao-ui-admin/src/views/mall/market/banner/index.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div class="app-container"> | |
| 3 | + | |
| 4 | + <!-- 搜索工作栏 --> | |
| 5 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> | |
| 6 | + <el-form-item label="标题" prop="title"> | |
| 7 | + <el-input v-model="queryParams.title" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery"/> | |
| 8 | + </el-form-item> | |
| 9 | + <el-form-item label="状态" prop="status"> | |
| 10 | + <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small"> | |
| 11 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | |
| 12 | + :key="dict.value" :label="dict.label" :value="dict.value"/> | |
| 13 | + </el-select> | |
| 14 | + </el-form-item> | |
| 15 | + <el-form-item label="创建时间"> | |
| 16 | + <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd" | |
| 17 | + type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/> | |
| 18 | + </el-form-item> | |
| 19 | + <el-form-item> | |
| 20 | + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> | |
| 21 | + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> | |
| 22 | + </el-form-item> | |
| 23 | + </el-form> | |
| 24 | + | |
| 25 | + <!-- 操作工具栏 --> | |
| 26 | + <el-row :gutter="10" class="mb8"> | |
| 27 | + <el-col :span="1.5"> | |
| 28 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" | |
| 29 | + v-hasPermi="['market:banner:create']">新增 | |
| 30 | + </el-button> | |
| 31 | + </el-col> | |
| 32 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | |
| 33 | + </el-row> | |
| 34 | + | |
| 35 | + <!-- 列表 --> | |
| 36 | + <el-table v-loading="loading" :data="list"> | |
| 37 | + <el-table-column label="标题" align="center" prop="title"/> | |
| 38 | + | |
| 39 | + <el-table-column label="缩略图" align="center" prop="picUrl"> | |
| 40 | + <template slot-scope="scope"> | |
| 41 | + <img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="缩略图片" class="img-height"/> | |
| 42 | + </template> | |
| 43 | + </el-table-column> | |
| 44 | + <el-table-column label="跳转链接" align="center" prop="url"/> | |
| 45 | + <el-table-column label="排序" align="center" prop="sort"/> | |
| 46 | + <el-table-column label="描述" align="center" prop="memo"/> | |
| 47 | + <el-table-column label="状态" align="center" prop="status"> | |
| 48 | + <template slot-scope="scope"> | |
| 49 | + <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/> | |
| 50 | + </template> | |
| 51 | + </el-table-column> | |
| 52 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | |
| 53 | + <template slot-scope="scope"> | |
| 54 | + <span>{{ parseTime(scope.row.createTime) }}</span> | |
| 55 | + </template> | |
| 56 | + </el-table-column> | |
| 57 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | |
| 58 | + <template slot-scope="scope"> | |
| 59 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | |
| 60 | + v-hasPermi="['market:banner:update']">修改 | |
| 61 | + </el-button> | |
| 62 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | |
| 63 | + v-hasPermi="['market:banner:delete']">删除 | |
| 64 | + </el-button> | |
| 65 | + </template> | |
| 66 | + </el-table-column> | |
| 67 | + </el-table> | |
| 68 | + <!-- 分页组件 --> | |
| 69 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | |
| 70 | + @pagination="getList"/> | |
| 71 | + | |
| 72 | + <!-- 对话框(添加 / 修改) --> | |
| 73 | + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | |
| 74 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | |
| 75 | + <el-form-item label="标题" prop="title"> | |
| 76 | + <el-input v-model="form.title" placeholder="请输入标题"/> | |
| 77 | + </el-form-item> | |
| 78 | + <el-form-item label="缩略图" prop="picUrl"> | |
| 79 | + <imageUpload v-model="form.picUrl" :limit="1"/> | |
| 80 | + </el-form-item> | |
| 81 | + <el-form-item label="跳转链接" prop="url"> | |
| 82 | + <el-input v-model="form.url" placeholder="请输入跳转链接"/> | |
| 83 | + </el-form-item> | |
| 84 | + <el-form-item label="排序" prop="sort"> | |
| 85 | + <el-input v-model="form.sort" placeholder="请输入排序"/> | |
| 86 | + </el-form-item> | |
| 87 | + <el-form-item label="描述" prop="memo"> | |
| 88 | + <el-input v-model="form.memo" type="textarea" placeholder="请输入描述"/> | |
| 89 | + </el-form-item> | |
| 90 | + <el-form-item label="状态" prop="status"> | |
| 91 | + <el-radio-group v-model="form.status"> | |
| 92 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | |
| 93 | + :key="dict.value" :label="parseInt(dict.value)">{{ dict.label }} | |
| 94 | + </el-radio> | |
| 95 | + </el-radio-group> | |
| 96 | + </el-form-item> | |
| 97 | + </el-form> | |
| 98 | + <div slot="footer" class="dialog-footer"> | |
| 99 | + <el-button type="primary" @click="submitForm">确 定</el-button> | |
| 100 | + <el-button @click="cancel">取 消</el-button> | |
| 101 | + </div> | |
| 102 | + </el-dialog> | |
| 103 | + </div> | |
| 104 | +</template> | |
| 105 | + | |
| 106 | +<script> | |
| 107 | +import { | |
| 108 | + createBanner, | |
| 109 | + deleteBanner, | |
| 110 | + exportBannerExcel, | |
| 111 | + getBanner, | |
| 112 | + getBannerPage, | |
| 113 | + updateBanner | |
| 114 | +} from "@/api/mall/market/banner"; | |
| 115 | +import ImageUpload from '@/components/ImageUpload'; | |
| 116 | + | |
| 117 | +export default { | |
| 118 | + name: "Banner", | |
| 119 | + components: { | |
| 120 | + ImageUpload | |
| 121 | + }, | |
| 122 | + data() { | |
| 123 | + return { | |
| 124 | + // 遮罩层 | |
| 125 | + loading: true, | |
| 126 | + // 导出遮罩层 | |
| 127 | + exportLoading: false, | |
| 128 | + // 显示搜索条件 | |
| 129 | + showSearch: true, | |
| 130 | + // 总条数 | |
| 131 | + total: 0, | |
| 132 | + // 品牌列表 | |
| 133 | + list: [], | |
| 134 | + // 弹出层标题 | |
| 135 | + title: "", | |
| 136 | + // 是否显示弹出层 | |
| 137 | + open: false, | |
| 138 | + dateRangeCreateTime: [], | |
| 139 | + // 查询参数 | |
| 140 | + queryParams: { | |
| 141 | + pageNo: 1, | |
| 142 | + pageSize: 10, | |
| 143 | + title: null, | |
| 144 | + status: null, | |
| 145 | + }, | |
| 146 | + // 商品分类树选项 | |
| 147 | + categoryOptions: [], | |
| 148 | + // 表单参数 | |
| 149 | + form: {}, | |
| 150 | + // 表单校验 | |
| 151 | + rules: { | |
| 152 | + title: [{required: true, message: "标题不能不空", trigger: "blur"}], | |
| 153 | + picUrl: [{required: true, message: "图片地址不能为空", trigger: "blur"}], | |
| 154 | + url: [{required: true, message: "跳转地址不能为空", trigger: "blur"}], | |
| 155 | + sort: [{required: true, message: "排序不能为空", trigger: "blur"}], | |
| 156 | + status: [{required: true, message: "状态不能为空", trigger: "change"}], | |
| 157 | + } | |
| 158 | + }; | |
| 159 | + }, | |
| 160 | + created() { | |
| 161 | + this.getList(); | |
| 162 | + }, | |
| 163 | + methods: { | |
| 164 | + /** 查询列表 */ | |
| 165 | + getList() { | |
| 166 | + this.loading = true; | |
| 167 | + // 处理查询参数 | |
| 168 | + let params = {...this.queryParams}; | |
| 169 | + this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); | |
| 170 | + // 执行查询 | |
| 171 | + getBannerPage(params).then(response => { | |
| 172 | + this.list = response.data.list; | |
| 173 | + this.total = response.data.total; | |
| 174 | + this.loading = false; | |
| 175 | + }); | |
| 176 | + }, | |
| 177 | + /** 取消按钮 */ | |
| 178 | + cancel() { | |
| 179 | + this.open = false; | |
| 180 | + this.reset(); | |
| 181 | + }, | |
| 182 | + /** 表单重置 */ | |
| 183 | + reset() { | |
| 184 | + this.form = { | |
| 185 | + id: undefined, | |
| 186 | + title: undefined, | |
| 187 | + link: undefined, | |
| 188 | + imgUrl: undefined, | |
| 189 | + sort: undefined, | |
| 190 | + memo: undefined, | |
| 191 | + status: undefined, | |
| 192 | + }; | |
| 193 | + this.resetForm("form"); | |
| 194 | + }, | |
| 195 | + /** 搜索按钮操作 */ | |
| 196 | + handleQuery() { | |
| 197 | + this.queryParams.pageNo = 1; | |
| 198 | + this.getList(); | |
| 199 | + }, | |
| 200 | + /** 重置按钮操作 */ | |
| 201 | + resetQuery() { | |
| 202 | + this.dateRangeCreateTime = []; | |
| 203 | + this.resetForm("queryForm"); | |
| 204 | + this.handleQuery(); | |
| 205 | + }, | |
| 206 | + /** 新增按钮操作 */ | |
| 207 | + handleAdd() { | |
| 208 | + this.reset(); | |
| 209 | + this.open = true; | |
| 210 | + this.title = "添加Banner"; | |
| 211 | + }, | |
| 212 | + /** 修改按钮操作 */ | |
| 213 | + handleUpdate(row) { | |
| 214 | + this.reset(); | |
| 215 | + const id = row.id; | |
| 216 | + getBanner(id).then(response => { | |
| 217 | + this.form = response.data; | |
| 218 | + this.open = true; | |
| 219 | + this.title = "修改Banner"; | |
| 220 | + }); | |
| 221 | + }, | |
| 222 | + /** 提交按钮 */ | |
| 223 | + submitForm() { | |
| 224 | + this.$refs["form"].validate(valid => { | |
| 225 | + if (!valid) { | |
| 226 | + return; | |
| 227 | + } | |
| 228 | + // 修改的提交 | |
| 229 | + if (this.form.id != null) { | |
| 230 | + updateBanner(this.form).then(response => { | |
| 231 | + this.$modal.msgSuccess("修改成功"); | |
| 232 | + this.open = false; | |
| 233 | + this.getList(); | |
| 234 | + }); | |
| 235 | + return; | |
| 236 | + } | |
| 237 | + // 添加的提交 | |
| 238 | + createBanner(this.form).then(response => { | |
| 239 | + this.$modal.msgSuccess("新增成功"); | |
| 240 | + this.open = false; | |
| 241 | + this.getList(); | |
| 242 | + }); | |
| 243 | + }); | |
| 244 | + }, | |
| 245 | + /** 删除按钮操作 */ | |
| 246 | + handleDelete(row) { | |
| 247 | + const id = row.id; | |
| 248 | + this.$modal.confirm('是否确认删除Banner编号为"' + id + '"的数据项?').then(function () { | |
| 249 | + return deleteBanner(id); | |
| 250 | + }).then(() => { | |
| 251 | + this.getList(); | |
| 252 | + this.$modal.msgSuccess("删除成功"); | |
| 253 | + }).catch(() => { | |
| 254 | + }); | |
| 255 | + } | |
| 256 | + } | |
| 257 | +}; | |
| 258 | +</script> | |
| 259 | + | |
| 260 | +<style scoped lang="scss"> | |
| 261 | +// | |
| 262 | +.img-height { | |
| 263 | + height: 150px; | |
| 264 | +} | |
| 265 | +</style> | ... | ... |
yudao-ui-admin/src/views/mall/product/spu/index.vue
| ... | ... | @@ -12,24 +12,17 @@ |
| 12 | 12 | <el-form-item label="分类id" prop="categoryId"> |
| 13 | 13 | <el-input v-model="queryParams.categoryId" placeholder="请输入分类id" clearable @keyup.enter.native="handleQuery"/> |
| 14 | 14 | </el-form-item> |
| 15 | - <el-form-item label="商品主图地址" prop="picUrls"> | |
| 16 | - <el-input v-model="queryParams.picUrls" placeholder="请输入商品主图地址" clearable @keyup.enter.native="handleQuery"/> | |
| 17 | - </el-form-item> | |
| 18 | - <el-form-item label="排序字段" prop="sort"> | |
| 19 | - <el-input v-model="queryParams.sort" placeholder="请输入排序字段" clearable @keyup.enter.native="handleQuery"/> | |
| 20 | - </el-form-item> | |
| 21 | - <el-form-item label="点赞初始人数" prop="likeCount"> | |
| 22 | - <el-input v-model="queryParams.likeCount" placeholder="请输入点赞初始人数" clearable @keyup.enter.native="handleQuery"/> | |
| 23 | - </el-form-item> | |
| 24 | - <el-form-item label="价格 单位使用:分" prop="price"> | |
| 15 | + <el-form-item label="价格(分)" prop="price"> | |
| 25 | 16 | <el-input v-model="queryParams.price" placeholder="请输入价格 单位使用:分" clearable @keyup.enter.native="handleQuery"/> |
| 26 | 17 | </el-form-item> |
| 27 | 18 | <el-form-item label="库存数量" prop="quantity"> |
| 28 | 19 | <el-input v-model="queryParams.quantity" placeholder="请输入库存数量" clearable @keyup.enter.native="handleQuery"/> |
| 29 | 20 | </el-form-item> |
| 30 | - <el-form-item label="上下架状态: 0 上架(开启) 1 下架(禁用)" prop="status"> | |
| 31 | - <el-select v-model="queryParams.status" placeholder="请选择上下架状态: 0 上架(开启) 1 下架(禁用)" clearable size="small"> | |
| 21 | + <el-form-item label="状态" prop="status"> | |
| 22 | + <el-select v-model="queryParams.status" placeholder="请选择上下架状态" clearable size="small"> | |
| 32 | 23 | <el-option label="请选择字典生成" value="" /> |
| 24 | + <el-option label="上架" value="0" /> | |
| 25 | + <el-option label="下架" value="1" /> | |
| 33 | 26 | </el-select> |
| 34 | 27 | </el-form-item> |
| 35 | 28 | <el-form-item label="创建时间"> |
| ... | ... | @@ -65,9 +58,9 @@ |
| 65 | 58 | <el-table-column label="商品主图地址" align="center" prop="picUrls" /> |
| 66 | 59 | <el-table-column label="排序字段" align="center" prop="sort" /> |
| 67 | 60 | <el-table-column label="点赞初始人数" align="center" prop="likeCount" /> |
| 68 | - <el-table-column label="价格 单位使用:分" align="center" prop="price" /> | |
| 61 | + <el-table-column label="价格 (分)" align="center" prop="price" /> | |
| 69 | 62 | <el-table-column label="库存数量" align="center" prop="quantity" /> |
| 70 | - <el-table-column label="上下架状态: 0 上架(开启) 1 下架(禁用)" align="center" prop="status" /> | |
| 63 | + <el-table-column label="状态" align="center" prop="status" /> | |
| 71 | 64 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 72 | 65 | <template slot-scope="scope"> |
| 73 | 66 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| ... | ... | @@ -87,7 +80,7 @@ |
| 87 | 80 | @pagination="getList"/> |
| 88 | 81 | |
| 89 | 82 | <!-- 对话框(添加 / 修改) --> |
| 90 | - <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | |
| 83 | + <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body> | |
| 91 | 84 | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| 92 | 85 | <el-form-item label="商品名称" prop="name"> |
| 93 | 86 | <el-input v-model="form.name" placeholder="请输入商品名称" /> |
| ... | ... | @@ -116,9 +109,10 @@ |
| 116 | 109 | <el-form-item label="库存数量" prop="quantity"> |
| 117 | 110 | <el-input v-model="form.quantity" placeholder="请输入库存数量" /> |
| 118 | 111 | </el-form-item> |
| 119 | - <el-form-item label="上下架状态: 0 上架(开启) 1 下架(禁用)" prop="status"> | |
| 112 | + <el-form-item label="上下架状态" prop="status"> | |
| 120 | 113 | <el-radio-group v-model="form.status"> |
| 121 | - <el-radio label="1">请选择字典生成</el-radio> | |
| 114 | + <el-radio label="0">上架</el-radio> | |
| 115 | + <el-radio label="1">下架</el-radio> | |
| 122 | 116 | </el-radio-group> |
| 123 | 117 | </el-form-item> |
| 124 | 118 | </el-form> | ... | ... |