refactor: 时间字段名变更实体类同步更新gmt_create→create_time,gmt_modified→update_time

This commit is contained in:
郝先瑞 2022-07-03 14:35:09 +08:00
parent 9680efb647
commit c6d1dad2cd
13 changed files with 84 additions and 97 deletions

View File

@ -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<SmsAdvert> 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<SmsAdvert> result = smsAdvertService.page(
new Page<>(pageNum, pageSize),
new LambdaQueryWrapper<SmsAdvert>()
.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<SmsAdvert> updateWrapper = new LambdaUpdateWrapper<SmsAdvert>().eq(SmsAdvert::getId, id);
updateWrapper.set(advert.getStatus() != null, SmsAdvert::getStatus, advert.getStatus());
boolean result = smsAdvertService.update(updateWrapper);
return Result.judge(result);
}
}

View File

@ -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<CouponPageVO> result = couponService.listPageCoupons(queryParams);
public PageResult listCouponPages(CouponPageQuery queryParams) {
Page<CouponPageVO> result = couponService.listCouponPages(queryParams);
return PageResult.success(result);
}

View File

@ -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))"),

View File

@ -13,7 +13,7 @@ import java.util.List;
@Mapper
public interface SmsCouponMapper extends BaseMapper<SmsCoupon> {
List<SmsCoupon> listPageCoupons(Page<CouponPageVO> page, CouponPageQuery queryParams);
List<SmsCoupon> listCouponPages(Page<CouponPageVO> page, CouponPageQuery queryParams);
}

View File

@ -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;

View File

@ -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<CouponSpuCategory> spuCategoryList;
@ApiModelProperty("优惠券适用商品列表")
private List<CouponSpu> 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;
}
}

View File

@ -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;
}

View File

@ -9,10 +9,10 @@ import lombok.NoArgsConstructor;
/**
* @author xinyi
* @desc: 优惠券领取使用详情条件分页查询
* @desc: 优惠券分页查询对象
* @date 2021/7/11
*/
@ApiModel("优惠券领取使用详情条件分页查询")
@ApiModel("优惠券分页查询对象")
@Data
@NoArgsConstructor
@AllArgsConstructor

View File

@ -21,7 +21,7 @@ public interface SmsCouponService extends IService<SmsCoupon> {
* @param queryParams
* @return
*/
Page<CouponPageVO> listPageCoupons(CouponPageQuery queryParams);
Page<CouponPageVO> listCouponPages(CouponPageQuery queryParams);
/**
* 新增优惠券

View File

@ -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<SmsCouponMapper, SmsCoupon>
implements SmsCouponService {
private final SmsCouponConvert smsCouponConvert;
private final SmsCouponConverter smsCouponConverter;
/**
* 优惠券分页列表
@ -38,12 +38,12 @@ public class SmsCouponServiceImpl extends ServiceImpl<SmsCouponMapper, SmsCoupon
* @return
*/
@Override
public Page<CouponPageVO> listPageCoupons(CouponPageQuery queryParams) {
public Page<CouponPageVO> listCouponPages(CouponPageQuery queryParams) {
Page<CouponPageVO> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
// 查询数据
List<SmsCoupon> couponList = this.baseMapper.listPageCoupons(page, queryParams);
List<SmsCoupon> couponList = this.baseMapper.listCouponPages(page, queryParams);
// 实体转换
List<CouponPageVO> records = smsCouponConvert.entity2PageVO(couponList);
List<CouponPageVO> records = smsCouponConverter.entity2PageVO(couponList);
page.setRecords(records);
return page;
}
@ -58,7 +58,7 @@ public class SmsCouponServiceImpl extends ServiceImpl<SmsCouponMapper, SmsCoupon
public CouponForm getCouponFormData(Long couponId) {
SmsCoupon entity = this.getById(couponId);
// 实体转换entity->form
CouponForm couponForm = smsCouponConvert.entity2Form(entity);
CouponForm couponForm = smsCouponConverter.entity2Form(entity);
return couponForm;
}
@ -70,7 +70,7 @@ public class SmsCouponServiceImpl extends ServiceImpl<SmsCouponMapper, SmsCoupon
*/
@Override
public boolean saveCoupon(CouponForm couponForm) {
SmsCoupon smsCoupon = smsCouponConvert.form2Entity(couponForm);
SmsCoupon smsCoupon = smsCouponConverter.form2Entity(couponForm);
boolean result = this.save(smsCoupon);
return result;
}
@ -84,7 +84,7 @@ public class SmsCouponServiceImpl extends ServiceImpl<SmsCouponMapper, SmsCoupon
*/
@Override
public boolean updateCoupon(Long couponId, CouponForm couponForm) {
SmsCoupon entity = smsCouponConvert.form2Entity(couponForm);
SmsCoupon entity = smsCouponConverter.form2Entity(couponForm);
boolean result = this.updateById(entity);
return result;
}

View File

@ -16,6 +16,6 @@
</if>
</where>
ORDER BY
gmt_modified desc
update_time desc
</select>
</mapper>

View File

@ -15,14 +15,14 @@
<result property="useTime" column="use_time" jdbcType="TIMESTAMP"/>
<result property="orderId" column="order_id" jdbcType="BIGINT"/>
<result property="orderSn" column="order_sn" jdbcType="VARCHAR"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
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
</sql>
</mapper>

View File

@ -4,44 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.mall.sms.mapper.SmsCouponMapper">
<resultMap id="BaseResultMap" type="com.youlai.mall.sms.pojo.entity.SmsCoupon">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="TINYINT"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="platform" column="platform" jdbcType="INTEGER"/>
<result property="amount" column="amount" jdbcType="BIGINT"/>
<result property="discount" column="discount" jdbcType="DECIMAL"/>
<result property="totalCount" column="total_count" jdbcType="INTEGER"/>
<result property="minPoint" column="min_point" jdbcType="BIGINT"/>
<result property="perLimit" column="per_limit" jdbcType="INTEGER"/>
<result property="validType" column="valid_type" jdbcType="TINYINT"/>
<result property="validDays" column="valid_days" jdbcType="INTEGER"/>
<result property="validBeginTime" column="valid_begin_time" jdbcType="TIMESTAMP"/>
<result property="validEndTime" column="valid_end_time" jdbcType="TIMESTAMP"/>
<result property="useType" column="use_type" jdbcType="TINYINT"/>
<result property="receivedCount" column="received_count" jdbcType="INTEGER"/>
<result property="usedCount" column="used_count" jdbcType="INTEGER"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
<result property="deleted" column="deleted" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
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
</sql>
<!-- 优惠券分页列表 -->
<select id="listPageCoupons" resultType="com.youlai.mall.sms.pojo.entity.SmsCoupon">
<select id="listCouponPages" resultType="com.youlai.mall.sms.pojo.entity.SmsCoupon">
SELECT
*
FROM