后端 + 前端:优惠劵更新功能
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.iocoder.mall.promotion.api.CouponService;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO;
|
||||
import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateAddDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateUpdateDTO;
|
||||
import cn.iocoder.mall.promotion.api.dto.CouponTemplatePageDTO;
|
||||
import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO;
|
||||
@@ -31,7 +32,7 @@ public class AdminsCouponTemplateController {
|
||||
// ========== 优惠劵(码)模板 ==========
|
||||
|
||||
@GetMapping("/template/page")
|
||||
@ApiOperation(value = "Banner 分页")
|
||||
@ApiOperation(value = "优惠劵(码)模板分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "title", value = "标题,模糊匹配", example = "活动 A"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@@ -75,7 +76,7 @@ public class AdminsCouponTemplateController {
|
||||
@RequestParam(value = "total", required = false) Integer total,
|
||||
@RequestParam(value = "priceAvailable") Integer priceAvailable,
|
||||
@RequestParam(value = "rangeType") Integer rangeType,
|
||||
@RequestParam(value = "rangeType", required = false) String rangeValues,
|
||||
@RequestParam(value = "rangeValues", required = false) String rangeValues,
|
||||
@RequestParam(value = "dateType") Integer dateType,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@RequestParam(value = "validStartTime", required = false) Date validStartTime,
|
||||
@@ -103,6 +104,33 @@ public class AdminsCouponTemplateController {
|
||||
return CouponTemplateConvert.INSTANCE.convert2(result);
|
||||
}
|
||||
|
||||
@PostMapping("/template/update_card")
|
||||
@ApiOperation(value = "更新优惠劵模板")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "title", value = "标题", required = true, example = "优惠劵牛逼"),
|
||||
@ApiImplicitParam(name = "description", value = "使用说明", example = "我只是描述"),
|
||||
@ApiImplicitParam(name = "quota", value = "每人限领个数", required = true),
|
||||
@ApiImplicitParam(name = "total", value = "发行总量"),
|
||||
@ApiImplicitParam(name = "rangeType", value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "rangeValues", value = "指定商品 / 分类列表,使用逗号分隔商品编号"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam(value = "id") Integer id,
|
||||
@RequestParam(value = "title") String title,
|
||||
@RequestParam(value = "description", required = false) String description,
|
||||
@RequestParam(value = "quota") Integer quota,
|
||||
@RequestParam(value = "total", required = false) Integer total,
|
||||
@RequestParam(value = "rangeType") Integer rangeType,
|
||||
@RequestParam(value = "rangeValues", required = false) String rangeValues) {
|
||||
// 创建 CouponCardTemplateAddDTO 对象
|
||||
CouponCardTemplateUpdateDTO couponCardTemplateUpdateDTO = new CouponCardTemplateUpdateDTO()
|
||||
.setId(id)
|
||||
.setTitle(title).setDescription(description)
|
||||
.setQuota(quota).setTotal(total)
|
||||
.setRangeType(rangeType).setRangeValues(rangeValues);
|
||||
return couponService.updateCouponCardTemplate(couponCardTemplateUpdateDTO);
|
||||
}
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
// ========== 优惠码 ==========
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2019-04-05T22:26:04+0800",
|
||||
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (Oracle Corporation)"
|
||||
)
|
||||
public class CouponTemplateConvertImpl implements CouponTemplateConvert {
|
||||
|
||||
@Override
|
||||
public AdminsCouponTemplateVO convert(CouponTemplateBO template) {
|
||||
if ( template == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AdminsCouponTemplateVO adminsCouponTemplateVO = new AdminsCouponTemplateVO();
|
||||
|
||||
adminsCouponTemplateVO.setId( template.getId() );
|
||||
adminsCouponTemplateVO.setTitle( template.getTitle() );
|
||||
adminsCouponTemplateVO.setDescription( template.getDescription() );
|
||||
adminsCouponTemplateVO.setType( template.getType() );
|
||||
adminsCouponTemplateVO.setCodeType( template.getCodeType() );
|
||||
adminsCouponTemplateVO.setStatus( template.getStatus() );
|
||||
adminsCouponTemplateVO.setQuota( template.getQuota() );
|
||||
adminsCouponTemplateVO.setPriceAvailable( template.getPriceAvailable() );
|
||||
adminsCouponTemplateVO.setRangeType( template.getRangeType() );
|
||||
adminsCouponTemplateVO.setRangeValues( template.getRangeValues() );
|
||||
adminsCouponTemplateVO.setDateType( template.getDateType() );
|
||||
adminsCouponTemplateVO.setValidStartTime( template.getValidStartTime() );
|
||||
adminsCouponTemplateVO.setValidEndTime( template.getValidEndTime() );
|
||||
adminsCouponTemplateVO.setFixedStartTerm( template.getFixedStartTerm() );
|
||||
adminsCouponTemplateVO.setFixedEndTerm( template.getFixedEndTerm() );
|
||||
adminsCouponTemplateVO.setPreferentialType( template.getPreferentialType() );
|
||||
adminsCouponTemplateVO.setPercentOff( template.getPercentOff() );
|
||||
adminsCouponTemplateVO.setPriceOff( template.getPriceOff() );
|
||||
adminsCouponTemplateVO.setDiscountPriceLimit( template.getDiscountPriceLimit() );
|
||||
adminsCouponTemplateVO.setStatFetchNum( template.getStatFetchNum() );
|
||||
adminsCouponTemplateVO.setCreateTime( template.getCreateTime() );
|
||||
adminsCouponTemplateVO.setTotal( template.getTotal() );
|
||||
|
||||
return adminsCouponTemplateVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<AdminsCouponTemplateVO> convert2(CommonResult<CouponTemplateBO> result) {
|
||||
if ( result == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommonResult<AdminsCouponTemplateVO> commonResult = new CommonResult<AdminsCouponTemplateVO>();
|
||||
|
||||
commonResult.setCode( result.getCode() );
|
||||
commonResult.setMessage( result.getMessage() );
|
||||
commonResult.setData( convert( result.getData() ) );
|
||||
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<AdminsCouponTemplatePageVO> convert(CommonResult<CouponTemplatePageBO> result) {
|
||||
if ( result == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommonResult<AdminsCouponTemplatePageVO> commonResult = new CommonResult<AdminsCouponTemplatePageVO>();
|
||||
|
||||
commonResult.setCode( result.getCode() );
|
||||
commonResult.setMessage( result.getMessage() );
|
||||
commonResult.setData( couponTemplatePageBOToAdminsCouponTemplatePageVO( result.getData() ) );
|
||||
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminsCouponTemplateVO> convertList(List<CouponTemplateBO> templates) {
|
||||
if ( templates == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<AdminsCouponTemplateVO> list = new ArrayList<AdminsCouponTemplateVO>( templates.size() );
|
||||
for ( CouponTemplateBO couponTemplateBO : templates ) {
|
||||
list.add( convert( couponTemplateBO ) );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
protected AdminsCouponTemplatePageVO couponTemplatePageBOToAdminsCouponTemplatePageVO(CouponTemplatePageBO couponTemplatePageBO) {
|
||||
if ( couponTemplatePageBO == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AdminsCouponTemplatePageVO adminsCouponTemplatePageVO = new AdminsCouponTemplatePageVO();
|
||||
|
||||
adminsCouponTemplatePageVO.setList( convertList( couponTemplatePageBO.getList() ) );
|
||||
adminsCouponTemplatePageVO.setTotal( couponTemplatePageBO.getTotal() );
|
||||
|
||||
return adminsCouponTemplatePageVO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2019-04-05T22:26:04+0800",
|
||||
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (Oracle Corporation)"
|
||||
)
|
||||
public class ProductRecommendConvertImpl implements ProductRecommendConvert {
|
||||
|
||||
@Override
|
||||
public AdminsProductRecommendVO convert(ProductRecommendBO bannerBO) {
|
||||
if ( bannerBO == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AdminsProductRecommendVO adminsProductRecommendVO = new AdminsProductRecommendVO();
|
||||
|
||||
adminsProductRecommendVO.setId( bannerBO.getId() );
|
||||
adminsProductRecommendVO.setType( bannerBO.getType() );
|
||||
adminsProductRecommendVO.setProductSpuId( bannerBO.getProductSpuId() );
|
||||
adminsProductRecommendVO.setSort( bannerBO.getSort() );
|
||||
adminsProductRecommendVO.setStatus( bannerBO.getStatus() );
|
||||
adminsProductRecommendVO.setMemo( bannerBO.getMemo() );
|
||||
adminsProductRecommendVO.setCreateTime( bannerBO.getCreateTime() );
|
||||
|
||||
return adminsProductRecommendVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<AdminsProductRecommendVO> convert2(CommonResult<ProductRecommendBO> result) {
|
||||
if ( result == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommonResult<AdminsProductRecommendVO> commonResult = new CommonResult<AdminsProductRecommendVO>();
|
||||
|
||||
commonResult.setCode( result.getCode() );
|
||||
commonResult.setMessage( result.getMessage() );
|
||||
commonResult.setData( convert( result.getData() ) );
|
||||
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<AdminsProductRecommendPageVO> convert(CommonResult<ProductRecommendPageBO> result) {
|
||||
if ( result == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommonResult<AdminsProductRecommendPageVO> commonResult = new CommonResult<AdminsProductRecommendPageVO>();
|
||||
|
||||
commonResult.setCode( result.getCode() );
|
||||
commonResult.setMessage( result.getMessage() );
|
||||
commonResult.setData( productRecommendPageBOToAdminsProductRecommendPageVO( result.getData() ) );
|
||||
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsersProductRecommendVO convert(ProductSpuBO productSpu) {
|
||||
if ( productSpu == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UsersProductRecommendVO usersProductRecommendVO = new UsersProductRecommendVO();
|
||||
|
||||
usersProductRecommendVO.setId( productSpu.getId() );
|
||||
usersProductRecommendVO.setName( productSpu.getName() );
|
||||
usersProductRecommendVO.setSellPoint( productSpu.getSellPoint() );
|
||||
List<String> list = productSpu.getPicUrls();
|
||||
if ( list != null ) {
|
||||
usersProductRecommendVO.setPicUrls( new ArrayList<String>( list ) );
|
||||
}
|
||||
usersProductRecommendVO.setPrice( productSpu.getPrice() );
|
||||
|
||||
return usersProductRecommendVO;
|
||||
}
|
||||
|
||||
protected List<AdminsProductRecommendVO> productRecommendBOListToAdminsProductRecommendVOList(List<ProductRecommendBO> list) {
|
||||
if ( list == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<AdminsProductRecommendVO> list1 = new ArrayList<AdminsProductRecommendVO>( list.size() );
|
||||
for ( ProductRecommendBO productRecommendBO : list ) {
|
||||
list1.add( convert( productRecommendBO ) );
|
||||
}
|
||||
|
||||
return list1;
|
||||
}
|
||||
|
||||
protected AdminsProductRecommendPageVO productRecommendPageBOToAdminsProductRecommendPageVO(ProductRecommendPageBO productRecommendPageBO) {
|
||||
if ( productRecommendPageBO == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AdminsProductRecommendPageVO adminsProductRecommendPageVO = new AdminsProductRecommendPageVO();
|
||||
|
||||
adminsProductRecommendPageVO.setList( productRecommendBOListToAdminsProductRecommendVOList( productRecommendPageBO.getList() ) );
|
||||
adminsProductRecommendPageVO.setTotal( productRecommendPageBO.getTotal() );
|
||||
|
||||
return adminsProductRecommendPageVO;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user