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