后端:增加商品推荐增删改查接口
This commit is contained in:
@@ -8,7 +8,7 @@ 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.AdminBannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -32,9 +32,9 @@ public class AdminsBannerController {
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<AdminBannerPageVO> page(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
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) {
|
||||
CommonResult<BannerPageBO> result = bannerService.getBannerPage(new BannerPageDTO().setTitle(title).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return BannerConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package cn.iocoder.mall.promotion.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.mall.promotion.api.ProductRecommendService;
|
||||
import cn.iocoder.mall.promotion.api.bo.ProductRecommendPageBO;
|
||||
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.application.convert.ProductRecommendConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendPageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendVO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/product_recommend")
|
||||
@Api("商品推荐模块")
|
||||
public class AdminsProductRecommendController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private ProductRecommendService productRecommendService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "商品推荐分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "推荐类型", example = "1"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<AdminsProductRecommendPageVO> page(@RequestParam(value = "type", required = false) Integer type,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
CommonResult<ProductRecommendPageBO> result = productRecommendService.getProductRecommendPage(new ProductRecommendPageDTO().setType(type).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return ProductRecommendConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建商品推荐")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "推荐类型", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "productSpuId", value = "商品编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", example = "活动很牛逼"),
|
||||
})
|
||||
public CommonResult<AdminsProductRecommendVO> add(@RequestParam("type") Integer type,
|
||||
@RequestParam("productSpuId") Integer productSpuId,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
ProductRecommendAddDTO bannerAddDTO = new ProductRecommendAddDTO().setType(type).setProductSpuId(productSpuId)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return ProductRecommendConvert.INSTANCE.convert2(productRecommendService.addProductRecommend(AdminSecurityContextHolder.getContext().getAdminId(), bannerAddDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新商品推荐")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "商品推荐编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "type", value = "推荐类型", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "productSpuId", value = "商品编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", example = "活动很牛逼"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("type") Integer type,
|
||||
@RequestParam("productSpuId") Integer productSpuId,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
ProductRecommendUpdateDTO bannerUpdateDTO = new ProductRecommendUpdateDTO().setId(id).setType(type).setProductSpuId(productSpuId)
|
||||
.setSort(sort).setMemo(memo);
|
||||
return 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 productRecommendService.updateProductRecommendStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除商品推荐")
|
||||
@ApiImplicitParam(name = "id", value = "商品推荐编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return productRecommendService.deleteProductRecommend(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package cn.iocoder.mall.promotion.application.convert;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminBannerPageVO;
|
||||
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;
|
||||
@@ -24,7 +24,7 @@ public interface BannerConvert {
|
||||
CommonResult<AdminsBannerVO> convert2(CommonResult<BannerBO> result);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminBannerPageVO> convert(CommonResult<BannerPageBO> result);
|
||||
CommonResult<AdminsBannerPageVO> convert(CommonResult<BannerPageBO> result);
|
||||
|
||||
@Mappings({})
|
||||
List<UsersBannerVO> convertList(List<BannerBO> banners);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
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 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({})
|
||||
CommonResult<AdminsProductRecommendVO> convert2(CommonResult<ProductRecommendBO> result);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminsProductRecommendPageVO> convert(CommonResult<ProductRecommendPageBO> result);
|
||||
|
||||
// @Mappings({})
|
||||
// List<UsersProductRecommendVO> convertList(List<ProductRecommendBO> banners);
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("Banner 分页 VO")
|
||||
public class AdminBannerPageVO {
|
||||
public class AdminsBannerPageVO {
|
||||
|
||||
@ApiModelProperty(value = "Banner 数组")
|
||||
private List<AdminsBannerVO> list;
|
||||
@@ -17,7 +17,7 @@ public class AdminBannerPageVO {
|
||||
return list;
|
||||
}
|
||||
|
||||
public AdminBannerPageVO setList(List<AdminsBannerVO> list) {
|
||||
public AdminsBannerPageVO setList(List<AdminsBannerVO> list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class AdminBannerPageVO {
|
||||
return total;
|
||||
}
|
||||
|
||||
public AdminBannerPageVO setTotal(Integer total) {
|
||||
public AdminsBannerPageVO setTotal(Integer total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.promotion.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("商品推荐分页 VO")
|
||||
public class AdminsProductRecommendPageVO {
|
||||
|
||||
@ApiModelProperty(value = "商品推荐数组")
|
||||
private List<AdminsProductRecommendVO> list;
|
||||
@ApiModelProperty(value = "商品推荐总数")
|
||||
private Integer total;
|
||||
|
||||
public List<AdminsProductRecommendVO> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendPageVO setList(List<AdminsProductRecommendVO> list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendPageVO setTotal(Integer total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package cn.iocoder.mall.promotion.application.vo.admins;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("商品推荐 VO")
|
||||
public class AdminsProductRecommendVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "推荐类型", required = true, example = "1")
|
||||
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")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注", required = true, example = "这个活动很牛逼")
|
||||
private String memo;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setType(Integer type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getProductSpuId() {
|
||||
return productSpuId;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setProductSpuId(Integer productSpuId) {
|
||||
this.productSpuId = productSpuId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setStatus(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMemo() {
|
||||
return memo;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setMemo(String memo) {
|
||||
this.memo = memo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public AdminsProductRecommendVO setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user