1.优化
Showing
150 changed files
with
1444 additions
and
1264 deletions
1 | package com.topdraw.business.module.common.domain; | 1 | package com.topdraw.business.module.common.domain; |
2 | 2 | ||
3 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
3 | import lombok.Data; | 4 | import lombok.Data; |
4 | import lombok.experimental.Accessors; | 5 | import lombok.experimental.Accessors; |
5 | 6 | ||
6 | import javax.persistence.Transient; | 7 | import javax.persistence.Transient; |
8 | import javax.validation.constraints.NotNull; | ||
7 | 9 | ||
8 | /** | 10 | /** |
9 | * @author : | 11 | * @author : |
... | @@ -16,12 +18,13 @@ import javax.persistence.Transient; | ... | @@ -16,12 +18,13 @@ import javax.persistence.Transient; |
16 | */ | 18 | */ |
17 | @Data | 19 | @Data |
18 | @Accessors(chain = true) | 20 | @Accessors(chain = true) |
19 | public class DefaultAsyncMqModule { | 21 | public class AsyncMqModule { |
20 | |||
21 | @Transient | ||
22 | private String platformAccount; | ||
23 | 22 | ||
24 | @Transient | 23 | @Transient |
24 | @NotNull(message = "memberCode can't be null" , groups = {UpdateGroup.class}) | ||
25 | private String memberCode; | 25 | private String memberCode; |
26 | 26 | ||
27 | /** 运营商平台账号 */ | ||
28 | @Transient | ||
29 | private String platformAccount; | ||
27 | } | 30 | } | ... | ... |
... | @@ -12,6 +12,7 @@ import javax.persistence.*; | ... | @@ -12,6 +12,7 @@ import javax.persistence.*; |
12 | import java.io.Serializable; | 12 | import java.io.Serializable; |
13 | import java.math.BigDecimal; | 13 | import java.math.BigDecimal; |
14 | import java.sql.Timestamp; | 14 | import java.sql.Timestamp; |
15 | import java.time.LocalDateTime; | ||
15 | 16 | ||
16 | /** | 17 | /** |
17 | * @author XiangHan | 18 | * @author XiangHan |
... | @@ -24,94 +25,94 @@ import java.sql.Timestamp; | ... | @@ -24,94 +25,94 @@ import java.sql.Timestamp; |
24 | @Table(name="m_coupon") | 25 | @Table(name="m_coupon") |
25 | public class Coupon implements Serializable { | 26 | public class Coupon implements Serializable { |
26 | 27 | ||
27 | // id | 28 | /** id */ |
28 | @Id | 29 | @Id |
29 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 30 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
30 | @Column(name = "id") | 31 | @Column(name = "id") |
31 | private Long id; | 32 | private Long id; |
32 | 33 | ||
33 | // 标识 | 34 | /** 标识 */ |
34 | @Column(name = "code", nullable = false) | 35 | @Column(name = "code", nullable = false) |
35 | private String code; | 36 | private String code; |
36 | 37 | ||
37 | // 名称 | 38 | /** 名称 */ |
38 | @Column(name = "title", nullable = false) | 39 | @Column(name = "title", nullable = false) |
39 | private String title; | 40 | private String title; |
40 | 41 | ||
41 | // 图片 | 42 | /** 图片 */ |
42 | @Column(name = "images") | 43 | @Column(name = "images") |
43 | private String images; | 44 | private String images; |
44 | 45 | ||
45 | // 发行量,-1代表不限量 | 46 | /** 发行量,-1代表不限量 */ |
46 | @Column(name = "stock") | 47 | @Column(name = "stock") |
47 | private Integer stock; | 48 | private Integer stock; |
48 | 49 | ||
49 | // 剩余量,-1代表不限量 | 50 | /** 剩余量,-1代表不限量 */ |
50 | @Column(name = "remain_stock") | 51 | @Column(name = "remain_stock") |
51 | private Integer remainStock; | 52 | private Integer remainStock; |
52 | 53 | ||
53 | // 优惠形式:1:现金;2:折扣 | 54 | /** 优惠形式:1:现金;2:折扣 */ |
54 | @Column(name = "use_type") | 55 | @Column(name = "use_type") |
55 | private Integer useType; | 56 | private Integer useType; |
56 | 57 | ||
57 | // 面额 | 58 | /** 面额 */ |
58 | @Column(name = "denomination") | 59 | @Column(name = "denomination") |
59 | private BigDecimal denomination; | 60 | private BigDecimal denomination; |
60 | 61 | ||
61 | // 折扣 | 62 | /** 折扣 */ |
62 | @Column(name = "discount") | 63 | @Column(name = "discount") |
63 | private BigDecimal discount; | 64 | private BigDecimal discount; |
64 | 65 | ||
65 | // 适用用户范围:1:新用户;2:全体用户 | 66 | /** 适用用户范围:1:新用户;2:全体用户 */ |
66 | @Column(name = "user_range") | 67 | @Column(name = "user_range") |
67 | private Integer userRange; | 68 | private Integer userRange; |
68 | 69 | ||
69 | // 限领次数 -1:无限次; >0:具体次数 | 70 | /** 限领次数 -1:无限次; >0:具体次数 */ |
70 | @Column(name = "collect_limit") | 71 | @Column(name = "collect_limit") |
71 | private Integer collectLimit; | 72 | private Integer collectLimit; |
72 | 73 | ||
73 | // 适用门槛:1:无门槛;2:满减形式 | 74 | /** 适用门槛:1:无门槛;2:满减形式 */ |
74 | @Column(name = "threshold_type") | 75 | @Column(name = "threshold_type") |
75 | private Integer thresholdType; | 76 | private Integer thresholdType; |
76 | 77 | ||
77 | // 满减门槛 | 78 | /** 满减门槛 */ |
78 | @Column(name = "amount_threshold") | 79 | @Column(name = "amount_threshold") |
79 | private BigDecimal amountThreshold; | 80 | private BigDecimal amountThreshold; |
80 | 81 | ||
81 | // 产品范围:1:全部商品;2:指定商品 | 82 | /** 产品范围:1:全部商品;2:指定商品 */ |
82 | @Column(name = "item_range") | 83 | @Column(name = "item_range") |
83 | private Integer itemRange; | 84 | private Integer itemRange; |
84 | 85 | ||
85 | // 生效形式:1:固定日期;2:相对日期 | 86 | /** 生效形式:1:固定日期;2:相对日期 */ |
86 | @Column(name = "effect_type") | 87 | @Column(name = "effect_type") |
87 | private Integer effectType; | 88 | private Integer effectType; |
88 | 89 | ||
89 | // 生效时间 | 90 | /** 生效时间 */ |
90 | @Column(name = "start_time") | 91 | @Column(name = "start_time") |
91 | private Timestamp startTime; | 92 | private Timestamp startTime; |
92 | 93 | ||
93 | // 过期时间 | 94 | /** 过期时间 */ |
94 | @Column(name = "expire_time") | 95 | @Column(name = "expire_time") |
95 | private Timestamp expireTime; | 96 | private LocalDateTime expireTime; |
96 | 97 | ||
97 | // 自领取当日,几天内有效 | 98 | /** 自领取当日,几天内有效 */ |
98 | @Column(name = "valid_days") | 99 | @Column(name = "valid_days") |
99 | private Integer validDays; | 100 | private Integer validDays; |
100 | 101 | ||
101 | // 使用说明 | 102 | /** 使用说明 */ |
102 | @Column(name = "description") | 103 | @Column(name = "description") |
103 | private String description; | 104 | private String description; |
104 | 105 | ||
105 | // 状态0:未开始,1:启用;2:停用 | 106 | /** 状态0:未开始,1:启用;2:停用 */ |
106 | @Column(name = "status") | 107 | @Column(name = "status") |
107 | private Integer status; | 108 | private Integer status; |
108 | 109 | ||
109 | // 创建时间 | 110 | /** 创建时间 */ |
110 | @CreatedDate | 111 | @CreatedDate |
111 | @Column(name = "create_time") | 112 | @Column(name = "create_time") |
112 | private Timestamp createTime; | 113 | private Timestamp createTime; |
113 | 114 | ||
114 | // 更新时间 | 115 | /** 更新时间 */ |
115 | @LastModifiedDate | 116 | @LastModifiedDate |
116 | @Column(name = "update_time") | 117 | @Column(name = "update_time") |
117 | private Timestamp updateTime; | 118 | private Timestamp updateTime; | ... | ... |
1 | package com.topdraw.business.module.coupon.domain; | ||
2 | |||
3 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | ||
4 | import com.topdraw.util.IdWorker; | ||
5 | import org.apache.commons.lang3.StringUtils; | ||
6 | import org.springframework.beans.BeanUtils; | ||
7 | |||
8 | import java.math.BigDecimal; | ||
9 | import java.sql.Timestamp; | ||
10 | import java.time.LocalDateTime; | ||
11 | import java.util.Objects; | ||
12 | |||
13 | /** | ||
14 | * 优惠券 | ||
15 | */ | ||
16 | public class CouponBuilder { | ||
17 | |||
18 | public static Coupon build(CouponDTO couponDTO){ | ||
19 | Coupon coupon = new Coupon(); | ||
20 | BeanUtils.copyProperties(couponDTO,coupon); | ||
21 | return build(coupon.getId(), | ||
22 | coupon.getCode(), | ||
23 | coupon.getTitle(),coupon.getImages(),coupon.getStock(),coupon.getRemainStock(),coupon.getUseType(), | ||
24 | coupon.getDenomination(),coupon.getDiscount(),coupon.getUserRange(),coupon.getCollectLimit(), | ||
25 | coupon.getThresholdType(),coupon.getAmountThreshold(),coupon.getItemRange(),coupon.getEffectType(), | ||
26 | coupon.getStartTime(),coupon.getExpireTime(),coupon.getValidDays(),coupon.getDescription(),coupon.getStatus()); | ||
27 | } | ||
28 | |||
29 | public static Coupon build(Coupon coupon){ | ||
30 | return build(coupon.getId(), | ||
31 | coupon.getCode(), | ||
32 | coupon.getTitle(),coupon.getImages(),coupon.getStock(),coupon.getRemainStock(),coupon.getUseType(), | ||
33 | coupon.getDenomination(),coupon.getDiscount(),coupon.getUserRange(),coupon.getCollectLimit(), | ||
34 | coupon.getThresholdType(),coupon.getAmountThreshold(),coupon.getItemRange(),coupon.getEffectType(), | ||
35 | coupon.getStartTime(),coupon.getExpireTime(),coupon.getValidDays(),coupon.getDescription(),coupon.getStatus()); | ||
36 | } | ||
37 | |||
38 | public static Coupon build(Long id , String code , String title, | ||
39 | String images, | ||
40 | Integer stock, | ||
41 | Integer remainStock, | ||
42 | Integer useType, | ||
43 | BigDecimal denomination, | ||
44 | BigDecimal discount, | ||
45 | Integer userRange, | ||
46 | Integer collectLimit, | ||
47 | Integer thresholdType, | ||
48 | BigDecimal amountThreshold, | ||
49 | Integer itemRange, | ||
50 | Integer effectType, | ||
51 | Timestamp startTime, | ||
52 | LocalDateTime expireTime, | ||
53 | Integer validDays,String description , Integer status){ | ||
54 | |||
55 | Coupon coupon = new Coupon(); | ||
56 | coupon.setId(id); | ||
57 | coupon.setCode(StringUtils.isBlank(code)? IdWorker.generatorCode("coupon"):code); | ||
58 | coupon.setTitle(StringUtils.isBlank(title)?null:title); | ||
59 | coupon.setImages(StringUtils.isBlank(images)?null:images); | ||
60 | coupon.setStock(Objects.isNull(stock)?null:stock); | ||
61 | coupon.setRemainStock(Objects.isNull(remainStock)?null:remainStock); | ||
62 | coupon.setUseType(Objects.isNull(useType)?null:useType); | ||
63 | coupon.setDenomination(Objects.isNull(denomination)?null:denomination); | ||
64 | coupon.setDiscount(Objects.isNull(discount)?null:discount); | ||
65 | coupon.setUserRange(Objects.isNull(userRange)?null:userRange); | ||
66 | coupon.setCollectLimit(collectLimit); | ||
67 | coupon.setThresholdType(Objects.isNull(thresholdType)?null:thresholdType); | ||
68 | coupon.setAmountThreshold(Objects.isNull(amountThreshold)?null:amountThreshold); | ||
69 | coupon.setItemRange(Objects.isNull(itemRange)?null:itemRange); | ||
70 | coupon.setEffectType(Objects.isNull(effectType)?null:effectType); | ||
71 | coupon.setStartTime(Objects.isNull(startTime)?null: startTime); | ||
72 | coupon.setExpireTime(Objects.isNull(expireTime)?null:expireTime); | ||
73 | coupon.setValidDays(validDays); | ||
74 | coupon.setDescription(StringUtils.isBlank(description)?"":description); | ||
75 | coupon.setStatus(Objects.nonNull(status)?status:0); | ||
76 | return coupon; | ||
77 | } | ||
78 | |||
79 | } |
... | @@ -10,7 +10,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -10,7 +10,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
10 | 10 | ||
11 | import javax.persistence.*; | 11 | import javax.persistence.*; |
12 | import java.io.Serializable; | 12 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | ||
14 | import java.time.LocalDateTime; | 13 | import java.time.LocalDateTime; |
15 | 14 | ||
16 | /** | 15 | /** |
... | @@ -24,54 +23,54 @@ import java.time.LocalDateTime; | ... | @@ -24,54 +23,54 @@ import java.time.LocalDateTime; |
24 | @Table(name="m_coupon_history") | 23 | @Table(name="m_coupon_history") |
25 | public class CouponHistory implements Serializable { | 24 | public class CouponHistory implements Serializable { |
26 | 25 | ||
27 | // 主键 | 26 | /** 主键 */ |
28 | @Id | 27 | @Id |
29 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
30 | @Column(name = "id") | 29 | @Column(name = "id") |
31 | private Long id; | 30 | private Long id; |
32 | 31 | ||
33 | // 优惠券id | 32 | /** 优惠券id */ |
34 | @Column(name = "coupon_id") | 33 | @Column(name = "coupon_id") |
35 | private Long couponId; | 34 | private Long couponId; |
36 | 35 | ||
37 | // 领券用户id(对应账号) | 36 | /** 领券用户id(对应账号) */ |
38 | @Column(name = "user_id") | 37 | @Column(name = "user_id") |
39 | private Long userId; | 38 | private Long userId; |
40 | 39 | ||
41 | // 优惠券code | 40 | /** 优惠券code */ |
42 | @Column(name = "coupon_code") | 41 | @Column(name = "coupon_code") |
43 | private String couponCode; | 42 | private String couponCode; |
44 | 43 | ||
45 | // 领取人昵称 | 44 | /** 领取人昵称 */ |
46 | @Column(name = "user_nickname") | 45 | @Column(name = "user_nickname") |
47 | private String userNickname; | 46 | private String userNickname; |
48 | 47 | ||
49 | // 领取时间 | 48 | /** 领取时间 */ |
50 | @Column(name = "receive_time") | 49 | @Column(name = "receive_time") |
51 | private LocalDateTime receiveTime; | 50 | private LocalDateTime receiveTime; |
52 | 51 | ||
53 | // 失效时间 | 52 | /** 失效时间 */ |
54 | @Column(name = "expire_time") | 53 | @Column(name = "expire_time") |
55 | private LocalDateTime expireTime; | 54 | private LocalDateTime expireTime; |
56 | 55 | ||
57 | // 使用状态 0:未使用;1:已使用;-1:已过期 | 56 | /** 使用状态 0:未使用;1:已使用;-1:已过期 */ |
58 | @Column(name = "use_status") | 57 | @Column(name = "use_status") |
59 | private Integer useStatus; | 58 | private Integer useStatus; |
60 | 59 | ||
61 | // 使用时间 | 60 | /** 使用时间 */ |
62 | @Column(name = "use_time") | 61 | @Column(name = "use_time") |
63 | private LocalDateTime useTime; | 62 | private LocalDateTime useTime; |
64 | 63 | ||
65 | // 订单详情id | 64 | /** 订单详情id */ |
66 | @Column(name = "order_detail_id") | 65 | @Column(name = "order_detail_id") |
67 | private Long orderDetailId; | 66 | private Long orderDetailId; |
68 | 67 | ||
69 | // 创建时间 | 68 | /** 创建时间 */ |
70 | @CreatedDate | 69 | @CreatedDate |
71 | @Column(name = "create_time") | 70 | @Column(name = "create_time") |
72 | private LocalDateTime createTime; | 71 | private LocalDateTime createTime; |
73 | 72 | ||
74 | // 更新时间 | 73 | /** 更新时间 */ |
75 | @LastModifiedDate | 74 | @LastModifiedDate |
76 | @Column(name = "update_time") | 75 | @Column(name = "update_time") |
77 | private LocalDateTime updateTime; | 76 | private LocalDateTime updateTime; | ... | ... |
src/main/java/com/topdraw/business/module/coupon/history/domain/CouponHistoryBuilder.java
0 → 100644
1 | package com.topdraw.business.module.coupon.history.domain; | ||
2 | |||
3 | import com.topdraw.business.module.coupon.domain.Coupon; | ||
4 | import org.apache.commons.lang3.StringUtils; | ||
5 | |||
6 | import java.time.LocalDateTime; | ||
7 | import java.util.Objects; | ||
8 | |||
9 | /** | ||
10 | * 优惠券 | ||
11 | */ | ||
12 | public class CouponHistoryBuilder { | ||
13 | |||
14 | public static CouponHistory build(CouponHistory couponHistory){ | ||
15 | return build(couponHistory.getId(), | ||
16 | couponHistory.getCouponId(), | ||
17 | couponHistory.getUserId(), | ||
18 | couponHistory.getCouponCode(), | ||
19 | couponHistory.getUserNickname(), | ||
20 | couponHistory.getReceiveTime(), | ||
21 | couponHistory.getExpireTime(), | ||
22 | couponHistory.getUseStatus(), | ||
23 | couponHistory.getUseTime(), | ||
24 | couponHistory.getOrderDetailId()); | ||
25 | } | ||
26 | |||
27 | public static CouponHistory build(Coupon coupon, Long userId, String userNickname){ | ||
28 | return build(coupon,userId,userNickname,null); | ||
29 | } | ||
30 | |||
31 | public static CouponHistory build(Coupon coupon, Long userId, String userNickname, Long orderDetailId){ | ||
32 | return build(null, | ||
33 | coupon.getId(),userId,coupon.getCode(),userNickname,LocalDateTime.now(), | ||
34 | coupon.getExpireTime(),coupon.getStatus(),null,orderDetailId); | ||
35 | } | ||
36 | |||
37 | public static CouponHistory build(Long id , Long couponId , Long userId, String couponCode, String userNickname, LocalDateTime receiveTime, | ||
38 | LocalDateTime expireTime, Integer useStatus, LocalDateTime useTime, | ||
39 | Long orderDetailId) { | ||
40 | CouponHistory couponHistory = new CouponHistory(); | ||
41 | couponHistory.setId(id); | ||
42 | couponHistory.setCouponId(Objects.isNull(couponId)?null:couponId); | ||
43 | couponHistory.setUserId(Objects.isNull(userId)?null:userId); | ||
44 | couponHistory.setCouponCode(StringUtils.isBlank(couponCode)?null:couponCode); | ||
45 | couponHistory.setUserNickname(StringUtils.isBlank(userNickname)?null:userNickname); | ||
46 | couponHistory.setReceiveTime(Objects.isNull(receiveTime)?null:receiveTime); | ||
47 | couponHistory.setExpireTime(Objects.isNull(expireTime)?null:expireTime); | ||
48 | couponHistory.setUseStatus(Objects.isNull(useStatus)?0:useStatus); | ||
49 | couponHistory.setUseTime(Objects.isNull(useTime)?null:useTime); | ||
50 | couponHistory.setOrderDetailId(Objects.isNull(orderDetailId)?null:orderDetailId); | ||
51 | return couponHistory; | ||
52 | } | ||
53 | |||
54 | } |
... | @@ -4,7 +4,6 @@ import com.topdraw.business.module.coupon.history.domain.CouponHistory; | ... | @@ -4,7 +4,6 @@ import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | 6 | ||
7 | import java.sql.Timestamp; | ||
8 | import java.time.LocalDateTime; | 7 | import java.time.LocalDateTime; |
9 | 8 | ||
10 | /** | 9 | /** | ... | ... |
... | @@ -2,13 +2,8 @@ package com.topdraw.business.module.coupon.history.service; | ... | @@ -2,13 +2,8 @@ package com.topdraw.business.module.coupon.history.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
4 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; | 4 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; |
5 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | 5 | ||
8 | import java.sql.Timestamp; | ||
9 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
10 | import java.util.List; | ||
11 | import java.util.Map; | ||
12 | 7 | ||
13 | /** | 8 | /** |
14 | * @author XiangHan | 9 | * @author XiangHan |
... | @@ -16,20 +11,6 @@ import java.util.Map; | ... | @@ -16,20 +11,6 @@ import java.util.Map; |
16 | */ | 11 | */ |
17 | public interface CouponHistoryService { | 12 | public interface CouponHistoryService { |
18 | 13 | ||
19 | /** | ||
20 | * 查询数据分页 | ||
21 | * @param criteria 条件参数 | ||
22 | * @param pageable 分页参数 | ||
23 | * @return Map<String,Object> | ||
24 | */ | ||
25 | Map<String,Object> queryAll(CouponHistoryQueryCriteria criteria, Pageable pageable); | ||
26 | |||
27 | /** | ||
28 | * 查询所有数据不分页 | ||
29 | * @param criteria 条件参数 | ||
30 | * @return List<CouponHistoryDTO> | ||
31 | */ | ||
32 | List<CouponHistoryDTO> queryAll(CouponHistoryQueryCriteria criteria); | ||
33 | 14 | ||
34 | /** | 15 | /** |
35 | * 根据ID查询 | 16 | * 根据ID查询 |
... | @@ -38,15 +19,33 @@ public interface CouponHistoryService { | ... | @@ -38,15 +19,33 @@ public interface CouponHistoryService { |
38 | */ | 19 | */ |
39 | CouponHistoryDTO findById(Long id); | 20 | CouponHistoryDTO findById(Long id); |
40 | 21 | ||
22 | /** | ||
23 | * | ||
24 | * @param resources | ||
25 | */ | ||
41 | void create(CouponHistory resources); | 26 | void create(CouponHistory resources); |
42 | 27 | ||
43 | void update(CouponHistory resources); | 28 | /** |
44 | 29 | * | |
45 | void delete(Long id); | 30 | * @param userId |
46 | 31 | * @return | |
32 | */ | ||
47 | Long countByUserId(Long userId); | 33 | Long countByUserId(Long userId); |
48 | 34 | ||
35 | /** | ||
36 | * | ||
37 | * @param userId | ||
38 | * @param now | ||
39 | * @return | ||
40 | */ | ||
49 | Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now); | 41 | Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now); |
50 | 42 | ||
43 | /** | ||
44 | * | ||
45 | * @param userId | ||
46 | * @param now | ||
47 | * @param expireTime | ||
48 | * @return | ||
49 | */ | ||
51 | Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime); | 50 | Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime); |
52 | } | 51 | } | ... | ... |
... | @@ -3,7 +3,6 @@ package com.topdraw.business.module.coupon.history.service.dto; | ... | @@ -3,7 +3,6 @@ package com.topdraw.business.module.coupon.history.service.dto; |
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | ||
7 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
8 | 7 | ||
9 | 8 | ||
... | @@ -14,39 +13,39 @@ import java.time.LocalDateTime; | ... | @@ -14,39 +13,39 @@ import java.time.LocalDateTime; |
14 | @Data | 13 | @Data |
15 | public class CouponHistoryDTO implements Serializable { | 14 | public class CouponHistoryDTO implements Serializable { |
16 | 15 | ||
17 | // 主键 | 16 | /** 主键 */ |
18 | private Long id; | 17 | private Long id; |
19 | 18 | ||
20 | // 优惠券id | 19 | /** 优惠券id */ |
21 | private Long couponId; | 20 | private Long couponId; |
22 | 21 | ||
23 | // 领券用户id(对应账号) | 22 | /** 领券用户id(对应账号) */ |
24 | private Long userId; | 23 | private Long userId; |
25 | 24 | ||
26 | // 优惠券code | 25 | /** 优惠券code */ |
27 | private String couponCode; | 26 | private String couponCode; |
28 | 27 | ||
29 | // 领取人昵称 | 28 | /** 领取人昵称 */ |
30 | private String userNickname; | 29 | private String userNickname; |
31 | 30 | ||
32 | // 领取时间 | 31 | /** 领取时间 */ |
33 | private LocalDateTime receiveTime; | 32 | private LocalDateTime receiveTime; |
34 | 33 | ||
35 | // 失效时间 | 34 | /** 失效时间 */ |
36 | private LocalDateTime expireTime; | 35 | private LocalDateTime expireTime; |
37 | 36 | ||
38 | // 使用状态 0:未使用;1:已使用;-1:已过期 | 37 | /** 使用状态 0:未使用;1:已使用;-1:已过期 */ |
39 | private Integer useStatus; | 38 | private Integer useStatus; |
40 | 39 | ||
41 | // 使用时间 | 40 | /** 使用时间 */ |
42 | private LocalDateTime useTime; | 41 | private LocalDateTime useTime; |
43 | 42 | ||
44 | // 订单详情id | 43 | /** 订单详情id */ |
45 | private Long orderDetailId; | 44 | private Long orderDetailId; |
46 | 45 | ||
47 | // 创建时间 | 46 | /** 创建时间 */ |
48 | private LocalDateTime createTime; | 47 | private LocalDateTime createTime; |
49 | 48 | ||
50 | // 更新时间 | 49 | /** 更新时间 */ |
51 | private LocalDateTime updateTime; | 50 | private LocalDateTime updateTime; |
52 | } | 51 | } | ... | ... |
1 | package com.topdraw.business.module.coupon.history.service.impl; | 1 | package com.topdraw.business.module.coupon.history.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
4 | import com.topdraw.business.module.coupon.history.domain.CouponHistoryBuilder; | ||
4 | import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository; | 5 | import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository; |
5 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; | 6 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; |
6 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; | 7 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO; |
7 | import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria; | ||
8 | import com.topdraw.business.module.coupon.history.service.mapper.CouponHistoryMapper; | 8 | import com.topdraw.business.module.coupon.history.service.mapper.CouponHistoryMapper; |
9 | import com.topdraw.utils.PageUtil; | ||
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.ValidationUtil; | 9 | import com.topdraw.utils.ValidationUtil; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
14 | import org.springframework.data.domain.Page; | ||
15 | import org.springframework.data.domain.Pageable; | ||
16 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
17 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
18 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
19 | import org.springframework.util.Assert; | ||
20 | 14 | ||
21 | import java.sql.Timestamp; | ||
22 | import java.time.LocalDateTime; | 15 | import java.time.LocalDateTime; |
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | 16 | ||
26 | /** | 17 | /** |
27 | * @author XiangHan | 18 | * @author XiangHan |
... | @@ -32,67 +23,38 @@ import java.util.Map; | ... | @@ -32,67 +23,38 @@ import java.util.Map; |
32 | public class CouponHistoryServiceImpl implements CouponHistoryService { | 23 | public class CouponHistoryServiceImpl implements CouponHistoryService { |
33 | 24 | ||
34 | @Autowired | 25 | @Autowired |
35 | private CouponHistoryRepository CouponHistoryRepository; | 26 | private CouponHistoryMapper couponHistoryMapper; |
36 | |||
37 | @Autowired | 27 | @Autowired |
38 | private CouponHistoryMapper CouponHistoryMapper; | 28 | private CouponHistoryRepository couponHistoryRepository; |
39 | |||
40 | @Override | ||
41 | public Map<String, Object> queryAll(CouponHistoryQueryCriteria criteria, Pageable pageable) { | ||
42 | Page<CouponHistory> page = CouponHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
43 | return PageUtil.toPage(page.map(CouponHistoryMapper::toDto)); | ||
44 | } | ||
45 | 29 | ||
46 | @Override | ||
47 | public List<CouponHistoryDTO> queryAll(CouponHistoryQueryCriteria criteria) { | ||
48 | return CouponHistoryMapper.toDto(CouponHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
49 | } | ||
50 | 30 | ||
51 | @Override | 31 | @Override |
52 | public CouponHistoryDTO findById(Long id) { | 32 | public CouponHistoryDTO findById(Long id) { |
53 | CouponHistory CouponHistory = CouponHistoryRepository.findById(id).orElseGet(CouponHistory::new); | 33 | CouponHistory couponHistory = this.couponHistoryRepository.findById(id).orElseGet(CouponHistory::new); |
54 | ValidationUtil.isNull(CouponHistory.getId(),"CouponHistory","id",id); | 34 | ValidationUtil.isNull(couponHistory.getId(),"CouponHistory","id",id); |
55 | return CouponHistoryMapper.toDto(CouponHistory); | 35 | return this.couponHistoryMapper.toDto(couponHistory); |
56 | } | 36 | } |
57 | 37 | ||
58 | @Override | 38 | @Override |
59 | @Transactional(rollbackFor = Exception.class) | 39 | @Transactional(rollbackFor = Exception.class) |
60 | public void create(CouponHistory resources) { | 40 | public void create(CouponHistory resources) { |
61 | CouponHistoryRepository.save(resources); | 41 | CouponHistory couponHistory = CouponHistoryBuilder.build(resources); |
62 | } | 42 | this.couponHistoryRepository.save(couponHistory); |
63 | |||
64 | @Override | ||
65 | @Transactional(rollbackFor = Exception.class) | ||
66 | public void update(CouponHistory resources) { | ||
67 | CouponHistory CouponHistory = CouponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new); | ||
68 | ValidationUtil.isNull( CouponHistory.getId(),"CouponHistory","id",resources.getId()); | ||
69 | CouponHistory.copy(resources); | ||
70 | CouponHistoryRepository.save(CouponHistory); | ||
71 | } | ||
72 | |||
73 | @Override | ||
74 | @Transactional(rollbackFor = Exception.class) | ||
75 | public void delete(Long id) { | ||
76 | Assert.notNull(id, "The given id must not be null!"); | ||
77 | CouponHistory CouponHistory = CouponHistoryRepository.findById(id).orElseThrow( | ||
78 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", CouponHistory.class, id), 1)); | ||
79 | CouponHistoryRepository.delete(CouponHistory); | ||
80 | } | 43 | } |
81 | 44 | ||
82 | @Override | 45 | @Override |
83 | public Long countByUserId(Long userId) { | 46 | public Long countByUserId(Long userId) { |
84 | return this.CouponHistoryRepository.countByUserId(userId); | 47 | return this.couponHistoryRepository.countByUserId(userId); |
85 | } | 48 | } |
86 | 49 | ||
87 | @Override | 50 | @Override |
88 | public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) { | 51 | public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) { |
89 | return this.CouponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now); | 52 | return this.couponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now); |
90 | } | 53 | } |
91 | 54 | ||
92 | @Override | 55 | @Override |
93 | public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) { | 56 | public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) { |
94 | return this.CouponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime); | 57 | return this.couponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime); |
95 | } | 58 | } |
96 | 59 | ||
97 | |||
98 | } | 60 | } | ... | ... |
... | @@ -13,4 +13,5 @@ import java.util.Optional; | ... | @@ -13,4 +13,5 @@ import java.util.Optional; |
13 | public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecificationExecutor<Coupon> { | 13 | public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecificationExecutor<Coupon> { |
14 | 14 | ||
15 | Optional<Coupon> findFirstByCode(String code); | 15 | Optional<Coupon> findFirstByCode(String code); |
16 | |||
16 | } | 17 | } | ... | ... |
1 | package com.topdraw.business.module.coupon.service; | 1 | package com.topdraw.business.module.coupon.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.coupon.domain.Coupon; | ||
4 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | 3 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; |
5 | import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | 4 | ||
11 | /** | 5 | /** |
12 | * @author XiangHan | 6 | * @author XiangHan |
... | @@ -15,37 +9,18 @@ import java.util.Map; | ... | @@ -15,37 +9,18 @@ import java.util.Map; |
15 | public interface CouponService { | 9 | public interface CouponService { |
16 | 10 | ||
17 | /** | 11 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(CouponQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<CouponDTO> | ||
29 | */ | ||
30 | List<CouponDTO> queryAll(CouponQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 12 | * 根据ID查询 |
34 | * @param id ID | 13 | * @param id ID |
35 | * @return CouponDTO | 14 | * @return CouponDTO |
36 | */ | 15 | */ |
37 | CouponDTO findById(Long id); | 16 | CouponDTO findById(Long id); |
38 | 17 | ||
39 | void create(Coupon resources); | ||
40 | |||
41 | void update(Coupon resources); | ||
42 | |||
43 | void delete(Long id); | ||
44 | |||
45 | /** | 18 | /** |
46 | * Code校验 | 19 | * Code校验 |
47 | * @param code | 20 | * @param code |
48 | * @return CouponDTO | 21 | * @return CouponDTO |
49 | */ | 22 | */ |
50 | CouponDTO getByCode(String code); | 23 | CouponDTO getByCode(String code); |
24 | |||
25 | |||
51 | } | 26 | } | ... | ... |
... | @@ -5,6 +5,7 @@ import lombok.Data; | ... | @@ -5,6 +5,7 @@ import lombok.Data; |
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.math.BigDecimal; | 6 | import java.math.BigDecimal; |
7 | import java.sql.Timestamp; | 7 | import java.sql.Timestamp; |
8 | import java.time.LocalDateTime; | ||
8 | 9 | ||
9 | 10 | ||
10 | /** | 11 | /** |
... | @@ -14,69 +15,69 @@ import java.sql.Timestamp; | ... | @@ -14,69 +15,69 @@ import java.sql.Timestamp; |
14 | @Data | 15 | @Data |
15 | public class CouponDTO implements Serializable { | 16 | public class CouponDTO implements Serializable { |
16 | 17 | ||
17 | // id | 18 | /** id */ |
18 | private Long id; | 19 | private Long id; |
19 | 20 | ||
20 | // 标识 | 21 | /** 标识 */ |
21 | private String code; | 22 | private String code; |
22 | 23 | ||
23 | // 名称 | 24 | /** 名称 */ |
24 | private String title; | 25 | private String title; |
25 | 26 | ||
26 | // 图片 | 27 | /** 图片 */ |
27 | private String images; | 28 | private String images; |
28 | 29 | ||
29 | // 发行量,-1代表不限量 | 30 | /** 发行量,-1代表不限量 */ |
30 | private Integer stock; | 31 | private Integer stock; |
31 | 32 | ||
32 | // 剩余量,-1代表不限量 | 33 | /** 剩余量,-1代表不限量 */ |
33 | private Integer remainStock; | 34 | private Integer remainStock; |
34 | 35 | ||
35 | // 优惠形式:1:现金;2:折扣 | 36 | /** 优惠形式:1:现金;2:折扣 */ |
36 | private Integer useType; | 37 | private Integer useType; |
37 | 38 | ||
38 | // 面额 | 39 | /** 面额 */ |
39 | private BigDecimal denomination; | 40 | private BigDecimal denomination; |
40 | 41 | ||
41 | // 折扣 | 42 | /** 折扣 */ |
42 | private BigDecimal discount; | 43 | private BigDecimal discount; |
43 | 44 | ||
44 | // 适用用户范围:1:新用户;2:全体用户 | 45 | /** 适用用户范围:1:新用户;2:全体用户 */ |
45 | private Integer userRange; | 46 | private Integer userRange; |
46 | 47 | ||
47 | // 限领次数 -1:无限次; >0:具体次数 | 48 | /** 限领次数 -1:无限次; >0:具体次数 */ |
48 | private Integer collectLimit; | 49 | private Integer collectLimit; |
49 | 50 | ||
50 | // 适用门槛:1:无门槛;2:满减形式 | 51 | /** 适用门槛:1:无门槛;2:满减形式 */ |
51 | private Integer thresholdType; | 52 | private Integer thresholdType; |
52 | 53 | ||
53 | // 满减门槛 | 54 | /** 满减门槛 */ |
54 | private BigDecimal amountThreshold; | 55 | private BigDecimal amountThreshold; |
55 | 56 | ||
56 | // 产品范围:1:全部商品;2:指定商品 | 57 | /** 产品范围:1:全部商品;2:指定商品 */ |
57 | private Integer itemRange; | 58 | private Integer itemRange; |
58 | 59 | ||
59 | // 生效形式:1:固定日期;2:相对日期 | 60 | /** 生效形式:1:固定日期;2:相对日期 */ |
60 | private Integer effectType; | 61 | private Integer effectType; |
61 | 62 | ||
62 | // 生效时间 | 63 | /** 生效时间 */ |
63 | private Timestamp startTime; | 64 | private Timestamp startTime; |
64 | 65 | ||
65 | // 过期时间 | 66 | /** 过期时间 */ |
66 | private Timestamp expireTime; | 67 | private LocalDateTime expireTime; |
67 | 68 | ||
68 | // 自领取当日,几天内有效 | 69 | /** 自领取当日,几天内有效 */ |
69 | private Integer validDays; | 70 | private Integer validDays; |
70 | 71 | ||
71 | // 使用说明 | 72 | /** 使用说明 */ |
72 | private String description; | 73 | private String description; |
73 | 74 | ||
74 | // 状态0:未开始,1:启用;2:停用 | 75 | /** 状态0:未开始,1:启用;2:停用 */ |
75 | private Integer status; | 76 | private Integer status; |
76 | 77 | ||
77 | // 创建时间 | 78 | /** 创建时间 */ |
78 | private Timestamp createTime; | 79 | private Timestamp createTime; |
79 | 80 | ||
80 | // 更新时间 | 81 | /** 更新时间 */ |
81 | private Timestamp updateTime; | 82 | private Timestamp updateTime; |
82 | } | 83 | } | ... | ... |
... | @@ -4,23 +4,16 @@ import com.topdraw.business.module.coupon.domain.Coupon; | ... | @@ -4,23 +4,16 @@ import com.topdraw.business.module.coupon.domain.Coupon; |
4 | import com.topdraw.business.module.coupon.repository.CouponRepository; | 4 | import com.topdraw.business.module.coupon.repository.CouponRepository; |
5 | import com.topdraw.business.module.coupon.service.CouponService; | 5 | import com.topdraw.business.module.coupon.service.CouponService; |
6 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; | 6 | import com.topdraw.business.module.coupon.service.dto.CouponDTO; |
7 | import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria; | ||
8 | import com.topdraw.business.module.coupon.service.mapper.CouponMapper; | 7 | import com.topdraw.business.module.coupon.service.mapper.CouponMapper; |
9 | import com.topdraw.utils.PageUtil; | 8 | import com.topdraw.exception.GlobeExceptionMsg; |
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.StringUtils; | 9 | import com.topdraw.utils.StringUtils; |
12 | import com.topdraw.utils.ValidationUtil; | 10 | import com.topdraw.utils.ValidationUtil; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.dao.EmptyResultDataAccessException; | ||
15 | import org.springframework.data.domain.Page; | ||
16 | import org.springframework.data.domain.Pageable; | ||
17 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
18 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
19 | import org.springframework.transaction.annotation.Transactional; | 14 | import org.springframework.transaction.annotation.Transactional; |
20 | import org.springframework.util.Assert; | 15 | import org.springframework.util.Assert; |
21 | 16 | ||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | 17 | ||
25 | /** | 18 | /** |
26 | * @author XiangHan | 19 | * @author XiangHan |
... | @@ -30,58 +23,24 @@ import java.util.Map; | ... | @@ -30,58 +23,24 @@ import java.util.Map; |
30 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 23 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
31 | public class CouponServiceImpl implements CouponService { | 24 | public class CouponServiceImpl implements CouponService { |
32 | 25 | ||
33 | @Autowired | ||
34 | private CouponRepository CouponRepository; | ||
35 | 26 | ||
36 | @Autowired | 27 | @Autowired |
37 | private CouponMapper CouponMapper; | 28 | private CouponMapper couponMapper; |
38 | 29 | @Autowired | |
39 | @Override | 30 | private CouponRepository couponRepository; |
40 | public Map<String, Object> queryAll(CouponQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<Coupon> page = CouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(CouponMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<CouponDTO> queryAll(CouponQueryCriteria criteria) { | ||
47 | return CouponMapper.toDto(CouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | 31 | ||
50 | @Override | 32 | @Override |
51 | public CouponDTO findById(Long id) { | 33 | public CouponDTO findById(Long id) { |
52 | Coupon Coupon = CouponRepository.findById(id).orElseGet(Coupon::new); | 34 | Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL); |
53 | ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id); | ||
54 | return CouponMapper.toDto(Coupon); | ||
55 | } | ||
56 | 35 | ||
57 | @Override | 36 | Coupon coupon = this.couponRepository.findById(id).orElseGet(Coupon::new); |
58 | @Transactional(rollbackFor = Exception.class) | 37 | ValidationUtil.isNull(coupon.getId(),"Coupon","id",id); |
59 | public void create(Coupon resources) { | 38 | return this.couponMapper.toDto(coupon); |
60 | CouponRepository.save(resources); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | @Transactional(rollbackFor = Exception.class) | ||
65 | public void update(Coupon resources) { | ||
66 | Coupon Coupon = CouponRepository.findById(resources.getId()).orElseGet(Coupon::new); | ||
67 | ValidationUtil.isNull( Coupon.getId(),"Coupon","id",resources.getId()); | ||
68 | Coupon.copy(resources); | ||
69 | CouponRepository.save(Coupon); | ||
70 | } | 39 | } |
71 | 40 | ||
72 | @Override | 41 | @Override |
73 | @Transactional(rollbackFor = Exception.class) | ||
74 | public void delete(Long id) { | ||
75 | Assert.notNull(id, "The given id must not be null!"); | ||
76 | Coupon Coupon = CouponRepository.findById(id).orElseThrow( | ||
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Coupon.class, id), 1)); | ||
78 | CouponRepository.delete(Coupon); | ||
79 | } | ||
80 | |||
81 | |||
82 | @Override | ||
83 | public CouponDTO getByCode(String code) { | 42 | public CouponDTO getByCode(String code) { |
84 | return StringUtils.isNotEmpty(code) ? CouponMapper.toDto(CouponRepository.findFirstByCode(code).orElseGet(Coupon::new)) | 43 | return StringUtils.isNotEmpty(code) ? this.couponMapper.toDto(this.couponRepository.findFirstByCode(code).orElseGet(Coupon::new)) |
85 | : new CouponDTO(); | 44 | : new CouponDTO(); |
86 | } | 45 | } |
87 | } | 46 | } | ... | ... |
... | @@ -23,70 +23,70 @@ import java.sql.Timestamp; | ... | @@ -23,70 +23,70 @@ import java.sql.Timestamp; |
23 | @Table(name="uc_exp_detail") | 23 | @Table(name="uc_exp_detail") |
24 | public class ExpDetail implements Serializable { | 24 | public class ExpDetail implements Serializable { |
25 | 25 | ||
26 | // 主键 | 26 | /** 主键 */ |
27 | @Id | 27 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
29 | @Column(name = "id") | 29 | @Column(name = "id") |
30 | private Long id; | 30 | private Long id; |
31 | 31 | ||
32 | // 标识 | 32 | /** 标识 */ |
33 | @Column(name = "code", nullable = false) | 33 | @Column(name = "code", nullable = false) |
34 | private String code; | 34 | private String code; |
35 | 35 | ||
36 | // 应用code | 36 | /** 应用code */ |
37 | @Column(name = "app_code") | 37 | @Column(name = "app_code") |
38 | private String appCode; | 38 | private String appCode; |
39 | 39 | ||
40 | // 会员id | 40 | /** 会员id */ |
41 | @Column(name = "member_id", nullable = false) | 41 | @Column(name = "member_id", nullable = false) |
42 | private Long memberId; | 42 | private Long memberId; |
43 | 43 | ||
44 | // 账号id | 44 | /** 账号id */ |
45 | @Column(name = "account_id") | 45 | @Column(name = "account_id") |
46 | private Long accountId; | 46 | private Long accountId; |
47 | 47 | ||
48 | // 原始成长值 | 48 | /** 原始成长值 */ |
49 | @Column(name = "original_exp", nullable = false) | 49 | @Column(name = "original_exp", nullable = false) |
50 | private Long originalExp; | 50 | private Long originalExp; |
51 | 51 | ||
52 | // 结果成长值 | 52 | /** 结果成长值 */ |
53 | @Column(name = "result_exp", nullable = false) | 53 | @Column(name = "result_exp", nullable = false) |
54 | private Long resultExp; | 54 | private Long resultExp; |
55 | 55 | ||
56 | // 成长值变化,一般为正数 | 56 | /** 成长值变化,一般为正数 */ |
57 | @Column(name = "exp", nullable = false) | 57 | @Column(name = "exp", nullable = false) |
58 | private Long exp; | 58 | private Long exp; |
59 | 59 | ||
60 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 60 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
61 | @Column(name = "device_type", nullable = false) | 61 | @Column(name = "device_type", nullable = false) |
62 | private Integer deviceType; | 62 | private Integer deviceType; |
63 | 63 | ||
64 | // 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 | 64 | /** 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 */ |
65 | @Column(name = "evt_type", nullable = false) | 65 | @Column(name = "evt_type", nullable = false) |
66 | private Integer evtType; | 66 | private Integer evtType; |
67 | 67 | ||
68 | // 订单id(针对订购操作) | 68 | /** 订单id(针对订购操作) */ |
69 | @Column(name = "order_id") | 69 | @Column(name = "order_id") |
70 | private Long orderId; | 70 | private Long orderId; |
71 | 71 | ||
72 | // 节目id(针对观影操作) | 72 | /** 节目id(针对观影操作) */ |
73 | @Column(name = "media_id") | 73 | @Column(name = "media_id") |
74 | private Long mediaId; | 74 | private Long mediaId; |
75 | 75 | ||
76 | // 活动id(针对参与活动) | 76 | /** 活动id(针对参与活动) */ |
77 | @Column(name = "activity_id") | 77 | @Column(name = "activity_id") |
78 | private Long activityId; | 78 | private Long activityId; |
79 | 79 | ||
80 | // 成长值变化描述,用于管理侧显示 | 80 | /** 成长值变化描述,用于管理侧显示 */ |
81 | @Column(name = "description", nullable = false) | 81 | @Column(name = "description", nullable = false) |
82 | private String description; | 82 | private String description; |
83 | 83 | ||
84 | // 创建时间 | 84 | /** 创建时间 */ |
85 | @CreatedDate | 85 | @CreatedDate |
86 | @Column(name = "create_time") | 86 | @Column(name = "create_time") |
87 | private Timestamp createTime; | 87 | private Timestamp createTime; |
88 | 88 | ||
89 | // 更新时间 | 89 | /** 更新时间 */ |
90 | @LastModifiedDate | 90 | @LastModifiedDate |
91 | @Column(name = "update_time") | 91 | @Column(name = "update_time") |
92 | private Timestamp updateTime; | 92 | private Timestamp updateTime; | ... | ... |
1 | package com.topdraw.business.module.exp.detail.domain; | ||
2 | |||
3 | import com.topdraw.exception.GlobeExceptionMsg; | ||
4 | import org.apache.commons.lang3.StringUtils; | ||
5 | import org.springframework.util.Assert; | ||
6 | |||
7 | import java.util.Objects; | ||
8 | |||
9 | public class ExpDetailBuilder { | ||
10 | |||
11 | public static ExpDetail build(Long memberId, Long originalExp, Long resultExp, | ||
12 | Integer deviceType, Integer evtType){ | ||
13 | ExpDetail expDetail = new ExpDetail(); | ||
14 | expDetail.setMemberId(memberId); | ||
15 | expDetail.setOriginalExp(originalExp); | ||
16 | expDetail.setResultExp(resultExp); | ||
17 | expDetail.setDeviceType(deviceType); | ||
18 | expDetail.setEvtType(evtType); | ||
19 | return build(expDetail); | ||
20 | } | ||
21 | |||
22 | public static ExpDetail build(ExpDetail expDetail){ | ||
23 | return build(expDetail.getId(), | ||
24 | expDetail.getCode(), | ||
25 | expDetail.getAppCode(), | ||
26 | expDetail.getMemberId(), | ||
27 | expDetail.getAccountId(), | ||
28 | expDetail.getOriginalExp(),expDetail.getResultExp(), | ||
29 | expDetail.getExp(),expDetail.getDeviceType(), | ||
30 | expDetail.getEvtType(), expDetail.getOrderId(), expDetail.getMediaId(), | ||
31 | expDetail.getActivityId(),expDetail.getDescription()); | ||
32 | } | ||
33 | |||
34 | public static ExpDetail build(Long id, String code, | ||
35 | String appCode, Long memberId, Long accountId, | ||
36 | Long originalExp, Long resultExp, Long exp, | ||
37 | Integer deviceType, Integer evtType, Long orderId, | ||
38 | Long mediaId, Long activityId, String description){ | ||
39 | Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL); | ||
40 | |||
41 | ExpDetail expDetail = new ExpDetail(); | ||
42 | expDetail.setId(Objects.isNull(id)?null:id); | ||
43 | expDetail.setCode(StringUtils.isBlank(code)?null:code); | ||
44 | expDetail.setAppCode(StringUtils.isBlank(appCode)?null:appCode); | ||
45 | expDetail.setMemberId(Objects.isNull(memberId)?null:memberId); | ||
46 | expDetail.setAccountId(Objects.isNull(accountId)?null:accountId); | ||
47 | expDetail.setOriginalExp(Objects.isNull(originalExp)?0:originalExp); | ||
48 | expDetail.setResultExp(Objects.isNull(resultExp)?0:resultExp); | ||
49 | expDetail.setExp(Objects.isNull(exp)?0:exp); | ||
50 | expDetail.setDeviceType(Objects.isNull(deviceType)?null:deviceType); | ||
51 | expDetail.setEvtType(Objects.isNull(evtType)?null:evtType); | ||
52 | expDetail.setOrderId(Objects.isNull(orderId)?null:orderId); | ||
53 | expDetail.setMediaId(Objects.isNull(mediaId)?null:mediaId); | ||
54 | expDetail.setActivityId(Objects.isNull(activityId)?null:activityId); | ||
55 | expDetail.setDescription(StringUtils.isBlank(description)?null:description); | ||
56 | return expDetail; | ||
57 | } | ||
58 | |||
59 | } |
... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.exp.detail.service; | ... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.exp.detail.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; | 3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; |
4 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO; | 4 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO; |
5 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | 5 | ||
11 | /** | 6 | /** |
12 | * @author XiangHan | 7 | * @author XiangHan |
... | @@ -15,31 +10,28 @@ import java.util.Map; | ... | @@ -15,31 +10,28 @@ import java.util.Map; |
15 | public interface ExpDetailService { | 10 | public interface ExpDetailService { |
16 | 11 | ||
17 | /** | 12 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<ExpDetailDTO> | ||
29 | */ | ||
30 | List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 13 | * 根据ID查询 |
34 | * @param id ID | 14 | * @param id ID |
35 | * @return ExpDetailDTO | 15 | * @return ExpDetailDTO |
36 | */ | 16 | */ |
37 | ExpDetailDTO findById(Long id); | 17 | ExpDetailDTO findById(Long id); |
38 | 18 | ||
19 | /** | ||
20 | * | ||
21 | * @param resources | ||
22 | */ | ||
39 | void create(ExpDetail resources); | 23 | void create(ExpDetail resources); |
40 | 24 | ||
25 | /** | ||
26 | * | ||
27 | * @param resources | ||
28 | */ | ||
41 | void update(ExpDetail resources); | 29 | void update(ExpDetail resources); |
42 | 30 | ||
31 | /** | ||
32 | * | ||
33 | * @param id | ||
34 | */ | ||
43 | void delete(Long id); | 35 | void delete(Long id); |
44 | 36 | ||
45 | /** | 37 | /** | ... | ... |
... | @@ -13,51 +13,51 @@ import java.sql.Timestamp; | ... | @@ -13,51 +13,51 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class ExpDetailDTO implements Serializable { | 14 | public class ExpDetailDTO implements Serializable { |
15 | 15 | ||
16 | // 主键 | 16 | /** 主键 */ |
17 | private Long id; | 17 | private Long id; |
18 | 18 | ||
19 | // 标识 | 19 | /** 标识 */ |
20 | private String code; | 20 | private String code; |
21 | 21 | ||
22 | // 应用code | 22 | /** 应用code */ |
23 | private String appCode; | 23 | private String appCode; |
24 | 24 | ||
25 | // 会员id | 25 | /** 会员id */ |
26 | private Long memberId; | 26 | private Long memberId; |
27 | 27 | ||
28 | // 账号id | 28 | /** 账号id */ |
29 | private Long accountId; | 29 | private Long accountId; |
30 | 30 | ||
31 | // 原始成长值 | 31 | /** 原始成长值 */ |
32 | private Long originalExp; | 32 | private Long originalExp; |
33 | 33 | ||
34 | // 结果成长值 | 34 | /** 结果成长值 */ |
35 | private Long resultExp; | 35 | private Long resultExp; |
36 | 36 | ||
37 | // 成长值变化,一般为正数 | 37 | /** 成长值变化,一般为正数 */ |
38 | private Long exp; | 38 | private Long exp; |
39 | 39 | ||
40 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 40 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
41 | private Integer deviceType; | 41 | private Integer deviceType; |
42 | 42 | ||
43 | // 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 | 43 | /** 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 */ |
44 | private Integer evtType; | 44 | private Integer evtType; |
45 | 45 | ||
46 | // 订单id(针对订购操作) | 46 | /** 订单id(针对订购操作) */ |
47 | private Long orderId; | 47 | private Long orderId; |
48 | 48 | ||
49 | // 节目id(针对观影操作) | 49 | /** 节目id(针对观影操作) */ |
50 | private Long mediaId; | 50 | private Long mediaId; |
51 | 51 | ||
52 | // 活动id(针对参与活动) | 52 | /** 活动id(针对参与活动) */ |
53 | private Long activityId; | 53 | private Long activityId; |
54 | 54 | ||
55 | // 成长值变化描述,用于管理侧显示 | 55 | /** 成长值变化描述,用于管理侧显示 */ |
56 | private String description; | 56 | private String description; |
57 | 57 | ||
58 | // 创建时间 | 58 | /** 创建时间 */ |
59 | private Timestamp createTime; | 59 | private Timestamp createTime; |
60 | 60 | ||
61 | // 更新时间 | 61 | /** 更新时间 */ |
62 | private Timestamp updateTime; | 62 | private Timestamp updateTime; |
63 | } | 63 | } | ... | ... |
1 | package com.topdraw.business.module.exp.detail.service.impl; | 1 | package com.topdraw.business.module.exp.detail.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; | 3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; |
4 | import com.topdraw.business.module.exp.detail.domain.ExpDetailBuilder; | ||
4 | import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository; | 5 | import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository; |
5 | import com.topdraw.business.module.exp.detail.service.ExpDetailService; | 6 | import com.topdraw.business.module.exp.detail.service.ExpDetailService; |
6 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO; | 7 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO; |
7 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria; | ||
8 | import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper; | 8 | import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper; |
9 | import com.topdraw.utils.PageUtil; | 9 | import com.topdraw.utils.RedisUtils; |
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.StringUtils; | 10 | import com.topdraw.utils.StringUtils; |
12 | import com.topdraw.utils.ValidationUtil; | 11 | import com.topdraw.utils.ValidationUtil; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.dao.EmptyResultDataAccessException; | 13 | import org.springframework.dao.EmptyResultDataAccessException; |
15 | import org.springframework.data.domain.Page; | ||
16 | import org.springframework.data.domain.Pageable; | ||
17 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
18 | import org.springframework.transaction.annotation.Propagation; | 15 | import org.springframework.transaction.annotation.Propagation; |
19 | import org.springframework.transaction.annotation.Transactional; | 16 | import org.springframework.transaction.annotation.Transactional; |
20 | import org.springframework.util.Assert; | 17 | import org.springframework.util.Assert; |
21 | 18 | ||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | 19 | ||
25 | /** | 20 | /** |
26 | * @author XiangHan | 21 | * @author XiangHan |
... | @@ -31,57 +26,56 @@ import java.util.Map; | ... | @@ -31,57 +26,56 @@ import java.util.Map; |
31 | public class ExpDetailServiceImpl implements ExpDetailService { | 26 | public class ExpDetailServiceImpl implements ExpDetailService { |
32 | 27 | ||
33 | @Autowired | 28 | @Autowired |
34 | private ExpDetailRepository ExpDetailRepository; | 29 | private ExpDetailRepository expDetailRepository; |
35 | |||
36 | @Autowired | 30 | @Autowired |
37 | private ExpDetailMapper ExpDetailMapper; | 31 | private ExpDetailMapper expDetailMapper; |
38 | 32 | ||
39 | @Override | 33 | @Autowired |
40 | public Map<String, Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable) { | 34 | private RedisUtils redisUtils; |
41 | Page<ExpDetail> page = ExpDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(ExpDetailMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria) { | ||
47 | return ExpDetailMapper.toDto(ExpDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | 35 | ||
50 | @Override | 36 | @Override |
51 | public ExpDetailDTO findById(Long id) { | 37 | public ExpDetailDTO findById(Long id) { |
52 | ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseGet(ExpDetail::new); | 38 | ExpDetail ExpDetail = this.expDetailRepository.findById(id).orElseGet(com.topdraw.business.module.exp.detail.domain.ExpDetail::new); |
53 | ValidationUtil.isNull(ExpDetail.getId(),"ExpDetail","id",id); | 39 | ValidationUtil.isNull(ExpDetail.getId(),"ExpDetail","id",id); |
54 | return ExpDetailMapper.toDto(ExpDetail); | 40 | return this.expDetailMapper.toDto(ExpDetail); |
55 | } | 41 | } |
56 | 42 | ||
57 | @Override | 43 | @Override |
58 | @Transactional(rollbackFor = Exception.class) | 44 | @Transactional(rollbackFor = Exception.class) |
59 | public void create(ExpDetail resources) { | 45 | public void create(ExpDetail resources) { |
60 | ExpDetailRepository.save(resources); | 46 | ExpDetail expDetail = ExpDetailBuilder.build(resources); |
47 | this.expDetailRepository.save(expDetail); | ||
61 | } | 48 | } |
62 | 49 | ||
63 | @Override | 50 | @Override |
64 | @Transactional(rollbackFor = Exception.class) | 51 | @Transactional(rollbackFor = Exception.class) |
65 | public void update(ExpDetail resources) { | 52 | public void update(ExpDetail resources) { |
66 | ExpDetail ExpDetail = ExpDetailRepository.findById(resources.getId()).orElseGet(ExpDetail::new); | 53 | this.redisUtils.doLock("expDetail::memberId::" + resources.getMemberId()); |
54 | try { | ||
55 | ExpDetail ExpDetail = this.expDetailRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.exp.detail.domain.ExpDetail::new); | ||
67 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); | 56 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); |
68 | ExpDetail.copy(resources); | 57 | ExpDetail.copy(resources); |
69 | ExpDetailRepository.save(ExpDetail); | 58 | this.expDetailRepository.save(ExpDetail); |
59 | } catch (Exception e) { | ||
60 | e.printStackTrace(); | ||
61 | throw e; | ||
62 | } finally { | ||
63 | this.redisUtils.doUnLock("expDetail::memberId::" + resources.getMemberId()); | ||
64 | } | ||
70 | } | 65 | } |
71 | 66 | ||
72 | @Override | 67 | @Override |
73 | @Transactional(rollbackFor = Exception.class) | 68 | @Transactional(rollbackFor = Exception.class) |
74 | public void delete(Long id) { | 69 | public void delete(Long id) { |
75 | Assert.notNull(id, "The given id must not be null!"); | 70 | Assert.notNull(id, "The given id must not be null!"); |
76 | ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseThrow( | 71 | ExpDetail ExpDetail = this.expDetailRepository.findById(id).orElseThrow( |
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ExpDetail.class, id), 1)); | 72 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.exp.detail.domain.ExpDetail.class, id), 1)); |
78 | ExpDetailRepository.delete(ExpDetail); | 73 | this.expDetailRepository.delete(ExpDetail); |
79 | } | 74 | } |
80 | 75 | ||
81 | |||
82 | @Override | 76 | @Override |
83 | public ExpDetailDTO getByCode(String code) { | 77 | public ExpDetailDTO getByCode(String code) { |
84 | return StringUtils.isNotEmpty(code) ? ExpDetailMapper.toDto(ExpDetailRepository.findFirstByCode(code).orElseGet(ExpDetail::new)) | 78 | return StringUtils.isNotEmpty(code) ? this.expDetailMapper.toDto(this.expDetailRepository.findFirstByCode(code).orElseGet(ExpDetail::new)) |
85 | : new ExpDetailDTO(); | 79 | : new ExpDetailDTO(); |
86 | } | 80 | } |
87 | } | 81 | } | ... | ... |
1 | package com.topdraw.business.module.exp.history.domain; | ||
2 | |||
3 | import com.topdraw.exception.GlobeExceptionMsg; | ||
4 | import com.topdraw.util.IdWorker; | ||
5 | import org.apache.commons.lang3.StringUtils; | ||
6 | import org.springframework.util.Assert; | ||
7 | |||
8 | import java.util.Objects; | ||
9 | |||
10 | public class ExpHistoryBuilder { | ||
11 | |||
12 | public ExpHistory build(Long memberId, Long originalExp, Long resultExp, Long exp,Integer deviceType , Integer evtType) { | ||
13 | ExpHistory expHistory = new ExpHistory(); | ||
14 | expHistory.setMemberId(memberId); | ||
15 | expHistory.setOriginalExp(originalExp); | ||
16 | expHistory.setResultExp(resultExp); | ||
17 | expHistory.setDeviceType(deviceType); | ||
18 | expHistory.setEvtType(evtType); | ||
19 | expHistory.setExp(exp); | ||
20 | return build(expHistory); | ||
21 | } | ||
22 | |||
23 | public ExpHistory build(ExpHistory expHistory) { | ||
24 | return build(expHistory.getId(),expHistory.getCode(), | ||
25 | expHistory.getMemberId(),expHistory.getAccountId(), | ||
26 | expHistory.getOriginalExp(),expHistory.getResultExp(),expHistory.getExp(), | ||
27 | expHistory.getDeviceType(),expHistory.getEvtType(),expHistory.getOrderId(), | ||
28 | expHistory.getMediaId(),expHistory.getActivityId(),expHistory.getDescription()); | ||
29 | } | ||
30 | |||
31 | public ExpHistory build(Long id,String code,Long memberId,Long accountId, | ||
32 | Long originalExp,Long resultExp,Long exp, | ||
33 | Integer deviceType,Integer evtType,Long orderId, | ||
34 | Long mediaId,Long activityId,String description) { | ||
35 | |||
36 | Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL); | ||
37 | |||
38 | ExpHistory expHistory = new ExpHistory(); | ||
39 | expHistory.setId(Objects.isNull(id)?null:id); | ||
40 | expHistory.setCode(StringUtils.isBlank(code)? IdWorker.generatorCode("exp") :code); | ||
41 | expHistory.setMemberId(memberId); | ||
42 | expHistory.setAccountId(Objects.isNull(accountId)?null:accountId); | ||
43 | expHistory.setOriginalExp(Objects.isNull(originalExp)?0L:originalExp); | ||
44 | expHistory.setResultExp(Objects.isNull(resultExp)?0L:resultExp); | ||
45 | expHistory.setExp(Objects.isNull(exp)?0L:exp); | ||
46 | expHistory.setDeviceType(Objects.isNull(deviceType)?4:deviceType); | ||
47 | expHistory.setEvtType(Objects.isNull(evtType)?98:evtType); | ||
48 | expHistory.setOrderId(Objects.isNull(orderId)?null:orderId); | ||
49 | expHistory.setMediaId(Objects.isNull(mediaId)?null:mediaId); | ||
50 | expHistory.setActivityId(Objects.isNull(activityId)?null:activityId); | ||
51 | expHistory.setDescription(StringUtils.isBlank(description)?null:description); | ||
52 | return expHistory; | ||
53 | } | ||
54 | |||
55 | |||
56 | } |
... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.exp.history.service; | ... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.exp.history.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.exp.history.domain.ExpHistory; | 3 | import com.topdraw.business.module.exp.history.domain.ExpHistory; |
4 | import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO; | 4 | import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO; |
5 | import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | 5 | ||
11 | /** | 6 | /** |
12 | * @author XiangHan | 7 | * @author XiangHan |
... | @@ -15,33 +10,18 @@ import java.util.Map; | ... | @@ -15,33 +10,18 @@ import java.util.Map; |
15 | public interface ExpHistoryService { | 10 | public interface ExpHistoryService { |
16 | 11 | ||
17 | /** | 12 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(ExpHistoryQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<ExpHistoryDTO> | ||
29 | */ | ||
30 | List<ExpHistoryDTO> queryAll(ExpHistoryQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 13 | * 根据ID查询 |
34 | * @param id ID | 14 | * @param id ID |
35 | * @return ExpHistoryDTO | 15 | * @return ExpHistoryDTO |
36 | */ | 16 | */ |
37 | ExpHistoryDTO findById(Long id); | 17 | ExpHistoryDTO findById(Long id); |
38 | 18 | ||
19 | /** | ||
20 | * | ||
21 | * @param resources | ||
22 | */ | ||
39 | void create(ExpHistory resources); | 23 | void create(ExpHistory resources); |
40 | 24 | ||
41 | void update(ExpHistory resources); | ||
42 | |||
43 | void delete(Long id); | ||
44 | |||
45 | /** | 25 | /** |
46 | * Code校验 | 26 | * Code校验 |
47 | * @param code | 27 | * @param code | ... | ... |
... | @@ -4,23 +4,14 @@ import com.topdraw.business.module.exp.history.domain.ExpHistory; | ... | @@ -4,23 +4,14 @@ import com.topdraw.business.module.exp.history.domain.ExpHistory; |
4 | import com.topdraw.business.module.exp.history.repository.ExpHistoryRepository; | 4 | import com.topdraw.business.module.exp.history.repository.ExpHistoryRepository; |
5 | import com.topdraw.business.module.exp.history.service.ExpHistoryService; | 5 | import com.topdraw.business.module.exp.history.service.ExpHistoryService; |
6 | import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO; | 6 | import com.topdraw.business.module.exp.history.service.dto.ExpHistoryDTO; |
7 | import com.topdraw.business.module.exp.history.service.dto.ExpHistoryQueryCriteria; | ||
8 | import com.topdraw.business.module.exp.history.service.mapper.ExpHistoryMapper; | 7 | import com.topdraw.business.module.exp.history.service.mapper.ExpHistoryMapper; |
9 | import com.topdraw.utils.PageUtil; | ||
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.StringUtils; | 8 | import com.topdraw.utils.StringUtils; |
12 | import com.topdraw.utils.ValidationUtil; | 9 | import com.topdraw.utils.ValidationUtil; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.dao.EmptyResultDataAccessException; | ||
15 | import org.springframework.data.domain.Page; | ||
16 | import org.springframework.data.domain.Pageable; | ||
17 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
18 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
19 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
20 | import org.springframework.util.Assert; | ||
21 | 14 | ||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | 15 | ||
25 | /** | 16 | /** |
26 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -31,57 +22,28 @@ import java.util.Map; | ... | @@ -31,57 +22,28 @@ import java.util.Map; |
31 | public class ExpHistoryServiceImpl implements ExpHistoryService { | 22 | public class ExpHistoryServiceImpl implements ExpHistoryService { |
32 | 23 | ||
33 | @Autowired | 24 | @Autowired |
34 | private ExpHistoryRepository ExpHistoryRepository; | 25 | private ExpHistoryMapper expHistoryMapper; |
35 | |||
36 | @Autowired | 26 | @Autowired |
37 | private ExpHistoryMapper ExpHistoryMapper; | 27 | private ExpHistoryRepository expHistoryRepository; |
38 | 28 | ||
39 | @Override | ||
40 | public Map<String, Object> queryAll(ExpHistoryQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<ExpHistory> page = ExpHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(ExpHistoryMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<ExpHistoryDTO> queryAll(ExpHistoryQueryCriteria criteria) { | ||
47 | return ExpHistoryMapper.toDto(ExpHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | 29 | ||
50 | @Override | 30 | @Override |
51 | public ExpHistoryDTO findById(Long id) { | 31 | public ExpHistoryDTO findById(Long id) { |
52 | ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseGet(ExpHistory::new); | 32 | ExpHistory ExpHistory = this.expHistoryRepository.findById(id).orElseGet(ExpHistory::new); |
53 | ValidationUtil.isNull(ExpHistory.getId(),"ExpHistory","id",id); | 33 | ValidationUtil.isNull(ExpHistory.getId(),"ExpHistory","id",id); |
54 | return ExpHistoryMapper.toDto(ExpHistory); | 34 | return this.expHistoryMapper.toDto(ExpHistory); |
55 | } | 35 | } |
56 | 36 | ||
57 | @Override | 37 | @Override |
58 | @Transactional(rollbackFor = Exception.class) | 38 | @Transactional(rollbackFor = Exception.class) |
59 | public void create(ExpHistory resources) { | 39 | public void create(ExpHistory resources) { |
60 | ExpHistoryRepository.save(resources); | 40 | this.expHistoryRepository.save(resources); |
61 | } | ||
62 | |||
63 | @Override | ||
64 | @Transactional(rollbackFor = Exception.class) | ||
65 | public void update(ExpHistory resources) { | ||
66 | ExpHistory ExpHistory = ExpHistoryRepository.findById(resources.getId()).orElseGet(ExpHistory::new); | ||
67 | ValidationUtil.isNull( ExpHistory.getId(),"ExpHistory","id",resources.getId()); | ||
68 | ExpHistory.copy(resources); | ||
69 | ExpHistoryRepository.save(ExpHistory); | ||
70 | } | ||
71 | |||
72 | @Override | ||
73 | @Transactional(rollbackFor = Exception.class) | ||
74 | public void delete(Long id) { | ||
75 | Assert.notNull(id, "The given id must not be null!"); | ||
76 | ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseThrow( | ||
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ExpHistory.class, id), 1)); | ||
78 | ExpHistoryRepository.delete(ExpHistory); | ||
79 | } | 41 | } |
80 | 42 | ||
81 | 43 | ||
82 | @Override | 44 | @Override |
83 | public ExpHistoryDTO getByCode(String code) { | 45 | public ExpHistoryDTO getByCode(String code) { |
84 | return StringUtils.isNotEmpty(code) ? ExpHistoryMapper.toDto(ExpHistoryRepository.findFirstByCode(code).orElseGet(ExpHistory::new)) | 46 | return StringUtils.isNotEmpty(code) ? this.expHistoryMapper.toDto(this.expHistoryRepository.findFirstByCode(code).orElseGet(ExpHistory::new)) |
85 | : new ExpHistoryDTO(); | 47 | : new ExpHistoryDTO(); |
86 | } | 48 | } |
87 | } | 49 | } | ... | ... |
... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.address.domain; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.address.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.domain.AsyncMqModule; | ||
5 | import lombok.Data; | 6 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 7 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 8 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -10,7 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -10,7 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
10 | 11 | ||
11 | import javax.persistence.*; | 12 | import javax.persistence.*; |
12 | import java.io.Serializable; | 13 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | 14 | import java.time.LocalDateTime; |
14 | 15 | ||
15 | /** | 16 | /** |
16 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -21,78 +22,75 @@ import java.sql.Timestamp; | ... | @@ -21,78 +22,75 @@ import java.sql.Timestamp; |
21 | @EntityListeners(AuditingEntityListener.class) | 22 | @EntityListeners(AuditingEntityListener.class) |
22 | @Accessors(chain = true) | 23 | @Accessors(chain = true) |
23 | @Table(name="uc_member_address") | 24 | @Table(name="uc_member_address") |
24 | public class MemberAddress implements Serializable { | 25 | public class MemberAddress extends AsyncMqModule implements Serializable { |
25 | 26 | ||
26 | // 主键 | 27 | /** 主键 */ |
27 | @Id | 28 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 29 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
29 | @Column(name = "id") | 30 | @Column(name = "id") |
30 | private Long id; | 31 | private Long id; |
31 | 32 | ||
32 | // 会员id | 33 | /** 会员id */ |
33 | @Column(name = "member_id", nullable = false) | 34 | @Column(name = "member_id", nullable = false) |
34 | private Long memberId; | 35 | private Long memberId; |
35 | 36 | ||
36 | @Transient | 37 | /** 类型 1:家;2:公司;3:学校 */ |
37 | private String memberCode; | ||
38 | |||
39 | // 类型 1:家;2:公司;3:学校 | ||
40 | @Column(name = "type", nullable = false) | 38 | @Column(name = "type", nullable = false) |
41 | private Integer type; | 39 | private Integer type; |
42 | 40 | ||
43 | // 是否默认地址 | 41 | /** 是否默认地址 */ |
44 | @Column(name = "is_default", nullable = false) | 42 | @Column(name = "is_default", nullable = false) |
45 | private Integer isDefault; | 43 | private Integer isDefault; |
46 | 44 | ||
47 | // 显示顺序 | 45 | /** 显示顺序 */ |
48 | @Column(name = "sequence") | 46 | @Column(name = "sequence") |
49 | private Integer sequence; | 47 | private Integer sequence; |
50 | 48 | ||
51 | // 状态 0:不可用;1-可用 | 49 | /** 状态 0:不可用;1-可用 */ |
52 | @Column(name = "status", nullable = false) | 50 | @Column(name = "status", nullable = false) |
53 | private Integer status; | 51 | private Integer status; |
54 | 52 | ||
55 | // 联系人姓名 | 53 | /** 联系人姓名 */ |
56 | @Column(name = "contactor", nullable = false) | 54 | @Column(name = "contactor", nullable = false) |
57 | private String contactor; | 55 | private String contactor; |
58 | 56 | ||
59 | // 联系人电话 | 57 | /** 联系人电话 */ |
60 | @Column(name = "cellphone", nullable = false) | 58 | @Column(name = "cellphone", nullable = false) |
61 | private String cellphone; | 59 | private String cellphone; |
62 | 60 | ||
63 | // 国家 | 61 | /** 国家 */ |
64 | @Column(name = "country", nullable = false) | 62 | @Column(name = "country", nullable = false) |
65 | private String country; | 63 | private String country; |
66 | 64 | ||
67 | // 省份 | 65 | /** 省份 */ |
68 | @Column(name = "province", nullable = false) | 66 | @Column(name = "province", nullable = false) |
69 | private String province; | 67 | private String province; |
70 | 68 | ||
71 | // 城市 | 69 | /** 城市 */ |
72 | @Column(name = "city", nullable = false) | 70 | @Column(name = "city", nullable = false) |
73 | private String city; | 71 | private String city; |
74 | 72 | ||
75 | // 区县 | 73 | /** 区县 */ |
76 | @Column(name = "district", nullable = false) | 74 | @Column(name = "district", nullable = false) |
77 | private String district; | 75 | private String district; |
78 | 76 | ||
79 | // 地址 | 77 | /** 地址 */ |
80 | @Column(name = "address", nullable = false) | 78 | @Column(name = "address", nullable = false) |
81 | private String address; | 79 | private String address; |
82 | 80 | ||
83 | // 邮编 | 81 | /** 邮编 */ |
84 | @Column(name = "zip_code") | 82 | @Column(name = "zip_code") |
85 | private String zipCode; | 83 | private String zipCode; |
86 | 84 | ||
87 | // 创建时间 | 85 | /** 创建时间 */ |
88 | @CreatedDate | 86 | @CreatedDate |
89 | @Column(name = "create_time") | 87 | @Column(name = "create_time") |
90 | private Timestamp createTime; | 88 | private LocalDateTime createTime; |
91 | 89 | ||
92 | // 更新时间 | 90 | /** 更新时间 */ |
93 | @LastModifiedDate | 91 | @LastModifiedDate |
94 | @Column(name = "update_time") | 92 | @Column(name = "update_time") |
95 | private Timestamp updateTime; | 93 | private LocalDateTime updateTime; |
96 | 94 | ||
97 | public void copy(MemberAddress source){ | 95 | public void copy(MemberAddress source){ |
98 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | 96 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ... | ... |
... | @@ -4,13 +4,10 @@ import com.topdraw.business.module.member.address.domain.MemberAddress; | ... | @@ -4,13 +4,10 @@ import com.topdraw.business.module.member.address.domain.MemberAddress; |
4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | 6 | ||
7 | import java.util.Optional; | ||
8 | |||
9 | /** | 7 | /** |
10 | * @author XiangHan | 8 | * @author XiangHan |
11 | * @date 2021-10-22 | 9 | * @date 2021-10-22 |
12 | */ | 10 | */ |
13 | public interface MemberAddressRepository extends JpaRepository<MemberAddress, Long>, JpaSpecificationExecutor<MemberAddress> { | 11 | public interface MemberAddressRepository extends JpaRepository<MemberAddress, Long>, JpaSpecificationExecutor<MemberAddress> { |
14 | 12 | ||
15 | Optional<MemberAddress> findByMemberIdAndSequence(Long memberId, Integer sequence); | ||
16 | } | 13 | } | ... | ... |
... | @@ -3,7 +3,7 @@ package com.topdraw.business.module.member.address.service.dto; | ... | @@ -3,7 +3,7 @@ package com.topdraw.business.module.member.address.service.dto; |
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | 6 | import java.time.LocalDateTime; |
7 | 7 | ||
8 | 8 | ||
9 | /** | 9 | /** |
... | @@ -13,51 +13,51 @@ import java.sql.Timestamp; | ... | @@ -13,51 +13,51 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class MemberAddressDTO implements Serializable { | 14 | public class MemberAddressDTO implements Serializable { |
15 | 15 | ||
16 | // 主键 | 16 | /** 主键 */ |
17 | private Long id; | 17 | private Long id; |
18 | 18 | ||
19 | // 会员id | 19 | /** 会员id */ |
20 | private Long memberId; | 20 | private Long memberId; |
21 | 21 | ||
22 | // 类型 1:家;2:公司;3:学校 | 22 | /** 类型 1:家;2:公司;3:学校 */ |
23 | private Integer type; | 23 | private Integer type; |
24 | 24 | ||
25 | // 是否默认地址 | 25 | /** 是否默认地址 */ |
26 | private Integer isDefault; | 26 | private Integer isDefault; |
27 | 27 | ||
28 | // 显示顺序 | 28 | /** 显示顺序 */ |
29 | private Integer sequence; | 29 | private Integer sequence; |
30 | 30 | ||
31 | // 状态 0:不可用;1-可用 | 31 | /** 状态 0:不可用;1-可用 */ |
32 | private Integer status; | 32 | private Integer status; |
33 | 33 | ||
34 | // 联系人姓名 | 34 | /** 联系人姓名 */ |
35 | private String contactor; | 35 | private String contactor; |
36 | 36 | ||
37 | // 联系人电话 | 37 | /** 联系人电话 */ |
38 | private String cellphone; | 38 | private String cellphone; |
39 | 39 | ||
40 | // 国家 | 40 | /** 国家 */ |
41 | private String country; | 41 | private String country; |
42 | 42 | ||
43 | // 省份 | 43 | /** 省份 */ |
44 | private String province; | 44 | private String province; |
45 | 45 | ||
46 | // 城市 | 46 | /** 城市 */ |
47 | private String city; | 47 | private String city; |
48 | 48 | ||
49 | // 区县 | 49 | /** 区县 */ |
50 | private String district; | 50 | private String district; |
51 | 51 | ||
52 | // 地址 | 52 | /** 地址 */ |
53 | private String address; | 53 | private String address; |
54 | 54 | ||
55 | // 邮编 | 55 | /** 邮编 */ |
56 | private String zipCode; | 56 | private String zipCode; |
57 | 57 | ||
58 | // 创建时间 | 58 | /** 创建时间 */ |
59 | private Timestamp createTime; | 59 | private LocalDateTime createTime; |
60 | 60 | ||
61 | // 更新时间 | 61 | /** 更新时间 */ |
62 | private Timestamp updateTime; | 62 | private LocalDateTime updateTime; |
63 | } | 63 | } | ... | ... |
... | @@ -8,7 +8,6 @@ import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; | ... | @@ -8,7 +8,6 @@ import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; |
8 | import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper; | 8 | import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper; |
9 | import com.topdraw.business.module.member.service.MemberService; | 9 | import com.topdraw.business.module.member.service.MemberService; |
10 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 10 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
11 | import com.topdraw.utils.RedisUtils; | ||
12 | import com.topdraw.utils.ValidationUtil; | 11 | import com.topdraw.utils.ValidationUtil; |
13 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
14 | import org.springframework.beans.BeanUtils; | 13 | import org.springframework.beans.BeanUtils; |
... | @@ -35,9 +34,6 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -35,9 +34,6 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
35 | @Autowired | 34 | @Autowired |
36 | private MemberAddressRepository memberAddressRepository; | 35 | private MemberAddressRepository memberAddressRepository; |
37 | 36 | ||
38 | @Autowired | ||
39 | private RedisUtils redisUtils; | ||
40 | |||
41 | @Override | 37 | @Override |
42 | public MemberAddressDTO findById(Long id) { | 38 | public MemberAddressDTO findById(Long id) { |
43 | Assert.notNull(id,"id can't be null"); | 39 | Assert.notNull(id,"id can't be null"); |
... | @@ -67,7 +63,6 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -67,7 +63,6 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
67 | log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); | 63 | log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); |
68 | Assert.notNull(resources.getId(),"id can't be null"); | 64 | Assert.notNull(resources.getId(),"id can't be null"); |
69 | try { | 65 | try { |
70 | this.redisUtils.doLock("MemberAddress::update::code" + resources.getId()); | ||
71 | MemberDTO memberDTO = this.checkMember(resources); | 66 | MemberDTO memberDTO = this.checkMember(resources); |
72 | resources.setMemberCode(memberDTO.getCode()); | 67 | resources.setMemberCode(memberDTO.getCode()); |
73 | 68 | ||
... | @@ -78,13 +73,14 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -78,13 +73,14 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
78 | 73 | ||
79 | MemberAddressDTO memberAddressDTO = new MemberAddressDTO(); | 74 | MemberAddressDTO memberAddressDTO = new MemberAddressDTO(); |
80 | BeanUtils.copyProperties(memberAddress, memberAddressDTO); | 75 | BeanUtils.copyProperties(memberAddress, memberAddressDTO); |
76 | |||
81 | return memberAddressDTO; | 77 | return memberAddressDTO; |
78 | |||
82 | } catch (Exception e) { | 79 | } catch (Exception e) { |
83 | e.printStackTrace(); | 80 | e.printStackTrace(); |
84 | throw e; | 81 | throw e; |
85 | } finally { | ||
86 | this.redisUtils.doUnLock("MemberAddress::update::code" + resources.getId()); | ||
87 | } | 82 | } |
83 | |||
88 | } | 84 | } |
89 | 85 | ||
90 | @Override | 86 | @Override |
... | @@ -117,5 +113,4 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -117,5 +113,4 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
117 | return this.memberService.checkMember(memberId, memberCode); | 113 | return this.memberService.checkMember(memberId, memberCode); |
118 | } | 114 | } |
119 | 115 | ||
120 | |||
121 | } | 116 | } | ... | ... |
... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.domain; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
5 | import lombok.Data; | 6 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 7 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 8 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -9,8 +10,8 @@ import org.springframework.data.annotation.LastModifiedDate; | ... | @@ -9,8 +10,8 @@ import org.springframework.data.annotation.LastModifiedDate; |
9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | 10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
10 | 11 | ||
11 | import javax.persistence.*; | 12 | import javax.persistence.*; |
13 | import javax.validation.constraints.NotNull; | ||
12 | import java.io.Serializable; | 14 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | ||
14 | import java.time.LocalDateTime; | 15 | import java.time.LocalDateTime; |
15 | 16 | ||
16 | /** | 17 | /** |
... | @@ -24,115 +25,116 @@ import java.time.LocalDateTime; | ... | @@ -24,115 +25,116 @@ import java.time.LocalDateTime; |
24 | @Table(name="uc_member") | 25 | @Table(name="uc_member") |
25 | public class Member implements Serializable { | 26 | public class Member implements Serializable { |
26 | 27 | ||
27 | // 运营商平台账号 | 28 | /** 运营商平台账号 */ |
28 | @Transient | 29 | @Transient |
29 | private String platformAccount; | 30 | private String platformAccount; |
30 | 31 | ||
31 | // 会员过期时间 | 32 | /** 会员过期时间 */ |
32 | @Column(name = "vip_expire_time", nullable = false) | 33 | @Column(name = "vip_expire_time", nullable = false) |
33 | private LocalDateTime vipExpireTime; | 34 | private LocalDateTime vipExpireTime; |
34 | 35 | ||
35 | // 主键 | 36 | /** 主键 */ |
36 | @Id | 37 | @Id |
37 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 38 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
38 | @Column(name = "id") | 39 | @Column(name = "id") |
40 | @NotNull(message = "id can't be null!!",groups = {UpdateGroup.class}) | ||
39 | private Long id; | 41 | private Long id; |
40 | 42 | ||
41 | // 标识 | 43 | /** 标识 */ |
42 | @Column(name = "code", nullable = false) | 44 | @Column(name = "code", nullable = false) |
43 | private String code; | 45 | private String code; |
44 | 46 | ||
45 | // 类型 1:大屏;2:小屏 | 47 | /** 类型 1:大屏;2:小屏 */ |
46 | @Column(name = "`type`", nullable = false) | 48 | @Column(name = "`type`", nullable = false) |
47 | private Integer type; | 49 | private Integer type; |
48 | 50 | ||
49 | // 状态 0:不可用;1:可用 | 51 | /** 状态 0:不可用;1:可用 */ |
50 | @Column(name = "`status`", nullable = false) | 52 | @Column(name = "`status`", nullable = false) |
51 | private Integer status; | 53 | private Integer status; |
52 | 54 | ||
53 | // 昵称 base64 | 55 | /** 昵称 base64 */ |
54 | @Column(name = "nickname") | 56 | @Column(name = "nickname") |
55 | private String nickname; | 57 | private String nickname; |
56 | 58 | ||
57 | // 描述 | 59 | /** 描述 */ |
58 | @Column(name = "description") | 60 | @Column(name = "description") |
59 | private String description; | 61 | private String description; |
60 | 62 | ||
61 | // 性别 0:女;1:男;-1:未知 | 63 | /** 性别 0:女;1:男;-1:未知 */ |
62 | @Column(name = "gender", nullable = false) | 64 | @Column(name = "gender", nullable = false) |
63 | private Integer gender; | 65 | private Integer gender; |
64 | 66 | ||
65 | // 生日 | 67 | /** 生日 */ |
66 | @Column(name = "birthday") | 68 | @Column(name = "birthday") |
67 | private String birthday; | 69 | private String birthday; |
68 | 70 | ||
69 | // 头像 | 71 | /** 头像 */ |
70 | @Column(name = "avatar_url") | 72 | @Column(name = "avatar_url") |
71 | private String avatarUrl; | 73 | private String avatarUrl; |
72 | 74 | ||
73 | // 分组信息 | 75 | /** 分组信息 */ |
74 | @Column(name = "`groups`") | 76 | @Column(name = "`groups`") |
75 | private String groups; | 77 | private String groups; |
76 | 78 | ||
77 | // 标签 | 79 | /** 标签 */ |
78 | @Column(name = "tags") | 80 | @Column(name = "tags") |
79 | private String tags; | 81 | private String tags; |
80 | 82 | ||
81 | // 是否会员 0:非会员;1:会员 | 83 | /** 是否会员 0:非会员;1:会员 */ |
82 | @Column(name = "vip", nullable = false) | 84 | @Column(name = "vip", nullable = false) |
83 | private Integer vip; | 85 | private Integer vip; |
84 | 86 | ||
85 | // 会员等级(对应level表的level字段,非id) | 87 | /** 会员等级(对应level表的level字段,非id) */ |
86 | @Column(name = "`level`", nullable = false) | 88 | @Column(name = "`level`", nullable = false) |
87 | private Integer level; | 89 | private Integer level; |
88 | 90 | ||
89 | // 成长值 | 91 | /** 成长值 */ |
90 | @Column(name = "`exp`") | 92 | @Column(name = "`exp`") |
91 | private Long exp; | 93 | private Long exp; |
92 | 94 | ||
93 | // 当前积分 | 95 | /** 当前积分 */ |
94 | @Column(name = "`points`") | 96 | @Column(name = "`points`") |
95 | private Long points; | 97 | private Long points; |
96 | 98 | ||
97 | // 即将到期积分(一个月内) | 99 | /** 即将到期积分(一个月内) */ |
98 | @Column(name = "due_points") | 100 | @Column(name = "due_points") |
99 | private Long duePoints; | 101 | private Long duePoints; |
100 | 102 | ||
101 | // 优惠券数量 | 103 | /** 优惠券数量 */ |
102 | @Column(name = "coupon_amount") | 104 | @Column(name = "coupon_amount") |
103 | private Long couponAmount; | 105 | private Long couponAmount; |
104 | 106 | ||
105 | // 即将过期优惠券数量 | 107 | /** 即将过期优惠券数量 */ |
106 | @Column(name = "due_coupon_amount") | 108 | @Column(name = "due_coupon_amount") |
107 | private Long dueCouponAmount; | 109 | private Long dueCouponAmount; |
108 | 110 | ||
109 | // iptv账号id | 111 | /** iptv账号id */ |
110 | @Column(name = "user_iptv_id") | 112 | @Column(name = "user_iptv_id") |
111 | private Long userIptvId; | 113 | private Long userIptvId; |
112 | 114 | ||
113 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | 115 | /** 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 */ |
114 | @Column(name = "bind_iptv_platform_type") | 116 | @Column(name = "bind_iptv_platform_type") |
115 | private Integer bindIptvPlatformType; | 117 | private Integer bindIptvPlatformType; |
116 | 118 | ||
117 | // iptv账号绑定时间 | 119 | /** iptv账号绑定时间 */ |
118 | @Column(name = "bind_iptv_time") | 120 | @Column(name = "bind_iptv_time") |
119 | private LocalDateTime bindIptvTime; | 121 | private LocalDateTime bindIptvTime; |
120 | 122 | ||
121 | // 创建时间 | 123 | /** 创建时间 */ |
122 | @CreatedDate | 124 | @CreatedDate |
123 | @Column(name = "create_time") | 125 | @Column(name = "create_time") |
124 | private LocalDateTime createTime; | 126 | private LocalDateTime createTime; |
125 | 127 | ||
126 | // 更新时间 | 128 | /** 更新时间 */ |
127 | @LastModifiedDate | 129 | @LastModifiedDate |
128 | @Column(name = "update_time") | 130 | @Column(name = "update_time") |
129 | private LocalDateTime updateTime; | 131 | private LocalDateTime updateTime; |
130 | 132 | ||
131 | // 是否在黑名单 1:是;0否 | 133 | /** 是否在黑名单 1:是;0否 */ |
132 | @Column(name = "black_status") | 134 | @Column(name = "black_status") |
133 | private Long blackStatus; | 135 | private Long blackStatus; |
134 | 136 | ||
135 | public void copy(Member source){ | 137 | public void copy(Member source){ |
136 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | 138 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false)); |
137 | } | 139 | } |
138 | } | 140 | } | ... | ... |
1 | package com.topdraw.business.module.member.group.domain; | ||
2 | |||
3 | import cn.hutool.core.bean.BeanUtil; | ||
4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
5 | import lombok.Data; | ||
6 | import lombok.experimental.Accessors; | ||
7 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
8 | |||
9 | import javax.persistence.*; | ||
10 | import java.io.Serializable; | ||
11 | |||
12 | /** | ||
13 | * @author luerlong | ||
14 | * @date 2021-09-27 | ||
15 | */ | ||
16 | @Entity | ||
17 | @Data | ||
18 | @EntityListeners(AuditingEntityListener.class) | ||
19 | @Accessors(chain = true) | ||
20 | @Table(name="uc_group") | ||
21 | public class Group implements Serializable { | ||
22 | |||
23 | /** ID */ | ||
24 | @Id | ||
25 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
26 | @Column(name = "id") | ||
27 | private Long id; | ||
28 | |||
29 | /** CODE */ | ||
30 | @Column(name = "code") | ||
31 | private String code; | ||
32 | |||
33 | /** 名称 */ | ||
34 | @Column(name = "name") | ||
35 | private String name; | ||
36 | |||
37 | /** 状态 0-下线 1-上线 */ | ||
38 | @Column(name = "status") | ||
39 | private Integer status; | ||
40 | |||
41 | /** 权限 0-测试分组 1-鉴权通过(白名单) 2-不允许精准(黑名单)3-可以精准(金名单) */ | ||
42 | @Column(name = "permission_type") | ||
43 | private Integer permissionType; | ||
44 | |||
45 | public void copy(Group source){ | ||
46 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
47 | } | ||
48 | } |
1 | package com.topdraw.business.module.member.group.domain; | ||
2 | |||
3 | import cn.hutool.core.bean.BeanUtil; | ||
4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
5 | import lombok.Data; | ||
6 | import lombok.experimental.Accessors; | ||
7 | import org.springframework.data.annotation.CreatedDate; | ||
8 | import org.springframework.data.annotation.LastModifiedDate; | ||
9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
10 | |||
11 | import javax.persistence.*; | ||
12 | import java.io.Serializable; | ||
13 | import java.sql.Timestamp; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-11-17 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_member_group") | ||
24 | public class MemberGroup implements Serializable { | ||
25 | |||
26 | /** ID */ | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | /** 分组ID */ | ||
33 | @Column(name = "group_id") | ||
34 | private Long groupId; | ||
35 | |||
36 | /** 会员ID */ | ||
37 | @Column(name = "member_id") | ||
38 | private Long memberId; | ||
39 | |||
40 | /** 运营商平台账号 */ | ||
41 | @Column(name = "platform_account") | ||
42 | private String platformAccount; | ||
43 | |||
44 | /** 手机号 */ | ||
45 | @Column(name = "cellphone") | ||
46 | private String cellphone; | ||
47 | |||
48 | /** 设备 */ | ||
49 | @Column(name = "stb_id") | ||
50 | private String stbId; | ||
51 | |||
52 | /** 有线MAC地址 */ | ||
53 | @Column(name = "eth_mac") | ||
54 | private String ethMac; | ||
55 | |||
56 | /** 无线MAC地址 */ | ||
57 | @Column(name = "wifi_mac") | ||
58 | private String wifiMac; | ||
59 | |||
60 | /** 描述 */ | ||
61 | @Column(name = "description") | ||
62 | private String description; | ||
63 | |||
64 | /** 创建者 */ | ||
65 | @Column(name = "create_by") | ||
66 | private String createBy; | ||
67 | |||
68 | /** 创建时间 */ | ||
69 | @CreatedDate | ||
70 | @Column(name = "create_time") | ||
71 | private Timestamp createTime; | ||
72 | |||
73 | /** 更新者 */ | ||
74 | @Column(name = "update_by") | ||
75 | private String updateBy; | ||
76 | |||
77 | /** 更新时间 */ | ||
78 | @LastModifiedDate | ||
79 | @Column(name = "update_time") | ||
80 | private Timestamp updateTime; | ||
81 | |||
82 | public void copy(MemberGroup source){ | ||
83 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
84 | } | ||
85 | } |
1 | package com.topdraw.business.module.member.group.repository; | ||
2 | |||
3 | import com.topdraw.business.module.member.group.domain.Group; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | import org.springframework.data.jpa.repository.Query; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | import java.util.Optional; | ||
11 | |||
12 | /** | ||
13 | * @author luerlong | ||
14 | * @date 2021-09-27 | ||
15 | */ | ||
16 | public interface GroupRepository extends JpaRepository<Group, Long>, JpaSpecificationExecutor<Group> { | ||
17 | |||
18 | Optional<Group> findFirstByCode(String code); | ||
19 | |||
20 | List<Group> findByName(String name); | ||
21 | |||
22 | @Query(value = "select t1.id from uc_group t1 left join uc_user__group t2 on t1.id = t2.group_id where t2.user_id = ?1 and t1.permission_type = ?2 ", nativeQuery = true) | ||
23 | List<Map<String, Object>> findByUserIdAndPermissionType(Long userId, Integer type); | ||
24 | } |
src/main/java/com/topdraw/business/module/member/group/repository/MemberGroupRepository.java
0 → 100644
1 | package com.topdraw.business.module.member.group.repository; | ||
2 | |||
3 | import com.topdraw.business.module.member.group.domain.MemberGroup; | ||
4 | import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO; | ||
5 | import org.springframework.data.jpa.repository.JpaRepository; | ||
6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
7 | |||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-11-17 | ||
13 | */ | ||
14 | public interface MemberGroupRepository extends JpaRepository<MemberGroup, Long>, JpaSpecificationExecutor<MemberGroup> { | ||
15 | |||
16 | List<MemberGroupDTO> findByMemberId(Long memberId); | ||
17 | } |
1 | package com.topdraw.business.module.member.group.service; | ||
2 | |||
3 | import com.topdraw.business.module.member.group.service.dto.GroupDTO; | ||
4 | |||
5 | |||
6 | /** | ||
7 | * @author luerlong | ||
8 | * @date 2021-09-27 | ||
9 | */ | ||
10 | public interface GroupService { | ||
11 | |||
12 | |||
13 | /** | ||
14 | * 根据ID查询 | ||
15 | * @param id ID | ||
16 | * @return GroupDTO | ||
17 | */ | ||
18 | GroupDTO findById(Long id); | ||
19 | |||
20 | /** | ||
21 | * Code校验 | ||
22 | * @param code | ||
23 | * @return GroupDTO | ||
24 | */ | ||
25 | GroupDTO getByCode(String code); | ||
26 | } |
1 | package com.topdraw.business.module.member.group.service; | ||
2 | |||
3 | import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO; | ||
4 | |||
5 | import java.util.List; | ||
6 | |||
7 | /** | ||
8 | * @author XiangHan | ||
9 | * @date 2021-11-17 | ||
10 | */ | ||
11 | public interface MemberGroupService { | ||
12 | |||
13 | /** | ||
14 | * 通过会员id获取会员分组列表 | ||
15 | * @param memberId | ||
16 | * @return | ||
17 | */ | ||
18 | List<MemberGroupDTO> findByMemberId(Long memberId); | ||
19 | |||
20 | /** | ||
21 | * 根据ID查询 | ||
22 | * @param id ID | ||
23 | * @return MemberGroupDTO | ||
24 | */ | ||
25 | MemberGroupDTO findById(Long id); | ||
26 | |||
27 | } |
1 | package com.topdraw.business.module.member.group.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author luerlong | ||
10 | * @date 2021-09-27 | ||
11 | */ | ||
12 | @Data | ||
13 | public class GroupDTO implements Serializable { | ||
14 | |||
15 | /** ID */ | ||
16 | private Long id; | ||
17 | |||
18 | /** CODE */ | ||
19 | private String code; | ||
20 | |||
21 | /** 名称 */ | ||
22 | private String name; | ||
23 | |||
24 | /** 状态 0-下线 1-上线 */ | ||
25 | private Integer status; | ||
26 | |||
27 | /** 权限 0-测试分组 1-鉴权通过(白名单) 2-不允许精准(黑名单)3-可以精准(金名单) */ | ||
28 | private Integer permissionType; | ||
29 | |||
30 | } |
1 | package com.topdraw.business.module.member.group.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.io.Serializable; | ||
6 | import java.sql.Timestamp; | ||
7 | |||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-11-17 | ||
12 | */ | ||
13 | @Data | ||
14 | public class MemberGroupDTO implements Serializable { | ||
15 | |||
16 | /** ID */ | ||
17 | private Long id; | ||
18 | |||
19 | /** 分组ID */ | ||
20 | private Long groupId; | ||
21 | |||
22 | /** 会员ID */ | ||
23 | private Long memberId; | ||
24 | |||
25 | /** 运营商平台账号 */ | ||
26 | private String platformAccount; | ||
27 | |||
28 | /** 手机号 */ | ||
29 | private String cellphone; | ||
30 | |||
31 | /** 设备 */ | ||
32 | private String stbId; | ||
33 | |||
34 | /** 有线MAC地址 */ | ||
35 | private String ethMac; | ||
36 | |||
37 | /** 无线MAC地址 */ | ||
38 | private String wifiMac; | ||
39 | |||
40 | /** 描述 */ | ||
41 | private String description; | ||
42 | |||
43 | /** 创建者 */ | ||
44 | private String createBy; | ||
45 | |||
46 | /** 创建时间 */ | ||
47 | private Timestamp createTime; | ||
48 | |||
49 | /** 更新者 */ | ||
50 | private String updateBy; | ||
51 | |||
52 | /** 更新时间 */ | ||
53 | private Timestamp updateTime; | ||
54 | |||
55 | } |
src/main/java/com/topdraw/business/module/member/group/service/impl/GroupServiceImpl.java
0 → 100644
1 | package com.topdraw.business.module.member.group.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.member.group.domain.Group; | ||
4 | import com.topdraw.business.module.member.group.repository.GroupRepository; | ||
5 | import com.topdraw.business.module.member.group.service.GroupService; | ||
6 | import com.topdraw.business.module.member.group.service.dto.GroupDTO; | ||
7 | import com.topdraw.business.module.member.group.service.mapper.GroupMapper; | ||
8 | import com.topdraw.utils.StringUtils; | ||
9 | import com.topdraw.utils.ValidationUtil; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | ||
11 | import org.springframework.stereotype.Service; | ||
12 | import org.springframework.transaction.annotation.Propagation; | ||
13 | import org.springframework.transaction.annotation.Transactional; | ||
14 | |||
15 | /** | ||
16 | * @author luerlong | ||
17 | * @date 2021-09-27 | ||
18 | */ | ||
19 | @Service | ||
20 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
21 | public class GroupServiceImpl implements GroupService { | ||
22 | |||
23 | @Autowired | ||
24 | private GroupRepository groupRepository; | ||
25 | |||
26 | @Autowired | ||
27 | private GroupMapper groupMapper; | ||
28 | |||
29 | @Override | ||
30 | public GroupDTO findById(Long id) { | ||
31 | Group group = groupRepository.findById(id).orElseGet(Group::new); | ||
32 | ValidationUtil.isNull(group.getId(),"Group","id",id); | ||
33 | return groupMapper.toDto(group); | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | public GroupDTO getByCode(String code) { | ||
38 | return StringUtils.isNotEmpty(code) ? groupMapper.toDto(groupRepository.findFirstByCode(code).orElseGet(Group::new)) | ||
39 | : new GroupDTO(); | ||
40 | } | ||
41 | } |
src/main/java/com/topdraw/business/module/member/group/service/impl/MemberGroupServiceImpl.java
0 → 100644
1 | package com.topdraw.business.module.member.group.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.member.group.domain.MemberGroup; | ||
4 | import com.topdraw.business.module.member.group.repository.MemberGroupRepository; | ||
5 | import com.topdraw.business.module.member.group.service.MemberGroupService; | ||
6 | import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO; | ||
7 | import com.topdraw.business.module.member.group.service.mapper.MemberGroupMapper; | ||
8 | import com.topdraw.utils.ValidationUtil; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | ||
10 | import org.springframework.stereotype.Service; | ||
11 | import org.springframework.transaction.annotation.Propagation; | ||
12 | import org.springframework.transaction.annotation.Transactional; | ||
13 | |||
14 | import java.util.List; | ||
15 | |||
16 | /** | ||
17 | * @author XiangHan | ||
18 | * @date 2021-11-17 | ||
19 | */ | ||
20 | @Service | ||
21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
22 | public class MemberGroupServiceImpl implements MemberGroupService { | ||
23 | |||
24 | @Autowired | ||
25 | private MemberGroupRepository memberGroupRepository; | ||
26 | @Autowired | ||
27 | private MemberGroupMapper memberGroupMapper; | ||
28 | |||
29 | @Override | ||
30 | public List<MemberGroupDTO> findByMemberId(Long memberId) { | ||
31 | return this.memberGroupRepository.findByMemberId(memberId); | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | public MemberGroupDTO findById(Long id) { | ||
36 | MemberGroup memberGroup = this.memberGroupRepository.findById(id).orElseGet(MemberGroup::new); | ||
37 | ValidationUtil.isNull(memberGroup.getId(),"MemberGroup","id",id); | ||
38 | return this.memberGroupMapper.toDto(memberGroup); | ||
39 | } | ||
40 | |||
41 | } |
1 | package com.topdraw.business.module.member.group.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.member.group.domain.Group; | ||
5 | import com.topdraw.business.module.member.group.service.dto.GroupDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author luerlong | ||
11 | * @date 2021-09-27 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface GroupMapper extends BaseMapper<GroupDTO, Group> { | ||
15 | |||
16 | } |
src/main/java/com/topdraw/business/module/member/group/service/mapper/MemberGroupMapper.java
0 → 100644
1 | package com.topdraw.business.module.member.group.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.member.group.domain.MemberGroup; | ||
5 | import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-11-17 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberGroupMapper extends BaseMapper<MemberGroupDTO, MemberGroup> { | ||
15 | |||
16 | } |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.level.domain; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.level.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
6 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
5 | import lombok.Data; | 7 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 9 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -9,6 +11,8 @@ import org.springframework.data.annotation.LastModifiedDate; | ... | @@ -9,6 +11,8 @@ import org.springframework.data.annotation.LastModifiedDate; |
9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | 11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
10 | 12 | ||
11 | import javax.persistence.*; | 13 | import javax.persistence.*; |
14 | import javax.validation.constraints.Min; | ||
15 | import javax.validation.constraints.NotNull; | ||
12 | import java.io.Serializable; | 16 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | 17 | import java.sql.Timestamp; |
14 | 18 | ||
... | @@ -23,50 +27,53 @@ import java.sql.Timestamp; | ... | @@ -23,50 +27,53 @@ import java.sql.Timestamp; |
23 | @Table(name="uc_member_level") | 27 | @Table(name="uc_member_level") |
24 | public class MemberLevel implements Serializable { | 28 | public class MemberLevel implements Serializable { |
25 | 29 | ||
26 | // 主键 | 30 | /** 主键 */ |
27 | @Id | 31 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
29 | @Column(name = "id") | 33 | @Column(name = "id") |
34 | @NotNull(message = "id can't be null !!" , groups = {UpdateGroup.class}) | ||
30 | private Long id; | 35 | private Long id; |
31 | 36 | ||
32 | // 标识 | 37 | /** 标识 */ |
33 | @Column(name = "code", nullable = false) | 38 | @Column(name = "code", nullable = false) |
34 | private String code; | 39 | private String code; |
35 | 40 | ||
36 | // 名称 | 41 | /** 名称 */ |
37 | @Column(name = "name", nullable = false) | 42 | @Column(name = "name", nullable = false) |
38 | private String name; | 43 | private String name; |
39 | 44 | ||
40 | // 状态 0:未启用;1:启用 | 45 | /** 状态 0:未启用;1:启用 */ |
41 | @Column(name = "status", nullable = false) | 46 | @Column(name = "status", nullable = false) |
42 | private Integer status; | 47 | private Integer status; |
43 | 48 | ||
44 | // 对应成长值 | 49 | /** 对应成长值 */ |
45 | @Column(name = "exp_value", nullable = false) | 50 | @Column(name = "exp_value", nullable = false) |
46 | private Long expValue; | 51 | private Long expValue; |
47 | 52 | ||
48 | // 等级(不可重复,数字越大等级越高) | 53 | /** 等级(不可重复,数字越大等级越高) */ |
49 | @Column(name = "level", nullable = false) | 54 | @Column(name = "level", nullable = false) |
55 | @Min(message = "level can't less then 1" , value = 1) | ||
56 | @NotNull(message = "level can't be null" , groups = {CreateGroup.class,UpdateGroup.class}) | ||
50 | private Integer level; | 57 | private Integer level; |
51 | 58 | ||
52 | // 会员徽标 | 59 | /** 会员徽标 */ |
53 | @Column(name = "icon_url") | 60 | @Column(name = "icon_url") |
54 | private String iconUrl; | 61 | private String iconUrl; |
55 | 62 | ||
56 | // 描述 | 63 | /** 描述 */ |
57 | @Column(name = "description") | 64 | @Column(name = "description") |
58 | private String description; | 65 | private String description; |
59 | 66 | ||
60 | // 对应任务id,通过此字段可获得该等级所对应的权益 | 67 | /** 对应任务id,通过此字段可获得该等级所对应的权益 */ |
61 | @Column(name = "task_id") | 68 | @Column(name = "task_id") |
62 | private Long taskId; | 69 | private Long taskId; |
63 | 70 | ||
64 | // 创建时间 | 71 | /** 创建时间 */ |
65 | @CreatedDate | 72 | @CreatedDate |
66 | @Column(name = "create_time") | 73 | @Column(name = "create_time") |
67 | private Timestamp createTime; | 74 | private Timestamp createTime; |
68 | 75 | ||
69 | // 更新时间 | 76 | /** 更新时间 */ |
70 | @LastModifiedDate | 77 | @LastModifiedDate |
71 | @Column(name = "update_time") | 78 | @Column(name = "update_time") |
72 | private Timestamp updateTime; | 79 | private Timestamp updateTime; | ... | ... |
1 | package com.topdraw.business.module.member.level.service; | 1 | package com.topdraw.business.module.member.level.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.level.domain.MemberLevel; | ||
4 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; | 3 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; |
5 | import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | 4 | ||
8 | import java.util.List; | 5 | import java.util.List; |
9 | import java.util.Map; | ||
10 | 6 | ||
11 | /** | 7 | /** |
12 | * @author XiangHan | 8 | * @author XiangHan |
... | @@ -36,4 +32,5 @@ public interface MemberLevelService { | ... | @@ -36,4 +32,5 @@ public interface MemberLevelService { |
36 | */ | 32 | */ |
37 | List<MemberLevelDTO> findLevelAndStatus(Integer i, Integer status); | 33 | List<MemberLevelDTO> findLevelAndStatus(Integer i, Integer status); |
38 | 34 | ||
35 | |||
39 | } | 36 | } | ... | ... |
... | @@ -13,36 +13,36 @@ import java.sql.Timestamp; | ... | @@ -13,36 +13,36 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class MemberLevelDTO implements Serializable { | 14 | public class MemberLevelDTO implements Serializable { |
15 | 15 | ||
16 | // 主键 | 16 | /** 主键 */ |
17 | private Long id; | 17 | private Long id; |
18 | 18 | ||
19 | // 标识 | 19 | /** 标识 */ |
20 | private String code; | 20 | private String code; |
21 | 21 | ||
22 | // 名称 | 22 | /** 名称 */ |
23 | private String name; | 23 | private String name; |
24 | 24 | ||
25 | // 状态 0:未启用;1:启用 | 25 | /** 状态 0:未启用;1:启用 */ |
26 | private Integer status; | 26 | private Integer status; |
27 | 27 | ||
28 | // 对应成长值 | 28 | /** 对应成长值 */ |
29 | private Long expValue; | 29 | private Long expValue; |
30 | 30 | ||
31 | // 等级(不可重复,数字越大等级越高) | 31 | /** 等级(不可重复,数字越大等级越高) */ |
32 | private Integer level; | 32 | private Integer level; |
33 | 33 | ||
34 | // 会员徽标 | 34 | /** 会员徽标 */ |
35 | private String iconUrl; | 35 | private String iconUrl; |
36 | 36 | ||
37 | // 描述 | 37 | /** 描述 */ |
38 | private String description; | 38 | private String description; |
39 | 39 | ||
40 | // 对应任务id,通过此字段可获得该等级所对应的权益 | 40 | /** 对应任务id,通过此字段可获得该等级所对应的权益 */ |
41 | private Long taskId; | 41 | private Long taskId; |
42 | 42 | ||
43 | // 创建时间 | 43 | /** 创建时间 */ |
44 | private Timestamp createTime; | 44 | private Timestamp createTime; |
45 | 45 | ||
46 | // 更新时间 | 46 | /** 更新时间 */ |
47 | private Timestamp updateTime; | 47 | private Timestamp updateTime; |
48 | } | 48 | } | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.profile.domain; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.profile.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
6 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
5 | import lombok.Data; | 7 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 9 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -9,6 +11,7 @@ import org.springframework.data.annotation.LastModifiedDate; | ... | @@ -9,6 +11,7 @@ import org.springframework.data.annotation.LastModifiedDate; |
9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | 11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
10 | 12 | ||
11 | import javax.persistence.*; | 13 | import javax.persistence.*; |
14 | import javax.validation.constraints.NotNull; | ||
12 | import java.io.Serializable; | 15 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | 16 | import java.sql.Timestamp; |
14 | 17 | ||
... | @@ -23,76 +26,80 @@ import java.sql.Timestamp; | ... | @@ -23,76 +26,80 @@ import java.sql.Timestamp; |
23 | @Table(name="uc_member_profile") | 26 | @Table(name="uc_member_profile") |
24 | public class MemberProfile implements Serializable { | 27 | public class MemberProfile implements Serializable { |
25 | 28 | ||
29 | /** 会员code */ | ||
30 | @Transient | ||
31 | @NotNull(message = "memberCode not be null!!" , groups = {CreateGroup.class, UpdateGroup.class}) | ||
32 | private String memberCode; | ||
33 | |||
34 | /** 头像 */ | ||
26 | @Transient | 35 | @Transient |
27 | private String avatarUrl; | 36 | private String avatarUrl; |
28 | 37 | ||
29 | // 主键 | 38 | /** 主键 */ |
30 | @Id | 39 | @Id |
31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 40 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
32 | @Column(name = "id") | 41 | @Column(name = "id") |
42 | @NotNull(message = "id not be null!!" , groups = UpdateGroup.class) | ||
33 | private Long id; | 43 | private Long id; |
34 | 44 | ||
35 | // 手机号 | 45 | /** 会员id */ |
36 | @Column(name = "phone") | ||
37 | private String phone; | ||
38 | |||
39 | // 会员id | ||
40 | @Column(name = "member_id", nullable = false) | 46 | @Column(name = "member_id", nullable = false) |
41 | private Long memberId; | 47 | private Long memberId; |
42 | 48 | ||
43 | @Transient | 49 | /** 姓名 */ |
44 | private String memberCode; | ||
45 | |||
46 | // 姓名 | ||
47 | @Column(name = "realname") | 50 | @Column(name = "realname") |
48 | private String realname; | 51 | private String realname; |
49 | 52 | ||
50 | // 性别 0:女; 1:男 -1:未知 | 53 | /** 性别 0:女; 1:男 -1:未知 */ |
51 | @Column(name = "gender", nullable = false) | 54 | @Column(name = "gender", nullable = false) |
52 | private Integer gender; | 55 | private Integer gender; |
53 | 56 | ||
54 | // 生日 | 57 | /** 生日 */ |
55 | @Column(name = "birthday", nullable = false) | 58 | @Column(name = "birthday", nullable = false) |
56 | private String birthday; | 59 | private String birthday; |
57 | 60 | ||
58 | // 星座 | 61 | /** 手机号 */ |
62 | @Column(name = "phone") | ||
63 | private String phone; | ||
64 | |||
65 | /** 星座 */ | ||
59 | @Column(name = "constellation") | 66 | @Column(name = "constellation") |
60 | private String constellation; | 67 | private String constellation; |
61 | 68 | ||
62 | // 身份证 | 69 | /** 身份证 */ |
63 | @Column(name = "id_card", nullable = false) | 70 | @Column(name = "id_card", nullable = false) |
64 | private String idCard; | 71 | private String idCard; |
65 | 72 | ||
66 | // 电子邮件 | 73 | /** 电子邮件 */ |
67 | @Column(name = "email") | 74 | @Column(name = "email") |
68 | private String email; | 75 | private String email; |
69 | 76 | ||
70 | // 国家 | 77 | /** 国家 */ |
71 | @Column(name = "country") | 78 | @Column(name = "country") |
72 | private String country; | 79 | private String country; |
73 | 80 | ||
74 | // 省份 | 81 | /** 省份 */ |
75 | @Column(name = "province") | 82 | @Column(name = "province") |
76 | private String province; | 83 | private String province; |
77 | 84 | ||
78 | // 城市 | 85 | /** 城市 */ |
79 | @Column(name = "city") | 86 | @Column(name = "city") |
80 | private String city; | 87 | private String city; |
81 | 88 | ||
82 | // 区县 | 89 | /** 区县 */ |
83 | @Column(name = "district") | 90 | @Column(name = "district") |
84 | private String district; | 91 | private String district; |
85 | 92 | ||
86 | // 描述 | 93 | /** 描述 */ |
87 | @Column(name = "description") | 94 | @Column(name = "description") |
88 | private String description; | 95 | private String description; |
89 | 96 | ||
90 | // 创建时间 | 97 | /** 创建时间 */ |
91 | @CreatedDate | 98 | @CreatedDate |
92 | @Column(name = "create_time") | 99 | @Column(name = "create_time") |
93 | private Timestamp createTime; | 100 | private Timestamp createTime; |
94 | 101 | ||
95 | // 更新时间 | 102 | /** 更新时间 */ |
96 | @LastModifiedDate | 103 | @LastModifiedDate |
97 | @Column(name = "update_time") | 104 | @Column(name = "update_time") |
98 | private Timestamp updateTime; | 105 | private Timestamp updateTime; | ... | ... |
... | @@ -19,13 +19,13 @@ public class MemberProfileBuilder { | ... | @@ -19,13 +19,13 @@ public class MemberProfileBuilder { |
19 | return memberProfile; | 19 | return memberProfile; |
20 | } | 20 | } |
21 | 21 | ||
22 | public static MemberProfile build(Long memberId , String memberCode, String realname , Integer gender, String birthday){ | 22 | public static MemberProfile build(Long memberId ,String memberCode, String realname , Integer gender, String birthday){ |
23 | MemberProfile memberProfile = build(memberId,memberCode,realname,gender,"","","","","","", | 23 | MemberProfile memberProfile = build(memberId,memberCode,realname,gender,"","","","","","", |
24 | "","","",birthday); | 24 | "","","",birthday); |
25 | return memberProfile; | 25 | return memberProfile; |
26 | } | 26 | } |
27 | 27 | ||
28 | public static MemberProfile build(Long memberId, String memberCode, String realName, Integer sex, | 28 | public static MemberProfile build(Long memberId,String memberCode, String realName, Integer sex, |
29 | String country, String district, String city, String idCard, String province, | 29 | String country, String district, String city, String idCard, String province, |
30 | String email, String description, String phone, String constellation, | 30 | String email, String description, String phone, String constellation, |
31 | String birthday) { | 31 | String birthday) { | ... | ... |
... | @@ -77,5 +77,4 @@ public interface MemberProfileService { | ... | @@ -77,5 +77,4 @@ public interface MemberProfileService { |
77 | * @param resources | 77 | * @param resources |
78 | */ | 78 | */ |
79 | MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources, MemberDTO memberDTO); | 79 | MemberProfileDTO updateMemberProfileAndMember(MemberProfile resources, MemberDTO memberDTO); |
80 | |||
81 | } | 80 | } | ... | ... |
... | @@ -13,60 +13,61 @@ import java.sql.Timestamp; | ... | @@ -13,60 +13,61 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class MemberProfileDTO implements Serializable { | 14 | public class MemberProfileDTO implements Serializable { |
15 | 15 | ||
16 | // 超时时间 | 16 | /** 主键 */ |
17 | private Long vipExpireTime; | ||
18 | |||
19 | // vip | ||
20 | private Integer vip; | ||
21 | |||
22 | // 头像 | ||
23 | private String avatarUrl; | ||
24 | |||
25 | // 主键 | ||
26 | private Long id; | 17 | private Long id; |
27 | 18 | ||
28 | // 会员id | 19 | /** 会员id */ |
29 | private Long memberId; | 20 | private Long memberId; |
30 | 21 | ||
31 | // 手机号 | 22 | /** 姓名 */ |
32 | private String phone; | ||
33 | |||
34 | // 姓名 | ||
35 | private String realname; | 23 | private String realname; |
36 | 24 | ||
37 | // 性别 0:女; 1:男 -1:未知 | 25 | /** 性别 0:女; 1:男 -1:未知 */ |
38 | private Integer gender; | 26 | private Integer gender; |
39 | 27 | ||
40 | // 生日 | 28 | /** 生日 */ |
41 | private String birthday; | 29 | private String birthday; |
42 | 30 | ||
43 | // 星座 | 31 | /** 电话 */ |
32 | private String phone; | ||
33 | |||
34 | /** 星座 */ | ||
44 | private String constellation; | 35 | private String constellation; |
45 | 36 | ||
46 | // 身份证 | 37 | /** 身份证 */ |
47 | private String idCard; | 38 | private String idCard; |
48 | 39 | ||
49 | // 电子邮件 | 40 | /** 电子邮件 */ |
50 | private String email; | 41 | private String email; |
51 | 42 | ||
52 | // 国家 | 43 | /** 国家 */ |
53 | private String country; | 44 | private String country; |
54 | 45 | ||
55 | // 省份 | 46 | /** 省份 */ |
56 | private String province; | 47 | private String province; |
57 | 48 | ||
58 | // 城市 | 49 | /** 城市 */ |
59 | private String city; | 50 | private String city; |
60 | 51 | ||
61 | // 区县 | 52 | /** 区县 */ |
62 | private String district; | 53 | private String district; |
63 | 54 | ||
64 | // 描述 | 55 | /** 描述 */ |
65 | private String description; | 56 | private String description; |
66 | 57 | ||
67 | // 创建时间 | 58 | /** 创建时间 */ |
68 | private Timestamp createTime; | 59 | private Timestamp createTime; |
69 | 60 | ||
70 | // 更新时间 | 61 | /** 更新时间 */ |
71 | private Timestamp updateTime; | 62 | private Timestamp updateTime; |
63 | |||
64 | |||
65 | /** vip */ | ||
66 | private Integer vip; | ||
67 | |||
68 | /** vip过期时间 */ | ||
69 | private Long vipExpireTime; | ||
70 | |||
71 | /** 头像 */ | ||
72 | private String avatarUrl; | ||
72 | } | 73 | } | ... | ... |
... | @@ -9,9 +9,11 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | ... | @@ -9,9 +9,11 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
9 | import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; | 9 | import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; |
10 | import com.topdraw.business.module.member.service.MemberService; | 10 | import com.topdraw.business.module.member.service.MemberService; |
11 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 11 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
12 | import com.topdraw.utils.*; | 12 | import com.topdraw.util.Base64Util; |
13 | import com.topdraw.utils.RedisUtils; | ||
14 | import com.topdraw.utils.StringUtils; | ||
15 | import com.topdraw.utils.ValidationUtil; | ||
13 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
14 | import org.apache.logging.log4j.util.Base64Util; | ||
15 | import org.springframework.beans.BeanUtils; | 17 | import org.springframework.beans.BeanUtils; |
16 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
17 | import org.springframework.dao.EmptyResultDataAccessException; | 19 | import org.springframework.dao.EmptyResultDataAccessException; |
... | @@ -20,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation; | ... | @@ -20,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation; |
20 | import org.springframework.transaction.annotation.Transactional; | 22 | import org.springframework.transaction.annotation.Transactional; |
21 | import org.springframework.util.Assert; | 23 | import org.springframework.util.Assert; |
22 | 24 | ||
25 | |||
23 | /** | 26 | /** |
24 | * @author XiangHan | 27 | * @author XiangHan |
25 | * @date 2021-10-22 | 28 | * @date 2021-10-22 |
... | @@ -116,6 +119,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -116,6 +119,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
116 | BeanUtils.copyProperties(resources,memberProfile); | 119 | BeanUtils.copyProperties(resources,memberProfile); |
117 | MemberProfile _memberProfile = this.memberProfileRepository.save(memberProfile); | 120 | MemberProfile _memberProfile = this.memberProfileRepository.save(memberProfile); |
118 | 121 | ||
122 | |||
119 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); | 123 | MemberProfileDTO memberProfileDTO = new MemberProfileDTO(); |
120 | BeanUtils.copyProperties(_memberProfile,memberProfileDTO); | 124 | BeanUtils.copyProperties(_memberProfile,memberProfileDTO); |
121 | return memberProfileDTO; | 125 | return memberProfileDTO; |
... | @@ -157,5 +161,4 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -157,5 +161,4 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
157 | 161 | ||
158 | this.memberService.update(member); | 162 | this.memberService.update(member); |
159 | } | 163 | } |
160 | |||
161 | } | 164 | } | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.relatedinfo.domain; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.relatedinfo.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.domain.AsyncMqModule; | ||
6 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
5 | import lombok.Data; | 7 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 9 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -9,6 +11,7 @@ import org.springframework.data.annotation.LastModifiedDate; | ... | @@ -9,6 +11,7 @@ import org.springframework.data.annotation.LastModifiedDate; |
9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | 11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
10 | 12 | ||
11 | import javax.persistence.*; | 13 | import javax.persistence.*; |
14 | import javax.validation.constraints.NotNull; | ||
12 | import java.io.Serializable; | 15 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | 16 | import java.sql.Timestamp; |
14 | import java.time.LocalDate; | 17 | import java.time.LocalDate; |
... | @@ -22,38 +25,36 @@ import java.time.LocalDate; | ... | @@ -22,38 +25,36 @@ import java.time.LocalDate; |
22 | @EntityListeners(AuditingEntityListener.class) | 25 | @EntityListeners(AuditingEntityListener.class) |
23 | @Accessors(chain = true) | 26 | @Accessors(chain = true) |
24 | @Table(name="uc_member_related_info") | 27 | @Table(name="uc_member_related_info") |
25 | public class MemberRelatedInfo implements Serializable { | 28 | public class MemberRelatedInfo extends AsyncMqModule implements Serializable { |
26 | 29 | ||
27 | // ID | 30 | /** ID */ |
28 | @Id | 31 | @Id |
29 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
30 | @Column(name = "id") | 33 | @Column(name = "id") |
34 | @NotNull(message = "id can't be null" , groups = {UpdateGroup.class}) | ||
31 | private Long id; | 35 | private Long id; |
32 | 36 | ||
33 | // 会员id | 37 | /** 会员id */ |
34 | @Column(name = "member_id", nullable = false) | 38 | @Column(name = "member_id", nullable = false) |
35 | private Long memberId; | 39 | private Long memberId; |
36 | 40 | ||
37 | @Transient | 41 | /** 人物关系 0:子女;1:父母 */ |
38 | private String memberCode; | ||
39 | |||
40 | // 人物关系 0:子女;1:父母 | ||
41 | @Column(name = "type") | 42 | @Column(name = "type") |
42 | private Integer type; | 43 | private Integer type; |
43 | 44 | ||
44 | // 手机号 | 45 | /** 手机号 */ |
45 | @Column(name = "cellphone") | 46 | @Column(name = "cellphone") |
46 | private String cellphone; | 47 | private String cellphone; |
47 | 48 | ||
48 | // 身份证号 | 49 | /** 身份证号 */ |
49 | @Column(name = "id_card") | 50 | @Column(name = "id_card") |
50 | private String idCard; | 51 | private String idCard; |
51 | 52 | ||
52 | // 姓名 | 53 | /** 姓名 */ |
53 | @Column(name = "name") | 54 | @Column(name = "name") |
54 | private String name; | 55 | private String name; |
55 | 56 | ||
56 | // 性别 0:女;1:男;-1:未知 | 57 | /** 性别 0:女;1:男;-1:未知 */ |
57 | @Column(name = "sex") | 58 | @Column(name = "sex") |
58 | private Integer sex; | 59 | private Integer sex; |
59 | 60 | ||
... | @@ -65,12 +66,12 @@ public class MemberRelatedInfo implements Serializable { | ... | @@ -65,12 +66,12 @@ public class MemberRelatedInfo implements Serializable { |
65 | @Column(name = "avatar_url") | 66 | @Column(name = "avatar_url") |
66 | private String avatarUrl; | 67 | private String avatarUrl; |
67 | 68 | ||
68 | // 创建时间 | 69 | /** 创建时间 */ |
69 | @CreatedDate | 70 | @CreatedDate |
70 | @Column(name = "create_time") | 71 | @Column(name = "create_time") |
71 | private Timestamp createTime; | 72 | private Timestamp createTime; |
72 | 73 | ||
73 | // 更新时间 | 74 | /** 更新时间 */ |
74 | @LastModifiedDate | 75 | @LastModifiedDate |
75 | @Column(name = "update_time") | 76 | @Column(name = "update_time") |
76 | private Timestamp updateTime; | 77 | private Timestamp updateTime; | ... | ... |
... | @@ -4,7 +4,6 @@ import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; | ... | @@ -4,7 +4,6 @@ import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; |
4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | 6 | ||
7 | import java.util.List; | ||
8 | 7 | ||
9 | /** | 8 | /** |
10 | * @author XiangHan | 9 | * @author XiangHan |
... | @@ -14,7 +13,7 @@ public interface MemberRelatedInfoRepository extends JpaRepository<MemberRelated | ... | @@ -14,7 +13,7 @@ public interface MemberRelatedInfoRepository extends JpaRepository<MemberRelated |
14 | 13 | ||
15 | MemberRelatedInfo findByIdCard(String idCard); | 14 | MemberRelatedInfo findByIdCard(String idCard); |
16 | 15 | ||
17 | MemberRelatedInfo findByMemberIdAndIdCard(Long memberId , String idCard); | 16 | MemberRelatedInfo findByMemberIdAndIdCard(Long memberId, String idCard); |
18 | 17 | ||
19 | MemberRelatedInfo findByIdOrIdCard(Long id, String idCard); | 18 | MemberRelatedInfo findByIdOrIdCard(Long id, String idCard); |
20 | 19 | ... | ... |
... | @@ -3,11 +3,6 @@ package com.topdraw.business.module.member.relatedinfo.service; | ... | @@ -3,11 +3,6 @@ package com.topdraw.business.module.member.relatedinfo.service; |
3 | import com.topdraw.business.module.member.domain.Member; | 3 | import com.topdraw.business.module.member.domain.Member; |
4 | import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; | 4 | import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; |
5 | import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; | 5 | import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; |
6 | import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; | ||
7 | import org.springframework.data.domain.Pageable; | ||
8 | |||
9 | import java.util.List; | ||
10 | import java.util.Map; | ||
11 | 6 | ||
12 | /** | 7 | /** |
13 | * @author XiangHan | 8 | * @author XiangHan |
... | @@ -60,7 +55,7 @@ public interface MemberRelatedInfoService { | ... | @@ -60,7 +55,7 @@ public interface MemberRelatedInfoService { |
60 | * @param idCard | 55 | * @param idCard |
61 | * @return | 56 | * @return |
62 | */ | 57 | */ |
63 | MemberRelatedInfoDTO findByMemberIdAndIdCard(Long memberId , String idCard); | 58 | MemberRelatedInfoDTO findByMemberIdAndIdCard(Long memberId, String idCard); |
64 | 59 | ||
65 | /** | 60 | /** |
66 | * | 61 | * |
... | @@ -68,7 +63,7 @@ public interface MemberRelatedInfoService { | ... | @@ -68,7 +63,7 @@ public interface MemberRelatedInfoService { |
68 | * @param idCard | 63 | * @param idCard |
69 | * @return | 64 | * @return |
70 | */ | 65 | */ |
71 | MemberRelatedInfoDTO findByMemberCodeAndIdCard(String memberCode , String idCard); | 66 | MemberRelatedInfoDTO findByMemberCodeAndIdCard(String memberCode, String idCard); |
72 | 67 | ||
73 | /** | 68 | /** |
74 | * | 69 | * |
... | @@ -83,6 +78,5 @@ public interface MemberRelatedInfoService { | ... | @@ -83,6 +78,5 @@ public interface MemberRelatedInfoService { |
83 | * @param resources | 78 | * @param resources |
84 | * @return | 79 | * @return |
85 | */ | 80 | */ |
86 | MemberRelatedInfoDTO findByMemberIdAndIdCard(Member member , MemberRelatedInfo resources); | 81 | MemberRelatedInfoDTO findByMemberIdAndIdCard(Member member, MemberRelatedInfo resources); |
87 | |||
88 | } | 82 | } | ... | ... |
... | @@ -11,11 +11,11 @@ import com.topdraw.business.module.member.service.MemberService; | ... | @@ -11,11 +11,11 @@ import com.topdraw.business.module.member.service.MemberService; |
11 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 11 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
12 | import com.topdraw.exception.BadRequestException; | 12 | import com.topdraw.exception.BadRequestException; |
13 | import com.topdraw.exception.GlobeExceptionMsg; | 13 | import com.topdraw.exception.GlobeExceptionMsg; |
14 | import com.topdraw.util.Base64Util; | ||
14 | import com.topdraw.utils.RedisUtils; | 15 | import com.topdraw.utils.RedisUtils; |
15 | import com.topdraw.utils.ValidationUtil; | 16 | import com.topdraw.utils.ValidationUtil; |
16 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
17 | import org.apache.commons.lang3.StringUtils; | 18 | import org.apache.commons.lang3.StringUtils; |
18 | import org.apache.logging.log4j.util.Base64Util; | ||
19 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
20 | import org.springframework.dao.EmptyResultDataAccessException; | 20 | import org.springframework.dao.EmptyResultDataAccessException; |
21 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
... | @@ -41,7 +41,6 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -41,7 +41,6 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
41 | @Autowired | 41 | @Autowired |
42 | private MemberRelatedInfoRepository memberRelatedInfoRepository; | 42 | private MemberRelatedInfoRepository memberRelatedInfoRepository; |
43 | 43 | ||
44 | |||
45 | private static final String DEFAULT_IDCARD = "000000000000000000"; | 44 | private static final String DEFAULT_IDCARD = "000000000000000000"; |
46 | 45 | ||
47 | @Override | 46 | @Override |
... | @@ -104,6 +103,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -104,6 +103,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
104 | @Transactional(rollbackFor = Exception.class) | 103 | @Transactional(rollbackFor = Exception.class) |
105 | public MemberRelatedInfoDTO update(MemberRelatedInfo resources) { | 104 | public MemberRelatedInfoDTO update(MemberRelatedInfo resources) { |
106 | log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]",resources); | 105 | log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]",resources); |
106 | try { | ||
107 | 107 | ||
108 | this.checkMemberAndEncodeRealname(resources); | 108 | this.checkMemberAndEncodeRealname(resources); |
109 | 109 | ||
... | @@ -115,6 +115,10 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -115,6 +115,10 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
115 | 115 | ||
116 | log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]", resources); | 116 | log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]", resources); |
117 | return this.memberRelatedInfoMapper.toDto(memberRelatedInfo); | 117 | return this.memberRelatedInfoMapper.toDto(memberRelatedInfo); |
118 | } catch (Exception e) { | ||
119 | e.printStackTrace(); | ||
120 | throw e; | ||
121 | } | ||
118 | } | 122 | } |
119 | 123 | ||
120 | @Override | 124 | @Override |
... | @@ -122,7 +126,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -122,7 +126,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
122 | public void delete(Long id) { | 126 | public void delete(Long id) { |
123 | Assert.notNull(id, "The given id must not be null!"); | 127 | Assert.notNull(id, "The given id must not be null!"); |
124 | MemberRelatedInfo MemberRelatedInfo = this.memberRelatedInfoRepository.findById(id).orElseThrow( | 128 | MemberRelatedInfo MemberRelatedInfo = this.memberRelatedInfoRepository.findById(id).orElseThrow( |
125 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberRelatedInfo.class, id), 1)); | 129 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo.class, id), 1)); |
126 | this.memberRelatedInfoRepository.delete(MemberRelatedInfo); | 130 | this.memberRelatedInfoRepository.delete(MemberRelatedInfo); |
127 | } | 131 | } |
128 | 132 | ||
... | @@ -133,10 +137,10 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -133,10 +137,10 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
133 | Assert.notNull(idCard,"idCard can't be null"); | 137 | Assert.notNull(idCard,"idCard can't be null"); |
134 | 138 | ||
135 | if (!idCard.equalsIgnoreCase(DEFAULT_IDCARD)) { | 139 | if (!idCard.equalsIgnoreCase(DEFAULT_IDCARD)) { |
136 | MemberRelatedInfoDTO memberRelatedInfo = this.findByIdCard(idCard); | 140 | MemberRelatedInfoDTO memberRelatedInfoDTO = this.findByIdCard(idCard); |
137 | ValidationUtil.isNull(memberRelatedInfo.getId(),"MemberRelatedInfo","id",resources.getId()); | 141 | ValidationUtil.isNull(memberRelatedInfoDTO.getId(),"MemberRelatedInfo","id",resources.getId()); |
138 | log.info("MemberRelatedInfoServiceImpl ==>> findByIdCard ==>> result ==>> [{}]",memberRelatedInfo); | 142 | log.info("MemberRelatedInfoServiceImpl ==>> findByIdCard ==>> result ==>> [{}]",memberRelatedInfoDTO); |
139 | return memberRelatedInfo; | 143 | return memberRelatedInfoDTO; |
140 | } | 144 | } |
141 | 145 | ||
142 | return null; | 146 | return null; | ... | ... |
... | @@ -3,8 +3,6 @@ package com.topdraw.business.module.member.repository; | ... | @@ -3,8 +3,6 @@ package com.topdraw.business.module.member.repository; |
3 | import com.topdraw.business.module.member.domain.Member; | 3 | import com.topdraw.business.module.member.domain.Member; |
4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | import org.springframework.data.jpa.repository.Modifying; | ||
7 | import org.springframework.data.jpa.repository.Query; | ||
8 | 6 | ||
9 | import java.util.List; | 7 | import java.util.List; |
10 | import java.util.Optional; | 8 | import java.util.Optional; |
... | @@ -19,9 +17,5 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif | ... | @@ -19,9 +17,5 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif |
19 | 17 | ||
20 | List<Member> findByUserIptvId(Long id); | 18 | List<Member> findByUserIptvId(Long id); |
21 | 19 | ||
22 | Optional<Member> findByIdOrCode(Long id,String code); | 20 | Optional<Member> findByIdOrCode(Long id, String code); |
23 | |||
24 | @Modifying | ||
25 | @Query(value = "update uc_member set `points` = ?2 , `due_points` = ?3 where id = ?1 ",nativeQuery = true) | ||
26 | void updateMemberPoints(Long id, Long points, Long duePoints); | ||
27 | } | 21 | } | ... | ... |
... | @@ -11,6 +11,8 @@ import java.util.List; | ... | @@ -11,6 +11,8 @@ import java.util.List; |
11 | */ | 11 | */ |
12 | public interface MemberService { | 12 | public interface MemberService { |
13 | 13 | ||
14 | |||
15 | |||
14 | /** | 16 | /** |
15 | * 根据ID查询 | 17 | * 根据ID查询 |
16 | * @param id ID | 18 | * @param id ID |
... | @@ -63,12 +65,11 @@ public interface MemberService { | ... | @@ -63,12 +65,11 @@ public interface MemberService { |
63 | * @param id 会员id | 65 | * @param id 会员id |
64 | * @param memberCode 会员编码 | 66 | * @param memberCode 会员编码 |
65 | */ | 67 | */ |
66 | MemberDTO checkMember(Long id , String memberCode); | 68 | MemberDTO checkMember(Long id, String memberCode); |
67 | 69 | ||
68 | /** | 70 | /** |
69 | * 检查会员信息 | 71 | * 检查会员信息 |
70 | * @param member 会员 | 72 | * @param member 会员 |
71 | */ | 73 | */ |
72 | MemberDTO checkMember(Member member); | 74 | MemberDTO checkMember(Member member); |
73 | |||
74 | } | 75 | } | ... | ... |
... | @@ -3,7 +3,6 @@ package com.topdraw.business.module.member.service.dto; | ... | @@ -3,7 +3,6 @@ package com.topdraw.business.module.member.service.dto; |
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | ||
7 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
8 | 7 | ||
9 | 8 | ||
... | @@ -14,7 +13,12 @@ import java.time.LocalDateTime; | ... | @@ -14,7 +13,12 @@ import java.time.LocalDateTime; |
14 | @Data | 13 | @Data |
15 | public class MemberDTO implements Serializable { | 14 | public class MemberDTO implements Serializable { |
16 | 15 | ||
17 | // 会员过期时间 | 16 | private String platformAccount; |
17 | |||
18 | // iptv绑定的主会员 0:否 1:是 | ||
19 | private Integer iptvMajor; | ||
20 | |||
21 | // vip过期时间 | ||
18 | private LocalDateTime vipExpireTime; | 22 | private LocalDateTime vipExpireTime; |
19 | 23 | ||
20 | // 主键 | 24 | // 主键 |
... | @@ -87,5 +91,5 @@ public class MemberDTO implements Serializable { | ... | @@ -87,5 +91,5 @@ public class MemberDTO implements Serializable { |
87 | private LocalDateTime updateTime; | 91 | private LocalDateTime updateTime; |
88 | 92 | ||
89 | // 是否在黑名单 1:是;0否 | 93 | // 是否在黑名单 1:是;0否 |
90 | // private Integer blackStatus; | 94 | private Long blackStatus; |
91 | } | 95 | } | ... | ... |
... | @@ -11,7 +11,8 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; | ... | @@ -11,7 +11,8 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; |
11 | import com.topdraw.business.module.member.service.mapper.MemberMapper; | 11 | import com.topdraw.business.module.member.service.mapper.MemberMapper; |
12 | import com.topdraw.exception.BadRequestException; | 12 | import com.topdraw.exception.BadRequestException; |
13 | import com.topdraw.exception.GlobeExceptionMsg; | 13 | import com.topdraw.exception.GlobeExceptionMsg; |
14 | import com.topdraw.utils.*; | 14 | import com.topdraw.utils.RedisUtils; |
15 | import com.topdraw.utils.ValidationUtil; | ||
15 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
16 | import org.apache.commons.lang3.StringUtils; | 17 | import org.apache.commons.lang3.StringUtils; |
17 | import org.springframework.beans.BeanUtils; | 18 | import org.springframework.beans.BeanUtils; |
... | @@ -27,7 +28,6 @@ import java.util.Objects; | ... | @@ -27,7 +28,6 @@ import java.util.Objects; |
27 | * @author XiangHan | 28 | * @author XiangHan |
28 | * @date 2021-10-22 | 29 | * @date 2021-10-22 |
29 | */ | 30 | */ |
30 | |||
31 | @Service | 31 | @Service |
32 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 32 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
33 | @Slf4j | 33 | @Slf4j |
... | @@ -60,7 +60,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -60,7 +60,7 @@ public class MemberServiceImpl implements MemberService { |
60 | 60 | ||
61 | } | 61 | } |
62 | 62 | ||
63 | private MemberDTO findByIdOrCode(Long id,String code) { | 63 | private MemberDTO findByIdOrCode(Long id, String code) { |
64 | 64 | ||
65 | Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new); | 65 | Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new); |
66 | ValidationUtil.isNull(member.getId(),"Member","param",code); | 66 | ValidationUtil.isNull(member.getId(),"Member","param",code); |
... | @@ -129,8 +129,8 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -129,8 +129,8 @@ public class MemberServiceImpl implements MemberService { |
129 | public MemberDTO update(Member resources) { | 129 | public MemberDTO update(Member resources) { |
130 | 130 | ||
131 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); | 131 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); |
132 | 132 | try { | |
133 | MemberDTO memberDTO = this.findByCode(resources.getCode()); | 133 | MemberDTO memberDTO = this.checkMember(resources); |
134 | 134 | ||
135 | Member member = new Member(); | 135 | Member member = new Member(); |
136 | BeanUtils.copyProperties(memberDTO,member); | 136 | BeanUtils.copyProperties(memberDTO,member); |
... | @@ -139,6 +139,11 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -139,6 +139,11 @@ public class MemberServiceImpl implements MemberService { |
139 | this.save(member); | 139 | this.save(member); |
140 | 140 | ||
141 | return this.memberMapper.toDto(member); | 141 | return this.memberMapper.toDto(member); |
142 | } catch (Exception e) { | ||
143 | e.printStackTrace(); | ||
144 | throw e; | ||
145 | } | ||
146 | |||
142 | } | 147 | } |
143 | 148 | ||
144 | @Transactional(propagation = Propagation.REQUIRES_NEW) | 149 | @Transactional(propagation = Propagation.REQUIRES_NEW) |
... | @@ -150,6 +155,9 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -150,6 +155,9 @@ public class MemberServiceImpl implements MemberService { |
150 | @Override | 155 | @Override |
151 | @Transactional(rollbackFor = Exception.class) | 156 | @Transactional(rollbackFor = Exception.class) |
152 | public MemberDTO doUpdateMemberPoints(Member resources) { | 157 | public MemberDTO doUpdateMemberPoints(Member resources) { |
158 | try { | ||
159 | //this.redisUtils.doLock("member::update::code" + resources.getCode()); | ||
160 | |||
153 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); | 161 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); |
154 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | 162 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); |
155 | member.copy(resources); | 163 | member.copy(resources); |
... | @@ -157,5 +165,12 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -157,5 +165,12 @@ public class MemberServiceImpl implements MemberService { |
157 | this.save(member); | 165 | this.save(member); |
158 | 166 | ||
159 | return this.memberMapper.toDto(member); | 167 | return this.memberMapper.toDto(member); |
168 | |||
169 | } catch (Exception e) { | ||
170 | e.printStackTrace(); | ||
171 | throw e; | ||
172 | } | ||
173 | |||
160 | } | 174 | } |
175 | |||
161 | } | 176 | } | ... | ... |
... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.viphistory.domain; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.viphistory.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.domain.AsyncMqModule; | ||
5 | import lombok.Data; | 6 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 7 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 8 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -22,10 +23,7 @@ import java.time.LocalDateTime; | ... | @@ -22,10 +23,7 @@ import java.time.LocalDateTime; |
22 | @EntityListeners(AuditingEntityListener.class) | 23 | @EntityListeners(AuditingEntityListener.class) |
23 | @Accessors(chain = true) | 24 | @Accessors(chain = true) |
24 | @Table(name="uc_member_vip_history") | 25 | @Table(name="uc_member_vip_history") |
25 | public class MemberVipHistory implements Serializable { | 26 | public class MemberVipHistory extends AsyncMqModule implements Serializable { |
26 | |||
27 | @Transient | ||
28 | private String memberCode; | ||
29 | 27 | ||
30 | // 主键 | 28 | // 主键 |
31 | @Id | 29 | @Id | ... | ... |
... | @@ -3,12 +3,8 @@ package com.topdraw.business.module.member.viphistory.service; | ... | @@ -3,12 +3,8 @@ package com.topdraw.business.module.member.viphistory.service; |
3 | import com.topdraw.business.module.member.domain.Member; | 3 | import com.topdraw.business.module.member.domain.Member; |
4 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | 4 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; |
5 | import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO; | 5 | import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO; |
6 | import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria; | ||
7 | import org.springframework.data.domain.Pageable; | ||
8 | 6 | ||
9 | import java.time.LocalDateTime; | 7 | import java.time.LocalDateTime; |
10 | import java.util.List; | ||
11 | import java.util.Map; | ||
12 | 8 | ||
13 | /** | 9 | /** |
14 | * @author luerlong | 10 | * @author luerlong | ... | ... |
... | @@ -9,25 +9,17 @@ import com.topdraw.business.module.member.viphistory.domain.MemberVipHistoryBuil | ... | @@ -9,25 +9,17 @@ import com.topdraw.business.module.member.viphistory.domain.MemberVipHistoryBuil |
9 | import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository; | 9 | import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository; |
10 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; | 10 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; |
11 | import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO; | 11 | import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO; |
12 | import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria; | ||
13 | import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHistoryMapper; | 12 | import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHistoryMapper; |
14 | import com.topdraw.utils.PageUtil; | ||
15 | import com.topdraw.utils.QueryHelp; | ||
16 | import com.topdraw.utils.ValidationUtil; | 13 | import com.topdraw.utils.ValidationUtil; |
17 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.dao.EmptyResultDataAccessException; | 16 | import org.springframework.dao.EmptyResultDataAccessException; |
20 | import org.springframework.data.domain.Page; | ||
21 | import org.springframework.data.domain.Pageable; | ||
22 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
23 | import org.springframework.transaction.annotation.Propagation; | 18 | import org.springframework.transaction.annotation.Propagation; |
24 | import org.springframework.transaction.annotation.Transactional; | 19 | import org.springframework.transaction.annotation.Transactional; |
25 | import org.springframework.util.Assert; | 20 | import org.springframework.util.Assert; |
26 | 21 | ||
27 | import java.time.LocalDateTime; | 22 | import java.time.LocalDateTime; |
28 | import java.util.List; | ||
29 | import java.util.Map; | ||
30 | import java.util.Objects; | ||
31 | 23 | ||
32 | /** | 24 | /** |
33 | * @author luerlong | 25 | * @author luerlong | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.points.available.domain; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.points.available.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
6 | import com.topdraw.business.module.common.domain.AsyncMqModule; | ||
5 | import lombok.Data; | 7 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 9 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -24,53 +26,49 @@ import java.time.LocalDateTime; | ... | @@ -24,53 +26,49 @@ import java.time.LocalDateTime; |
24 | @EntityListeners(AuditingEntityListener.class) | 26 | @EntityListeners(AuditingEntityListener.class) |
25 | @Accessors(chain = true) | 27 | @Accessors(chain = true) |
26 | @Table(name="uc_points_available") | 28 | @Table(name="uc_points_available") |
27 | public class PointsAvailable implements Serializable { | 29 | public class PointsAvailable extends AsyncMqModule implements Serializable { |
28 | 30 | ||
29 | /** 会员编号 */ | 31 | /** 主键 */ |
30 | @Transient | ||
31 | private String memberCode; | ||
32 | |||
33 | // 主键 | ||
34 | @Id | 32 | @Id |
35 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 33 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
36 | @Column(name = "id") | 34 | @Column(name = "id") |
37 | private Long id; | 35 | private Long id; |
38 | 36 | ||
39 | // 标识 | 37 | /** 标识 */ |
40 | @Column(name = "code") | 38 | @Column(name = "code") |
41 | private String code; | 39 | private String code; |
42 | 40 | ||
43 | // 积分类型 0:通用型 | 41 | /** 积分类型 0:通用型 */ |
44 | @Column(name = "points_type") | 42 | @Column(name = "points_type") |
45 | private Integer pointsType; | 43 | private Integer pointsType; |
46 | 44 | ||
47 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 45 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
48 | @Column(name = "device_type") | 46 | @Column(name = "device_type") |
49 | private Integer deviceType; | 47 | private Integer deviceType; |
50 | 48 | ||
51 | // 会员id | 49 | /** 会员id */ |
52 | @Column(name = "member_id", nullable = false) | 50 | @Column(name = "member_id", nullable = false) |
53 | private Long memberId; | 51 | private Long memberId; |
54 | 52 | ||
55 | // 积分值 | 53 | /** 积分值 */ |
56 | @Column(name = "points") | 54 | @Column(name = "points") |
57 | private Long points; | 55 | private Long points; |
58 | 56 | ||
59 | // 过期时间 | 57 | /** 过期时间 */ |
60 | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 58 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "") |
61 | @Column(name = "expire_time") | 59 | @Column(name = "expire_time") |
62 | private LocalDateTime expireTime; | 60 | private LocalDateTime expireTime; |
63 | 61 | ||
64 | // 描述 | 62 | /** 描述 */ |
65 | @Column(name = "description") | 63 | @Column(name = "description") |
66 | private String description; | 64 | private String description; |
67 | 65 | ||
68 | // 创建时间 | 66 | /** 创建时间 */ |
69 | @CreatedDate | 67 | @CreatedDate |
70 | @Column(name = "create_time") | 68 | @Column(name = "create_time") |
71 | private Timestamp createTime; | 69 | private Timestamp createTime; |
72 | 70 | ||
73 | // 更新时间 | 71 | /** 更新时间 */ |
74 | @LastModifiedDate | 72 | @LastModifiedDate |
75 | @Column(name = "update_time") | 73 | @Column(name = "update_time") |
76 | private Timestamp updateTime; | 74 | private Timestamp updateTime; | ... | ... |
src/main/java/com/topdraw/business/module/points/available/repository/PointsAvailableRepository.java
... | @@ -25,7 +25,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable | ... | @@ -25,7 +25,7 @@ public interface PointsAvailableRepository extends JpaRepository<PointsAvailable |
25 | 25 | ||
26 | List<PointsAvailableDTO> findByMemberId(Long memberId); | 26 | List<PointsAvailableDTO> findByMemberId(Long memberId); |
27 | 27 | ||
28 | List<PointsAvailable> findByMemberIdAndExpireTimeBefore(Long memberId , LocalDateTime now); | 28 | List<PointsAvailable> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime now); |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * 即将过期的积分 | 31 | * 即将过期的积分 | ... | ... |
... | @@ -2,12 +2,9 @@ package com.topdraw.business.module.points.available.service; | ... | @@ -2,12 +2,9 @@ package com.topdraw.business.module.points.available.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.points.available.domain.PointsAvailable; | 3 | import com.topdraw.business.module.points.available.domain.PointsAvailable; |
4 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO; | 4 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO; |
5 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | 5 | ||
8 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
9 | import java.util.List; | 7 | import java.util.List; |
10 | import java.util.Map; | ||
11 | 8 | ||
12 | /** | 9 | /** |
13 | * @author XiangHan | 10 | * @author XiangHan |
... | @@ -16,21 +13,6 @@ import java.util.Map; | ... | @@ -16,21 +13,6 @@ import java.util.Map; |
16 | public interface PointsAvailableService { | 13 | public interface PointsAvailableService { |
17 | 14 | ||
18 | /** | 15 | /** |
19 | * 查询数据分页 | ||
20 | * @param criteria 条件参数 | ||
21 | * @param pageable 分页参数 | ||
22 | * @return Map<String,Object> | ||
23 | */ | ||
24 | Map<String,Object> queryAll(PointsAvailableQueryCriteria criteria, Pageable pageable); | ||
25 | |||
26 | /** | ||
27 | * 查询所有数据不分页 | ||
28 | * @param criteria 条件参数 | ||
29 | * @return List<PointsAvailableDTO> | ||
30 | */ | ||
31 | List<PointsAvailableDTO> queryAll(PointsAvailableQueryCriteria criteria); | ||
32 | |||
33 | /** | ||
34 | * 根据ID查询 | 16 | * 根据ID查询 |
35 | * @param id ID | 17 | * @param id ID |
36 | * @return PointsAvailableDTO | 18 | * @return PointsAvailableDTO |
... | @@ -41,13 +23,13 @@ public interface PointsAvailableService { | ... | @@ -41,13 +23,13 @@ public interface PointsAvailableService { |
41 | * | 23 | * |
42 | * @param resources | 24 | * @param resources |
43 | */ | 25 | */ |
44 | void create(PointsAvailable resources); | 26 | PointsAvailableDTO create(PointsAvailable resources); |
45 | 27 | ||
46 | /** | 28 | /** |
47 | * | 29 | * |
48 | * @param resources | 30 | * @param resources |
49 | */ | 31 | */ |
50 | void update(PointsAvailable resources); | 32 | PointsAvailableDTO update(PointsAvailable resources); |
51 | 33 | ||
52 | /** | 34 | /** |
53 | * | 35 | * |
... | @@ -55,8 +37,6 @@ public interface PointsAvailableService { | ... | @@ -55,8 +37,6 @@ public interface PointsAvailableService { |
55 | */ | 37 | */ |
56 | void delete(Long id); | 38 | void delete(Long id); |
57 | 39 | ||
58 | void delete4Custom(Long id); | ||
59 | |||
60 | /** | 40 | /** |
61 | * | 41 | * |
62 | * @param id | 42 | * @param id |
... | @@ -84,7 +64,7 @@ public interface PointsAvailableService { | ... | @@ -84,7 +64,7 @@ public interface PointsAvailableService { |
84 | * @param factor 阈值 | 64 | * @param factor 阈值 |
85 | * @return | 65 | * @return |
86 | */ | 66 | */ |
87 | Long findSoonExpireTime(Long memberId,Integer factor); | 67 | Long findSoonExpireTime(Long memberId, Integer factor); |
88 | 68 | ||
89 | /** | 69 | /** |
90 | * | 70 | * |
... | @@ -107,6 +87,15 @@ public interface PointsAvailableService { | ... | @@ -107,6 +87,15 @@ public interface PointsAvailableService { |
107 | */ | 87 | */ |
108 | long findTotalPointsByMemberId(Long memberId); | 88 | long findTotalPointsByMemberId(Long memberId); |
109 | 89 | ||
110 | void create4Custom(PointsAvailable pointsAvailable); | 90 | /** |
91 | * | ||
92 | * @param id | ||
93 | */ | ||
94 | void delete4Custom(Long id); | ||
111 | 95 | ||
96 | /** | ||
97 | * | ||
98 | * @param pointsAvailable | ||
99 | */ | ||
100 | PointsAvailableDTO create4Custom(PointsAvailable pointsAvailable); | ||
112 | } | 101 | } | ... | ... |
... | @@ -14,33 +14,33 @@ import java.time.LocalDateTime; | ... | @@ -14,33 +14,33 @@ import java.time.LocalDateTime; |
14 | @Data | 14 | @Data |
15 | public class PointsAvailableDTO implements Serializable { | 15 | public class PointsAvailableDTO implements Serializable { |
16 | 16 | ||
17 | // 主键 | 17 | /** 主键 */ |
18 | private Long id; | 18 | private Long id; |
19 | 19 | ||
20 | // 标识 | 20 | /** 标识 */ |
21 | private String code; | 21 | private String code; |
22 | 22 | ||
23 | // 积分类型 0:通用型 | 23 | /** 积分类型 0:通用型 */ |
24 | private Integer pointsType; | 24 | private Integer pointsType; |
25 | 25 | ||
26 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 26 | /** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */ |
27 | private Integer deviceType; | 27 | private Integer deviceType; |
28 | 28 | ||
29 | // 会员id | 29 | /** 会员id */ |
30 | private Long memberId; | 30 | private Long memberId; |
31 | 31 | ||
32 | // 积分值 | 32 | /** 积分值 */ |
33 | private Long points; | 33 | private Long points; |
34 | 34 | ||
35 | // 过期时间 | 35 | /** 过期时间 */ |
36 | private LocalDateTime expireTime; | 36 | private LocalDateTime expireTime; |
37 | 37 | ||
38 | // 描述 | 38 | /** 描述 */ |
39 | private String description; | 39 | private String description; |
40 | 40 | ||
41 | // 创建时间 | 41 | /** 创建时间 */ |
42 | private Timestamp createTime; | 42 | private Timestamp createTime; |
43 | 43 | ||
44 | // 更新时间 | 44 | /** 更新时间 */ |
45 | private Timestamp updateTime; | 45 | private Timestamp updateTime; |
46 | } | 46 | } | ... | ... |
This diff is collapsed.
Click to expand it.
1 | package com.topdraw.business.module.points.detail.detailhistory.service.impl; | 1 | package com.topdraw.business.module.points.detail.detailhistory.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory; | 3 | import com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory; |
4 | import com.topdraw.business.module.points.detail.detailhistory.repository.PointsDetailHistoryRepository; | ||
5 | import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService; | 4 | import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService; |
6 | import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO; | 5 | import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryDTO; |
7 | import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria; | 6 | import com.topdraw.business.module.points.detail.detailhistory.service.dto.PointsDetailHistoryQueryCriteria; |
8 | import com.topdraw.business.module.points.detail.detailhistory.service.mapper.PointsDetailHistoryMapper; | ||
9 | import com.topdraw.utils.PageUtil; | 7 | import com.topdraw.utils.PageUtil; |
10 | import com.topdraw.utils.QueryHelp; | 8 | import com.topdraw.utils.QueryHelp; |
11 | import com.topdraw.utils.StringUtils; | 9 | import com.topdraw.utils.StringUtils; |
... | @@ -31,10 +29,10 @@ import java.util.Map; | ... | @@ -31,10 +29,10 @@ import java.util.Map; |
31 | public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryService { | 29 | public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryService { |
32 | 30 | ||
33 | @Autowired | 31 | @Autowired |
34 | private PointsDetailHistoryRepository PointsDetailHistoryRepository; | 32 | private com.topdraw.business.module.points.detail.detailhistory.repository.PointsDetailHistoryRepository PointsDetailHistoryRepository; |
35 | 33 | ||
36 | @Autowired | 34 | @Autowired |
37 | private PointsDetailHistoryMapper PointsDetailHistoryMapper; | 35 | private com.topdraw.business.module.points.detail.detailhistory.service.mapper.PointsDetailHistoryMapper PointsDetailHistoryMapper; |
38 | 36 | ||
39 | @Override | 37 | @Override |
40 | public Map<String, Object> queryAll(PointsDetailHistoryQueryCriteria criteria, Pageable pageable) { | 38 | public Map<String, Object> queryAll(PointsDetailHistoryQueryCriteria criteria, Pageable pageable) { |
... | @@ -49,7 +47,7 @@ public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryServic | ... | @@ -49,7 +47,7 @@ public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryServic |
49 | 47 | ||
50 | @Override | 48 | @Override |
51 | public PointsDetailHistoryDTO findById(Long id) { | 49 | public PointsDetailHistoryDTO findById(Long id) { |
52 | PointsDetailHistory PointsDetailHistory = PointsDetailHistoryRepository.findById(id).orElseGet(PointsDetailHistory::new); | 50 | PointsDetailHistory PointsDetailHistory = PointsDetailHistoryRepository.findById(id).orElseGet(com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory::new); |
53 | ValidationUtil.isNull(PointsDetailHistory.getId(),"PointsDetailHistory","id",id); | 51 | ValidationUtil.isNull(PointsDetailHistory.getId(),"PointsDetailHistory","id",id); |
54 | return PointsDetailHistoryMapper.toDto(PointsDetailHistory); | 52 | return PointsDetailHistoryMapper.toDto(PointsDetailHistory); |
55 | } | 53 | } |
... | @@ -63,7 +61,7 @@ public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryServic | ... | @@ -63,7 +61,7 @@ public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryServic |
63 | @Override | 61 | @Override |
64 | @Transactional(rollbackFor = Exception.class) | 62 | @Transactional(rollbackFor = Exception.class) |
65 | public void update(PointsDetailHistory resources) { | 63 | public void update(PointsDetailHistory resources) { |
66 | PointsDetailHistory PointsDetailHistory = PointsDetailHistoryRepository.findById(resources.getId()).orElseGet(PointsDetailHistory::new); | 64 | PointsDetailHistory PointsDetailHistory = PointsDetailHistoryRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory::new); |
67 | ValidationUtil.isNull( PointsDetailHistory.getId(),"PointsDetailHistory","id",resources.getId()); | 65 | ValidationUtil.isNull( PointsDetailHistory.getId(),"PointsDetailHistory","id",resources.getId()); |
68 | PointsDetailHistory.copy(resources); | 66 | PointsDetailHistory.copy(resources); |
69 | PointsDetailHistoryRepository.save(PointsDetailHistory); | 67 | PointsDetailHistoryRepository.save(PointsDetailHistory); |
... | @@ -74,7 +72,7 @@ public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryServic | ... | @@ -74,7 +72,7 @@ public class PointsDetailHistoryServiceImpl implements PointsDetailHistoryServic |
74 | public void delete(Long id) { | 72 | public void delete(Long id) { |
75 | Assert.notNull(id, "The given id must not be null!"); | 73 | Assert.notNull(id, "The given id must not be null!"); |
76 | PointsDetailHistory PointsDetailHistory = PointsDetailHistoryRepository.findById(id).orElseThrow( | 74 | PointsDetailHistory PointsDetailHistory = PointsDetailHistoryRepository.findById(id).orElseThrow( |
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsDetailHistory.class, id), 1)); | 75 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.points.detail.detailhistory.domain.PointsDetailHistory.class, id), 1)); |
78 | PointsDetailHistoryRepository.delete(PointsDetailHistory); | 76 | PointsDetailHistoryRepository.delete(PointsDetailHistory); |
79 | } | 77 | } |
80 | 78 | ... | ... |
1 | package com.topdraw.business.module.points.detail.rest; | ||
2 | |||
3 | import io.swagger.annotations.Api; | ||
4 | |||
5 | /** | ||
6 | * @author XiangHan | ||
7 | * @date 2021-10-22 | ||
8 | */ | ||
9 | @Api(tags = "PointsDetail管理") | ||
10 | //@RestController | ||
11 | //@RequestMapping("/api/PointsDetail") | ||
12 | public class PointsDetailController { | ||
13 | |||
14 | /*@Autowired | ||
15 | private PointsDetailService PointsDetailService; | ||
16 | |||
17 | @GetMapping | ||
18 | @ApiOperation("查询PointsDetail") | ||
19 | public ResultInfo getPointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) { | ||
20 | return ResultInfo.successPage(PointsDetailService.queryAll(criteria,pageable)); | ||
21 | } | ||
22 | |||
23 | @GetMapping(value = "/all") | ||
24 | @ApiOperation("查询所有PointsDetail") | ||
25 | public ResultInfo getPointsDetails(PointsDetailQueryCriteria criteria) { | ||
26 | return ResultInfo.success(PointsDetailService.queryAll(criteria)); | ||
27 | } | ||
28 | |||
29 | @Log | ||
30 | @PostMapping | ||
31 | @ApiOperation("新增PointsDetail") | ||
32 | public ResultInfo create(@Validated @RequestBody PointsDetail resources) { | ||
33 | PointsDetailService.create(resources); | ||
34 | return ResultInfo.success(); | ||
35 | } | ||
36 | |||
37 | @Log | ||
38 | @PutMapping | ||
39 | @ApiOperation("修改PointsDetail") | ||
40 | public ResultInfo update(@Validated @RequestBody PointsDetail resources) { | ||
41 | PointsDetailService.update(resources); | ||
42 | return ResultInfo.success(); | ||
43 | } | ||
44 | |||
45 | @Log | ||
46 | @DeleteMapping(value = "/{id}") | ||
47 | @ApiOperation("删除PointsDetail") | ||
48 | public ResultInfo delete(@PathVariable Long id) { | ||
49 | PointsDetailService.delete(id); | ||
50 | return ResultInfo.success(); | ||
51 | } | ||
52 | |||
53 | @GetMapping(value = "/getByCode/{code}") | ||
54 | @ApiOperation(value = "根据标识查询") | ||
55 | public ResultInfo getByCode(@PathVariable String code) { | ||
56 | return ResultInfo.success(PointsDetailService.getByCode(code)); | ||
57 | }*/ | ||
58 | } |
... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.points.detail.service; | ... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.points.detail.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | 3 | import com.topdraw.business.module.points.detail.domain.PointsDetail; |
4 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; | 4 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; |
5 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | 5 | ||
8 | import java.util.List; | 6 | import java.util.List; |
9 | import java.util.Map; | ||
10 | 7 | ||
11 | /** | 8 | /** |
12 | * @author XiangHan | 9 | * @author XiangHan |
... | @@ -15,33 +12,30 @@ import java.util.Map; | ... | @@ -15,33 +12,30 @@ import java.util.Map; |
15 | public interface PointsDetailService { | 12 | public interface PointsDetailService { |
16 | 13 | ||
17 | /** | 14 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(PointsDetailQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<PointsDetailDTO> | ||
29 | */ | ||
30 | List<PointsDetailDTO> queryAll(PointsDetailQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 15 | * 根据ID查询 |
34 | * @param id ID | 16 | * @param id ID |
35 | * @return PointsDetailDTO | 17 | * @return PointsDetailDTO |
36 | */ | 18 | */ |
37 | PointsDetailDTO findById(Long id); | 19 | PointsDetailDTO findById(Long id); |
38 | 20 | ||
39 | void create(PointsDetail resources); | 21 | /** |
40 | 22 | * | |
41 | void create4Custom(PointsDetail resources); | 23 | * @param resources |
24 | * @return | ||
25 | */ | ||
26 | PointsDetailDTO create(PointsDetail resources); | ||
42 | 27 | ||
43 | void update(PointsDetail resources); | 28 | /** |
29 | * | ||
30 | * @param resources | ||
31 | * @return | ||
32 | */ | ||
33 | PointsDetailDTO update(PointsDetail resources); | ||
44 | 34 | ||
35 | /** | ||
36 | * | ||
37 | * @param id | ||
38 | */ | ||
45 | void delete(Long id); | 39 | void delete(Long id); |
46 | 40 | ||
47 | /** | 41 | /** |
... | @@ -51,13 +45,23 @@ public interface PointsDetailService { | ... | @@ -51,13 +45,23 @@ public interface PointsDetailService { |
51 | */ | 45 | */ |
52 | PointsDetailDTO getByCode(String code); | 46 | PointsDetailDTO getByCode(String code); |
53 | 47 | ||
48 | /** | ||
49 | * | ||
50 | * @param memberId | ||
51 | * @return | ||
52 | */ | ||
54 | List<PointsDetailDTO> loadListExpirePointsByMemberId(Long memberId); | 53 | List<PointsDetailDTO> loadListExpirePointsByMemberId(Long memberId); |
55 | 54 | ||
56 | |||
57 | /** | 55 | /** |
58 | * 已过期的积分 | 56 | * 已过期的积分 |
59 | * @param memberId | 57 | * @param memberId |
60 | * @return | 58 | * @return |
61 | */ | 59 | */ |
62 | List<PointsDetailDTO> findByMemberId(Long memberId); | 60 | List<PointsDetailDTO> findByMemberId(Long memberId); |
61 | |||
62 | /** | ||
63 | * | ||
64 | * @param pointsDetail | ||
65 | */ | ||
66 | void create4Custom(PointsDetail pointsDetail); | ||
63 | } | 67 | } | ... | ... |
1 | package com.topdraw.business.module.points.detail.service.impl; | 1 | package com.topdraw.business.module.points.detail.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.service.MemberService; | ||
4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
5 | import com.topdraw.business.module.points.detail.domain.PointsDetail; | 3 | import com.topdraw.business.module.points.detail.domain.PointsDetail; |
6 | import com.topdraw.business.module.points.detail.repository.PointsDetailRepository; | 4 | import com.topdraw.business.module.points.detail.repository.PointsDetailRepository; |
7 | import com.topdraw.business.module.points.detail.service.PointsDetailService; | 5 | import com.topdraw.business.module.points.detail.service.PointsDetailService; |
8 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; | 6 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailDTO; |
9 | import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria; | ||
10 | import com.topdraw.business.module.points.detail.service.mapper.PointsDetailMapper; | 7 | import com.topdraw.business.module.points.detail.service.mapper.PointsDetailMapper; |
11 | import com.topdraw.utils.PageUtil; | ||
12 | import com.topdraw.utils.QueryHelp; | ||
13 | import com.topdraw.utils.StringUtils; | 8 | import com.topdraw.utils.StringUtils; |
14 | import com.topdraw.utils.ValidationUtil; | 9 | import com.topdraw.utils.ValidationUtil; |
15 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
16 | import org.springframework.dao.EmptyResultDataAccessException; | 11 | import org.springframework.dao.EmptyResultDataAccessException; |
17 | import org.springframework.data.domain.Page; | ||
18 | import org.springframework.data.domain.Pageable; | ||
19 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
20 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
21 | import org.springframework.transaction.annotation.Transactional; | 14 | import org.springframework.transaction.annotation.Transactional; |
22 | import org.springframework.util.Assert; | 15 | import org.springframework.util.Assert; |
23 | 16 | ||
24 | import java.util.List; | 17 | import java.util.List; |
25 | import java.util.Map; | ||
26 | import java.util.Objects; | 18 | import java.util.Objects; |
27 | 19 | ||
28 | /** | 20 | /** |
... | @@ -34,81 +26,47 @@ import java.util.Objects; | ... | @@ -34,81 +26,47 @@ import java.util.Objects; |
34 | public class PointsDetailServiceImpl implements PointsDetailService { | 26 | public class PointsDetailServiceImpl implements PointsDetailService { |
35 | 27 | ||
36 | @Autowired | 28 | @Autowired |
37 | private PointsDetailRepository PointsDetailRepository; | 29 | private PointsDetailRepository pointsDetailRepository; |
38 | |||
39 | @Autowired | ||
40 | private MemberService memberService; | ||
41 | |||
42 | @Autowired | 30 | @Autowired |
43 | private PointsDetailMapper PointsDetailMapper; | 31 | private PointsDetailMapper pointsDetailMapper; |
44 | |||
45 | @Override | ||
46 | public Map<String, Object> queryAll(PointsDetailQueryCriteria criteria, Pageable pageable) { | ||
47 | Page<PointsDetail> page = PointsDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
48 | return PageUtil.toPage(page.map(PointsDetailMapper::toDto)); | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public List<PointsDetailDTO> queryAll(PointsDetailQueryCriteria criteria) { | ||
53 | return PointsDetailMapper.toDto(PointsDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
54 | } | ||
55 | 32 | ||
56 | @Override | 33 | @Override |
57 | public PointsDetailDTO findById(Long id) { | 34 | public PointsDetailDTO findById(Long id) { |
58 | PointsDetail PointsDetail = PointsDetailRepository.findById(id).orElseGet(PointsDetail::new); | 35 | PointsDetail pointsDetail = this.pointsDetailRepository.findById(id).orElseGet(PointsDetail::new); |
59 | ValidationUtil.isNull(PointsDetail.getId(),"PointsDetail","id",id); | 36 | ValidationUtil.isNull(pointsDetail.getId(),"PointsDetail","id",id); |
60 | return PointsDetailMapper.toDto(PointsDetail); | 37 | return this.pointsDetailMapper.toDto(pointsDetail); |
61 | } | 38 | } |
62 | 39 | ||
63 | @Override | 40 | @Override |
64 | @Transactional(rollbackFor = Exception.class) | 41 | @Transactional(rollbackFor = Exception.class) |
65 | public void create(PointsDetail resources) { | 42 | public PointsDetailDTO create(PointsDetail resources) { |
66 | String memberCode = resources.getMemberCode(); | 43 | PointsDetail pointsDetail = this.pointsDetailRepository.save(resources); |
67 | if (StringUtils.isNotEmpty(memberCode)) { | 44 | return this.pointsDetailMapper.toDto(pointsDetail); |
68 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
69 | if (Objects.nonNull(memberDTO)) { | ||
70 | Long memberId = memberDTO.getId(); | ||
71 | resources.setMemberId(memberId); | ||
72 | } | ||
73 | } | ||
74 | PointsDetailRepository.save(resources); | ||
75 | } | ||
76 | |||
77 | @Override | ||
78 | public void create4Custom(PointsDetail resources) { | ||
79 | String memberCode = resources.getMemberCode(); | ||
80 | if (StringUtils.isNotEmpty(memberCode)) { | ||
81 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
82 | if (Objects.nonNull(memberDTO)) { | ||
83 | Long memberId = memberDTO.getId(); | ||
84 | resources.setMemberId(memberId); | ||
85 | } | ||
86 | } | ||
87 | PointsDetailRepository.save(resources); | ||
88 | } | 45 | } |
89 | 46 | ||
90 | @Override | 47 | @Override |
91 | @Transactional(rollbackFor = Exception.class) | 48 | @Transactional(rollbackFor = Exception.class) |
92 | public void update(PointsDetail resources) { | 49 | public PointsDetailDTO update(PointsDetail resources) { |
93 | PointsDetail PointsDetail = PointsDetailRepository.findById(resources.getId()).orElseGet(PointsDetail::new); | 50 | PointsDetail pointsDetail = this.pointsDetailRepository.findById(resources.getId()).orElseGet(PointsDetail::new); |
94 | ValidationUtil.isNull( PointsDetail.getId(),"PointsDetail","id",resources.getId()); | 51 | ValidationUtil.isNull( pointsDetail.getId(),"PointsDetail","id",resources.getId()); |
95 | PointsDetail.copy(resources); | 52 | pointsDetail.copy(resources); |
96 | PointsDetailRepository.save(PointsDetail); | 53 | PointsDetail _pointsDetail = this.pointsDetailRepository.save(pointsDetail); |
54 | return this.pointsDetailMapper.toDto(_pointsDetail); | ||
97 | } | 55 | } |
98 | 56 | ||
99 | @Override | 57 | @Override |
100 | @Transactional(rollbackFor = Exception.class) | 58 | @Transactional(rollbackFor = Exception.class) |
101 | public void delete(Long id) { | 59 | public void delete(Long id) { |
102 | Assert.notNull(id, "The given id must not be null!"); | 60 | Assert.notNull(id, "The given id must not be null!"); |
103 | PointsDetail PointsDetail = PointsDetailRepository.findById(id).orElseThrow( | 61 | PointsDetail pointsDetail = this.pointsDetailRepository.findById(id).orElseThrow( |
104 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsDetail.class, id), 1)); | 62 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsDetail.class, id), 1)); |
105 | PointsDetailRepository.delete(PointsDetail); | 63 | this.pointsDetailRepository.delete(pointsDetail); |
106 | } | 64 | } |
107 | 65 | ||
108 | 66 | ||
109 | @Override | 67 | @Override |
110 | public PointsDetailDTO getByCode(String code) { | 68 | public PointsDetailDTO getByCode(String code) { |
111 | return StringUtils.isNotEmpty(code) ? PointsDetailMapper.toDto(PointsDetailRepository.findFirstByCode(code).orElseGet(PointsDetail::new)) | 69 | return StringUtils.isNotEmpty(code) ? this.pointsDetailMapper.toDto(this.pointsDetailRepository.findFirstByCode(code).orElseGet(PointsDetail::new)) |
112 | : new PointsDetailDTO(); | 70 | : new PointsDetailDTO(); |
113 | } | 71 | } |
114 | 72 | ||
... | @@ -120,7 +78,12 @@ public class PointsDetailServiceImpl implements PointsDetailService { | ... | @@ -120,7 +78,12 @@ public class PointsDetailServiceImpl implements PointsDetailService { |
120 | @Override | 78 | @Override |
121 | public List<PointsDetailDTO> findByMemberId(Long memberId) { | 79 | public List<PointsDetailDTO> findByMemberId(Long memberId) { |
122 | return Objects.nonNull(memberId)? | 80 | return Objects.nonNull(memberId)? |
123 | PointsDetailMapper.toDto(PointsDetailRepository.findByMemberId(memberId)) | 81 | this.pointsDetailMapper.toDto(this.pointsDetailRepository.findByMemberId(memberId)) |
124 | :null; | 82 | :null; |
125 | } | 83 | } |
84 | |||
85 | @Override | ||
86 | public void create4Custom(PointsDetail pointsDetail) { | ||
87 | this.pointsDetailRepository.save(pointsDetail); | ||
88 | } | ||
126 | } | 89 | } | ... | ... |
... | @@ -27,35 +27,37 @@ public class Points implements Serializable { | ... | @@ -27,35 +27,37 @@ public class Points implements Serializable { |
27 | @Column(name = "id") | 27 | @Column(name = "id") |
28 | private Long id; | 28 | private Long id; |
29 | 29 | ||
30 | /** 账号id */ | ||
30 | @Column(name = "user_id") | 31 | @Column(name = "user_id") |
31 | private Long userId; | 32 | private Long userId; |
32 | 33 | ||
33 | // 积分类型,通用,绑定, 区分大小屏 | 34 | /** 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) |
35 | 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途)*/ | ||
34 | @Column(name = "point_type") | 36 | @Column(name = "point_type") |
35 | private Integer pointType; | 37 | private Integer pointType; |
36 | 38 | ||
37 | // 绑定对应的实体, 如何描述? | 39 | /** 绑定对应的实体, 如何描述? */ |
38 | @Column(name = "target_no") | 40 | @Column(name = "target_no") |
39 | private String targetNo; | 41 | private String targetNo; |
40 | 42 | ||
41 | // 本月期初积分值 | 43 | /** 本月期初积分值 */ |
42 | @Column(name = "begin_points") | 44 | @Column(name = "begin_points") |
43 | private Integer beginPoints; | 45 | private Integer beginPoints; |
44 | 46 | ||
45 | // 当前积分余额 | 47 | /** 当前积分余额 */ |
46 | @Column(name = "current_points") | 48 | @Column(name = "current_points") |
47 | private Integer currentPoints; | 49 | private Integer currentPoints; |
48 | 50 | ||
49 | // 本月到期积分 | 51 | /** 本月到期积分 */ |
50 | @Column(name = "expire_points") | 52 | @Column(name = "expire_points") |
51 | private Integer expirePoints; | 53 | private Integer expirePoints; |
52 | 54 | ||
53 | // 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途) | 55 | /** 创建时间 */ |
54 | @CreatedDate | 56 | @CreatedDate |
55 | @Column(name = "create_time") | 57 | @Column(name = "create_time") |
56 | private Timestamp createTime; | 58 | private Timestamp createTime; |
57 | 59 | ||
58 | // 最后修改时间 | 60 | /** 最后修改时间 */ |
59 | @LastModifiedDate | 61 | @LastModifiedDate |
60 | @Column(name = "update_time") | 62 | @Column(name = "update_time") |
61 | private Timestamp updateTime; | 63 | private Timestamp updateTime; | ... | ... |
... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.points.service; | ... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.points.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.points.domain.Points; | 3 | import com.topdraw.business.module.points.domain.Points; |
4 | import com.topdraw.business.module.points.service.dto.PointsDTO; | 4 | import com.topdraw.business.module.points.service.dto.PointsDTO; |
5 | import com.topdraw.business.module.points.service.dto.PointsQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | 5 | ||
11 | /** | 6 | /** |
12 | * @author XiangHan | 7 | * @author XiangHan |
... | @@ -15,31 +10,28 @@ import java.util.Map; | ... | @@ -15,31 +10,28 @@ import java.util.Map; |
15 | public interface PointsService { | 10 | public interface PointsService { |
16 | 11 | ||
17 | /** | 12 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(PointsQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<PointsDTO> | ||
29 | */ | ||
30 | List<PointsDTO> queryAll(PointsQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 13 | * 根据ID查询 |
34 | * @param id ID | 14 | * @param id ID |
35 | * @return PointsDTO | 15 | * @return PointsDTO |
36 | */ | 16 | */ |
37 | PointsDTO findById(Long id); | 17 | PointsDTO findById(Long id); |
38 | 18 | ||
39 | void create(Points resources); | 19 | /** |
20 | * | ||
21 | * @param resources | ||
22 | */ | ||
23 | PointsDTO create(Points resources); | ||
40 | 24 | ||
41 | void update(Points resources); | 25 | /** |
26 | * | ||
27 | * @param resources | ||
28 | */ | ||
29 | PointsDTO update(Points resources); | ||
42 | 30 | ||
31 | /** | ||
32 | * | ||
33 | * @param id | ||
34 | */ | ||
43 | void delete(Long id); | 35 | void delete(Long id); |
44 | 36 | ||
45 | } | 37 | } | ... | ... |
... | @@ -19,26 +19,30 @@ public class PointsDTO implements Serializable { | ... | @@ -19,26 +19,30 @@ public class PointsDTO implements Serializable { |
19 | @JsonSerialize(using= ToStringSerializer.class) | 19 | @JsonSerialize(using= ToStringSerializer.class) |
20 | private Long id; | 20 | private Long id; |
21 | 21 | ||
22 | /** 账号id */ | ||
22 | private Long userId; | 23 | private Long userId; |
23 | 24 | ||
24 | // 积分类型,通用,绑定, 区分大小屏 todo | 25 | /** 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) |
26 | 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途)*/ | ||
25 | private Integer pointType; | 27 | private Integer pointType; |
26 | 28 | ||
27 | // 绑定对应的实体, 如何描述? | 29 | /** 绑定对应的实体, 如何描述? */ |
28 | private String targetNo; | 30 | private String targetNo; |
29 | 31 | ||
30 | // 本月期初积分值 | 32 | /** 本月期初积分值 */ |
31 | private Integer beginPoints; | 33 | private Integer beginPoints; |
32 | 34 | ||
33 | // 当前积分余额 | 35 | /** 当前积分余额 */ |
34 | private Integer currentPoints; | 36 | private Integer currentPoints; |
35 | 37 | ||
36 | // 本月到期积分 | 38 | /** 本月到期积分 */ |
37 | private Integer expirePoints; | 39 | private Integer expirePoints; |
38 | 40 | ||
39 | // 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途) | 41 | /** 积分类型:10:通用积分(跨屏) 11:定向积分(跨屏,绑定用途)20:通用积分(大屏) |
42 | * 21:定向积分(大屏,绑定用途)30:通用积分(小屏) 31:定向积分(小屏,绑定用途) | ||
43 | */ | ||
40 | private Timestamp createTime; | 44 | private Timestamp createTime; |
41 | 45 | ||
42 | // 最后修改时间 | 46 | /** 最后修改时间 */ |
43 | private Timestamp updateTime; | 47 | private Timestamp updateTime; |
44 | } | 48 | } | ... | ... |
1 | package com.topdraw.business.module.points.service.impl; | 1 | package com.topdraw.business.module.points.service.impl; |
2 | 2 | ||
3 | import cn.hutool.core.lang.Snowflake; | ||
4 | import cn.hutool.core.util.IdUtil; | ||
5 | import com.topdraw.business.module.points.domain.Points; | 3 | import com.topdraw.business.module.points.domain.Points; |
6 | import com.topdraw.business.module.points.repository.PointsRepository; | 4 | import com.topdraw.business.module.points.repository.PointsRepository; |
7 | import com.topdraw.business.module.points.service.PointsService; | 5 | import com.topdraw.business.module.points.service.PointsService; |
8 | import com.topdraw.business.module.points.service.dto.PointsDTO; | 6 | import com.topdraw.business.module.points.service.dto.PointsDTO; |
9 | import com.topdraw.business.module.points.service.dto.PointsQueryCriteria; | ||
10 | import com.topdraw.business.module.points.service.mapper.PointsMapper; | 7 | import com.topdraw.business.module.points.service.mapper.PointsMapper; |
11 | import com.topdraw.util.RedissonUtil; | 8 | import com.topdraw.utils.RedisUtils; |
12 | import com.topdraw.utils.PageUtil; | ||
13 | import com.topdraw.utils.QueryHelp; | ||
14 | import com.topdraw.utils.ValidationUtil; | 9 | import com.topdraw.utils.ValidationUtil; |
15 | import org.redisson.api.RLock; | ||
16 | import org.redisson.api.RedissonClient; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.dao.EmptyResultDataAccessException; | 11 | import org.springframework.dao.EmptyResultDataAccessException; |
19 | import org.springframework.data.domain.Page; | ||
20 | import org.springframework.data.domain.Pageable; | ||
21 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
22 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
23 | import org.springframework.transaction.annotation.Transactional; | 14 | import org.springframework.transaction.annotation.Transactional; |
24 | import org.springframework.util.Assert; | 15 | import org.springframework.util.Assert; |
25 | 16 | ||
26 | import java.util.List; | ||
27 | import java.util.Map; | ||
28 | 17 | ||
29 | /** | 18 | /** |
30 | * @author XiangHan | 19 | * @author XiangHan |
... | @@ -35,48 +24,44 @@ import java.util.Map; | ... | @@ -35,48 +24,44 @@ import java.util.Map; |
35 | public class PointsServiceImpl implements PointsService { | 24 | public class PointsServiceImpl implements PointsService { |
36 | 25 | ||
37 | @Autowired | 26 | @Autowired |
38 | private PointsRepository PointsRepository; | 27 | private PointsRepository pointsRepository; |
39 | |||
40 | @Autowired | 28 | @Autowired |
41 | private PointsMapper PointsMapper; | 29 | private PointsMapper pointsMapper; |
42 | 30 | @Autowired | |
43 | @Override | 31 | private RedisUtils redisUtils; |
44 | public Map<String, Object> queryAll(PointsQueryCriteria criteria, Pageable pageable) { | ||
45 | Page<Points> page = PointsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
46 | return PageUtil.toPage(page.map(PointsMapper::toDto)); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public List<PointsDTO> queryAll(PointsQueryCriteria criteria) { | ||
51 | return PointsMapper.toDto(PointsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
52 | } | ||
53 | 32 | ||
54 | @Override | 33 | @Override |
55 | public PointsDTO findById(Long id) { | 34 | public PointsDTO findById(Long id) { |
56 | Points Points = PointsRepository.findById(id).orElseGet(Points::new); | 35 | Points Points = this.pointsRepository.findById(id).orElseGet(Points::new); |
57 | ValidationUtil.isNull(Points.getId(),"Points","id",id); | 36 | ValidationUtil.isNull(Points.getId(),"Points","id",id); |
58 | return PointsMapper.toDto(Points); | 37 | return this.pointsMapper.toDto(Points); |
59 | } | 38 | } |
60 | 39 | ||
61 | @Override | 40 | @Override |
62 | @Transactional(rollbackFor = Exception.class) | 41 | @Transactional(rollbackFor = Exception.class) |
63 | public void create(Points resources) { | 42 | public PointsDTO create(Points resources) { |
64 | Snowflake snowflake = IdUtil.createSnowflake(1, 1); | 43 | |
65 | resources.setId(snowflake.nextId()); | 44 | Points points = this.pointsRepository.save(resources); |
66 | PointsRepository.save(resources); | 45 | |
46 | return this.pointsMapper.toDto(points); | ||
67 | } | 47 | } |
68 | 48 | ||
69 | @Override | 49 | @Override |
70 | @Transactional(rollbackFor = Exception.class) | 50 | @Transactional(rollbackFor = Exception.class) |
71 | public void update(Points resources) { | 51 | public PointsDTO update(Points resources) { |
52 | this.redisUtils.doLock("Points::update::userId"+resources.getUserId().toString()); | ||
72 | try { | 53 | try { |
73 | Points Points = PointsRepository.findById(resources.getId()).orElseGet(Points::new); | 54 | Points points = this.pointsRepository.findById(resources.getId()).orElseGet(Points::new); |
74 | ValidationUtil.isNull(Points.getId(), "Points", "id", resources.getId()); | 55 | ValidationUtil.isNull(points.getId(), "Points", "id", resources.getId()); |
75 | Points.copy(resources); | 56 | points.copy(resources); |
76 | PointsRepository.save(Points); | 57 | this.pointsRepository.save(points); |
58 | |||
59 | return this.pointsMapper.toDto(points); | ||
77 | } catch (Exception e) { | 60 | } catch (Exception e) { |
78 | e.printStackTrace(); | 61 | e.printStackTrace(); |
79 | throw e; | 62 | throw e; |
63 | } finally { | ||
64 | this.redisUtils.doUnLock("Points::update::userId"+resources.getUserId().toString()); | ||
80 | } | 65 | } |
81 | } | 66 | } |
82 | 67 | ||
... | @@ -84,9 +69,9 @@ public class PointsServiceImpl implements PointsService { | ... | @@ -84,9 +69,9 @@ public class PointsServiceImpl implements PointsService { |
84 | @Transactional(rollbackFor = Exception.class) | 69 | @Transactional(rollbackFor = Exception.class) |
85 | public void delete(Long id) { | 70 | public void delete(Long id) { |
86 | Assert.notNull(id, "The given id must not be null!"); | 71 | Assert.notNull(id, "The given id must not be null!"); |
87 | Points Points = PointsRepository.findById(id).orElseThrow( | 72 | Points Points = this.pointsRepository.findById(id).orElseThrow( |
88 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Points.class, id), 1)); | 73 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Points.class, id), 1)); |
89 | PointsRepository.delete(Points); | 74 | this.pointsRepository.delete(Points); |
90 | } | 75 | } |
91 | 76 | ||
92 | 77 | ... | ... |
1 | package com.topdraw.business.module.points.standingbook.repository; | ||
2 | |||
3 | import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | |||
7 | /** | ||
8 | * @author XiangHan | ||
9 | * @date 2021-10-29 | ||
10 | */ | ||
11 | public interface PointsStandingBookRepository extends JpaRepository<PointsStandingBook, Long>, JpaSpecificationExecutor<PointsStandingBook> { | ||
12 | |||
13 | } |
1 | package com.topdraw.business.module.points.standingbook.service; | ||
2 | |||
3 | import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook; | ||
4 | import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO; | ||
5 | import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | |||
11 | /** | ||
12 | * @author XiangHan | ||
13 | * @date 2021-10-29 | ||
14 | */ | ||
15 | public interface PointsStandingBookService { | ||
16 | |||
17 | /** | ||
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(PointsStandingBookQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<PointsStandingBookDTO> | ||
29 | */ | ||
30 | List<PointsStandingBookDTO> queryAll(PointsStandingBookQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | ||
34 | * @param id ID | ||
35 | * @return PointsStandingBookDTO | ||
36 | */ | ||
37 | PointsStandingBookDTO findById(Long id); | ||
38 | |||
39 | void create(PointsStandingBook resources); | ||
40 | |||
41 | void update(PointsStandingBook resources); | ||
42 | |||
43 | void delete(Long id); | ||
44 | |||
45 | } |
1 | package com.topdraw.business.module.points.standingbook.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.io.Serializable; | ||
6 | import java.sql.Timestamp; | ||
7 | |||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-29 | ||
12 | */ | ||
13 | @Data | ||
14 | public class PointsStandingBookDTO implements Serializable { | ||
15 | |||
16 | // 主键 | ||
17 | private Long id; | ||
18 | |||
19 | // 积分生产 | ||
20 | private Long pointsProduce; | ||
21 | |||
22 | // 积分消耗 | ||
23 | private Long pointsConsume; | ||
24 | |||
25 | // 可用总积分 | ||
26 | private Long pointsAvailable; | ||
27 | |||
28 | // 积分过期 | ||
29 | private Long pointsExpire; | ||
30 | |||
31 | // 日期 | ||
32 | private String day; | ||
33 | |||
34 | // 创建时间 | ||
35 | private Timestamp createTime; | ||
36 | |||
37 | // 创建时间 | ||
38 | private Timestamp updateTime; | ||
39 | } |
1 | package com.topdraw.business.module.points.standingbook.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook; | ||
4 | import com.topdraw.business.module.points.standingbook.repository.PointsStandingBookRepository; | ||
5 | import com.topdraw.business.module.points.standingbook.service.PointsStandingBookService; | ||
6 | import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO; | ||
7 | import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookQueryCriteria; | ||
8 | import com.topdraw.business.module.points.standingbook.service.mapper.PointsStandingBookMapper; | ||
9 | import com.topdraw.utils.PageUtil; | ||
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.ValidationUtil; | ||
12 | import org.springframework.beans.factory.annotation.Autowired; | ||
13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
14 | import org.springframework.data.domain.Page; | ||
15 | import org.springframework.data.domain.Pageable; | ||
16 | import org.springframework.stereotype.Service; | ||
17 | import org.springframework.transaction.annotation.Propagation; | ||
18 | import org.springframework.transaction.annotation.Transactional; | ||
19 | import org.springframework.util.Assert; | ||
20 | |||
21 | import java.util.List; | ||
22 | import java.util.Map; | ||
23 | |||
24 | /** | ||
25 | * @author XiangHan | ||
26 | * @date 2021-10-29 | ||
27 | */ | ||
28 | @Service | ||
29 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
30 | public class PointsStandingBookServiceImpl implements PointsStandingBookService { | ||
31 | |||
32 | @Autowired | ||
33 | private PointsStandingBookRepository PointsStandingBookRepository; | ||
34 | |||
35 | @Autowired | ||
36 | private PointsStandingBookMapper PointsStandingBookMapper; | ||
37 | |||
38 | @Override | ||
39 | public Map<String, Object> queryAll(PointsStandingBookQueryCriteria criteria, Pageable pageable) { | ||
40 | Page<PointsStandingBook> page = PointsStandingBookRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
41 | return PageUtil.toPage(page.map(PointsStandingBookMapper::toDto)); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public List<PointsStandingBookDTO> queryAll(PointsStandingBookQueryCriteria criteria) { | ||
46 | return PointsStandingBookMapper.toDto(PointsStandingBookRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public PointsStandingBookDTO findById(Long id) { | ||
51 | PointsStandingBook PointsStandingBook = PointsStandingBookRepository.findById(id).orElseGet(PointsStandingBook::new); | ||
52 | ValidationUtil.isNull(PointsStandingBook.getId(),"PointsStandingBook","id",id); | ||
53 | return PointsStandingBookMapper.toDto(PointsStandingBook); | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | @Transactional(rollbackFor = Exception.class) | ||
58 | public void create(PointsStandingBook resources) { | ||
59 | PointsStandingBookRepository.save(resources); | ||
60 | } | ||
61 | |||
62 | @Override | ||
63 | @Transactional(rollbackFor = Exception.class) | ||
64 | public void update(PointsStandingBook resources) { | ||
65 | PointsStandingBook PointsStandingBook = PointsStandingBookRepository.findById(resources.getId()).orElseGet(PointsStandingBook::new); | ||
66 | ValidationUtil.isNull( PointsStandingBook.getId(),"PointsStandingBook","id",resources.getId()); | ||
67 | PointsStandingBook.copy(resources); | ||
68 | PointsStandingBookRepository.save(PointsStandingBook); | ||
69 | } | ||
70 | |||
71 | @Override | ||
72 | @Transactional(rollbackFor = Exception.class) | ||
73 | public void delete(Long id) { | ||
74 | Assert.notNull(id, "The given id must not be null!"); | ||
75 | PointsStandingBook PointsStandingBook = PointsStandingBookRepository.findById(id).orElseThrow( | ||
76 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsStandingBook.class, id), 1)); | ||
77 | PointsStandingBookRepository.delete(PointsStandingBook); | ||
78 | } | ||
79 | |||
80 | |||
81 | } |
... | @@ -23,63 +23,63 @@ import java.sql.Timestamp; | ... | @@ -23,63 +23,63 @@ import java.sql.Timestamp; |
23 | @Table(name="tr_rights") | 23 | @Table(name="tr_rights") |
24 | public class Rights implements Serializable { | 24 | public class Rights implements Serializable { |
25 | 25 | ||
26 | // 主键 | 26 | /** 主键 */ |
27 | @Id | 27 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
29 | @Column(name = "id") | 29 | @Column(name = "id") |
30 | private Long id; | 30 | private Long id; |
31 | 31 | ||
32 | // 标识 | 32 | /** 标识 */ |
33 | @Column(name = "code", nullable = false) | 33 | @Column(name = "code", nullable = false) |
34 | private String code; | 34 | private String code; |
35 | 35 | ||
36 | // 权益名称 | 36 | /** 权益名称 */ |
37 | // @Column(name = "name") | 37 | @Column(name = "name") |
38 | // private String name; | 38 | private String name; |
39 | 39 | ||
40 | // 类型 1:实体类 (预留字段) | 40 | /** 类型 1:实体类 (预留字段) */ |
41 | @Column(name = "type", nullable = false) | 41 | @Column(name = "type", nullable = false) |
42 | private Integer type; | 42 | private Integer type; |
43 | 43 | ||
44 | // 终端类型 0:大屏;1:微信小程序/公众号;2:App | 44 | /** 终端类型 0:大屏;1:微信小程序/公众号;2:App */ |
45 | @Column(name = "device_type", nullable = false) | 45 | @Column(name = "device_type", nullable = false) |
46 | private Integer deviceType; | 46 | private Integer deviceType; |
47 | 47 | ||
48 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 48 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ |
49 | @Column(name = "entity_type", nullable = false) | 49 | @Column(name = "entity_type", nullable = false) |
50 | private String entityType; | 50 | private String entityType; |
51 | 51 | ||
52 | // 实体id | 52 | /** 实体id */ |
53 | @Column(name = "entity_id", nullable = false) | 53 | @Column(name = "entity_id", nullable = false) |
54 | private Long entityId; | 54 | private Long entityId; |
55 | 55 | ||
56 | // 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 | 56 | /** 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 */ |
57 | @Column(name = "valid_time") | 57 | @Column(name = "valid_time") |
58 | private Timestamp validTime; | 58 | private Timestamp validTime; |
59 | 59 | ||
60 | // 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 | 60 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ |
61 | @Column(name = "expire_time") | 61 | @Column(name = "expire_time") |
62 | private Long expireTime; | 62 | private Long expireTime; |
63 | 63 | ||
64 | // 创建时间 | 64 | /** 创建时间 */ |
65 | @CreatedDate | 65 | @CreatedDate |
66 | @Column(name = "create_time") | 66 | @Column(name = "create_time") |
67 | private Timestamp createTime; | 67 | private Timestamp createTime; |
68 | 68 | ||
69 | // 更新时间 | 69 | /** 更新时间 */ |
70 | @LastModifiedDate | 70 | @LastModifiedDate |
71 | @Column(name = "update_time") | 71 | @Column(name = "update_time") |
72 | private Timestamp updateTime; | 72 | private Timestamp updateTime; |
73 | 73 | ||
74 | // 图片 | 74 | /** 图片 */ |
75 | @Column(name = "image") | 75 | @Column(name = "image") |
76 | private String image; | 76 | private String image; |
77 | 77 | ||
78 | // 图片 | 78 | /** 图片 */ |
79 | @Column(name = "images") | 79 | @Column(name = "images") |
80 | private String images; | 80 | private String images; |
81 | 81 | ||
82 | // 描述 | 82 | /** 描述 */ |
83 | @Column(name = "description") | 83 | @Column(name = "description") |
84 | private String description; | 84 | private String description; |
85 | 85 | ... | ... |
... | @@ -2,7 +2,7 @@ package com.topdraw.business.module.rights.history.domain; | ... | @@ -2,7 +2,7 @@ package com.topdraw.business.module.rights.history.domain; |
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.bean.copier.CopyOptions; | 4 | import cn.hutool.core.bean.copier.CopyOptions; |
5 | import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; | 5 | import com.topdraw.business.module.common.domain.AsyncMqModule; |
6 | import lombok.Data; | 6 | import lombok.Data; |
7 | import lombok.experimental.Accessors; | 7 | import lombok.experimental.Accessors; |
8 | import org.springframework.data.annotation.CreatedDate; | 8 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -23,7 +23,7 @@ import java.time.LocalDateTime; | ... | @@ -23,7 +23,7 @@ import java.time.LocalDateTime; |
23 | @EntityListeners(AuditingEntityListener.class) | 23 | @EntityListeners(AuditingEntityListener.class) |
24 | @Accessors(chain = true) | 24 | @Accessors(chain = true) |
25 | @Table(name="tr_rights_histroy") | 25 | @Table(name="tr_rights_histroy") |
26 | public class RightsHistory extends DefaultAsyncMqModule implements Serializable { | 26 | public class RightsHistory extends AsyncMqModule implements Serializable { |
27 | 27 | ||
28 | // 主键id | 28 | // 主键id |
29 | @Id | 29 | @Id |
... | @@ -52,7 +52,7 @@ public class RightsHistory extends DefaultAsyncMqModule implements Serializable | ... | @@ -52,7 +52,7 @@ public class RightsHistory extends DefaultAsyncMqModule implements Serializable |
52 | 52 | ||
53 | // 发放时间 | 53 | // 发放时间 |
54 | @Column(name = "send_time") | 54 | @Column(name = "send_time") |
55 | private LocalDateTime sendTime; | 55 | private Timestamp sendTime; |
56 | 56 | ||
57 | // 失效时间 | 57 | // 失效时间 |
58 | @Column(name = "expire_time") | 58 | @Column(name = "expire_time") |
... | @@ -60,11 +60,11 @@ public class RightsHistory extends DefaultAsyncMqModule implements Serializable | ... | @@ -60,11 +60,11 @@ public class RightsHistory extends DefaultAsyncMqModule implements Serializable |
60 | 60 | ||
61 | @CreatedDate | 61 | @CreatedDate |
62 | @Column(name = "create_time") | 62 | @Column(name = "create_time") |
63 | private LocalDateTime createTime; | 63 | private Timestamp createTime; |
64 | 64 | ||
65 | @LastModifiedDate | 65 | @LastModifiedDate |
66 | @Column(name = "update_time") | 66 | @Column(name = "update_time") |
67 | private LocalDateTime updateTime; | 67 | private Timestamp updateTime; |
68 | 68 | ||
69 | public void copy(RightsHistory source){ | 69 | public void copy(RightsHistory source){ |
70 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | 70 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ... | ... |
1 | package com.topdraw.business.module.rights.history.repository; | 1 | package com.topdraw.business.module.rights.history.repository; |
2 | 2 | ||
3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; | 3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; |
4 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | 5 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | 7 | ||
8 | import java.util.List; | ||
9 | |||
7 | /** | 10 | /** |
8 | * @author XiangHan | 11 | * @author XiangHan |
9 | * @date 2021-10-22 | 12 | * @date 2021-10-22 |
10 | */ | 13 | */ |
11 | public interface RightsHistoryRepository extends JpaRepository<RightsHistory, Long>, JpaSpecificationExecutor<RightsHistory> { | 14 | public interface RightsHistoryRepository extends JpaRepository<RightsHistory, Long>, JpaSpecificationExecutor<RightsHistory> { |
12 | 15 | ||
16 | List<RightsHistoryDTO> findByMemberId(Long memberId); | ||
13 | } | 17 | } | ... | ... |
... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.rights.history.service; | ... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.rights.history.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; | 3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; |
4 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO; | 4 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO; |
5 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | 5 | ||
8 | import java.util.List; | 6 | import java.util.List; |
9 | import java.util.Map; | ||
10 | 7 | ||
11 | /** | 8 | /** |
12 | * @author XiangHan | 9 | * @author XiangHan |
... | @@ -15,19 +12,12 @@ import java.util.Map; | ... | @@ -15,19 +12,12 @@ import java.util.Map; |
15 | public interface RightsHistoryService { | 12 | public interface RightsHistoryService { |
16 | 13 | ||
17 | /** | 14 | /** |
18 | * 查询数据分页 | 15 | * |
19 | * @param criteria 条件参数 | 16 | * @param memberId |
20 | * @param pageable 分页参数 | 17 | * @param memberCode |
21 | * @return Map<String,Object> | 18 | * @return |
22 | */ | ||
23 | Map<String,Object> queryAll(RightsHistoryQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<RightsHistoryDTO> | ||
29 | */ | 19 | */ |
30 | List<RightsHistoryDTO> queryAll(RightsHistoryQueryCriteria criteria); | 20 | List<RightsHistoryDTO> findByMemberIdOrMemberCode(Long memberId, String memberCode); |
31 | 21 | ||
32 | /** | 22 | /** |
33 | * 根据ID查询 | 23 | * 根据ID查询 | ... | ... |
... | @@ -30,12 +30,12 @@ public class RightsHistoryDTO implements Serializable { | ... | @@ -30,12 +30,12 @@ public class RightsHistoryDTO implements Serializable { |
30 | private String operatorName; | 30 | private String operatorName; |
31 | 31 | ||
32 | // 发放时间 | 32 | // 发放时间 |
33 | private LocalDateTime sendTime; | 33 | private Timestamp sendTime; |
34 | 34 | ||
35 | // 失效时间 | 35 | // 失效时间 |
36 | private LocalDateTime expireTime; | 36 | private LocalDateTime expireTime; |
37 | 37 | ||
38 | private LocalDateTime createTime; | 38 | private Timestamp createTime; |
39 | 39 | ||
40 | private LocalDateTime updateTime; | 40 | private Timestamp updateTime; |
41 | } | 41 | } | ... | ... |
... | @@ -6,23 +6,16 @@ import com.topdraw.business.module.rights.history.domain.RightsHistory; | ... | @@ -6,23 +6,16 @@ import com.topdraw.business.module.rights.history.domain.RightsHistory; |
6 | import com.topdraw.business.module.rights.history.repository.RightsHistoryRepository; | 6 | import com.topdraw.business.module.rights.history.repository.RightsHistoryRepository; |
7 | import com.topdraw.business.module.rights.history.service.RightsHistoryService; | 7 | import com.topdraw.business.module.rights.history.service.RightsHistoryService; |
8 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO; | 8 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO; |
9 | import com.topdraw.business.module.rights.history.service.dto.RightsHistoryQueryCriteria; | ||
10 | import com.topdraw.business.module.rights.history.service.mapper.RightsHistoryMapper; | 9 | import com.topdraw.business.module.rights.history.service.mapper.RightsHistoryMapper; |
11 | import com.topdraw.utils.PageUtil; | ||
12 | import com.topdraw.utils.QueryHelp; | ||
13 | import com.topdraw.utils.ValidationUtil; | 10 | import com.topdraw.utils.ValidationUtil; |
14 | import org.apache.commons.lang3.StringUtils; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
16 | import org.springframework.dao.EmptyResultDataAccessException; | 12 | import org.springframework.dao.EmptyResultDataAccessException; |
17 | import org.springframework.data.domain.Page; | ||
18 | import org.springframework.data.domain.Pageable; | ||
19 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
20 | import org.springframework.transaction.annotation.Propagation; | 14 | import org.springframework.transaction.annotation.Propagation; |
21 | import org.springframework.transaction.annotation.Transactional; | 15 | import org.springframework.transaction.annotation.Transactional; |
22 | import org.springframework.util.Assert; | 16 | import org.springframework.util.Assert; |
23 | 17 | ||
24 | import java.util.List; | 18 | import java.util.List; |
25 | import java.util.Map; | ||
26 | 19 | ||
27 | /** | 20 | /** |
28 | * @author XiangHan | 21 | * @author XiangHan |
... | @@ -33,60 +26,49 @@ import java.util.Map; | ... | @@ -33,60 +26,49 @@ import java.util.Map; |
33 | public class RightsHistoryServiceImpl implements RightsHistoryService { | 26 | public class RightsHistoryServiceImpl implements RightsHistoryService { |
34 | 27 | ||
35 | @Autowired | 28 | @Autowired |
36 | private RightsHistoryRepository RightsHistoryRepository; | ||
37 | |||
38 | @Autowired | ||
39 | private MemberService memberService; | 29 | private MemberService memberService; |
40 | |||
41 | @Autowired | 30 | @Autowired |
42 | private RightsHistoryMapper RightsHistoryMapper; | 31 | private RightsHistoryMapper rightsHistoryMapper; |
32 | @Autowired | ||
33 | private RightsHistoryRepository rightsHistoryRepository; | ||
43 | 34 | ||
44 | @Override | ||
45 | public Map<String, Object> queryAll(RightsHistoryQueryCriteria criteria, Pageable pageable) { | ||
46 | Page<RightsHistory> page = RightsHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
47 | return PageUtil.toPage(page.map(RightsHistoryMapper::toDto)); | ||
48 | } | ||
49 | 35 | ||
50 | @Override | 36 | @Override |
51 | public List<RightsHistoryDTO> queryAll(RightsHistoryQueryCriteria criteria) { | 37 | public List<RightsHistoryDTO> findByMemberIdOrMemberCode(Long memberId, String memberCode) { |
52 | return RightsHistoryMapper.toDto(RightsHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | 38 | MemberDTO memberDTO = this.memberService.checkMember(memberId, memberCode); |
39 | List<RightsHistoryDTO> rightsHistoryDTOList = this.rightsHistoryRepository.findByMemberId(memberDTO.getId()); | ||
40 | return rightsHistoryDTOList; | ||
53 | } | 41 | } |
54 | 42 | ||
55 | @Override | 43 | @Override |
56 | public RightsHistoryDTO findById(Long id) { | 44 | public RightsHistoryDTO findById(Long id) { |
57 | RightsHistory RightsHistory = RightsHistoryRepository.findById(id).orElseGet(RightsHistory::new); | 45 | RightsHistory RightsHistory = this.rightsHistoryRepository.findById(id).orElseGet(com.topdraw.business.module.rights.history.domain.RightsHistory::new); |
58 | ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",id); | 46 | ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",id); |
59 | return RightsHistoryMapper.toDto(RightsHistory); | 47 | return this.rightsHistoryMapper.toDto(RightsHistory); |
60 | } | 48 | } |
61 | 49 | ||
62 | @Override | 50 | @Override |
63 | @Transactional(rollbackFor = Exception.class) | 51 | @Transactional(rollbackFor = Exception.class) |
64 | public void create(RightsHistory resources) { | 52 | public void create(RightsHistory resources) { |
65 | String memberCode = resources.getMemberCode(); | 53 | this.rightsHistoryRepository.save(resources); |
66 | if (StringUtils.isNotBlank(memberCode)) { | ||
67 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
68 | Long id = memberDTO.getId(); | ||
69 | resources.setMemberId(id); | ||
70 | } | ||
71 | RightsHistoryRepository.save(resources); | ||
72 | } | 54 | } |
73 | 55 | ||
74 | @Override | 56 | @Override |
75 | @Transactional(rollbackFor = Exception.class) | 57 | @Transactional(rollbackFor = Exception.class) |
76 | public void update(RightsHistory resources) { | 58 | public void update(RightsHistory resources) { |
77 | RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new); | 59 | RightsHistory RightsHistory = this.rightsHistoryRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.rights.history.domain.RightsHistory::new); |
78 | ValidationUtil.isNull( RightsHistory.getId(),"RightsHistory","id",resources.getId()); | 60 | ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId()); |
79 | RightsHistory.copy(resources); | 61 | RightsHistory.copy(resources); |
80 | RightsHistoryRepository.save(RightsHistory); | 62 | this.rightsHistoryRepository.save(RightsHistory); |
81 | } | 63 | } |
82 | 64 | ||
83 | @Override | 65 | @Override |
84 | @Transactional(rollbackFor = Exception.class) | 66 | @Transactional(rollbackFor = Exception.class) |
85 | public void delete(Long id) { | 67 | public void delete(Long id) { |
86 | Assert.notNull(id, "The given id must not be null!"); | 68 | Assert.notNull(id, "The given id must not be null!"); |
87 | RightsHistory RightsHistory = RightsHistoryRepository.findById(id).orElseThrow( | 69 | RightsHistory RightsHistory = this.rightsHistoryRepository.findById(id).orElseThrow( |
88 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", RightsHistory.class, id), 1)); | 70 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.rights.history.domain.RightsHistory.class, id), 1)); |
89 | RightsHistoryRepository.delete(RightsHistory); | 71 | this.rightsHistoryRepository.delete(RightsHistory); |
90 | } | 72 | } |
91 | 73 | ||
92 | 74 | ... | ... |
... | @@ -24,58 +24,58 @@ import java.sql.Timestamp; | ... | @@ -24,58 +24,58 @@ import java.sql.Timestamp; |
24 | @Table(name="uc_permanent_rights") | 24 | @Table(name="uc_permanent_rights") |
25 | public class PermanentRights implements Serializable { | 25 | public class PermanentRights implements Serializable { |
26 | 26 | ||
27 | // ID | 27 | /** ID */ |
28 | @Id | 28 | @Id |
29 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 29 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
30 | @Column(name = "id") | 30 | @Column(name = "id") |
31 | private Long id; | 31 | private Long id; |
32 | 32 | ||
33 | // 标识 | 33 | /** 标识 */ |
34 | @Column(name = "code", nullable = false) | 34 | @Column(name = "code", nullable = false) |
35 | private String code; | 35 | private String code; |
36 | 36 | ||
37 | // 名称 | 37 | /** 名称 */ |
38 | @Column(name = "name", nullable = false) | 38 | @Column(name = "name", nullable = false) |
39 | private String name; | 39 | private String name; |
40 | 40 | ||
41 | // 永久权益类型 0:vip;1:会员等级 | 41 | /** 永久权益类型 0:vip;1:会员等级 */ |
42 | @Column(name = "type") | 42 | @Column(name = "type") |
43 | private Integer type; | 43 | private Integer type; |
44 | 44 | ||
45 | // 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index) | 45 | /** 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index) */ |
46 | @Column(name = "level") | 46 | @Column(name = "level") |
47 | private Integer level; | 47 | private Integer level; |
48 | 48 | ||
49 | // 商品折扣,10代表10% off,范围为0-100 | 49 | /** 商品折扣,10代表10% off,范围为0-100 */ |
50 | @Column(name = "item_discount", nullable = false) | 50 | @Column(name = "item_discount", nullable = false) |
51 | private BigDecimal itemDiscount; | 51 | private BigDecimal itemDiscount; |
52 | 52 | ||
53 | // 额外积分比率,范围为0-1000 | 53 | /** 额外积分比率,范围为0-1000 */ |
54 | @Column(name = "extra_points", nullable = false) | 54 | @Column(name = "extra_points", nullable = false) |
55 | private BigDecimal extraPoints; | 55 | private BigDecimal extraPoints; |
56 | 56 | ||
57 | // 免广告 | 57 | /** 免广告 */ |
58 | @Column(name = "ad_disabled", nullable = false) | 58 | @Column(name = "ad_disabled", nullable = false) |
59 | private Integer adDisabled; | 59 | private Integer adDisabled; |
60 | 60 | ||
61 | // 额外活动参与机会 | 61 | /** 额外活动参与机会 */ |
62 | @Column(name = "extra_activity_ticket", nullable = false) | 62 | @Column(name = "extra_activity_ticket", nullable = false) |
63 | private Integer extraActivityTicket; | 63 | private Integer extraActivityTicket; |
64 | 64 | ||
65 | // 免费试看 | 65 | /** 免费试看 */ |
66 | @Column(name = "free_trial", nullable = false) | 66 | @Column(name = "free_trial", nullable = false) |
67 | private Integer freeTrial; | 67 | private Integer freeTrial; |
68 | 68 | ||
69 | // 上电视专区权益 | 69 | /** 上电视专区权益 */ |
70 | @Column(name = "zone_sds", nullable = false) | 70 | @Column(name = "zone_sds", nullable = false) |
71 | private Integer zoneSds; | 71 | private Integer zoneSds; |
72 | 72 | ||
73 | // 创建时间 | 73 | /** 创建时间 */ |
74 | @CreatedDate | 74 | @CreatedDate |
75 | @Column(name = "create_time") | 75 | @Column(name = "create_time") |
76 | private Timestamp createTime; | 76 | private Timestamp createTime; |
77 | 77 | ||
78 | // 更新时间 | 78 | /** 更新时间 */ |
79 | @LastModifiedDate | 79 | @LastModifiedDate |
80 | @Column(name = "update_time") | 80 | @Column(name = "update_time") |
81 | private Timestamp updateTime; | 81 | private Timestamp updateTime; | ... | ... |
... | @@ -13,4 +13,6 @@ import java.util.Optional; | ... | @@ -13,4 +13,6 @@ import java.util.Optional; |
13 | public interface PermanentRightsRepository extends JpaRepository<PermanentRights, Long>, JpaSpecificationExecutor<PermanentRights> { | 13 | public interface PermanentRightsRepository extends JpaRepository<PermanentRights, Long>, JpaSpecificationExecutor<PermanentRights> { |
14 | 14 | ||
15 | Optional<PermanentRights> findFirstByCode(String code); | 15 | Optional<PermanentRights> findFirstByCode(String code); |
16 | |||
17 | PermanentRights findByLevel(Integer level); | ||
16 | } | 18 | } | ... | ... |
src/main/java/com/topdraw/business/module/rights/permanentrights/service/PermanentRightsService.java
1 | package com.topdraw.business.module.rights.permanentrights.service; | 1 | package com.topdraw.business.module.rights.permanentrights.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights; | ||
4 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO; | 3 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO; |
5 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | 4 | ||
11 | /** | 5 | /** |
12 | * @author XiangHan | 6 | * @author XiangHan |
... | @@ -15,37 +9,23 @@ import java.util.Map; | ... | @@ -15,37 +9,23 @@ import java.util.Map; |
15 | public interface PermanentRightsService { | 9 | public interface PermanentRightsService { |
16 | 10 | ||
17 | /** | 11 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(PermanentRightsQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<PermanentRightsDTO> | ||
29 | */ | ||
30 | List<PermanentRightsDTO> queryAll(PermanentRightsQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 12 | * 根据ID查询 |
34 | * @param id ID | 13 | * @param id ID |
35 | * @return PermanentRightsDTO | 14 | * @return PermanentRightsDTO |
36 | */ | 15 | */ |
37 | PermanentRightsDTO findById(Long id); | 16 | PermanentRightsDTO findById(Long id); |
38 | 17 | ||
39 | void create(PermanentRights resources); | ||
40 | |||
41 | void update(PermanentRights resources); | ||
42 | |||
43 | void delete(Long id); | ||
44 | |||
45 | /** | 18 | /** |
46 | * Code校验 | 19 | * Code校验 |
47 | * @param code | 20 | * @param code |
48 | * @return PermanentRightsDTO | 21 | * @return PermanentRightsDTO |
49 | */ | 22 | */ |
50 | PermanentRightsDTO getByCode(String code); | 23 | PermanentRightsDTO getByCode(String code); |
24 | |||
25 | /** | ||
26 | * 通过会员等级获取对应的永久权益 | ||
27 | * @param level | ||
28 | * @return | ||
29 | */ | ||
30 | PermanentRightsDTO findByLevel(Integer level); | ||
51 | } | 31 | } | ... | ... |
src/main/java/com/topdraw/business/module/rights/permanentrights/service/dto/PermanentRightsDTO.java
... | @@ -14,42 +14,42 @@ import java.sql.Timestamp; | ... | @@ -14,42 +14,42 @@ import java.sql.Timestamp; |
14 | @Data | 14 | @Data |
15 | public class PermanentRightsDTO implements Serializable { | 15 | public class PermanentRightsDTO implements Serializable { |
16 | 16 | ||
17 | // ID | 17 | /** ID */ |
18 | private Long id; | 18 | private Long id; |
19 | 19 | ||
20 | // 标识 | 20 | /** 标识 */ |
21 | private String code; | 21 | private String code; |
22 | 22 | ||
23 | // 名称 | 23 | /** 名称 */ |
24 | private String name; | 24 | private String name; |
25 | 25 | ||
26 | // 永久权益类型 0:vip;1:会员等级 | 26 | /** 永久权益类型 0:vip;1:会员等级 */ |
27 | private Integer type; | 27 | private Integer type; |
28 | 28 | ||
29 | // 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index) | 29 | /** 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index) */ |
30 | private Integer level; | 30 | private Integer level; |
31 | 31 | ||
32 | // 商品折扣,10代表10% off,范围为0-100 | 32 | /** 商品折扣,10代表10% off,范围为0-100 */ |
33 | private BigDecimal itemDiscount; | 33 | private BigDecimal itemDiscount; |
34 | 34 | ||
35 | // 额外积分比率,范围为0-1000 | 35 | /** 额外积分比率,范围为0-1000 */ |
36 | private BigDecimal extraPoints; | 36 | private BigDecimal extraPoints; |
37 | 37 | ||
38 | // 免广告 | 38 | /** 免广告 */ |
39 | private Integer adDisabled; | 39 | private Integer adDisabled; |
40 | 40 | ||
41 | // 额外活动参与机会 | 41 | /** 额外活动参与机会 */ |
42 | private Integer extraActivityTicket; | 42 | private Integer extraActivityTicket; |
43 | 43 | ||
44 | // 免费试看 | 44 | /** 免费试看 */ |
45 | private Integer freeTrial; | 45 | private Integer freeTrial; |
46 | 46 | ||
47 | // 上电视专区权益 | 47 | /** 上电视专区权益 */ |
48 | private Integer zoneSds; | 48 | private Integer zoneSds; |
49 | 49 | ||
50 | // 创建时间 | 50 | /** 创建时间 */ |
51 | private Timestamp createTime; | 51 | private Timestamp createTime; |
52 | 52 | ||
53 | // 更新时间 | 53 | /** 更新时间 */ |
54 | private Timestamp updateTime; | 54 | private Timestamp updateTime; |
55 | } | 55 | } | ... | ... |
1 | package com.topdraw.business.module.rights.permanentrights.service.dto; | ||
2 | |||
3 | import com.topdraw.annotation.Query; | ||
4 | import lombok.Data; | ||
5 | |||
6 | /** | ||
7 | * @author XiangHan | ||
8 | * @date 2021-10-22 | ||
9 | */ | ||
10 | @Data | ||
11 | public class PermanentRightsQueryCriteria{ | ||
12 | |||
13 | @Query(type = Query.Type.EQUAL) | ||
14 | private Integer level; | ||
15 | |||
16 | } |
... | @@ -4,23 +4,13 @@ import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights | ... | @@ -4,23 +4,13 @@ import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights |
4 | import com.topdraw.business.module.rights.permanentrights.repository.PermanentRightsRepository; | 4 | import com.topdraw.business.module.rights.permanentrights.repository.PermanentRightsRepository; |
5 | import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService; | 5 | import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService; |
6 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO; | 6 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO; |
7 | import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria; | ||
8 | import com.topdraw.business.module.rights.permanentrights.service.mapper.PermanentRightsMapper; | 7 | import com.topdraw.business.module.rights.permanentrights.service.mapper.PermanentRightsMapper; |
9 | import com.topdraw.utils.PageUtil; | ||
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.StringUtils; | 8 | import com.topdraw.utils.StringUtils; |
12 | import com.topdraw.utils.ValidationUtil; | 9 | import com.topdraw.utils.ValidationUtil; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.dao.EmptyResultDataAccessException; | ||
15 | import org.springframework.data.domain.Page; | ||
16 | import org.springframework.data.domain.Pageable; | ||
17 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
18 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
19 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
20 | import org.springframework.util.Assert; | ||
21 | |||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | 14 | ||
25 | /** | 15 | /** |
26 | * @author XiangHan | 16 | * @author XiangHan |
... | @@ -31,57 +21,27 @@ import java.util.Map; | ... | @@ -31,57 +21,27 @@ import java.util.Map; |
31 | public class PermanentRightsServiceImpl implements PermanentRightsService { | 21 | public class PermanentRightsServiceImpl implements PermanentRightsService { |
32 | 22 | ||
33 | @Autowired | 23 | @Autowired |
34 | private PermanentRightsRepository PermanentRightsRepository; | 24 | private PermanentRightsRepository permanentRightsRepository; |
35 | 25 | ||
36 | @Autowired | 26 | @Autowired |
37 | private PermanentRightsMapper PermanentRightsMapper; | 27 | private PermanentRightsMapper permanentRightsMapper; |
38 | |||
39 | @Override | ||
40 | public Map<String, Object> queryAll(PermanentRightsQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<PermanentRights> page = PermanentRightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(PermanentRightsMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<PermanentRightsDTO> queryAll(PermanentRightsQueryCriteria criteria) { | ||
47 | return PermanentRightsMapper.toDto(PermanentRightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | 28 | ||
50 | @Override | 29 | @Override |
51 | public PermanentRightsDTO findById(Long id) { | 30 | public PermanentRightsDTO findById(Long id) { |
52 | PermanentRights PermanentRights = PermanentRightsRepository.findById(id).orElseGet(PermanentRights::new); | 31 | PermanentRights PermanentRights = this.permanentRightsRepository.findById(id).orElseGet(com.topdraw.business.module.rights.permanentrights.domain.PermanentRights::new); |
53 | ValidationUtil.isNull(PermanentRights.getId(),"PermanentRights","id",id); | 32 | ValidationUtil.isNull(PermanentRights.getId(),"PermanentRights","id",id); |
54 | return PermanentRightsMapper.toDto(PermanentRights); | 33 | return this.permanentRightsMapper.toDto(PermanentRights); |
55 | } | ||
56 | |||
57 | @Override | ||
58 | @Transactional(rollbackFor = Exception.class) | ||
59 | public void create(PermanentRights resources) { | ||
60 | PermanentRightsRepository.save(resources); | ||
61 | } | 34 | } |
62 | 35 | ||
63 | @Override | 36 | @Override |
64 | @Transactional(rollbackFor = Exception.class) | 37 | public PermanentRightsDTO getByCode(String code) { |
65 | public void update(PermanentRights resources) { | 38 | return StringUtils.isNotEmpty(code) ? this.permanentRightsMapper.toDto(this.permanentRightsRepository.findFirstByCode(code).orElseGet(PermanentRights::new)) |
66 | PermanentRights PermanentRights = PermanentRightsRepository.findById(resources.getId()).orElseGet(PermanentRights::new); | 39 | : new PermanentRightsDTO(); |
67 | ValidationUtil.isNull( PermanentRights.getId(),"PermanentRights","id",resources.getId()); | ||
68 | PermanentRights.copy(resources); | ||
69 | PermanentRightsRepository.save(PermanentRights); | ||
70 | } | ||
71 | |||
72 | @Override | ||
73 | @Transactional(rollbackFor = Exception.class) | ||
74 | public void delete(Long id) { | ||
75 | Assert.notNull(id, "The given id must not be null!"); | ||
76 | PermanentRights PermanentRights = PermanentRightsRepository.findById(id).orElseThrow( | ||
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PermanentRights.class, id), 1)); | ||
78 | PermanentRightsRepository.delete(PermanentRights); | ||
79 | } | 40 | } |
80 | 41 | ||
81 | |||
82 | @Override | 42 | @Override |
83 | public PermanentRightsDTO getByCode(String code) { | 43 | public PermanentRightsDTO findByLevel(Integer level) { |
84 | return StringUtils.isNotEmpty(code) ? PermanentRightsMapper.toDto(PermanentRightsRepository.findFirstByCode(code).orElseGet(PermanentRights::new)) | 44 | PermanentRights PermanentRights = this.permanentRightsRepository.findByLevel(level); |
85 | : new PermanentRightsDTO(); | 45 | return this.permanentRightsMapper.toDto(PermanentRights); |
86 | } | 46 | } |
87 | } | 47 | } | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/rights/service/dto/RightsQueryCriteria.java
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/rights/service/dto/RightsQueryType.java
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/attribute/repository/TaskAttrRepository.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/attribute/service/impl/TaskAttrServiceImpl.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/progress/repository/TrTaskProgressRepository.java
0 → 100644
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/progress/service/TrTaskProgressService.java
0 → 100644
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/progress/service/dto/TrTaskProgressDTO.java
0 → 100644
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/progress/service/impl/TrTaskProgressServiceImpl.java
0 → 100644
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/progress/service/mapper/TrTaskProgressMapper.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
src/main/java/com/topdraw/business/module/task/service/dto/TaskQueryCriteria.java
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment