Banner 的迁移
商品推荐的迁移
This commit is contained in:
parent
c94fae173e
commit
f0999eac46
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.manager.promotion.brand.BannerManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* Banner Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/promotion/banner")
|
||||
@Api(tags = "Banner API")
|
||||
@Validated
|
||||
public class BannerController {
|
||||
|
||||
@Autowired
|
||||
private BannerManager bannerManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建 Banner")
|
||||
@RequiresPermissions("promotion:banner:create")
|
||||
public CommonResult<Integer> createBanner(@Valid BannerCreateReqVO createVO) {
|
||||
return success(bannerManager.createBanner(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新 Banner")
|
||||
@RequiresPermissions("promotion:banner:update")
|
||||
public CommonResult<Boolean> updateBanner(@Valid BannerUpdateReqVO updateVO) {
|
||||
bannerManager.updateBanner(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除 Banner")
|
||||
@ApiImplicitParam(name = "bannerId", value = " Banner 编号", required = true)
|
||||
@RequiresPermissions("promotion:banner:delete")
|
||||
public CommonResult<Boolean> deleteBanner(@RequestParam("bannerId") Integer bannerId) {
|
||||
bannerManager.deleteBanner(bannerId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得 Banner 分页")
|
||||
@RequiresPermissions("promotion:banner:page")
|
||||
public CommonResult<PageResult<BannerRespVO>> pageBanner(BannerPageReqVO pageVO) {
|
||||
return success(bannerManager.pageBanner(pageVO));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("Banner 创建 Request VO")
|
||||
@Data
|
||||
public class BannerCreateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com")
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "跳转链接格式不正确")
|
||||
@Length(max = 255, message = "跳转链接最大长度为 255 位")
|
||||
private String url;
|
||||
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.iocoder.cn/01.jpg")
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "图片链接格式不正确")
|
||||
@Length(max = 255, message = "图片链接最大长度为 255 位")
|
||||
private String picUrl;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "10")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", example = "这个活动很牛逼")
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("Banner 分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BannerPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
|
||||
private String title;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.promotion.application.vo.admins;
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -10,7 +10,7 @@ import java.util.Date;
|
||||
@ApiModel("Banner VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsBannerVO {
|
||||
public class BannerRespVO {
|
||||
|
||||
@ApiModelProperty(value = "Banner 编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ -24,7 +24,7 @@ public class AdminsBannerVO {
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", required = true, example = "这个活动很牛逼")
|
||||
@ApiModelProperty(value = "备注", example = "这个活动很牛逼")
|
||||
private String memo;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
@ -1,36 +1,42 @@
|
||||
package cn.iocoder.mall.promotionservice.service.banner.bo;
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Banner 更新 DTO
|
||||
*/
|
||||
@ApiModel("Banner 更新 Request VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerUpdateBO implements Serializable {
|
||||
public class BannerUpdateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "Banner 编号", required = true, example = "1")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com")
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "跳转链接格式不正确")
|
||||
@Length(max = 255, message = "跳转链接最大长度为 255 位")
|
||||
private String url;
|
||||
@NotEmpty(message = "图片链接不能为空")
|
||||
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.iocoder.cn/01.jpg")
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "图片链接格式不正确")
|
||||
@Length(max = 255, message = "图片链接最大长度为 255 位")
|
||||
private String picUrl;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "10")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", example = "这个活动很牛逼")
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
@ -0,0 +1,60 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendDetailVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.manager.promotion.recommend.ProductRecommendManager;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 商品推荐 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/promotion/product-recommend")
|
||||
@Api(tags = "商品推荐")
|
||||
@Validated
|
||||
public class ProductRecommendController {
|
||||
|
||||
@Autowired
|
||||
private ProductRecommendManager productRecommendManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建商品推荐")
|
||||
public CommonResult<Integer> createProductRecommend(@Valid ProductRecommendCreateReqVO createVO) {
|
||||
return success(productRecommendManager.createProductRecommend(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新商品推荐")
|
||||
public CommonResult<Boolean> updateProductRecommend(@Valid ProductRecommendUpdateReqVO updateVO) {
|
||||
productRecommendManager.updateProductRecommend(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除商品推荐")
|
||||
@ApiImplicitParam(name = "productRecommendId", value = "商品推荐编号", required = true)
|
||||
public CommonResult<Boolean> deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) {
|
||||
productRecommendManager.deleteProductRecommend(productRecommendId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得商品推荐分页")
|
||||
public CommonResult<PageResult<ProductRecommendDetailVO>> pageProductRecommend(ProductRecommendPageReqVO pageVO) {
|
||||
return success(productRecommendManager.pageProductRecommend(pageVO));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品推荐创建 Request VO")
|
||||
@Data
|
||||
public class ProductRecommendCreateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "类型", example = "1", required = true, notes = "参见 ProductRecommendTypeEnum 枚举")
|
||||
@NotNull(message = "类型不能为空")
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "商品 Spu 编号", required = true, example = "1")
|
||||
@NotNull(message = "商品 Spu 编号不能为空")
|
||||
private Integer productSpuId;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", example = "我是备注")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("商品推荐明细 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendDetailVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "推荐类型", required = true, example = "1", notes = "参见 ProductRecommendTypeEnum 枚举")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "商品编号", required = true, example = "1")
|
||||
private Integer productSpuId;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "10")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", required = true, example = "这个活动很牛逼")
|
||||
private String memo;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 商品信息
|
||||
*/
|
||||
private Spu spu;
|
||||
|
||||
@ApiModel("商品信息")
|
||||
@Data
|
||||
public static class Spu {
|
||||
|
||||
@ApiModelProperty(value = "SPU 名字", required = true, example = "厮大牛逼")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("商品推荐分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProductRecommendPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "类型", example = "1", notes = "参见 ProductRecommendTypeEnum 枚举")
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
|
||||
private Integer type;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品推荐更新 Request VO")
|
||||
@Data
|
||||
public class ProductRecommendUpdateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "类型", example = "1", required = true, notes = "参见 ProductRecommendTypeEnum 枚举")
|
||||
@NotNull(message = "类型不能为空")
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "商品 Spu 编号", required = true, example = "1")
|
||||
@NotNull(message = "商品 Spu 编号不能为空")
|
||||
private Integer productSpuId;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", example = "我是备注")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.mall.managementweb.convert.promotion;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerCreateReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerPageReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerUpdateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface BannerConvert {
|
||||
|
||||
BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class);
|
||||
|
||||
BannerCreateReqDTO convert(BannerCreateReqVO bean);
|
||||
|
||||
BannerUpdateReqDTO convert(BannerUpdateReqVO bean);
|
||||
|
||||
BannerPageReqDTO convert(BannerPageReqVO bean);
|
||||
|
||||
PageResult<BannerRespVO> convertPage(PageResult<BannerRespDTO> page);
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.managementweb.convert.promotion.coupon;
|
||||
package cn.iocoder.mall.managementweb.convert.promotion;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardCreateReqVO;
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.mall.managementweb.convert.promotion;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendDetailVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendCreateReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendPageReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendUpdateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface ProductRecommendConvert {
|
||||
|
||||
ProductRecommendConvert INSTANCE = Mappers.getMapper(ProductRecommendConvert.class);
|
||||
|
||||
ProductRecommendCreateReqDTO convert(ProductRecommendCreateReqVO bean);
|
||||
|
||||
ProductRecommendUpdateReqDTO convert(ProductRecommendUpdateReqVO bean);
|
||||
|
||||
ProductRecommendPageReqDTO convert(ProductRecommendPageReqVO bean);
|
||||
|
||||
PageResult<ProductRecommendDetailVO> convertPage(PageResult<ProductRecommendRespDTO> page);
|
||||
|
||||
ProductRecommendDetailVO.Spu convert(ProductSpuRespDTO bean);
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.managementweb.convert.promotion.activity;
|
||||
package cn.iocoder.mall.managementweb.convert.promotion;
|
||||
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
|
@ -3,7 +3,7 @@ package cn.iocoder.mall.managementweb.manager.promotion.activity;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.activity.PromotionActivityConvert;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.PromotionActivityConvert;
|
||||
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
|
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.mall.managementweb.manager.promotion.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Banner Manager
|
||||
*/
|
||||
@Service
|
||||
public class BannerManager {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.BannerRpc.version}")
|
||||
private BannerRpc bannerRpc;
|
||||
|
||||
/**
|
||||
* 创建 Banner
|
||||
*
|
||||
* @param createVO 创建 Banner VO
|
||||
* @return Banner
|
||||
*/
|
||||
public Integer createBanner(BannerCreateReqVO createVO) {
|
||||
CommonResult<Integer> createBannerResult = bannerRpc.createBanner(BannerConvert.INSTANCE.convert(createVO));
|
||||
createBannerResult.checkError();
|
||||
return createBannerResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 Banner
|
||||
*
|
||||
* @param updateVO 更新 Banner VO
|
||||
*/
|
||||
public void updateBanner(BannerUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateBannerResult = bannerRpc.updateBanner(BannerConvert.INSTANCE.convert(updateVO));
|
||||
updateBannerResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 Banner
|
||||
*
|
||||
* @param bannerId Banner 编号
|
||||
*/
|
||||
public void deleteBanner(Integer bannerId) {
|
||||
CommonResult<Boolean> deleteBannerResult = bannerRpc.deleteBanner(bannerId);
|
||||
deleteBannerResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 Banner 分页
|
||||
*
|
||||
* @param pageVO Banner 分页查询
|
||||
* @return Banner 分页结果
|
||||
*/
|
||||
public PageResult<BannerRespVO> pageBanner(BannerPageReqVO pageVO) {
|
||||
CommonResult<PageResult<BannerRespDTO>> pageBannerResult = bannerRpc.pageBanner(BannerConvert.INSTANCE.convert(pageVO));
|
||||
pageBannerResult.checkError();
|
||||
return BannerConvert.INSTANCE.convertPage(pageBannerResult.getData());
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.Cou
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.coupon.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateStatusReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO;
|
||||
|
@ -0,0 +1,91 @@
|
||||
package cn.iocoder.mall.managementweb.manager.promotion.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.util.CollectionUtils;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendDetailVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品推荐 Manager
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductRecommendManager {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}")
|
||||
private ProductRecommendRpc productRecommendRpc;
|
||||
@DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
|
||||
private ProductSpuRpc productSpuRpc;
|
||||
|
||||
/**
|
||||
* 创建商品推荐
|
||||
*
|
||||
* @param createVO 创建商品推荐 VO
|
||||
* @return 商品推荐
|
||||
*/
|
||||
public Integer createProductRecommend(ProductRecommendCreateReqVO createVO) {
|
||||
CommonResult<Integer> createProductRecommendResult = productRecommendRpc.createProductRecommend(
|
||||
ProductRecommendConvert.INSTANCE.convert(createVO));
|
||||
createProductRecommendResult.checkError();
|
||||
return createProductRecommendResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品推荐
|
||||
*
|
||||
* @param updateVO 更新商品推荐 VO
|
||||
*/
|
||||
public void updateProductRecommend(ProductRecommendUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateProductRecommendResult = productRecommendRpc.updateProductRecommend(
|
||||
ProductRecommendConvert.INSTANCE.convert(updateVO));
|
||||
updateProductRecommendResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品推荐
|
||||
*
|
||||
* @param productRecommendId 商品推荐编号
|
||||
*/
|
||||
public void deleteProductRecommend(Integer productRecommendId) {
|
||||
CommonResult<Boolean> deleteProductRecommendResult = productRecommendRpc.deleteProductRecommend(productRecommendId);
|
||||
deleteProductRecommendResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品推荐分页
|
||||
*
|
||||
* @param pageVO 商品推荐分页查询
|
||||
* @return 商品推荐分页结果
|
||||
*/
|
||||
public PageResult<ProductRecommendDetailVO> pageProductRecommend(ProductRecommendPageReqVO pageVO) {
|
||||
CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommendResult = productRecommendRpc.pageProductRecommend(ProductRecommendConvert.INSTANCE.convert(pageVO));
|
||||
pageProductRecommendResult.checkError();
|
||||
// 拼接结果
|
||||
PageResult<ProductRecommendDetailVO> pageResult = ProductRecommendConvert.INSTANCE.convertPage(pageProductRecommendResult.getData());
|
||||
if (!CollectionUtils.isEmpty(pageResult.getList())) {
|
||||
// 获取商品信息,并进行拼接
|
||||
CommonResult<List<ProductSpuRespDTO>> listProductSpusResult = productSpuRpc.listProductSpus(
|
||||
CollectionUtils.convertSet(pageResult.getList(), ProductRecommendDetailVO::getProductSpuId));
|
||||
listProductSpusResult.checkError();
|
||||
Map<Integer, ProductSpuRespDTO> productSpuMap = CollectionUtils.convertMap(listProductSpusResult.getData(), ProductSpuRespDTO::getId);
|
||||
pageResult.getList().forEach(detailVO ->
|
||||
detailVO.setSpu(ProductRecommendConvert.INSTANCE.convert(productSpuMap.get(detailVO.getProductSpuId()))));
|
||||
}
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
}
|
@ -61,6 +61,10 @@ dubbo:
|
||||
version: 1.0.0
|
||||
PromotionActivityRpc:
|
||||
version: 1.0.0
|
||||
BannerRpc:
|
||||
version: 1.0.0
|
||||
ProductRecommendRpc:
|
||||
version: 1.0.0
|
||||
|
||||
# Swagger 配置项
|
||||
swagger:
|
||||
|
@ -1,28 +1,52 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerPageRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerAddReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerPageDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerUpdateReqDTO;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Banner Rpc 接口
|
||||
*/
|
||||
public interface BannerRpc {
|
||||
|
||||
List<BannerRespDTO> getBannerListByStatus(Integer status);
|
||||
/**
|
||||
* 创建 Banner
|
||||
*
|
||||
* @param createDTO 创建 Banner DTO
|
||||
* @return Banner 编号
|
||||
*/
|
||||
CommonResult<Integer> createBanner(BannerCreateReqDTO createDTO);
|
||||
|
||||
BannerPageRespDTO getBannerPage(BannerPageDTO bannerPageDTO);
|
||||
/**
|
||||
* 更新 Banner
|
||||
*
|
||||
* @param updateDTO 更新 Banner DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateBanner(BannerUpdateReqDTO updateDTO);
|
||||
|
||||
BannerRespDTO addBanner(Integer adminId, BannerAddReqDTO bannerAddDTO);
|
||||
/**
|
||||
* 删除 Banner
|
||||
*
|
||||
* @param bannerId Banner 编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteBanner(Integer bannerId);
|
||||
|
||||
Boolean updateBanner(Integer adminId, BannerUpdateReqDTO bannerUpdateDTO);
|
||||
/**
|
||||
* 获得 Banner 列表
|
||||
*
|
||||
* @param listDTO Banner 列表查询 DTO
|
||||
* @return Banner 列表
|
||||
*/
|
||||
CommonResult<List<BannerRespDTO>> listBanners(BannerListReqDTO listDTO);
|
||||
|
||||
Boolean updateBannerStatus(Integer adminId, Integer bannerId,
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status);
|
||||
|
||||
Boolean deleteBanner(Integer adminId, Integer bannerId);
|
||||
/**
|
||||
* 获得 Banner 分页
|
||||
*
|
||||
* @param pageDTO Banner 分页查询
|
||||
* @return Banner 分页结果
|
||||
*/
|
||||
CommonResult<PageResult<BannerRespDTO>> pageBanner(BannerPageReqDTO pageDTO);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@ -10,25 +12,46 @@ import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Banner 添加 DTO
|
||||
* Banner 创建 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerAddReqDTO implements Serializable {
|
||||
public class BannerCreateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
|
||||
private String title;
|
||||
/**
|
||||
* 跳转链接
|
||||
*/
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "跳转链接格式不正确")
|
||||
@Length(max = 255, message = "跳转链接最大长度为 255 位")
|
||||
private String url;
|
||||
/**
|
||||
* 图片链接
|
||||
*/
|
||||
@NotEmpty(message = "图片链接不能为空")
|
||||
@URL(message = "图片链接格式不正确")
|
||||
@Length(max = 255, message = "图片链接最大长度为 255 位")
|
||||
private String picUrl;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Banner 列表 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class BannerListReqDTO extends PageParam {
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Banner 分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerPageDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 标题,模糊匹配
|
||||
*/
|
||||
private String title;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Banner 分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class BannerPageReqDTO extends PageParam {
|
||||
|
||||
/**
|
||||
* 标题,模糊匹配
|
||||
*/
|
||||
private String title;
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Banner 分页 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerPageRespDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* Banner 数组
|
||||
*/
|
||||
private List<BannerRespDTO> list;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private Integer total;
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Banner BO
|
||||
* Banner Response DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.banner.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@ -10,27 +12,51 @@ import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Banner 更新 DTO
|
||||
* Banner 更新 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerUpdateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
|
||||
private String title;
|
||||
/**
|
||||
* 跳转链接
|
||||
*/
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "跳转链接格式不正确")
|
||||
@Length(max = 255, message = "跳转链接最大长度为 255 位")
|
||||
private String url;
|
||||
/**
|
||||
* 图片链接
|
||||
*/
|
||||
@NotEmpty(message = "图片链接不能为空")
|
||||
@URL(message = "图片链接格式不正确")
|
||||
@Length(max = 255, message = "图片链接最大长度为 255 位")
|
||||
private String picUrl;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
||||
|
@ -1,24 +1,52 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.exception.ServiceException;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品推荐 Rpc 接口
|
||||
*/
|
||||
public interface ProductRecommendRpc {
|
||||
|
||||
List<ProductRecommendRespDTO> getProductRecommendList(Integer type, Integer status);
|
||||
/**
|
||||
* 创建商品推荐
|
||||
*
|
||||
* @param createDTO 创建商品推荐 DTO
|
||||
* @return 商品推荐编号
|
||||
*/
|
||||
CommonResult<Integer> createProductRecommend(ProductRecommendCreateReqDTO createDTO);
|
||||
|
||||
ProductRecommendPageRespDTO getProductRecommendPage(ProductRecommendPageReqDTO productRecommendPageDTO);
|
||||
/**
|
||||
* 更新商品推荐
|
||||
*
|
||||
* @param updateDTO 更新商品推荐 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateProductRecommend(ProductRecommendUpdateReqDTO updateDTO);
|
||||
|
||||
ProductRecommendRespDTO addProductRecommend(Integer adminId, ProductRecommendAddReqDTO productRecommendAddDTO) throws ServiceException;
|
||||
/**
|
||||
* 删除商品推荐
|
||||
*
|
||||
* @param productRecommendId 商品推荐编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteProductRecommend(Integer productRecommendId);
|
||||
|
||||
Boolean updateProductRecommend(Integer adminId, ProductRecommendUpdateReqDTO productRecommendUpdateDTO) throws ServiceException;
|
||||
/**
|
||||
* 获得商品推荐列表
|
||||
*
|
||||
* @param listReqDTO 商品推荐列表查询 DTO
|
||||
* @return 商品推荐列表
|
||||
*/
|
||||
CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(ProductRecommendListReqDTO listReqDTO);
|
||||
|
||||
Boolean updateProductRecommendStatus(Integer adminId, Integer productRecommendId,
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status) throws ServiceException;
|
||||
|
||||
Boolean deleteProductRecommend(Integer adminId, Integer productRecommendId);
|
||||
/**
|
||||
* 获得商品推荐分页
|
||||
*
|
||||
* @param pageDTO 商品推荐分页查询
|
||||
* @return 商品推荐分页结果
|
||||
*/
|
||||
CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(ProductRecommendPageReqDTO pageDTO);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
@ -10,19 +11,37 @@ import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐添加 DTO
|
||||
* 商品推荐创建 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendAddReqDTO implements Serializable {
|
||||
public class ProductRecommendCreateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 推荐类型
|
||||
*/
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "修改推荐类型必须是 {value}")
|
||||
@NotNull(message = "推荐类型不能为空")
|
||||
private Integer type;
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Integer productSpuId;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐列表 Req DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendListReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
|
||||
private Integer type;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,26 +1,24 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐分页 DTO
|
||||
* 商品推荐分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendPageReqDTO implements Serializable {
|
||||
public class ProductRecommendPageReqDTO extends PageParam {
|
||||
|
||||
/**
|
||||
* 推荐类型
|
||||
*/
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
|
||||
private Integer type;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品推荐分页 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendPageRespDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* ProductRecommend 数组
|
||||
*/
|
||||
private List<ProductRecommendRespDTO> list;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private Integer total;
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
@ -10,21 +11,42 @@ import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐更新 DTO
|
||||
* 商品推荐更新 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendUpdateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@NotNull(message = "类型不能为空")
|
||||
/**
|
||||
* 推荐类型
|
||||
*/
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "修改推荐类型必须是 {value}")
|
||||
@NotNull(message = "推荐类型不能为空")
|
||||
private Integer type;
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Integer productSpuId;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package cn.iocoder.mall.promotionservice.convert.banner;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerCreateReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerUpdateReqDTO;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.banner.BannerDO;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerAddBO;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,16 +17,13 @@ public interface BannerConvert {
|
||||
|
||||
BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
BannerBO convertToBO(BannerDO banner);
|
||||
BannerDO convert(BannerCreateReqDTO bean);
|
||||
|
||||
@Mappings({})
|
||||
List<BannerBO> convertToBO(List<BannerDO> bannerList);
|
||||
BannerDO convert(BannerUpdateReqDTO bean);
|
||||
|
||||
@Mappings({})
|
||||
BannerDO convert(BannerAddBO bannerAddDTO);
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<BannerRespDTO> convertPage(IPage<BannerDO> page);
|
||||
|
||||
@Mappings({})
|
||||
BannerDO convert(BannerUpdateBO bannerUpdateDTO);
|
||||
List<BannerRespDTO> convertList(List<BannerDO> list);
|
||||
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package cn.iocoder.mall.promotionservice.convert.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendCreateReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendUpdateReqDTO;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend.ProductRecommendDO;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.bo.ProductRecommendAddBO;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.bo.ProductRecommendBO;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.bo.ProductRecommendUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,19 +17,13 @@ public interface ProductRecommendConvert {
|
||||
|
||||
ProductRecommendConvert INSTANCE = Mappers.getMapper(ProductRecommendConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
ProductRecommendBO convertToBO(ProductRecommendDO recommend);
|
||||
List<ProductRecommendRespDTO> convertList(List<ProductRecommendDO> list);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductRecommendBO> convertToBO(List<ProductRecommendDO> recommendList);
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<ProductRecommendRespDTO> convertPage(IPage<ProductRecommendDO> page);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductRecommendRespDTO> convertToDTO(List<ProductRecommendDO> recommendList);
|
||||
ProductRecommendDO convert(ProductRecommendCreateReqDTO bean);
|
||||
|
||||
@Mappings({})
|
||||
ProductRecommendDO convert(ProductRecommendAddBO recommendAddDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductRecommendDO convert(ProductRecommendUpdateBO recommendUpdateDTO);
|
||||
ProductRecommendDO convert(ProductRecommendUpdateReqDTO bean);
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,17 @@
|
||||
package cn.iocoder.mall.promotionservice.dal.mysql.dataobject.banner;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Banner 广告页
|
||||
*/
|
||||
@TableName("banner")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class BannerDO extends DeletableDO {
|
||||
|
||||
|
@ -3,12 +3,14 @@ package cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 商品推荐 DO
|
||||
*/
|
||||
@TableName("product_recommend")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendDO extends DeletableDO {
|
||||
|
@ -1,26 +1,26 @@
|
||||
package cn.iocoder.mall.promotionservice.dal.mysql.mapper.banner;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerListReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerPageReqDTO;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.banner.BannerDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface BannerMapper {
|
||||
public interface BannerMapper extends BaseMapper<BannerDO> {
|
||||
|
||||
BannerDO selectById(@Param("id") Integer id);
|
||||
default List<BannerDO> selectList(BannerListReqDTO listReqDTO) {
|
||||
return selectList(new QueryWrapperX<BannerDO>().eqIfPresent("status", listReqDTO.getStatus()));
|
||||
}
|
||||
|
||||
List<BannerDO> selectListByStatus(@Param("status") Integer status);
|
||||
|
||||
List<BannerDO> selectListByTitleLike(@Param("title") String title,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByTitleLike(@Param("title") String title);
|
||||
|
||||
void insert(BannerDO bannerDO);
|
||||
|
||||
int update(BannerDO bannerDO);
|
||||
default IPage<BannerDO> selectPage(BannerPageReqDTO pageReqDTO) {
|
||||
return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()),
|
||||
new QueryWrapperX<BannerDO>().likeIfPresent("title", pageReqDTO.getTitle()));
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +1,33 @@
|
||||
package cn.iocoder.mall.promotionservice.dal.mysql.mapper.recommend;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendListReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendPageReqDTO;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend.ProductRecommendDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductRecommendMapper {
|
||||
public interface ProductRecommendMapper extends BaseMapper<ProductRecommendDO> {
|
||||
|
||||
ProductRecommendDO selectById(@Param("id") Integer id);
|
||||
default ProductRecommendDO selectByProductSpuIdAndType(Integer productSpuId, Integer type) {
|
||||
return selectOne(new QueryWrapper<ProductRecommendDO>().eq("product_spu_id", productSpuId)
|
||||
.eq("type", type));
|
||||
}
|
||||
|
||||
ProductRecommendDO selectByProductSpuIdAndType(@Param("productSpuId") Integer productSpuId,
|
||||
@Param("type") Integer type);
|
||||
default List<ProductRecommendDO> selectList(ProductRecommendListReqDTO listReqDTO) {
|
||||
return selectList(new QueryWrapperX<ProductRecommendDO>().eqIfPresent("type", listReqDTO.getType())
|
||||
.eqIfPresent("status", listReqDTO.getStatus()));
|
||||
}
|
||||
|
||||
List<ProductRecommendDO> selectListByTypeAndStatus(@Param("type") Integer type,
|
||||
@Param("status") Integer status);
|
||||
|
||||
List<ProductRecommendDO> selectPageByType(@Param("type") Integer type,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByType(@Param("type") Integer type);
|
||||
|
||||
void insert(ProductRecommendDO bannerDO);
|
||||
|
||||
int update(ProductRecommendDO bannerDO);
|
||||
default IPage<ProductRecommendDO> selectPage(ProductRecommendPageReqDTO pageReqDTO) {
|
||||
return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()),
|
||||
new QueryWrapperX<ProductRecommendDO>().eqIfPresent("type", pageReqDTO.getType()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.mall.promotionservice.manager.banner;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.BannerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Banner Manager
|
||||
*/
|
||||
@Service
|
||||
@Valid
|
||||
public class BannerManager {
|
||||
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
public Integer createBanner(BannerCreateReqDTO createDTO) {
|
||||
return bannerService.createBanner(createDTO);
|
||||
}
|
||||
|
||||
public void updateBanner(BannerUpdateReqDTO updateDTO) {
|
||||
bannerService.updateBanner(updateDTO);
|
||||
}
|
||||
|
||||
public void deleteBanner(Integer bannerId) {
|
||||
bannerService.deleteBanner(bannerId);
|
||||
}
|
||||
|
||||
public List<BannerRespDTO> listBanners(BannerListReqDTO listDTO) {
|
||||
return bannerService.listBanners(listDTO);
|
||||
}
|
||||
|
||||
public PageResult<BannerRespDTO> pageBanner(BannerPageReqDTO pageDTO) {
|
||||
return bannerService.pageBanner(pageDTO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package cn.iocoder.mall.promotionservice.manager.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.ProductRecommendService;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 商品推荐 Manager
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductRecommendManager {
|
||||
|
||||
@DubboReference(validation = "true", version = "${dubbo.consumer.ProductSpuRpc.version}")
|
||||
private ProductSpuRpc productSpuRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductRecommendService productRecommendService;
|
||||
|
||||
public List<ProductRecommendRespDTO> listProductRecommends(ProductRecommendListReqDTO listReqDTO) {
|
||||
return productRecommendService.listProductRecommends(listReqDTO);
|
||||
}
|
||||
|
||||
public PageResult<ProductRecommendRespDTO> pageProductRecommend(ProductRecommendPageReqDTO pageReqDTO) {
|
||||
return productRecommendService.pageProductRecommend(pageReqDTO);
|
||||
}
|
||||
|
||||
public Integer createProductRecommend(ProductRecommendCreateReqDTO createReqDTO) {
|
||||
// 校验商品不存在
|
||||
checkProductSpu(createReqDTO.getProductSpuId());
|
||||
// 创建商品推荐
|
||||
return productRecommendService.createProductRecommend(createReqDTO);
|
||||
}
|
||||
|
||||
public void updateProductRecommend(ProductRecommendUpdateReqDTO updateReqDTO) {
|
||||
// 校验商品不存在
|
||||
checkProductSpu(updateReqDTO.getProductSpuId());
|
||||
// 更新商品推荐
|
||||
productRecommendService.updateProductRecommend(updateReqDTO);
|
||||
}
|
||||
|
||||
public void deleteProductRecommend(Integer productRecommendId) {
|
||||
productRecommendService.deleteProductRecommend(productRecommendId);
|
||||
}
|
||||
|
||||
private void checkProductSpu(Integer productSpuId) {
|
||||
CommonResult<ProductSpuRespDTO> getProductSpuResult = productSpuRpc.getProductSpu(productSpuId);
|
||||
getProductSpuResult.checkError();
|
||||
if (getProductSpuResult.getData() == null) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.mall.promotionservice.rpc.banner;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
|
||||
import cn.iocoder.mall.promotionservice.manager.banner.BannerManager;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@DubboService
|
||||
public class BannerRpcImpl implements BannerRpc {
|
||||
|
||||
@Autowired
|
||||
private BannerManager bannerManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createBanner(BannerCreateReqDTO createDTO) {
|
||||
return success(bannerManager.createBanner(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateBanner(BannerUpdateReqDTO updateDTO) {
|
||||
bannerManager.updateBanner(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteBanner(Integer bannerId) {
|
||||
bannerManager.deleteBanner(bannerId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<BannerRespDTO>> listBanners(BannerListReqDTO listDTO) {
|
||||
return success(bannerManager.listBanners(listDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<BannerRespDTO>> pageBanner(BannerPageReqDTO pageDTO) {
|
||||
return success(bannerManager.pageBanner(pageDTO));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.mall.promotionservice.rpc.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
|
||||
import cn.iocoder.mall.promotionservice.manager.recommend.ProductRecommendManager;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@DubboService
|
||||
public class ProductRecommendRpcImpl implements ProductRecommendRpc {
|
||||
|
||||
@Autowired
|
||||
private ProductRecommendManager productRecommendManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createProductRecommend(ProductRecommendCreateReqDTO createDTO) {
|
||||
return success(productRecommendManager.createProductRecommend(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateProductRecommend(ProductRecommendUpdateReqDTO updateDTO) {
|
||||
productRecommendManager.updateProductRecommend(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteProductRecommend(Integer productRecommendId) {
|
||||
productRecommendManager.deleteProductRecommend(productRecommendId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(ProductRecommendListReqDTO listReqDTO) {
|
||||
return success(productRecommendManager.listProductRecommends(listReqDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(ProductRecommendPageReqDTO pageDTO) {
|
||||
return success(productRecommendManager.pageProductRecommend(pageDTO));
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +1,20 @@
|
||||
package cn.iocoder.mall.promotionservice.service.banner;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.mybatis.core.enums.DeletedStatusEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerPageDTO;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
|
||||
import cn.iocoder.mall.promotionservice.convert.banner.BannerConvert;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.banner.BannerDO;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.mapper.banner.BannerMapper;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerAddBO;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotionservice.service.banner.bo.BannerUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.BANNER_NOT_EXISTS;
|
||||
|
||||
|
||||
@Service
|
||||
@ -26,66 +24,69 @@ public class BannerService {
|
||||
@Autowired
|
||||
private BannerMapper bannerMapper;
|
||||
|
||||
public List<BannerBO> getBannerListByStatus(Integer status) {
|
||||
List<BannerDO> banners = bannerMapper.selectListByStatus(status);
|
||||
return BannerConvert.INSTANCE.convertToBO(banners);
|
||||
/**
|
||||
* 获得 Banner 列表
|
||||
*
|
||||
* @param listReqDTO Banner 列表查询
|
||||
* @return Banner 列表
|
||||
*/
|
||||
public List<BannerRespDTO> listBanners(BannerListReqDTO listReqDTO) {
|
||||
List<BannerDO> banners = bannerMapper.selectList(listReqDTO);
|
||||
return BannerConvert.INSTANCE.convertList(banners);
|
||||
}
|
||||
|
||||
public BannerPageBO getBannerPage(BannerPageDTO bannerPageDTO) {
|
||||
BannerPageBO bannerPageBO = new BannerPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (bannerPageDTO.getPageNo() - 1) * bannerPageDTO.getPageSize();
|
||||
bannerPageBO.setList(BannerConvert.INSTANCE.convertToBO(bannerMapper.selectListByTitleLike(bannerPageDTO.getTitle(),
|
||||
offset, bannerPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
bannerPageBO.setTotal(bannerMapper.selectCountByTitleLike(bannerPageDTO.getTitle()));
|
||||
return bannerPageBO;
|
||||
/**
|
||||
* 获得 Banner 分页
|
||||
*
|
||||
* @param bannerPageDTO Banner 分页查询
|
||||
* @return Banner 分页结果
|
||||
*/
|
||||
public PageResult<BannerRespDTO> pageBanner(BannerPageReqDTO bannerPageDTO) {
|
||||
IPage<BannerDO> bannerPage = bannerMapper.selectPage(bannerPageDTO);
|
||||
return BannerConvert.INSTANCE.convertPage(bannerPage);
|
||||
}
|
||||
|
||||
public BannerBO addBanner(Integer adminId, BannerAddBO bannerAddDTO) {
|
||||
// 保存到数据库
|
||||
BannerDO banner = BannerConvert.INSTANCE.convert(bannerAddDTO).setStatus(CommonStatusEnum.ENABLE.getValue());
|
||||
banner.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()).setCreateTime(new Date());
|
||||
bannerMapper.insert(banner);
|
||||
// 返回成功
|
||||
return BannerConvert.INSTANCE.convertToBO(banner);
|
||||
/**
|
||||
* 创建 Banner
|
||||
*
|
||||
* @param createReqDTO 创建 Banner 信息
|
||||
* @return banner
|
||||
*/
|
||||
public Integer createBanner(@Valid BannerCreateReqDTO createReqDTO) {
|
||||
// 插入到数据库
|
||||
BannerDO bannerDO = BannerConvert.INSTANCE.convert(createReqDTO);
|
||||
bannerMapper.insert(bannerDO);
|
||||
// 返回
|
||||
return bannerDO.getId();
|
||||
}
|
||||
|
||||
public Boolean updateBanner(Integer adminId, BannerUpdateBO bannerUpdateDTO) {
|
||||
// 校验 Banner 存在
|
||||
if (bannerMapper.selectById(bannerUpdateDTO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.BANNER_NOT_EXISTS.getCode());
|
||||
/**
|
||||
* 更新 Banner
|
||||
*
|
||||
* @param updateReqDTO 更新 Banner 信息
|
||||
*/
|
||||
public void updateBanner(@Valid BannerUpdateReqDTO updateReqDTO) {
|
||||
// 校验更新的 Banner 是否存在
|
||||
if (bannerMapper.selectById(updateReqDTO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(BANNER_NOT_EXISTS);
|
||||
}
|
||||
// 更新到数据库
|
||||
BannerDO updateBanner = BannerConvert.INSTANCE.convert(bannerUpdateDTO);
|
||||
bannerMapper.update(updateBanner);
|
||||
// 返回成功
|
||||
return true;
|
||||
BannerDO updateObject = BannerConvert.INSTANCE.convert(updateReqDTO);
|
||||
bannerMapper.updateById(updateObject);
|
||||
}
|
||||
|
||||
public Boolean updateBannerStatus(Integer adminId, Integer bannerId, Integer status) {
|
||||
/**
|
||||
* 删除 Banner
|
||||
*
|
||||
* @param bannerId Banner 编号
|
||||
*/
|
||||
public void deleteBanner(Integer bannerId) {
|
||||
// 校验 Banner 存在
|
||||
if (bannerMapper.selectById(bannerId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.BANNER_NOT_EXISTS.getCode());
|
||||
throw ServiceExceptionUtil.exception(BANNER_NOT_EXISTS);
|
||||
}
|
||||
// 更新到数据库
|
||||
BannerDO updateBanner = new BannerDO().setId(bannerId).setStatus(status);
|
||||
bannerMapper.update(updateBanner);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean deleteBanner(Integer adminId, Integer bannerId) {
|
||||
// 校验 Banner 存在
|
||||
if (bannerMapper.selectById(bannerId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.BANNER_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
BannerDO updateBanner = new BannerDO().setId(bannerId);
|
||||
updateBanner.setDeleted(DeletedStatusEnum.DELETED_YES.getValue());
|
||||
bannerMapper.update(updateBanner);
|
||||
// 返回成功
|
||||
return true;
|
||||
bannerMapper.deleteById(bannerId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.banner.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Banner 添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerAddBO implements Serializable {
|
||||
|
||||
@NotEmpty(message = "标题不能为空")
|
||||
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
|
||||
private String title;
|
||||
@NotEmpty(message = "跳转链接不能为空")
|
||||
@URL(message = "跳转链接格式不正确")
|
||||
@Length(max = 255, message = "跳转链接最大长度为 255 位")
|
||||
private String url;
|
||||
@NotEmpty(message = "图片链接不能为空")
|
||||
@URL(message = "图片链接格式不正确")
|
||||
@Length(max = 255, message = "图片链接最大长度为 255 位")
|
||||
private String picUrl;
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.banner.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Banner BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 跳转链接
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 图片链接
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String memo;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.banner.bo;
|
||||
|
||||
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Banner 分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BannerPageBO implements Serializable {
|
||||
|
||||
/**
|
||||
* Banner 数组
|
||||
*/
|
||||
private List<BannerBO> list;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private Integer total;
|
||||
}
|
@ -1,113 +1,93 @@
|
||||
package cn.iocoder.mall.promotionservice.service.recommend;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.mybatis.core.enums.DeletedStatusEnum;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
|
||||
import cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendPageReqDTO;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendPageRespDTO;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
|
||||
import cn.iocoder.mall.promotionservice.convert.recommend.ProductRecommendConvert;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend.ProductRecommendDO;
|
||||
import cn.iocoder.mall.promotionservice.dal.mysql.mapper.recommend.ProductRecommendMapper;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.bo.ProductRecommendAddBO;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.bo.ProductRecommendBO;
|
||||
import cn.iocoder.mall.promotionservice.service.recommend.bo.ProductRecommendUpdateBO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PRODUCT_RECOMMEND_EXISTS;
|
||||
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PRODUCT_RECOMMEND_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 商品推荐 Service
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductRecommendService {
|
||||
|
||||
@DubboReference(validation = "true", version = "${dubbo.consumer.ProductSpuRpc.version}")
|
||||
private ProductSpuRpc productSpuRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductRecommendMapper productRecommendMapper;
|
||||
|
||||
public List<ProductRecommendBO> getProductRecommendList(Integer type, Integer status) {
|
||||
List<ProductRecommendDO> productRecommends = productRecommendMapper.selectListByTypeAndStatus(type, status);
|
||||
return ProductRecommendConvert.INSTANCE.convertToBO(productRecommends);
|
||||
/**
|
||||
* 获得商品推荐列表
|
||||
*
|
||||
* @param listReqDTO 列表查询 DTO
|
||||
* @return 商品推荐列表
|
||||
*/
|
||||
public List<ProductRecommendRespDTO> listProductRecommends(ProductRecommendListReqDTO listReqDTO) {
|
||||
List<ProductRecommendDO> productRecommends = productRecommendMapper.selectList(listReqDTO);
|
||||
return ProductRecommendConvert.INSTANCE.convertList(productRecommends);
|
||||
}
|
||||
|
||||
public ProductRecommendPageRespDTO getProductRecommendPage(ProductRecommendPageReqDTO productRecommendPageDTO) {
|
||||
ProductRecommendPageRespDTO productRecommendPageBO = new ProductRecommendPageRespDTO();
|
||||
// 查询分页数据
|
||||
int offset = (productRecommendPageDTO.getPageNo() - 1) * productRecommendPageDTO.getPageSize();
|
||||
productRecommendPageBO.setList(ProductRecommendConvert.INSTANCE.convertToDTO(productRecommendMapper.selectPageByType(productRecommendPageDTO.getType(),
|
||||
offset, productRecommendPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
productRecommendPageBO.setTotal(productRecommendMapper.selectCountByType(productRecommendPageDTO.getType()));
|
||||
return productRecommendPageBO;
|
||||
/**
|
||||
* 获得商品推荐分页
|
||||
*
|
||||
* @param pageReqDTO 分页查询 DTO
|
||||
* @return 商品推荐分页
|
||||
*/
|
||||
public PageResult<ProductRecommendRespDTO> pageProductRecommend(ProductRecommendPageReqDTO pageReqDTO) {
|
||||
IPage<ProductRecommendDO> productRecommendPage = productRecommendMapper.selectPage(pageReqDTO);
|
||||
return ProductRecommendConvert.INSTANCE.convertPage(productRecommendPage);
|
||||
}
|
||||
|
||||
public ProductRecommendBO addProductRecommend(Integer adminId, ProductRecommendAddBO productRecommendAddDTO) {
|
||||
// 校验商品不存在
|
||||
if (productSpuRpc.getProductSpu(productRecommendAddDTO.getProductSpuId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS.getCode());
|
||||
}
|
||||
/**
|
||||
* 创建商品推荐
|
||||
*
|
||||
* @param createReqDTO 商品推荐信息
|
||||
* @return 商品推荐编号
|
||||
*/
|
||||
public Integer createProductRecommend(ProductRecommendCreateReqDTO createReqDTO) {
|
||||
// 校验商品是否已经推荐
|
||||
if (productRecommendMapper.selectByProductSpuIdAndType(productRecommendAddDTO.getProductSpuId(), productRecommendAddDTO.getType()) != null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_EXISTS.getCode());
|
||||
if (productRecommendMapper.selectByProductSpuIdAndType(createReqDTO.getProductSpuId(), createReqDTO.getType()) != null) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_EXISTS);
|
||||
}
|
||||
// 保存到数据库
|
||||
ProductRecommendDO productRecommend = ProductRecommendConvert.INSTANCE.convert(productRecommendAddDTO).setStatus(CommonStatusEnum.ENABLE.getValue());
|
||||
productRecommend.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()).setCreateTime(new Date());
|
||||
ProductRecommendDO productRecommend = ProductRecommendConvert.INSTANCE.convert(createReqDTO);
|
||||
productRecommendMapper.insert(productRecommend);
|
||||
// 返回成功
|
||||
return ProductRecommendConvert.INSTANCE.convertToBO(productRecommend);
|
||||
return productRecommend.getId();
|
||||
}
|
||||
|
||||
public Boolean updateProductRecommend(Integer adminId, ProductRecommendUpdateBO productRecommendUpdateDTO) {
|
||||
public void updateProductRecommend(ProductRecommendUpdateReqDTO updateReqDTO) {
|
||||
// 校验更新的商品推荐存在
|
||||
if (productRecommendMapper.selectById(productRecommendUpdateDTO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 校验商品不存在
|
||||
if (productSpuRpc.getProductSpu(productRecommendUpdateDTO.getProductSpuId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS.getCode());
|
||||
if (productRecommendMapper.selectById(updateReqDTO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_NOT_EXISTS);
|
||||
}
|
||||
// 校验商品是否已经推荐
|
||||
ProductRecommendDO existProductRecommend = productRecommendMapper.selectByProductSpuIdAndType(productRecommendUpdateDTO.getProductSpuId(), productRecommendUpdateDTO.getType());
|
||||
if (existProductRecommend != null && !existProductRecommend.getId().equals(productRecommendUpdateDTO.getId())) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_EXISTS.getCode());
|
||||
ProductRecommendDO existProductRecommend = productRecommendMapper.selectByProductSpuIdAndType(updateReqDTO.getProductSpuId(), updateReqDTO.getType());
|
||||
if (existProductRecommend != null && !existProductRecommend.getId().equals(updateReqDTO.getId())) {
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductRecommendDO updateProductRecommend = ProductRecommendConvert.INSTANCE.convert(productRecommendUpdateDTO);
|
||||
productRecommendMapper.update(updateProductRecommend);
|
||||
// 返回成功
|
||||
return true;
|
||||
ProductRecommendDO updateProductRecommend = ProductRecommendConvert.INSTANCE.convert(updateReqDTO);
|
||||
productRecommendMapper.updateById(updateProductRecommend);
|
||||
}
|
||||
|
||||
public Boolean updateProductRecommendStatus(Integer adminId, Integer productRecommendId, Integer status) {
|
||||
public void deleteProductRecommend(Integer productRecommendId) {
|
||||
// 校验更新的商品推荐存在
|
||||
if (productRecommendMapper.selectById(productRecommendId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_NOT_EXISTS.getCode());
|
||||
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_NOT_EXISTS);
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductRecommendDO updateProductRecommend = new ProductRecommendDO().setId(productRecommendId).setStatus(status);
|
||||
productRecommendMapper.update(updateProductRecommend);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean deleteProductRecommend(Integer adminId, Integer productRecommendId) {
|
||||
// 校验更新的商品推荐存在
|
||||
if (productRecommendMapper.selectById(productRecommendId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.PRODUCT_RECOMMEND_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductRecommendDO updateProductRecommend = new ProductRecommendDO().setId(productRecommendId);
|
||||
updateProductRecommend.setDeleted(DeletedStatusEnum.DELETED_YES.getValue());
|
||||
productRecommendMapper.update(updateProductRecommend);
|
||||
// 返回成功
|
||||
return true;
|
||||
productRecommendMapper.deleteById(productRecommendId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.recommend.bo;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendAddBO implements Serializable {
|
||||
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "修改推荐类型必须是 {value}")
|
||||
@NotNull(message = "推荐类型不能为空")
|
||||
private Integer type;
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Integer productSpuId;
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.recommend.bo;
|
||||
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品推荐 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 类型
|
||||
*
|
||||
* {@link ProductRecommendTypeEnum}
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 商品 Spu 编号
|
||||
*/
|
||||
private Integer productSpuId;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* {@link cn.iocoder.common.framework.enums.CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String memo;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.recommend.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendPageBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 推荐类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package cn.iocoder.mall.promotionservice.service.recommend.bo;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品推荐更新 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductRecommendUpdateBO implements Serializable {
|
||||
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@NotNull(message = "类型不能为空")
|
||||
@InEnum(value = ProductRecommendTypeEnum.class, message = "修改推荐类型必须是 {value}")
|
||||
private Integer type;
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Integer productSpuId;
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@Length(max = 255, message = "备注最大长度为 255 位")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.biz.dataobject.BannerDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BannerConvert {
|
||||
|
||||
BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
BannerBO convertToBO(BannerDO banner);
|
||||
|
||||
@Mappings({})
|
||||
List<BannerBO> convertToBO(List<BannerDO> bannerList);
|
||||
|
||||
@Mappings({})
|
||||
BannerDO convert(BannerAddDTO bannerAddDTO);
|
||||
|
||||
@Mappings({})
|
||||
BannerDO convert(BannerUpdateDTO bannerUpdateDTO);
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO;
|
||||
import cn.iocoder.mall.promotion.api.dto.ProductRecommendAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.ProductRecommendUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.biz.dataobject.ProductRecommendDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductRecommendConvert {
|
||||
|
||||
ProductRecommendConvert INSTANCE = Mappers.getMapper(ProductRecommendConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
ProductRecommendBO convertToBO(ProductRecommendDO recommend);
|
||||
|
||||
@Mappings({})
|
||||
List<ProductRecommendBO> convertToBO(List<ProductRecommendDO> recommendList);
|
||||
|
||||
@Mappings({})
|
||||
ProductRecommendDO convert(ProductRecommendAddDTO recommendAddDTO);
|
||||
|
||||
@Mappings({})
|
||||
ProductRecommendDO convert(ProductRecommendUpdateDTO recommendUpdateDTO);
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.biz.dao;
|
||||
|
||||
import cn.iocoder.mall.promotion.biz.dataobject.BannerDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface BannerMapper {
|
||||
|
||||
BannerDO selectById(@Param("id") Integer id);
|
||||
|
||||
List<BannerDO> selectListByStatus(@Param("status") Integer status);
|
||||
|
||||
List<BannerDO> selectListByTitleLike(@Param("title") String title,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByTitleLike(@Param("title") String title);
|
||||
|
||||
void insert(BannerDO bannerDO);
|
||||
|
||||
int update(BannerDO bannerDO);
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.biz.dao;
|
||||
|
||||
import cn.iocoder.mall.promotion.biz.dataobject.ProductRecommendDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductRecommendMapper {
|
||||
|
||||
ProductRecommendDO selectById(@Param("id") Integer id);
|
||||
|
||||
ProductRecommendDO selectByProductSpuIdAndType(@Param("productSpuId") Integer productSpuId,
|
||||
@Param("type") Integer type);
|
||||
|
||||
List<ProductRecommendDO> selectListByTypeAndStatus(@Param("type") Integer type,
|
||||
@Param("status") Integer status);
|
||||
|
||||
List<ProductRecommendDO> selectPageByType(@Param("type") Integer type,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByType(@Param("type") Integer type);
|
||||
|
||||
void insert(ProductRecommendDO bannerDO);
|
||||
|
||||
int update(ProductRecommendDO bannerDO);
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.biz.service;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.mybatis.core.enums.DeletedStatusEnum;
|
||||
import cn.iocoder.mall.promotion.api.BannerService;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeEnum;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerPageDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.biz.convert.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.biz.dao.BannerMapper;
|
||||
import cn.iocoder.mall.promotion.biz.dataobject.BannerDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.BannerService.version}")
|
||||
public class BannerServiceImpl implements BannerService {
|
||||
|
||||
@Autowired
|
||||
private BannerMapper bannerMapper;
|
||||
|
||||
@Override
|
||||
public List<BannerBO> getBannerListByStatus(Integer status) {
|
||||
List<BannerDO> banners = bannerMapper.selectListByStatus(status);
|
||||
return BannerConvert.INSTANCE.convertToBO(banners);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BannerPageBO getBannerPage(BannerPageDTO bannerPageDTO) {
|
||||
BannerPageBO bannerPageBO = new BannerPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (bannerPageDTO.getPageNo() - 1) * bannerPageDTO.getPageSize();
|
||||
bannerPageBO.setList(BannerConvert.INSTANCE.convertToBO(bannerMapper.selectListByTitleLike(bannerPageDTO.getTitle(),
|
||||
offset, bannerPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
bannerPageBO.setTotal(bannerMapper.selectCountByTitleLike(bannerPageDTO.getTitle()));
|
||||
return bannerPageBO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BannerBO addBanner(Integer adminId, BannerAddDTO bannerAddDTO) {
|
||||
// 保存到数据库
|
||||
BannerDO banner = BannerConvert.INSTANCE.convert(bannerAddDTO).setStatus(CommonStatusEnum.ENABLE.getValue());
|
||||
banner.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()).setCreateTime(new Date());
|
||||
bannerMapper.insert(banner);
|
||||
// 返回成功
|
||||
return BannerConvert.INSTANCE.convertToBO(banner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateBanner(Integer adminId, BannerUpdateDTO bannerUpdateDTO) {
|
||||
// 校验 Banner 存在
|
||||
if (bannerMapper.selectById(bannerUpdateDTO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.BANNER_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
BannerDO updateBanner = BannerConvert.INSTANCE.convert(bannerUpdateDTO);
|
||||
bannerMapper.update(updateBanner);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateBannerStatus(Integer adminId, Integer bannerId, Integer status) {
|
||||
// 校验 Banner 存在
|
||||
if (bannerMapper.selectById(bannerId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.BANNER_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
BannerDO updateBanner = new BannerDO().setId(bannerId).setStatus(status);
|
||||
bannerMapper.update(updateBanner);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteBanner(Integer adminId, Integer bannerId) {
|
||||
// 校验 Banner 存在
|
||||
if (bannerMapper.selectById(bannerId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.BANNER_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
BannerDO updateBanner = new BannerDO().setId(bannerId);
|
||||
updateBanner.setDeleted(DeletedStatusEnum.DELETED_YES.getValue());
|
||||
bannerMapper.update(updateBanner);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.biz.service;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.mybatis.core.enums.DeletedStatusEnum;
|
||||
import cn.iocoder.mall.product.rpc.api.ProductSpuRpc;
|
||||
import cn.iocoder.mall.promotion.api.ProductRecommendService;
|
||||
import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.ProductRecommendPageBO;
|
||||
import cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeEnum;
|
||||
import cn.iocoder.mall.promotion.api.dto.ProductRecommendAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.ProductRecommendPageDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.ProductRecommendUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.biz.convert.ProductRecommendConvert;
|
||||
import cn.iocoder.mall.promotion.biz.dao.ProductRecommendMapper;
|
||||
import cn.iocoder.mall.promotion.biz.dataobject.ProductRecommendDO;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.ProductRecommendService.version}")
|
||||
public class ProductRecommendServiceImpl implements ProductRecommendService {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.ProductSpuService.version}")
|
||||
private ProductSpuRpc productSpuRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductRecommendMapper productRecommendMapper;
|
||||
|
||||
@Override
|
||||
public List<ProductRecommendBO> getProductRecommendList(Integer type, Integer status) {
|
||||
List<ProductRecommendDO> productRecommends = productRecommendMapper.selectListByTypeAndStatus(type, status);
|
||||
return ProductRecommendConvert.INSTANCE.convertToBO(productRecommends);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductRecommendPageBO getProductRecommendPage(ProductRecommendPageDTO productRecommendPageDTO) {
|
||||
ProductRecommendPageBO productRecommendPageBO = new ProductRecommendPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (productRecommendPageDTO.getPageNo() - 1) * productRecommendPageDTO.getPageSize();
|
||||
productRecommendPageBO.setList(ProductRecommendConvert.INSTANCE.convertToBO(productRecommendMapper.selectPageByType(productRecommendPageDTO.getType(),
|
||||
offset, productRecommendPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
productRecommendPageBO.setTotal(productRecommendMapper.selectCountByType(productRecommendPageDTO.getType()));
|
||||
return productRecommendPageBO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductRecommendBO addProductRecommend(Integer adminId, ProductRecommendAddDTO productRecommendAddDTO) {
|
||||
// 校验商品不存在
|
||||
if (productSpuRpc.getProductSpuDetail(productRecommendAddDTO.getProductSpuId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 校验商品是否已经推荐
|
||||
if (productRecommendMapper.selectByProductSpuIdAndType(productRecommendAddDTO.getProductSpuId(), productRecommendAddDTO.getType()) != null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_EXISTS.getCode());
|
||||
}
|
||||
// 保存到数据库
|
||||
ProductRecommendDO productRecommend = ProductRecommendConvert.INSTANCE.convert(productRecommendAddDTO).setStatus(CommonStatusEnum.ENABLE.getValue());
|
||||
productRecommend.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()).setCreateTime(new Date());
|
||||
productRecommendMapper.insert(productRecommend);
|
||||
// 返回成功
|
||||
return ProductRecommendConvert.INSTANCE.convertToBO(productRecommend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateProductRecommend(Integer adminId, ProductRecommendUpdateDTO productRecommendUpdateDTO) {
|
||||
// 校验更新的商品推荐存在
|
||||
if (productRecommendMapper.selectById(productRecommendUpdateDTO.getId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 校验商品不存在
|
||||
if (productSpuRpc.getProductSpuDetail(productRecommendUpdateDTO.getProductSpuId()) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 校验商品是否已经推荐
|
||||
ProductRecommendDO existProductRecommend = productRecommendMapper.selectByProductSpuIdAndType(productRecommendUpdateDTO.getProductSpuId(), productRecommendUpdateDTO.getType());
|
||||
if (existProductRecommend != null && !existProductRecommend.getId().equals(productRecommendUpdateDTO.getId())) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductRecommendDO updateProductRecommend = ProductRecommendConvert.INSTANCE.convert(productRecommendUpdateDTO);
|
||||
productRecommendMapper.update(updateProductRecommend);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateProductRecommendStatus(Integer adminId, Integer productRecommendId, Integer status) {
|
||||
// 校验更新的商品推荐存在
|
||||
if (productRecommendMapper.selectById(productRecommendId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductRecommendDO updateProductRecommend = new ProductRecommendDO().setId(productRecommendId).setStatus(status);
|
||||
productRecommendMapper.update(updateProductRecommend);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteProductRecommend(Integer adminId, Integer productRecommendId) {
|
||||
// 校验更新的商品推荐存在
|
||||
if (productRecommendMapper.selectById(productRecommendId) == null) {
|
||||
throw ServiceExceptionUtil.exception(PromotionErrorCodeEnum.PRODUCT_RECOMMEND_NOT_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductRecommendDO updateProductRecommend = new ProductRecommendDO().setId(productRecommendId);
|
||||
updateProductRecommend.setDeleted(DeletedStatusEnum.DELETED_YES.getValue());
|
||||
productRecommendMapper.update(updateProductRecommend);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.iocoder.mall.promotion.biz.dao.BannerMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, title, url, pic_url, sort,
|
||||
status, memo, create_time
|
||||
</sql>
|
||||
|
||||
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="BannerDO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- <include refid="FIELDS" />-->
|
||||
<!-- FROM banner-->
|
||||
<!-- WHERE pid = #{pid}-->
|
||||
<!-- AND status = #{status}-->
|
||||
<!-- AND deleted = 0-->
|
||||
<!-- ORDER BY sort ASC-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <select id="selectList" resultType="BannerDO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- <include refid="FIELDS" />-->
|
||||
<!-- FROM banner-->
|
||||
<!-- WHERE deleted = 0-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="BannerDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM banner
|
||||
WHERE id = #{id}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListByStatus" parameterType="Integer" resultType="BannerDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM banner
|
||||
<where>
|
||||
<if test="status != null">
|
||||
status = #{status}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListByTitleLike" resultType="BannerDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM banner
|
||||
<where>
|
||||
<if test="title != null">
|
||||
title LIKE "%"#{title}"%"
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectCountByTitleLike" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM banner
|
||||
<where>
|
||||
<if test="title != null">
|
||||
title LIKE "%"#{title}"%"
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="BannerDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO banner (
|
||||
title, url, pic_url, sort, status,
|
||||
memo, create_time, deleted
|
||||
) VALUES (
|
||||
#{title}, #{url}, #{picUrl}, #{sort}, #{status},
|
||||
#{memo}, #{createTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="BannerDO">
|
||||
UPDATE banner
|
||||
<set>
|
||||
<if test="title != null">
|
||||
title = #{title},
|
||||
</if>
|
||||
<if test="url != null">
|
||||
url = #{url},
|
||||
</if>
|
||||
<if test="picUrl != null">
|
||||
pic_url = #{picUrl} ,
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="memo != null">
|
||||
memo = #{memo},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -1,125 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.iocoder.mall.promotion.biz.dao.ProductRecommendMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, type, product_spu_id, sort,
|
||||
status, memo, create_time
|
||||
</sql>
|
||||
|
||||
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="ProductRecommendDO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- <include refid="FIELDS" />-->
|
||||
<!-- FROM product_recommend-->
|
||||
<!-- WHERE pid = #{pid}-->
|
||||
<!-- AND status = #{status}-->
|
||||
<!-- AND deleted = 0-->
|
||||
<!-- ORDER BY sort ASC-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <select id="selectList" resultType="ProductRecommendDO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- <include refid="FIELDS" />-->
|
||||
<!-- FROM product_recommend-->
|
||||
<!-- WHERE deleted = 0-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
WHERE id = #{id}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByProductSpuIdAndType" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
<where>
|
||||
<if test="productSpuId != null">
|
||||
product_spu_id = #{productSpuId}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListByTypeAndStatus" parameterType="Integer" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
<where>
|
||||
<if test="type != null">
|
||||
type = #{type}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPageByType" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
<where>
|
||||
<if test="type != null">
|
||||
type = #{type}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectCountByType" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM product_recommend
|
||||
<where>
|
||||
<if test="type != null">
|
||||
type = #{type}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="ProductRecommendDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_recommend (
|
||||
type, product_spu_id, sort, status, memo,
|
||||
create_time, deleted
|
||||
) VALUES (
|
||||
#{type}, #{productSpuId}, #{sort}, #{status}, #{memo},
|
||||
#{createTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="ProductRecommendDO">
|
||||
UPDATE product_recommend
|
||||
<set>
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="productSpuId != null">
|
||||
product_spu_id = #{productSpuId},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="memo != null">
|
||||
memo = #{memo},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -1,132 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>promotion</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>promotion-start</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>product-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>promotion-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>promotion-service-impl</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>user-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>user-sdk</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>system-sdk</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 服务保障相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 监控 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 测试相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-security</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-security</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 提供给 mapstruct 使用 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<!-- 打包 -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,101 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.BannerService;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerPageDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.BannerUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.application.convert.BannerConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/banner")
|
||||
@Api("Banner 模块")
|
||||
public class AdminsBannerController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.provider.BannerService.version}")
|
||||
private BannerService bannerService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "Banner 分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "title", value = "标题,模糊匹配", example = "活动 A"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<AdminsBannerPageVO> page(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
BannerPageBO result = bannerService.getBannerPage(new BannerPageDTO().setTitle(title).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return success(BannerConvert.ADMINS.convert3(result));
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建 Banner")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "title", value = "标题", required = true, example = "活动A"),
|
||||
@ApiImplicitParam(name = "url", value = "跳转链接", required = true, example = "http://www.iocoder.cn"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "图片链接", required = true, example = "http://www.iocoder.cn/01.jpg"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", required = true, example = "活动很牛逼"),
|
||||
})
|
||||
public CommonResult<AdminsBannerVO> add(@RequestParam("title") String title,
|
||||
@RequestParam("url") String url,
|
||||
@RequestParam("picUrl") String picUrl,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
BannerAddDTO bannerAddDTO = new BannerAddDTO().setTitle(title).setUrl(url).setPicUrl(picUrl)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return success(BannerConvert.ADMINS.convert(bannerService.addBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerAddDTO)));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新 Banner")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "url", value = "跳转链接", required = true, example = "http://www.iocoder.cn"),
|
||||
@ApiImplicitParam(name = "picUrl", value = "图片链接", required = true, example = "http://www.iocoder.cn/01.jpg"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", required = true, example = "活动很牛逼"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("title") String title,
|
||||
@RequestParam("url") String url,
|
||||
@RequestParam("picUrl") String picUrl,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
BannerUpdateDTO bannerUpdateDTO = new BannerUpdateDTO().setId(id).setTitle(title).setUrl(url).setPicUrl(picUrl)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return success(bannerService.updateBanner(AdminSecurityContextHolder.getContext().getAdminId(), bannerUpdateDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@ApiOperation(value = "更新 Banner 状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return success(bannerService.updateBannerStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除 Banner")
|
||||
@ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return success(bannerService.deleteBanner(AdminSecurityContextHolder.getContext().getAdminId(), id));
|
||||
}
|
||||
|
||||
}
|
@ -93,17 +93,6 @@ public class AdminsProductRecommendController {
|
||||
return success(productRecommendService.updateProductRecommend(AdminSecurityContextHolder.getContext().getAdminId(), bannerUpdateDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@ApiOperation(value = "更新商品推荐状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "商品推荐编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return success(productRecommendService.updateProductRecommendStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status));
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除商品推荐")
|
||||
@ApiImplicitParam(name = "id", value = "商品推荐编号", required = true, example = "1")
|
||||
|
@ -1,39 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersBannerVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BannerConvert {
|
||||
|
||||
Users USERS = Mappers.getMapper(Users.class);
|
||||
|
||||
Admins ADMINS = Mappers.getMapper(Admins.class);
|
||||
|
||||
@Mapper
|
||||
interface Admins {
|
||||
|
||||
@Mappings({})
|
||||
AdminsBannerVO convert(BannerBO bannerBO);
|
||||
|
||||
@Mappings({})
|
||||
AdminsBannerPageVO convert3(BannerPageBO bannerPageBO);
|
||||
|
||||
}
|
||||
|
||||
@Mapper
|
||||
interface Users {
|
||||
|
||||
@Mappings({})
|
||||
List<UsersBannerVO> convertList(List<BannerBO> banners);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.mall.product.api.bo.ProductSpuBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.ProductRecommendPageBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersProductRecommendVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface ProductRecommendConvert {
|
||||
|
||||
ProductRecommendConvert INSTANCE = Mappers.getMapper(ProductRecommendConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductRecommendVO convert(ProductRecommendBO bannerBO);
|
||||
|
||||
@Mappings({})
|
||||
AdminsProductRecommendPageVO convert(ProductRecommendPageBO result);
|
||||
|
||||
@Mappings({})
|
||||
UsersProductRecommendVO convert(ProductSpuBO productSpu);
|
||||
|
||||
// @Mappings({})
|
||||
// List<UsersProductRecommendVO> convertList(List<ProductRecommendBO> banners);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user