diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsAdvertController.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsAdvertController.java index 07ed61cb9..652227fda 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsAdvertController.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsAdvertController.java @@ -2,14 +2,13 @@ package com.youlai.mall.sms.controller.admin; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.youlai.common.result.PageResult; import com.youlai.common.result.Result; import com.youlai.mall.sms.pojo.entity.SmsAdvert; +import com.youlai.mall.sms.pojo.query.AdvertPageQuery; import com.youlai.mall.sms.service.SmsAdvertService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; @@ -17,7 +16,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Arrays; -@Api(tags = "「系统端」营销广告") +@Api(tags = "「管理端」营销广告") @RestController @RequestMapping("/api/v1/adverts") @RequiredArgsConstructor @@ -25,18 +24,21 @@ public class SmsAdvertController { private final SmsAdvertService smsAdvertService; - @ApiOperation(value = "列表分页") - @GetMapping - public PageResult listAdvertsPage( - @ApiParam("页码") Long pageNum, - @ApiParam("每页数量") Long pageSize, - @ApiParam("广告标题") String title - ) { - Page result = smsAdvertService.page(new Page<>(pageNum, pageSize), + @ApiOperation(value = "广告分页列表") + @GetMapping("/pages") + public PageResult listAdvertPages(AdvertPageQuery queryParams) { + + // 查询参数 + int pageNum = queryParams.getPageNum(); + int pageSize = queryParams.getPageSize(); + String keywords = queryParams.getKeywords(); + + // 分页查询 + Page result = smsAdvertService.page( + new Page<>(pageNum, pageSize), new LambdaQueryWrapper() - .like(StrUtil.isNotBlank(title), SmsAdvert::getTitle, StrUtil.isNotBlank(title) ? title : null) + .like(StrUtil.isNotBlank(keywords), SmsAdvert::getTitle, keywords) .orderByAsc(SmsAdvert::getSort) - .orderByDesc(SmsAdvert::getGmtModified) ); return PageResult.success(result); } @@ -67,20 +69,12 @@ public class SmsAdvertController { } @ApiOperation(value = "删除广告") - @ApiImplicitParam(name = "ids", value = "id集合", required = true, paramType = "query", dataType = "String") @DeleteMapping("/{ids}") - public Result delete(@PathVariable("ids") String ids) { + public Result deleteAdverts(@ApiParam("广告ID,多个以英文逗号(,)分割") @PathVariable("ids") String ids) { boolean status = smsAdvertService.removeByIds(Arrays.asList(ids.split(","))); return Result.judge(status); + + } - @ApiOperation(value = "选择性更新广告") - @ApiImplicitParam(name = "id", value = "用户ID", required = true, paramType = "path", dataType = "Long") - @PatchMapping(value = "/{id}") - public Result patch(@PathVariable Integer id, @RequestBody SmsAdvert advert) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(SmsAdvert::getId, id); - updateWrapper.set(advert.getStatus() != null, SmsAdvert::getStatus, advert.getStatus()); - boolean result = smsAdvertService.update(updateWrapper); - return Result.judge(result); - } } diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsCouponController.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsCouponController.java index 9735a7ee5..b2d0376c9 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsCouponController.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/SmsCouponController.java @@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; -@Api(tags = "「系统端」优惠券管理") +@Api(tags = "「管理端」优惠券管理") @RestController @RequestMapping("/api/v1/coupons") @RequiredArgsConstructor @@ -25,8 +25,8 @@ public class SmsCouponController { @ApiOperation(value = "优惠券分页列表") @GetMapping - public PageResult listPageCoupons(CouponPageQuery queryParams) { - Page result = couponService.listPageCoupons(queryParams); + public PageResult listCouponPages(CouponPageQuery queryParams) { + Page result = couponService.listCouponPages(queryParams); return PageResult.success(result); } diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/convert/SmsCouponConvert.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/converter/SmsCouponConverter.java similarity index 93% rename from mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/convert/SmsCouponConvert.java rename to mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/converter/SmsCouponConverter.java index ea821cf99..544e9659a 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/convert/SmsCouponConvert.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/converter/SmsCouponConverter.java @@ -1,4 +1,4 @@ -package com.youlai.mall.sms.convert; +package com.youlai.mall.sms.converter; import com.youlai.mall.sms.pojo.entity.SmsCoupon; @@ -11,13 +11,13 @@ import org.mapstruct.Mappings; import java.util.List; /** - * 优惠券实体转换器 + * 优惠券对象转换器 * * @author haoxr * @date 2022/5/29 */ @Mapper(componentModel = "spring") -public interface SmsCouponConvert { +public interface SmsCouponConverter { @Mappings({ @Mapping(target = "platformLabel", expression = "java(com.youlai.common.base.IBaseEnum.getLabelByValue(entity.getPlatform(), com.youlai.mall.sms.common.enums.PlatformEnum.class))"), diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponMapper.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponMapper.java index 72977f6fe..2d03be60e 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponMapper.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponMapper.java @@ -13,7 +13,7 @@ import java.util.List; @Mapper public interface SmsCouponMapper extends BaseMapper { - List listPageCoupons(Page page, CouponPageQuery queryParams); + List listCouponPages(Page page, CouponPageQuery queryParams); } diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/entity/SmsCouponHistory.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/entity/SmsCouponHistory.java index 18e755f33..4c5a2917a 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/entity/SmsCouponHistory.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/entity/SmsCouponHistory.java @@ -69,12 +69,12 @@ public class SmsCouponHistory implements Serializable { /** * 创建时间 */ - private Date gmtCreate; + private Date createTime; /** * 更新时间 */ - private Date gmtModified; + private Date updateTime; @TableField(exist = false) private static final long serialVersionUID = 1L; diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java index 1a39dbe95..629b9bb31 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java @@ -6,6 +6,7 @@ import lombok.Data; import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** * 优惠券表单对象 @@ -35,10 +36,7 @@ public class CouponForm { @ApiModelProperty("优惠券码") private String code; - @ApiModelProperty("优惠券状态(0:未发布;1:已发布;2:已结束;)") - private Integer status; - - @ApiModelProperty("使用平台(0:全部;1:移动端;2:PC;)") + @ApiModelProperty("使用平台(0-全平台;1-移动端;2-PC;)") private Integer platform; @ApiModelProperty("优惠券总数(0:无限制)") @@ -62,10 +60,40 @@ public class CouponForm { @ApiModelProperty("有效期截止时间") private Date validEndTime; - @ApiModelProperty("使用类型(0:全场通用;1:指定分类;2:指定商品)") - private Integer useType; + @ApiModelProperty("适用类型(0-全场通用;1-指定商品分类;2-指定商品)") + private Integer applicableType; @ApiModelProperty("备注") private String remark; -} + @ApiModelProperty("优惠券适用商品分类列表") + private List spuCategoryList; + + @ApiModelProperty("优惠券适用商品列表") + private List spuList; + + @ApiModel("优惠券适用商品分类") + @Data + public static class CouponSpuCategory { + + private Long id; + + private Long categoryId; + + private String categoryName; + + } + + @ApiModel("优惠券适用商品") + @Data + + public static class CouponSpu { + + private Long id; + + private Long spuId; + + private String spuName; + + } +} \ No newline at end of file diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/AdvertPageQuery.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/AdvertPageQuery.java index 0545c5e39..07e86b3b0 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/AdvertPageQuery.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/AdvertPageQuery.java @@ -6,15 +6,16 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** - * @author xinyi - * @desc: 优惠券领取使用详情条件分页查询 + * 广告分页列表查询对象 + * + * @author haoxr * @date 2021/7/11 */ -@ApiModel("优惠券领取使用详情条件分页查询") +@ApiModel("广告分页查询对象") @Data public class AdvertPageQuery extends BasePageQuery { - @ApiModelProperty("广告)") - private String title; + @ApiModelProperty("关键字") + private String keywords; } diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/CouponPageQuery.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/CouponPageQuery.java index 578145273..c4f1aaa2d 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/CouponPageQuery.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/pojo/query/CouponPageQuery.java @@ -9,10 +9,10 @@ import lombok.NoArgsConstructor; /** * @author xinyi - * @desc: 优惠券领取使用详情条件分页查询 + * @desc: 优惠券分页查询对象 * @date 2021/7/11 */ -@ApiModel("优惠券领取使用详情条件分页查询") +@ApiModel("优惠券分页查询对象") @Data @NoArgsConstructor @AllArgsConstructor diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsCouponService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsCouponService.java index 7319458e8..58d505353 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsCouponService.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsCouponService.java @@ -21,7 +21,7 @@ public interface SmsCouponService extends IService { * @param queryParams * @return */ - Page listPageCoupons(CouponPageQuery queryParams); + Page listCouponPages(CouponPageQuery queryParams); /** * 新增优惠券 diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java index 2cc58eb6e..364701cf7 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java @@ -4,7 +4,7 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.youlai.mall.sms.convert.SmsCouponConvert; +import com.youlai.mall.sms.converter.SmsCouponConverter; import com.youlai.mall.sms.mapper.SmsCouponMapper; import com.youlai.mall.sms.pojo.entity.SmsCoupon; import com.youlai.mall.sms.pojo.form.CouponForm; @@ -29,7 +29,7 @@ import java.util.stream.Collectors; public class SmsCouponServiceImpl extends ServiceImpl implements SmsCouponService { - private final SmsCouponConvert smsCouponConvert; + private final SmsCouponConverter smsCouponConverter; /** * 优惠券分页列表 @@ -38,12 +38,12 @@ public class SmsCouponServiceImpl extends ServiceImpl listPageCoupons(CouponPageQuery queryParams) { + public Page listCouponPages(CouponPageQuery queryParams) { Page page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize()); // 查询数据 - List couponList = this.baseMapper.listPageCoupons(page, queryParams); + List couponList = this.baseMapper.listCouponPages(page, queryParams); // 实体转换 - List records = smsCouponConvert.entity2PageVO(couponList); + List records = smsCouponConverter.entity2PageVO(couponList); page.setRecords(records); return page; } @@ -58,7 +58,7 @@ public class SmsCouponServiceImpl extends ServiceImplform - CouponForm couponForm = smsCouponConvert.entity2Form(entity); + CouponForm couponForm = smsCouponConverter.entity2Form(entity); return couponForm; } @@ -70,7 +70,7 @@ public class SmsCouponServiceImpl extends ServiceImpl ORDER BY - gmt_modified desc + update_time desc diff --git a/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponHistoryMapper.xml b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponHistoryMapper.xml index eda71aa24..be36220f6 100644 --- a/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponHistoryMapper.xml +++ b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponHistoryMapper.xml @@ -15,14 +15,14 @@ - - + + id,coupon_id,member_id, member_nickname,coupon_code,get_type, status,use_time,order_id, - order_sn,gmt_create,gmt_modified + order_sn,create_time,update_time diff --git a/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponMapper.xml b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponMapper.xml index 6e7340681..90da03504 100644 --- a/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponMapper.xml +++ b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponMapper.xml @@ -4,44 +4,8 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - id,name,type, - code,status,platform, - amount,discount,total_count, - min_point,per_limit,valid_type, - valid_days,valid_begin_time,valid_end_time, - use_type,received_count,used_count, - remark,gmt_create,gmt_modified, - deleted - - - SELECT * FROM