1.优化
Showing
150 changed files
with
2363 additions
and
2010 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 | |||
39 | @Override | ||
40 | public Map<String, Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable) { | ||
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 | 32 | ||
45 | @Override | 33 | @Autowired |
46 | public List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria) { | 34 | private RedisUtils redisUtils; |
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()); |
67 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); | 54 | try { |
68 | ExpDetail.copy(resources); | 55 | ExpDetail ExpDetail = this.expDetailRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.exp.detail.domain.ExpDetail::new); |
69 | ExpDetailRepository.save(ExpDetail); | 56 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); |
57 | ExpDetail.copy(resources); | ||
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; |
... | @@ -34,10 +33,7 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -34,10 +33,7 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
34 | private MemberAddressMapper memberAddressMapper; | 33 | private MemberAddressMapper memberAddressMapper; |
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 |
... | @@ -22,10 +18,10 @@ public interface MemberLevelService { | ... | @@ -22,10 +18,10 @@ public interface MemberLevelService { |
22 | MemberLevelDTO findById(Long id); | 18 | MemberLevelDTO findById(Long id); |
23 | 19 | ||
24 | /** | 20 | /** |
25 | * Code校验 | 21 | * Code校验 |
26 | * @param code | 22 | * @param code |
27 | * @return MemberLevelDTO | 23 | * @return MemberLevelDTO |
28 | */ | 24 | */ |
29 | MemberLevelDTO getByCode(String code); | 25 | MemberLevelDTO getByCode(String code); |
30 | 26 | ||
31 | /** | 27 | /** |
... | @@ -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 | } | ... | ... |
... | @@ -38,7 +38,7 @@ public class MemberLevelServiceImpl implements MemberLevelService { | ... | @@ -38,7 +38,7 @@ public class MemberLevelServiceImpl implements MemberLevelService { |
38 | @Override | 38 | @Override |
39 | public MemberLevelDTO getByCode(String code) { | 39 | public MemberLevelDTO getByCode(String code) { |
40 | return StringUtils.isNotEmpty(code) ? this.memberLevelMapper.toDto(this.memberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new)) | 40 | return StringUtils.isNotEmpty(code) ? this.memberLevelMapper.toDto(this.memberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new)) |
41 | : new MemberLevelDTO(); | 41 | : new MemberLevelDTO(); |
42 | } | 42 | } |
43 | 43 | ||
44 | @Override | 44 | @Override | ... | ... |
... | @@ -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,17 +103,22 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -104,17 +103,22 @@ 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 | ||
110 | MemberRelatedInfo memberRelatedInfo = this.memberRelatedInfoRepository.findById(resources.getId()).orElseGet(MemberRelatedInfo::new); | 110 | MemberRelatedInfo memberRelatedInfo = this.memberRelatedInfoRepository.findById(resources.getId()).orElseGet(MemberRelatedInfo::new); |
111 | ValidationUtil.isNull(memberRelatedInfo.getId(), "MemberRelatedInfo", "id", resources.getId()); | 111 | ValidationUtil.isNull(memberRelatedInfo.getId(), "MemberRelatedInfo", "id", resources.getId()); |
112 | memberRelatedInfo.copy(resources); | 112 | memberRelatedInfo.copy(resources); |
113 | 113 | ||
114 | this.memberRelatedInfoRepository.save(memberRelatedInfo); | 114 | this.memberRelatedInfoRepository.save(memberRelatedInfo); |
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,16 +129,21 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -129,16 +129,21 @@ 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 | try { | ||
133 | MemberDTO memberDTO = this.checkMember(resources); | ||
132 | 134 | ||
133 | MemberDTO memberDTO = this.findByCode(resources.getCode()); | 135 | Member member = new Member(); |
136 | BeanUtils.copyProperties(memberDTO,member); | ||
137 | member.copy(resources); | ||
134 | 138 | ||
135 | Member member = new Member(); | 139 | this.save(member); |
136 | BeanUtils.copyProperties(memberDTO,member); | ||
137 | member.copy(resources); | ||
138 | 140 | ||
139 | this.save(member); | 141 | return this.memberMapper.toDto(member); |
142 | } catch (Exception e) { | ||
143 | e.printStackTrace(); | ||
144 | throw e; | ||
145 | } | ||
140 | 146 | ||
141 | return this.memberMapper.toDto(member); | ||
142 | } | 147 | } |
143 | 148 | ||
144 | @Transactional(propagation = Propagation.REQUIRES_NEW) | 149 | @Transactional(propagation = Propagation.REQUIRES_NEW) |
... | @@ -150,12 +155,22 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -150,12 +155,22 @@ 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) { |
153 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); | 158 | try { |
154 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | 159 | //this.redisUtils.doLock("member::update::code" + resources.getCode()); |
155 | member.copy(resources); | ||
156 | 160 | ||
157 | this.save(member); | 161 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); |
162 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | ||
163 | member.copy(resources); | ||
164 | |||
165 | this.save(member); | ||
166 | |||
167 | return this.memberMapper.toDto(member); | ||
168 | |||
169 | } catch (Exception e) { | ||
170 | e.printStackTrace(); | ||
171 | throw e; | ||
172 | } | ||
158 | 173 | ||
159 | return this.memberMapper.toDto(member); | ||
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 |
... | @@ -107,5 +99,5 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { | ... | @@ -107,5 +99,5 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { |
107 | String code = resources.getCode(); | 99 | String code = resources.getCode(); |
108 | return this.memberService.checkMember(memberId, code); | 100 | return this.memberService.checkMember(memberId, code); |
109 | } | 101 | } |
110 | 102 | ||
111 | } | 103 | } | ... | ... |
... | @@ -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 | } | ... | ... |
1 | package com.topdraw.business.module.points.available.service.impl; | 1 | package com.topdraw.business.module.points.available.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.available.domain.PointsAvailable; | 3 | import com.topdraw.business.module.points.available.domain.PointsAvailable; |
6 | import com.topdraw.business.module.points.available.repository.PointsAvailableRepository; | 4 | import com.topdraw.business.module.points.available.repository.PointsAvailableRepository; |
7 | import com.topdraw.business.module.points.available.service.PointsAvailableService; | 5 | import com.topdraw.business.module.points.available.service.PointsAvailableService; |
8 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO; | 6 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO; |
9 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria; | ||
10 | import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper; | 7 | import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper; |
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.StringUtils; | 9 | import com.topdraw.utils.StringUtils; |
15 | import com.topdraw.utils.ValidationUtil; | 10 | import com.topdraw.utils.ValidationUtil; |
16 | import org.redisson.api.RLock; | ||
17 | import org.redisson.api.RedissonClient; | ||
18 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.dao.EmptyResultDataAccessException; | 12 | 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; | 13 | import org.springframework.stereotype.Service; |
23 | import org.springframework.transaction.annotation.Propagation; | 14 | import org.springframework.transaction.annotation.Propagation; |
24 | import org.springframework.transaction.annotation.Transactional; | 15 | import org.springframework.transaction.annotation.Transactional; |
... | @@ -26,7 +17,6 @@ import org.springframework.util.Assert; | ... | @@ -26,7 +17,6 @@ import org.springframework.util.Assert; |
26 | 17 | ||
27 | import java.time.LocalDateTime; | 18 | import java.time.LocalDateTime; |
28 | import java.util.List; | 19 | import java.util.List; |
29 | import java.util.Map; | ||
30 | import java.util.Objects; | 20 | import java.util.Objects; |
31 | 21 | ||
32 | /** | 22 | /** |
... | @@ -38,147 +28,149 @@ import java.util.Objects; | ... | @@ -38,147 +28,149 @@ import java.util.Objects; |
38 | public class PointsAvailableServiceImpl implements PointsAvailableService { | 28 | public class PointsAvailableServiceImpl implements PointsAvailableService { |
39 | 29 | ||
40 | @Autowired | 30 | @Autowired |
41 | private PointsAvailableRepository PointsAvailableRepository; | 31 | private PointsAvailableRepository pointsAvailableRepository; |
42 | |||
43 | @Autowired | 32 | @Autowired |
44 | private PointsAvailableMapper PointsAvailableMapper; | 33 | private PointsAvailableMapper pointsAvailableMapper; |
45 | |||
46 | @Autowired | 34 | @Autowired |
47 | private MemberService memberService; | 35 | private RedisUtils redisUtils; |
48 | |||
49 | @Override | ||
50 | public Map<String, Object> queryAll(PointsAvailableQueryCriteria criteria, Pageable pageable) { | ||
51 | Page<PointsAvailable> page = PointsAvailableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> | ||
52 | QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
53 | return PageUtil.toPage(page.map(PointsAvailableMapper::toDto)); | ||
54 | } | ||
55 | 36 | ||
56 | @Override | 37 | @Override |
57 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { | 38 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { |
58 | return PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId)); | 39 | return this.pointsAvailableMapper.toDto(this.pointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId)); |
59 | } | ||
60 | |||
61 | @Override | ||
62 | public List<PointsAvailableDTO> queryAll(PointsAvailableQueryCriteria criteria) { | ||
63 | return PointsAvailableMapper.toDto(PointsAvailableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
64 | } | 40 | } |
65 | 41 | ||
66 | @Override | 42 | @Override |
67 | public PointsAvailableDTO findById(Long id) { | 43 | public PointsAvailableDTO findById(Long id) { |
68 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseGet(PointsAvailable::new); | 44 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.findById(id).orElseGet(PointsAvailable::new); |
69 | ValidationUtil.isNull(PointsAvailable.getId(),"PointsAvailable","id",id); | 45 | ValidationUtil.isNull(pointsAvailable.getId(),"PointsAvailable","id",id); |
70 | return PointsAvailableMapper.toDto(PointsAvailable); | 46 | return this.pointsAvailableMapper.toDto(pointsAvailable); |
71 | } | 47 | } |
72 | 48 | ||
73 | @Override | 49 | @Override |
74 | @Transactional(rollbackFor = Exception.class) | 50 | @Transactional(rollbackFor = Exception.class) |
75 | public void create(PointsAvailable resources) { | 51 | public PointsAvailableDTO create(PointsAvailable resources) { |
76 | String memberCode = resources.getMemberCode(); | 52 | try { |
77 | if (StringUtils.isNotEmpty(memberCode)) { | ||
78 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
79 | if (Objects.nonNull(memberDTO)) { | ||
80 | Long memberId = memberDTO.getId(); | ||
81 | resources.setMemberId(memberId); | ||
82 | } | ||
83 | } | ||
84 | 53 | ||
85 | PointsAvailableRepository.save(resources); | 54 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
86 | } | 55 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources); |
87 | 56 | ||
88 | @Override | 57 | return this.pointsAvailableMapper.toDto(pointsAvailable); |
89 | @Transactional(rollbackFor = Exception.class) | ||
90 | public void update(PointsAvailable resources) { | ||
91 | try { | ||
92 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); | ||
93 | ValidationUtil.isNull( PointsAvailable.getId(),"PointsAvailable","id",resources.getId()); | ||
94 | PointsAvailable.copy(resources); | ||
95 | PointsAvailableRepository.save(PointsAvailable); | ||
96 | } catch (Exception e) { | 58 | } catch (Exception e) { |
97 | e.printStackTrace(); | 59 | e.printStackTrace(); |
98 | throw e; | 60 | throw e; |
61 | } finally { | ||
62 | this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
99 | } | 63 | } |
100 | } | 64 | } |
101 | 65 | ||
102 | @Override | 66 | @Override |
103 | @Transactional(rollbackFor = Exception.class) | 67 | @Transactional(rollbackFor = Exception.class) |
104 | public void delete(Long id) { | 68 | public PointsAvailableDTO update(PointsAvailable resources) { |
105 | Assert.notNull(id, "The given id must not be null!"); | ||
106 | try { | 69 | try { |
107 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 70 | this.redisUtils.doLock("PointsAvailable::update::id"+resources.getMemberId().toString()); |
108 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 71 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); |
109 | PointsAvailableRepository.delete(PointsAvailable); | 72 | ValidationUtil.isNull(pointsAvailable.getId(),"PointsAvailable","id",resources.getId()); |
73 | pointsAvailable.copy(resources); | ||
74 | PointsAvailable _pointsAvailable = this.pointsAvailableRepository.save(pointsAvailable); | ||
75 | |||
76 | return this.pointsAvailableMapper.toDto(_pointsAvailable); | ||
110 | } catch (Exception e) { | 77 | } catch (Exception e) { |
111 | e.printStackTrace(); | 78 | e.printStackTrace(); |
112 | throw e; | 79 | throw e; |
80 | } finally { | ||
81 | this.redisUtils.doUnLock("PointsAvailable::update::id"+resources.getMemberId().toString()); | ||
113 | } | 82 | } |
114 | } | 83 | } |
115 | 84 | ||
116 | @Override | 85 | @Override |
117 | public void delete4Custom(Long id) { | 86 | @Transactional(rollbackFor = Exception.class) |
87 | public void delete(Long id) { | ||
118 | Assert.notNull(id, "The given id must not be null!"); | 88 | Assert.notNull(id, "The given id must not be null!"); |
89 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); | ||
119 | try { | 90 | try { |
120 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 91 | PointsAvailable PointsAvailable = this.pointsAvailableRepository.findById(id).orElseThrow( |
121 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 92 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.points.available.domain.PointsAvailable.class, id), 1)); |
122 | PointsAvailableRepository.delete(PointsAvailable); | 93 | this.pointsAvailableRepository.delete(PointsAvailable); |
123 | } catch (Exception e) { | 94 | } catch (Exception e) { |
124 | e.printStackTrace(); | 95 | e.printStackTrace(); |
125 | throw e; | 96 | throw e; |
97 | } finally { | ||
98 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); | ||
126 | } | 99 | } |
127 | } | 100 | } |
128 | 101 | ||
129 | @Override | 102 | @Override |
130 | @Transactional(rollbackFor = Exception.class) | 103 | @Transactional(rollbackFor = Exception.class) |
131 | public void deleteBatchByIds(List<Long> id) { | 104 | public void deleteBatchByIds(List<Long> id) { |
105 | this.redisUtils.doLock("PointsAvailable::create::id"+id); | ||
132 | try { | 106 | try { |
133 | PointsAvailableRepository.deleteBatchByIds(id); | 107 | this.pointsAvailableRepository.deleteBatchByIds(id); |
134 | } catch (Exception e) { | 108 | } catch (Exception e) { |
135 | e.printStackTrace(); | 109 | e.printStackTrace(); |
136 | throw e; | 110 | throw e; |
111 | } finally { | ||
112 | this.redisUtils.doUnLock("PointsAvailable::create::id"+id); | ||
137 | } | 113 | } |
138 | } | 114 | } |
139 | 115 | ||
140 | 116 | ||
141 | @Override | 117 | @Override |
142 | public PointsAvailableDTO getByCode(String code) { | 118 | public PointsAvailableDTO getByCode(String code) { |
143 | return StringUtils.isNotEmpty(code) ? PointsAvailableMapper.toDto(PointsAvailableRepository.findFirstByCode(code).orElseGet(PointsAvailable::new)) | 119 | return StringUtils.isNotEmpty(code) ? this.pointsAvailableMapper.toDto(this.pointsAvailableRepository.findFirstByCode(code).orElseGet(PointsAvailable::new)) |
144 | : new PointsAvailableDTO(); | 120 | : new PointsAvailableDTO(); |
145 | } | 121 | } |
146 | 122 | ||
147 | @Override | 123 | @Override |
148 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime timestamp) { | 124 | public List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, LocalDateTime timestamp) { |
149 | return Objects.nonNull(memberId)? | 125 | return Objects.nonNull(memberId)? |
150 | PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdAndExpireTimeBefore(memberId, timestamp)) | 126 | this.pointsAvailableMapper.toDto(this.pointsAvailableRepository.findByMemberIdAndExpireTimeBefore(memberId, timestamp)) |
151 | :null; | 127 | :null; |
152 | } | 128 | } |
153 | 129 | ||
154 | @Override | 130 | @Override |
155 | public Long findSoonExpireTime(Long memberId, Integer factor) { | 131 | public Long findSoonExpireTime(Long memberId, Integer factor) { |
156 | return PointsAvailableRepository.findSoonExpireTime(memberId, factor); | 132 | return this.pointsAvailableRepository.findSoonExpireTime(memberId, factor); |
157 | } | 133 | } |
158 | 134 | ||
159 | @Override | 135 | @Override |
160 | public long findAvailablePointsByMemberId(long memberId) { | 136 | public long findAvailablePointsByMemberId(long memberId) { |
161 | Long availablePoints = this.PointsAvailableRepository.findAvailablePointsByMemberId(memberId); | 137 | Long availablePoints = this.pointsAvailableRepository.findAvailablePointsByMemberId(memberId); |
162 | return availablePoints == null ? 0L : availablePoints; | 138 | return availablePoints == null ? 0L : availablePoints; |
163 | } | 139 | } |
164 | 140 | ||
165 | @Override | 141 | @Override |
166 | public long findTotalPointsByMemberId(Long memberId) { | 142 | public long findTotalPointsByMemberId(Long memberId) { |
167 | return this.PointsAvailableRepository.findTotalCountByMemberId(memberId); | 143 | return this.pointsAvailableRepository.findTotalCountByMemberId(memberId); |
168 | } | 144 | } |
169 | 145 | ||
170 | @Override | 146 | @Override |
171 | public void create4Custom(PointsAvailable resources) { | 147 | public void delete4Custom(Long id) { |
172 | String memberCode = resources.getMemberCode(); | 148 | Assert.notNull(id, "The given id must not be null!"); |
173 | if (StringUtils.isNotEmpty(memberCode)) { | 149 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); |
174 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | 150 | try { |
175 | if (Objects.nonNull(memberDTO)) { | 151 | PointsAvailable PointsAvailable = this.pointsAvailableRepository.findById(id).orElseThrow( |
176 | Long memberId = memberDTO.getId(); | 152 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.points.available.domain.PointsAvailable.class, id), 1)); |
177 | resources.setMemberId(memberId); | 153 | this.pointsAvailableRepository.delete(PointsAvailable); |
178 | } | 154 | } catch (Exception e) { |
155 | e.printStackTrace(); | ||
156 | throw e; | ||
157 | } finally { | ||
158 | this.redisUtils.doUnLock("PointsAvailable::delete::id"+id); | ||
179 | } | 159 | } |
160 | } | ||
180 | 161 | ||
181 | PointsAvailableRepository.save(resources); | 162 | @Override |
163 | public PointsAvailableDTO create4Custom(PointsAvailable resources) { | ||
164 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
165 | try { | ||
166 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources); | ||
167 | return this.pointsAvailableMapper.toDto(pointsAvailable); | ||
168 | } catch (Exception e) { | ||
169 | e.printStackTrace(); | ||
170 | throw e; | ||
171 | } finally { | ||
172 | this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
173 | } | ||
182 | } | 174 | } |
183 | 175 | ||
184 | } | 176 | } | ... | ... |
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 | */ | 19 | */ |
23 | Map<String,Object> queryAll(RightsHistoryQueryCriteria criteria, Pageable pageable); | 20 | List<RightsHistoryDTO> findByMemberIdOrMemberCode(Long memberId, String memberCode); |
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<RightsHistoryDTO> | ||
29 | */ | ||
30 | List<RightsHistoryDTO> queryAll(RightsHistoryQueryCriteria criteria); | ||
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 | } | ... | ... |
1 | package com.topdraw.business.module.rights.service; | 1 | package com.topdraw.business.module.rights.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.rights.domain.Rights; | ||
4 | import com.topdraw.business.module.rights.service.dto.RightsDTO; | 3 | import com.topdraw.business.module.rights.service.dto.RightsDTO; |
5 | import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria; | ||
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,21 +9,6 @@ import java.util.Map; | ... | @@ -15,21 +9,6 @@ import java.util.Map; |
15 | public interface RightsService { | 9 | public interface RightsService { |
16 | 10 | ||
17 | /** | 11 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(RightsQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<RightsDTO> | ||
29 | */ | ||
30 | List<RightsDTO> queryAll(RightsQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 12 | * 根据ID查询 |
34 | * @param id ID | 13 | * @param id ID |
35 | * @return RightsDTO | 14 | * @return RightsDTO |
... | @@ -37,19 +16,6 @@ public interface RightsService { | ... | @@ -37,19 +16,6 @@ public interface RightsService { |
37 | RightsDTO findById(Long id); | 16 | RightsDTO findById(Long id); |
38 | 17 | ||
39 | /** | 18 | /** |
40 | * 批量查询 | ||
41 | * @param ids | ||
42 | * @return | ||
43 | */ | ||
44 | List<RightsDTO> findBatchByIds(Long... ids); | ||
45 | |||
46 | void create(Rights resources); | ||
47 | |||
48 | void update(Rights resources); | ||
49 | |||
50 | void delete(Long id); | ||
51 | |||
52 | /** | ||
53 | * Code校验 | 19 | * Code校验 |
54 | * @param code | 20 | * @param code |
55 | * @return RightsDTO | 21 | * @return RightsDTO | ... | ... |
... | @@ -13,44 +13,45 @@ import java.sql.Timestamp; | ... | @@ -13,44 +13,45 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class RightsDTO implements Serializable { | 14 | public class RightsDTO 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 | // 终端类型 0:大屏;1:微信小程序/公众号;2:App | 24 | |
25 | /** 终端类型 0:大屏;1:微信小程序/公众号;2:App */ | ||
25 | private Integer deviceType; | 26 | private Integer deviceType; |
26 | 27 | ||
27 | // 类型 1:实体类 (预留字段) | 28 | /** 类型 1:实体类 (预留字段) */ |
28 | private Integer type; | 29 | private Integer type; |
29 | 30 | ||
30 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 31 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ |
31 | private String entityType; | 32 | private String entityType; |
32 | 33 | ||
33 | // 实体id | 34 | /** 实体id */ |
34 | private Long entityId; | 35 | private Long entityId; |
35 | 36 | ||
36 | // 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 | 37 | /** 生效时间,为null表示获取后立即生效,不为空时,表示特定的生效时间 */ |
37 | private Timestamp validTime; | 38 | private Timestamp validTime; |
38 | 39 | ||
39 | // 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 | 40 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ |
40 | private Long expireTime; | 41 | private Long expireTime; |
41 | 42 | ||
42 | // 创建时间 | 43 | /** 创建时间 */ |
43 | private Timestamp createTime; | 44 | private Timestamp createTime; |
44 | 45 | ||
45 | // 更新时间 | 46 | /** 更新时间 */ |
46 | private Timestamp updateTime; | 47 | private Timestamp updateTime; |
47 | 48 | ||
48 | // 图片 | 49 | /** 图片 */ |
49 | private String image; | 50 | private String image; |
50 | 51 | ||
51 | // 图片 | 52 | /** 图片 */ |
52 | private String images; | 53 | private String images; |
53 | 54 | ||
54 | // 描述 | 55 | /** 描述 */ |
55 | private String description; | 56 | private String description; |
56 | } | 57 | } | ... | ... |
src/main/java/com/topdraw/business/module/rights/service/dto/RightsQueryCriteria.java
deleted
100644 → 0
1 | package com.topdraw.business.module.rights.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 RightsQueryCriteria{ | ||
12 | |||
13 | @Query | ||
14 | private Long memberId; | ||
15 | |||
16 | private RightsQueryType queryType; | ||
17 | |||
18 | } |
... | @@ -4,24 +4,13 @@ import com.topdraw.business.module.rights.domain.Rights; | ... | @@ -4,24 +4,13 @@ import com.topdraw.business.module.rights.domain.Rights; |
4 | import com.topdraw.business.module.rights.repository.RightsRepository; | 4 | import com.topdraw.business.module.rights.repository.RightsRepository; |
5 | import com.topdraw.business.module.rights.service.RightsService; | 5 | import com.topdraw.business.module.rights.service.RightsService; |
6 | import com.topdraw.business.module.rights.service.dto.RightsDTO; | 6 | import com.topdraw.business.module.rights.service.dto.RightsDTO; |
7 | import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria; | ||
8 | import com.topdraw.business.module.rights.service.mapper.RightsMapper; | 7 | import com.topdraw.business.module.rights.service.mapper.RightsMapper; |
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 | import org.springframework.util.CollectionUtils; | ||
22 | |||
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | 14 | ||
26 | /** | 15 | /** |
27 | * @author XiangHan | 16 | * @author XiangHan |
... | @@ -32,63 +21,20 @@ import java.util.Map; | ... | @@ -32,63 +21,20 @@ import java.util.Map; |
32 | public class RightsServiceImpl implements RightsService { | 21 | public class RightsServiceImpl implements RightsService { |
33 | 22 | ||
34 | @Autowired | 23 | @Autowired |
35 | private RightsRepository RightsRepository; | 24 | private RightsRepository rightsRepository; |
36 | |||
37 | @Autowired | 25 | @Autowired |
38 | private RightsMapper RightsMapper; | 26 | private RightsMapper rightsMapper; |
39 | |||
40 | @Override | ||
41 | public Map<String, Object> queryAll(RightsQueryCriteria criteria, Pageable pageable) { | ||
42 | Page<Rights> page = RightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
43 | return PageUtil.toPage(page.map(RightsMapper::toDto)); | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public List<RightsDTO> queryAll(RightsQueryCriteria criteria) { | ||
48 | return RightsMapper.toDto(RightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
49 | } | ||
50 | 27 | ||
51 | @Override | 28 | @Override |
52 | public RightsDTO findById(Long id) { | 29 | public RightsDTO findById(Long id) { |
53 | Rights Rights = RightsRepository.findById(id).orElseGet(Rights::new); | 30 | Rights Rights = this.rightsRepository.findById(id).orElseGet(com.topdraw.business.module.rights.domain.Rights::new); |
54 | ValidationUtil.isNull(Rights.getId(),"Rights","id",id); | 31 | ValidationUtil.isNull(Rights.getId(),"Rights","id",id); |
55 | return RightsMapper.toDto(Rights); | 32 | return this.rightsMapper.toDto(Rights); |
56 | } | ||
57 | |||
58 | @Override | ||
59 | public List<RightsDTO> findBatchByIds(Long... ids) { | ||
60 | List<Rights> rightsList = this.RightsRepository.findBatchByIds(ids); | ||
61 | return !CollectionUtils.isEmpty(rightsList) ? RightsMapper.toDto(rightsList) : null; | ||
62 | } | 33 | } |
63 | 34 | ||
64 | @Override | 35 | @Override |
65 | @Transactional(rollbackFor = Exception.class) | ||
66 | public void create(Rights resources) { | ||
67 | RightsRepository.save(resources); | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | @Transactional(rollbackFor = Exception.class) | ||
72 | public void update(Rights resources) { | ||
73 | Rights Rights = RightsRepository.findById(resources.getId()).orElseGet(Rights::new); | ||
74 | ValidationUtil.isNull( Rights.getId(),"Rights","id",resources.getId()); | ||
75 | Rights.copy(resources); | ||
76 | RightsRepository.save(Rights); | ||
77 | } | ||
78 | |||
79 | @Override | ||
80 | @Transactional(rollbackFor = Exception.class) | ||
81 | public void delete(Long id) { | ||
82 | Assert.notNull(id, "The given id must not be null!"); | ||
83 | Rights Rights = RightsRepository.findById(id).orElseThrow( | ||
84 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Rights.class, id), 1)); | ||
85 | RightsRepository.delete(Rights); | ||
86 | } | ||
87 | |||
88 | |||
89 | @Override | ||
90 | public RightsDTO getByCode(String code) { | 36 | public RightsDTO getByCode(String code) { |
91 | return StringUtils.isNotEmpty(code) ? RightsMapper.toDto(RightsRepository.findFirstByCode(code).orElseGet(Rights::new)) | 37 | return StringUtils.isNotEmpty(code) ? this.rightsMapper.toDto(this.rightsRepository.findFirstByCode(code).orElseGet(Rights::new)) |
92 | : new RightsDTO(); | 38 | : new RightsDTO(); |
93 | } | 39 | } |
94 | } | 40 | } | ... | ... |
1 | package com.topdraw.business.module.task.attribute.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 XiangHan | ||
14 | * @date 2022-01-13 | ||
15 | */ | ||
16 | @Entity | ||
17 | @Data | ||
18 | @EntityListeners(AuditingEntityListener.class) | ||
19 | @Accessors(chain = true) | ||
20 | @Table(name="tr_task_attr") | ||
21 | public class TaskAttr implements Serializable { | ||
22 | |||
23 | @Id | ||
24 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
25 | @Column(name = "id") | ||
26 | private Long id; | ||
27 | |||
28 | /** 任务id(关联task主键) */ | ||
29 | @Column(name = "task_id") | ||
30 | private Long taskId; | ||
31 | |||
32 | /** 任务属性字符串 */ | ||
33 | @Column(name = "attr_str") | ||
34 | private String attrStr; | ||
35 | |||
36 | public void copy(TaskAttr source){ | ||
37 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
38 | } | ||
39 | } |
src/main/java/com/topdraw/business/module/task/attribute/repository/TaskAttrRepository.java
0 → 100644
1 | package com.topdraw.business.module.task.attribute.repository; | ||
2 | |||
3 | import com.topdraw.business.module.task.attribute.domain.TaskAttr; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | |||
7 | import java.util.Optional; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2022-01-13 | ||
12 | */ | ||
13 | public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> { | ||
14 | |||
15 | Optional<TaskAttr> findByTaskId(Long taskId); | ||
16 | } |
1 | package com.topdraw.business.module.task.attribute.service; | ||
2 | |||
3 | import com.topdraw.business.module.task.attribute.domain.TaskAttr; | ||
4 | import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; | ||
5 | |||
6 | /** | ||
7 | * @author XiangHan | ||
8 | * @date 2022-01-13 | ||
9 | */ | ||
10 | public interface TaskAttrService { | ||
11 | /** | ||
12 | * 根据ID查询 | ||
13 | * @param id ID | ||
14 | * @return TaskAttrDTO | ||
15 | */ | ||
16 | TaskAttrDTO findById(Long id); | ||
17 | |||
18 | /** | ||
19 | * | ||
20 | * @param resources | ||
21 | */ | ||
22 | void create(TaskAttr resources); | ||
23 | |||
24 | /** | ||
25 | * | ||
26 | * @param resources | ||
27 | */ | ||
28 | void update(TaskAttr resources); | ||
29 | |||
30 | /** | ||
31 | * | ||
32 | * @param id | ||
33 | */ | ||
34 | void delete(Long id); | ||
35 | |||
36 | /** | ||
37 | * | ||
38 | * @param taskId | ||
39 | * @return | ||
40 | */ | ||
41 | TaskAttrDTO findByTaskId(Long taskId); | ||
42 | } |
1 | package com.topdraw.business.module.coupon.history.service.dto; | 1 | package com.topdraw.business.module.task.attribute.service.dto; |
2 | 2 | ||
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | ||
6 | |||
5 | /** | 7 | /** |
6 | * @author XiangHan | 8 | * @author XiangHan |
7 | * @date 2021-10-23 | 9 | * @date 2022-01-13 |
8 | */ | 10 | */ |
9 | @Data | 11 | @Data |
10 | public class CouponHistoryQueryCriteria{ | 12 | public class TaskAttrDTO implements Serializable { |
13 | |||
14 | private Long id; | ||
15 | |||
16 | /** 任务id(关联task主键) */ | ||
17 | private Long taskId; | ||
18 | |||
19 | /** 任务属性字符串 */ | ||
20 | private String attrStr; | ||
11 | } | 21 | } | ... | ... |
src/main/java/com/topdraw/business/module/task/attribute/service/impl/TaskAttrServiceImpl.java
0 → 100644
1 | package com.topdraw.business.module.task.attribute.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.task.attribute.domain.TaskAttr; | ||
4 | import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository; | ||
5 | import com.topdraw.business.module.task.attribute.service.TaskAttrService; | ||
6 | import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; | ||
7 | import com.topdraw.business.module.task.attribute.service.mapper.TaskAttrMapper; | ||
8 | import com.topdraw.utils.ValidationUtil; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | ||
10 | import org.springframework.dao.EmptyResultDataAccessException; | ||
11 | import org.springframework.stereotype.Service; | ||
12 | import org.springframework.transaction.annotation.Propagation; | ||
13 | import org.springframework.transaction.annotation.Transactional; | ||
14 | import org.springframework.util.Assert; | ||
15 | |||
16 | /** | ||
17 | * @author XiangHan | ||
18 | * @date 2022-01-13 | ||
19 | */ | ||
20 | @Service | ||
21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
22 | public class TaskAttrServiceImpl implements TaskAttrService { | ||
23 | |||
24 | @Autowired | ||
25 | private TaskAttrMapper taskAttrMapper; | ||
26 | @Autowired | ||
27 | private TaskAttrRepository taskAttrRepository; | ||
28 | |||
29 | |||
30 | @Override | ||
31 | public TaskAttrDTO findById(Long id) { | ||
32 | TaskAttr TaskAttr = this.taskAttrRepository.findById(id).orElseGet(TaskAttr::new); | ||
33 | ValidationUtil.isNull(TaskAttr.getId(),"TaskAttr","id",id); | ||
34 | return this.taskAttrMapper.toDto(TaskAttr); | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | @Transactional(rollbackFor = Exception.class) | ||
39 | public void create(TaskAttr resources) { | ||
40 | this.taskAttrRepository.save(resources); | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | @Transactional(rollbackFor = Exception.class) | ||
45 | public void update(TaskAttr resources) { | ||
46 | TaskAttr TaskAttr = this.taskAttrRepository.findById(resources.getId()).orElseGet(TaskAttr::new); | ||
47 | ValidationUtil.isNull( TaskAttr.getId(),"TaskAttr","id",resources.getId()); | ||
48 | TaskAttr.copy(resources); | ||
49 | this.taskAttrRepository.save(TaskAttr); | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | @Transactional(rollbackFor = Exception.class) | ||
54 | public void delete(Long id) { | ||
55 | Assert.notNull(id, "The given id must not be null!"); | ||
56 | TaskAttr TaskAttr = this.taskAttrRepository.findById(id).orElseThrow( | ||
57 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TaskAttr.class, id), 1)); | ||
58 | this.taskAttrRepository.delete(TaskAttr); | ||
59 | } | ||
60 | |||
61 | @Override | ||
62 | public TaskAttrDTO findByTaskId(Long taskId) { | ||
63 | TaskAttr TaskAttr = this.taskAttrRepository.findByTaskId(taskId).orElseGet(TaskAttr::new); | ||
64 | return this.taskAttrMapper.toDto(TaskAttr); | ||
65 | } | ||
66 | |||
67 | |||
68 | } |
1 | package com.topdraw.business.module.points.standingbook.service.mapper; | 1 | package com.topdraw.business.module.task.attribute.service.mapper; |
2 | 2 | ||
3 | import com.topdraw.base.BaseMapper; | 3 | import com.topdraw.base.BaseMapper; |
4 | import com.topdraw.business.module.points.standingbook.domain.PointsStandingBook; | 4 | import com.topdraw.business.module.task.attribute.domain.TaskAttr; |
5 | import com.topdraw.business.module.points.standingbook.service.dto.PointsStandingBookDTO; | 5 | import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; |
6 | import org.mapstruct.Mapper; | 6 | import org.mapstruct.Mapper; |
7 | import org.mapstruct.ReportingPolicy; | 7 | import org.mapstruct.ReportingPolicy; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * @author XiangHan | 10 | * @author XiangHan |
11 | * @date 2021-10-29 | 11 | * @date 2022-01-13 |
12 | */ | 12 | */ |
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
14 | public interface PointsStandingBookMapper extends BaseMapper<PointsStandingBookDTO, PointsStandingBook> { | 14 | public interface TaskAttrMapper extends BaseMapper<TaskAttrDTO, TaskAttr> { |
15 | 15 | ||
16 | } | 16 | } | ... | ... |
... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | import javax.persistence.*; | 11 | import javax.persistence.*; |
12 | import java.io.Serializable; | 12 | import java.io.Serializable; |
13 | import java.sql.Timestamp; | 13 | import java.sql.Timestamp; |
14 | import java.time.LocalDateTime; | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * @author XiangHan | 17 | * @author XiangHan |
... | @@ -28,104 +29,104 @@ public class Task implements Serializable { | ... | @@ -28,104 +29,104 @@ public class Task implements Serializable { |
28 | @Column(name = "id") | 29 | @Column(name = "id") |
29 | private Long id; | 30 | private Long id; |
30 | 31 | ||
31 | // 任务模板id | 32 | /** 任务模板id */ |
32 | @Column(name = "task_template_id", nullable = false) | 33 | @Column(name = "task_template_id", nullable = false) |
33 | private Long taskTemplateId; | 34 | private Long taskTemplateId; |
34 | 35 | ||
35 | // 任务重复类型,-1:不限次;1:单次;>1:多次 | 36 | /** 任务重复类型,-1:不限次;1:单次;>1:多次 */ |
36 | @Column(name = "task_repeat_type", nullable = false) | 37 | @Column(name = "task_repeat_type", nullable = false) |
37 | private Integer taskRepeatType; | 38 | private Integer taskRepeatType; |
38 | 39 | ||
39 | // 任务每日重置 0:不重置;1:重置 | 40 | /** 任务每日重置 0:不重置;1:重置 */ |
40 | @Column(name = "task_daily_reset", nullable = false) | 41 | @Column(name = "task_daily_reset", nullable = false) |
41 | private Integer taskDailyReset; | 42 | private Integer taskDailyReset; |
42 | 43 | ||
43 | // 行为量(完成此任务需要多少次相同行为的触发) | 44 | /** 行为量(完成此任务需要多少次相同行为的触发) */ |
44 | @Column(name = "action_amount", nullable = false) | 45 | @Column(name = "action_amount", nullable = false) |
45 | private Integer actionAmount; | 46 | private Integer actionAmount; |
46 | 47 | ||
47 | // 任务生效时间 | 48 | /** 任务生效时间 */ |
48 | @Column(name = "valid_time") | 49 | @Column(name = "valid_time") |
49 | private Timestamp validTime; | 50 | private Timestamp validTime; |
50 | 51 | ||
51 | // 任务失效时间 | 52 | /** 任务失效时间 */ |
52 | @Column(name = "expire_time") | 53 | @Column(name = "expire_time") |
53 | private Timestamp expireTime; | 54 | private LocalDateTime expireTime; |
54 | 55 | ||
55 | // 显示顺序 | 56 | /** 显示顺序 */ |
56 | @Column(name = "sequence") | 57 | @Column(name = "sequence") |
57 | private Integer sequence; | 58 | private Integer sequence; |
58 | 59 | ||
59 | // 获得成长值 | 60 | /** 获得成长值 */ |
60 | @Column(name = "reward_exp", nullable = false) | 61 | @Column(name = "reward_exp", nullable = false) |
61 | private Long rewardExp; | 62 | private Long rewardExp; |
62 | 63 | ||
63 | // 获得积分 | 64 | /** 获得积分 */ |
64 | @Column(name = "reward_points", nullable = false) | 65 | @Column(name = "reward_points", nullable = false) |
65 | private Long rewardPoints; | 66 | private Long rewardPoints; |
66 | 67 | ||
67 | // 积分过期时间(空为不过期) | 68 | /** 积分过期时间(空为不过期) */ |
68 | @Column(name = "reward_points_expire_time") | 69 | @Column(name = "reward_points_expire_time") |
69 | private Long rewardPointsExpireTime; | 70 | private Long rewardPointsExpireTime; |
70 | 71 | ||
71 | // 积分获取类型 0:定值;1:随机 | 72 | /** 积分获取类型 0:定值;1:随机 */ |
72 | @Column(name = "points_type") | 73 | @Column(name = "points_type") |
73 | private Integer pointsType; | 74 | private Integer pointsType; |
74 | 75 | ||
75 | // 随机积分最大值 | 76 | /** 随机积分最大值 */ |
76 | @Column(name = "reward_max_points") | 77 | @Column(name = "reward_max_points") |
77 | private Integer rewardMaxPoints; | 78 | private Integer rewardMaxPoints; |
78 | 79 | ||
79 | // 能够获取该任务的用户分组,为空则都能获取 | 80 | /** 能够获取该任务的用户分组,为空则都能获取 */ |
80 | @Column(name = "groups") | 81 | @Column(name = "groups") |
81 | private String groups; | 82 | private String groups; |
82 | 83 | ||
83 | // 权益发放策略 0:立即发放;1:次日发放;2:次月发放 | 84 | /** 权益发放策略 0:立即发放;1:次日发放;2:次月发放 */ |
84 | @Column(name = "rights_send_strategy", nullable = false) | 85 | @Column(name = "rights_send_strategy", nullable = false) |
85 | private Integer rightsSendStrategy; | 86 | private Integer rightsSendStrategy; |
86 | 87 | ||
87 | // 会员等级门槛(0表示无门槛) | 88 | /** 会员等级门槛(0表示无门槛) */ |
88 | @Column(name = "member_level", nullable = false) | 89 | @Column(name = "member_level", nullable = false) |
89 | private Integer memberLevel; | 90 | private Integer memberLevel; |
90 | 91 | ||
91 | // 会员vip门槛(0表示没有门槛) | 92 | /** 会员vip门槛(0表示没有门槛) */ |
92 | @Column(name = "member_vip") | 93 | @Column(name = "member_vip") |
93 | private Integer memberVip; | 94 | private Integer memberVip; |
94 | 95 | ||
95 | // 权益id | 96 | /** 权益id */ |
96 | @Column(name = "rights_id") | 97 | @Column(name = "rights_id") |
97 | private Long rightsId; | 98 | private Long rightsId; |
98 | 99 | ||
99 | // 权益数量(活动机会次数、优惠券数量、奖品数量) | 100 | /** 权益数量(活动机会次数、优惠券数量、奖品数量) */ |
100 | @Column(name = "rights_amount") | 101 | @Column(name = "rights_amount") |
101 | private Integer rightsAmount; | 102 | private Integer rightsAmount; |
102 | 103 | ||
103 | // 权益2id | 104 | /** 权益2id */ |
104 | @Column(name = "rights2_id") | 105 | @Column(name = "rights2_id") |
105 | private Long rights2Id; | 106 | private Long rights2Id; |
106 | 107 | ||
107 | // 权益2数量 | 108 | /** 权益2数量 */ |
108 | @Column(name = "rights2_amount") | 109 | @Column(name = "rights2_amount") |
109 | private Integer rights2Amount; | 110 | private Integer rights2Amount; |
110 | 111 | ||
111 | // 权益3id | 112 | /** 权益3id */ |
112 | @Column(name = "rights3_id") | 113 | @Column(name = "rights3_id") |
113 | private Long rights3Id; | 114 | private Long rights3Id; |
114 | 115 | ||
115 | // 权益3数量 | 116 | /** 权益3数量 */ |
116 | @Column(name = "rights3_amount") | 117 | @Column(name = "rights3_amount") |
117 | private Integer rights3Amount; | 118 | private Integer rights3Amount; |
118 | 119 | ||
119 | // 状态 0:失效;1:生效 | 120 | /** 状态 0:失效;1:生效 */ |
120 | @Column(name = "status", nullable = false) | 121 | @Column(name = "status", nullable = false) |
121 | private Integer status; | 122 | private Integer status; |
122 | 123 | ||
123 | // 创建时间 | 124 | /** 创建时间 */ |
124 | @CreatedDate | 125 | @CreatedDate |
125 | @Column(name = "create_time") | 126 | @Column(name = "create_time") |
126 | private Timestamp createTime; | 127 | private Timestamp createTime; |
127 | 128 | ||
128 | // 更新时间 | 129 | /** 更新时间 */ |
129 | @LastModifiedDate | 130 | @LastModifiedDate |
130 | @Column(name = "update_time") | 131 | @Column(name = "update_time") |
131 | private Timestamp updateTime; | 132 | private Timestamp updateTime; | ... | ... |
1 | package com.topdraw.business.module.points.standingbook.domain; | 1 | package com.topdraw.business.module.task.progress.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 lombok.AllArgsConstructor; | ||
5 | import lombok.Data; | 6 | import lombok.Data; |
7 | import lombok.NoArgsConstructor; | ||
6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 9 | import org.springframework.data.annotation.CreatedDate; |
8 | import org.springframework.data.annotation.LastModifiedDate; | 10 | import org.springframework.data.annotation.LastModifiedDate; |
... | @@ -14,52 +16,55 @@ import java.sql.Timestamp; | ... | @@ -14,52 +16,55 @@ import java.sql.Timestamp; |
14 | 16 | ||
15 | /** | 17 | /** |
16 | * @author XiangHan | 18 | * @author XiangHan |
17 | * @date 2021-10-29 | 19 | * @date 2021-11-02 |
18 | */ | 20 | */ |
19 | @Entity | 21 | @Entity |
20 | @Data | 22 | @Data |
21 | @EntityListeners(AuditingEntityListener.class) | 23 | @EntityListeners(AuditingEntityListener.class) |
22 | @Accessors(chain = true) | 24 | @Accessors(chain = true) |
23 | @Table(name="uc_points_standing_book") | 25 | @Table(name="uc_tr_task_progress") |
24 | public class PointsStandingBook implements Serializable { | 26 | @AllArgsConstructor |
27 | @NoArgsConstructor | ||
28 | public class TrTaskProgress implements Serializable { | ||
25 | 29 | ||
26 | // 主键 | ||
27 | @Id | 30 | @Id |
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 31 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
29 | @Column(name = "id") | 32 | @Column(name = "id") |
30 | private Long id; | 33 | private Long id; |
31 | 34 | ||
32 | // 积分生产 | 35 | /** 用户id */ |
33 | @Column(name = "points_produce", nullable = false) | 36 | @Column(name = "member_id", nullable = false) |
34 | private Long pointsProduce; | 37 | private Long memberId; |
35 | 38 | ||
36 | // 积分消耗 | 39 | /** 任务id */ |
37 | @Column(name = "points_consume", nullable = false) | 40 | @Column(name = "task_id") |
38 | private Long pointsConsume; | 41 | private Long taskId; |
39 | 42 | ||
40 | // 可用总积分 | 43 | /** 已完成的行为量 */ |
41 | @Column(name = "points_available", nullable = false) | 44 | @Column(name = "current_action_amount") |
42 | private Long pointsAvailable; | 45 | private Integer currentActionAmount; |
43 | 46 | ||
44 | // 积分过期 | 47 | /** 目标行为量 */ |
45 | @Column(name = "points_expire", nullable = false) | 48 | @Column(name = "target_action_amount") |
46 | private Long pointsExpire; | 49 | private Integer targetActionAmount; |
47 | 50 | ||
48 | // 日期 | 51 | /** 状态 0:未完成;1:已完成 */ |
49 | @Column(name = "day") | 52 | @Column(name = "status") |
50 | private String day; | 53 | private Integer status; |
54 | |||
55 | /** 完成时间 */ | ||
56 | @Column(name = "completion_time") | ||
57 | private Timestamp completionTime; | ||
51 | 58 | ||
52 | // 创建时间 | ||
53 | @CreatedDate | 59 | @CreatedDate |
54 | @Column(name = "create_time") | 60 | @Column(name = "create_time") |
55 | private Timestamp createTime; | 61 | private Timestamp createTime; |
56 | 62 | ||
57 | // 创建时间 | ||
58 | @LastModifiedDate | 63 | @LastModifiedDate |
59 | @Column(name = "update_time") | 64 | @Column(name = "update_time") |
60 | private Timestamp updateTime; | 65 | private Timestamp updateTime; |
61 | 66 | ||
62 | public void copy(PointsStandingBook source){ | 67 | public void copy(TrTaskProgress source){ |
63 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | 68 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
64 | } | 69 | } |
65 | } | 70 | } | ... | ... |
src/main/java/com/topdraw/business/module/task/progress/repository/TrTaskProgressRepository.java
0 → 100644
1 | package com.topdraw.business.module.task.progress.repository; | ||
2 | |||
3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | ||
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 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-11-02 | ||
13 | */ | ||
14 | public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, Long>, JpaSpecificationExecutor<TrTaskProgress> { | ||
15 | |||
16 | @Query(value = "select id, member_id, task_id , current_action_amount , \n" + | ||
17 | " target_action_amount , `status` , completion_time,create_time,update_time from uc_tr_task_progress where member_id = ?1 \n" + | ||
18 | " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true) | ||
19 | List<TrTaskProgress> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); | ||
20 | } |
src/main/java/com/topdraw/business/module/task/progress/service/TrTaskProgressService.java
0 → 100644
1 | package com.topdraw.business.module.task.progress.service; | ||
2 | |||
3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | ||
4 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | ||
5 | |||
6 | import java.util.List; | ||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-11-02 | ||
11 | */ | ||
12 | public interface TrTaskProgressService { | ||
13 | |||
14 | /** | ||
15 | * 根据ID查询 | ||
16 | * @param id ID | ||
17 | * @return TrTaskProgressDTO | ||
18 | */ | ||
19 | TrTaskProgressDTO findById(Long id); | ||
20 | |||
21 | /** | ||
22 | * | ||
23 | * @param resources | ||
24 | */ | ||
25 | void create(TrTaskProgress resources); | ||
26 | |||
27 | /** | ||
28 | * | ||
29 | * @param resources | ||
30 | */ | ||
31 | void update(TrTaskProgress resources); | ||
32 | |||
33 | /** | ||
34 | * | ||
35 | * @param id | ||
36 | */ | ||
37 | void delete(Long id); | ||
38 | |||
39 | /** | ||
40 | * | ||
41 | * @param memberId | ||
42 | * @param taskId | ||
43 | * @param time1 | ||
44 | * @return | ||
45 | */ | ||
46 | List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); | ||
47 | } |
src/main/java/com/topdraw/business/module/task/progress/service/dto/TrTaskProgressDTO.java
0 → 100644
1 | package com.topdraw.business.module.task.progress.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-02 | ||
12 | */ | ||
13 | @Data | ||
14 | public class TrTaskProgressDTO implements Serializable { | ||
15 | |||
16 | private Long id; | ||
17 | |||
18 | /** 用户id */ | ||
19 | private Long memberId; | ||
20 | |||
21 | /** 任务id */ | ||
22 | private Long taskId; | ||
23 | |||
24 | /** 已完成的行为量 */ | ||
25 | private Integer currentActionAmount; | ||
26 | |||
27 | /** 目标行为量 */ | ||
28 | private Integer targetActionAmount; | ||
29 | |||
30 | /** 状态 0:未完成;1:已完成 */ | ||
31 | private Integer status; | ||
32 | |||
33 | /** 完成时间 */ | ||
34 | private Timestamp completionTime; | ||
35 | |||
36 | private Timestamp createTime; | ||
37 | |||
38 | private Timestamp updateTime; | ||
39 | } |
src/main/java/com/topdraw/business/module/task/progress/service/impl/TrTaskProgressServiceImpl.java
0 → 100644
1 | package com.topdraw.business.module.task.progress.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | ||
4 | import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; | ||
5 | import com.topdraw.business.module.task.progress.service.TrTaskProgressService; | ||
6 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | ||
7 | import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper; | ||
8 | import com.topdraw.utils.ValidationUtil; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | ||
10 | import org.springframework.dao.EmptyResultDataAccessException; | ||
11 | import org.springframework.stereotype.Service; | ||
12 | import org.springframework.transaction.annotation.Propagation; | ||
13 | import org.springframework.transaction.annotation.Transactional; | ||
14 | import org.springframework.util.Assert; | ||
15 | |||
16 | import java.util.List; | ||
17 | |||
18 | /** | ||
19 | * @author XiangHan | ||
20 | * @date 2021-11-02 | ||
21 | */ | ||
22 | @Service | ||
23 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
24 | public class TrTaskProgressServiceImpl implements TrTaskProgressService { | ||
25 | |||
26 | @Autowired | ||
27 | private TrTaskProgressRepository trTaskProgressRepository; | ||
28 | |||
29 | @Autowired | ||
30 | private TrTaskProgressMapper trTaskProgressMapper; | ||
31 | |||
32 | @Override | ||
33 | public TrTaskProgressDTO findById(Long id) { | ||
34 | TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new); | ||
35 | ValidationUtil.isNull(TrTaskProgress.getId(),"TrTaskProgress","id",id); | ||
36 | return this.trTaskProgressMapper.toDto(TrTaskProgress); | ||
37 | } | ||
38 | |||
39 | @Override | ||
40 | @Transactional(rollbackFor = Exception.class) | ||
41 | public void create(TrTaskProgress resources) { | ||
42 | this.trTaskProgressRepository.save(resources); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | @Transactional(rollbackFor = Exception.class) | ||
47 | public void update(TrTaskProgress resources) { | ||
48 | TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new); | ||
49 | ValidationUtil.isNull( TrTaskProgress.getId(),"TrTaskProgress","id",resources.getId()); | ||
50 | TrTaskProgress.copy(resources); | ||
51 | this.trTaskProgressRepository.save(TrTaskProgress); | ||
52 | } | ||
53 | |||
54 | @Override | ||
55 | @Transactional(rollbackFor = Exception.class) | ||
56 | public void delete(Long id) { | ||
57 | Assert.notNull(id, "The given id must not be null!"); | ||
58 | TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseThrow( | ||
59 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TrTaskProgress.class, id), 1)); | ||
60 | this.trTaskProgressRepository.delete(TrTaskProgress); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) { | ||
65 | return this.trTaskProgressMapper.toDto(this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1)); | ||
66 | } | ||
67 | |||
68 | |||
69 | } |
src/main/java/com/topdraw/business/module/task/progress/service/mapper/TrTaskProgressMapper.java
0 → 100644
1 | package com.topdraw.business.module.task.progress.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | ||
5 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-11-02 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface TrTaskProgressMapper extends BaseMapper<TrTaskProgressDTO, TrTaskProgress> { | ||
15 | |||
16 | } |
... | @@ -14,5 +14,4 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat | ... | @@ -14,5 +14,4 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat |
14 | 14 | ||
15 | List<Task> findByTaskTemplateId(Long taskTemplateId); | 15 | List<Task> findByTaskTemplateId(Long taskTemplateId); |
16 | 16 | ||
17 | // List<Task> findByTemplateId(Long taskTemplateId); | ||
18 | } | 17 | } | ... | ... |
... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.task.service; | ... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.task.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.task.domain.Task; | 3 | import com.topdraw.business.module.task.domain.Task; |
4 | import com.topdraw.business.module.task.service.dto.TaskDTO; | 4 | import com.topdraw.business.module.task.service.dto.TaskDTO; |
5 | import com.topdraw.business.module.task.service.dto.TaskQueryCriteria; | ||
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,32 +12,16 @@ import java.util.Map; | ... | @@ -15,32 +12,16 @@ import java.util.Map; |
15 | public interface TaskService { | 12 | public interface TaskService { |
16 | 13 | ||
17 | /** | 14 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(TaskQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<TaskDTO> | ||
29 | */ | ||
30 | List<TaskDTO> queryAll(TaskQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | 15 | * 根据ID查询 |
34 | * @param id ID | 16 | * @param id ID |
35 | * @return TaskDTO | 17 | * @return TaskDTO |
36 | */ | 18 | */ |
37 | TaskDTO findById(Long id); | 19 | TaskDTO findById(Long id); |
38 | 20 | ||
39 | void create(Task resources); | 21 | /** |
40 | 22 | * | |
41 | void update(Task resources); | 23 | * @param taskTemplateId |
42 | 24 | * @return | |
43 | void delete(Long id); | 25 | */ |
44 | |||
45 | List<Task> findByTemplateId(Long taskTemplateId); | 26 | List<Task> findByTemplateId(Long taskTemplateId); |
46 | } | 27 | } | ... | ... |
... | @@ -4,6 +4,7 @@ import lombok.Data; | ... | @@ -4,6 +4,7 @@ import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
7 | import java.time.LocalDateTime; | ||
7 | 8 | ||
8 | 9 | ||
9 | /** | 10 | /** |
... | @@ -15,69 +16,69 @@ public class TaskDTO implements Serializable { | ... | @@ -15,69 +16,69 @@ public class TaskDTO implements Serializable { |
15 | 16 | ||
16 | private Long id; | 17 | private Long id; |
17 | 18 | ||
18 | // 任务模板id | 19 | /** 任务模板id */ |
19 | private Long taskTemplateId; | 20 | private Long taskTemplateId; |
20 | 21 | ||
21 | // 任务重复类型,-1:不限次;1:单次;>1:多次 | 22 | /** 任务重复类型,-1:不限次;1:单次;>1:多次 */ |
22 | private Integer taskRepeatType; | 23 | private Integer taskRepeatType; |
23 | 24 | ||
24 | // 任务每日重置 0:不重置;1:重置 | 25 | /** 任务每日重置 0:不重置;1:重置 */ |
25 | private Integer taskDailyReset; | 26 | private Integer taskDailyReset; |
26 | 27 | ||
27 | // 行为量(完成此任务需要多少次相同行为的触发) | 28 | /** 行为量(完成此任务需要多少次相同行为的触发) */ |
28 | private Integer actionAmount; | 29 | private Integer actionAmount; |
29 | 30 | ||
30 | // 任务生效时间 | 31 | /** 任务生效时间 */ |
31 | private Timestamp validTime; | 32 | private Timestamp validTime; |
32 | 33 | ||
33 | // 任务失效时间 | 34 | /** 任务失效时间 */ |
34 | private Timestamp expireTime; | 35 | private LocalDateTime expireTime; |
35 | 36 | ||
36 | // 显示顺序 | 37 | /** 显示顺序 */ |
37 | private Integer sequence; | 38 | private Integer sequence; |
38 | 39 | ||
39 | // 获得成长值 | 40 | /** 获得成长值 */ |
40 | private Long rewardExp; | 41 | private Long rewardExp; |
41 | 42 | ||
42 | // 获得积分 | 43 | /** 获得积分 */ |
43 | private Long rewardPoints; | 44 | private Long rewardPoints; |
44 | 45 | ||
45 | // 积分过期时间(空为不过期) | 46 | /** 积分过期时间(空为不过期) */ |
46 | private Long rewardPointsExpireTime; | 47 | private Long rewardPointsExpireTime; |
47 | 48 | ||
48 | // 能够获取该任务的用户分组,为空则都能获取 | 49 | /** 能够获取该任务的用户分组,为空则都能获取 */ |
49 | private String groups; | 50 | private String groups; |
50 | 51 | ||
51 | // 会员等级门槛(0表示无门槛) | 52 | /** 会员等级门槛(0表示无门槛) */ |
52 | private Integer memberLevel; | 53 | private Integer memberLevel; |
53 | 54 | ||
54 | // 会员vip门槛(0表示没有门槛) | 55 | /** 会员vip门槛(0表示没有门槛) */ |
55 | private Integer memberVip; | 56 | private Integer memberVip; |
56 | 57 | ||
57 | // 权益id | 58 | /** 权益id */ |
58 | private Long rightsId; | 59 | private Long rightsId; |
59 | 60 | ||
60 | // 权益数量(活动机会次数、优惠券数量、奖品数量) | 61 | /** 权益数量(活动机会次数、优惠券数量、奖品数量) */ |
61 | private Integer rightsAmount; | 62 | private Integer rightsAmount; |
62 | 63 | ||
63 | // 权益2id | 64 | /** 权益2id */ |
64 | private Long rights2Id; | 65 | private Long rights2Id; |
65 | 66 | ||
66 | // 权益2数量 | 67 | /** 权益2数量 */ |
67 | private Integer rights2Amount; | 68 | private Integer rights2Amount; |
68 | 69 | ||
69 | // 权益3id | 70 | /** 权益3id */ |
70 | private Long rights3Id; | 71 | private Long rights3Id; |
71 | 72 | ||
72 | // 权益3数量 | 73 | /** 权益3数量 */ |
73 | private Integer rights3Amount; | 74 | private Integer rights3Amount; |
74 | 75 | ||
75 | // 状态 0:失效;1:生效 | 76 | /** 状态 0:失效;1:生效 */ |
76 | private Integer status; | 77 | private Integer status; |
77 | 78 | ||
78 | // 创建时间 | 79 | /** 创建时间 */ |
79 | private Timestamp createTime; | 80 | private Timestamp createTime; |
80 | 81 | ||
81 | // 更新时间 | 82 | /** 更新时间 */ |
82 | private Timestamp updateTime; | 83 | private Timestamp updateTime; |
83 | } | 84 | } | ... | ... |
... | @@ -4,22 +4,14 @@ import com.topdraw.business.module.task.domain.Task; | ... | @@ -4,22 +4,14 @@ import com.topdraw.business.module.task.domain.Task; |
4 | import com.topdraw.business.module.task.repository.TaskRepository; | 4 | import com.topdraw.business.module.task.repository.TaskRepository; |
5 | import com.topdraw.business.module.task.service.TaskService; | 5 | import com.topdraw.business.module.task.service.TaskService; |
6 | import com.topdraw.business.module.task.service.dto.TaskDTO; | 6 | import com.topdraw.business.module.task.service.dto.TaskDTO; |
7 | import com.topdraw.business.module.task.service.dto.TaskQueryCriteria; | ||
8 | import com.topdraw.business.module.task.service.mapper.TaskMapper; | 7 | import com.topdraw.business.module.task.service.mapper.TaskMapper; |
9 | import com.topdraw.utils.PageUtil; | ||
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.ValidationUtil; | 8 | import com.topdraw.utils.ValidationUtil; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 9 | 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; | 10 | import org.springframework.stereotype.Service; |
17 | import org.springframework.transaction.annotation.Propagation; | 11 | import org.springframework.transaction.annotation.Propagation; |
18 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
19 | import org.springframework.util.Assert; | ||
20 | 13 | ||
21 | import java.util.List; | 14 | import java.util.List; |
22 | import java.util.Map; | ||
23 | import java.util.Objects; | 15 | import java.util.Objects; |
24 | 16 | ||
25 | /** | 17 | /** |
... | @@ -31,56 +23,21 @@ import java.util.Objects; | ... | @@ -31,56 +23,21 @@ import java.util.Objects; |
31 | public class TaskServiceImpl implements TaskService { | 23 | public class TaskServiceImpl implements TaskService { |
32 | 24 | ||
33 | @Autowired | 25 | @Autowired |
34 | private TaskRepository TaskRepository; | 26 | private TaskMapper taskMapper; |
35 | |||
36 | @Autowired | 27 | @Autowired |
37 | private TaskMapper TaskMapper; | 28 | private TaskRepository taskRepository; |
38 | |||
39 | @Override | ||
40 | public Map<String, Object> queryAll(TaskQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<Task> page = TaskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(TaskMapper::toDto)); | ||
43 | } | ||
44 | 29 | ||
45 | @Override | ||
46 | public List<TaskDTO> queryAll(TaskQueryCriteria criteria) { | ||
47 | return TaskMapper.toDto(TaskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | 30 | ||
50 | @Override | 31 | @Override |
51 | public TaskDTO findById(Long id) { | 32 | public TaskDTO findById(Long id) { |
52 | Task Task = TaskRepository.findById(id).orElseGet(Task::new); | 33 | Task Task = this.taskRepository.findById(id).orElseGet(Task::new); |
53 | ValidationUtil.isNull(Task.getId(),"Task","id",id); | 34 | ValidationUtil.isNull(Task.getId(),"Task","id",id); |
54 | return TaskMapper.toDto(Task); | 35 | return this.taskMapper.toDto(Task); |
55 | } | ||
56 | |||
57 | @Override | ||
58 | @Transactional(rollbackFor = Exception.class) | ||
59 | public void create(Task resources) { | ||
60 | TaskRepository.save(resources); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | @Transactional(rollbackFor = Exception.class) | ||
65 | public void update(Task resources) { | ||
66 | Task Task = TaskRepository.findById(resources.getId()).orElseGet(Task::new); | ||
67 | ValidationUtil.isNull( Task.getId(),"Task","id",resources.getId()); | ||
68 | Task.copy(resources); | ||
69 | TaskRepository.save(Task); | ||
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 | Task Task = TaskRepository.findById(id).orElseThrow( | ||
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Task.class, id), 1)); | ||
78 | TaskRepository.delete(Task); | ||
79 | } | 36 | } |
80 | 37 | ||
81 | @Override | 38 | @Override |
82 | public List<Task> findByTemplateId(Long taskTemplateId) { | 39 | public List<Task> findByTemplateId(Long taskTemplateId) { |
83 | return Objects.nonNull(taskTemplateId) ? this.TaskRepository.findByTaskTemplateId(taskTemplateId) : null; | 40 | return Objects.nonNull(taskTemplateId) ? this.taskRepository.findByTaskTemplateId(taskTemplateId) : null; |
84 | } | 41 | } |
85 | 42 | ||
86 | 43 | ... | ... |
... | @@ -4,6 +4,7 @@ import com.topdraw.business.module.task.template.domain.TaskTemplate; | ... | @@ -4,6 +4,7 @@ import com.topdraw.business.module.task.template.domain.TaskTemplate; |
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; | ||
7 | import java.util.Optional; | 8 | import java.util.Optional; |
8 | 9 | ||
9 | /** | 10 | /** |
... | @@ -15,4 +16,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long | ... | @@ -15,4 +16,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long |
15 | Optional<TaskTemplate> findFirstByCode(String code); | 16 | Optional<TaskTemplate> findFirstByCode(String code); |
16 | 17 | ||
17 | TaskTemplate findByEvent(String event); | 18 | TaskTemplate findByEvent(String event); |
19 | |||
20 | List<TaskTemplate> findByType(Integer event); | ||
18 | } | 21 | } | ... | ... |
... | @@ -50,4 +50,6 @@ public interface TaskTemplateService { | ... | @@ -50,4 +50,6 @@ public interface TaskTemplateService { |
50 | TaskTemplateDTO getByCode(String code); | 50 | TaskTemplateDTO getByCode(String code); |
51 | 51 | ||
52 | TaskTemplate findByEvent(String event); | 52 | TaskTemplate findByEvent(String event); |
53 | |||
54 | List<TaskTemplate> findByType(Integer event); | ||
53 | } | 55 | } | ... | ... |
1 | package com.topdraw.business.module.task.template.service.impl; | 1 | package com.topdraw.business.module.task.template.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.task.template.domain.TaskTemplate; | 3 | import com.topdraw.business.module.task.template.domain.TaskTemplate; |
4 | import com.topdraw.business.module.task.template.repository.TaskTemplateRepository; | ||
5 | import com.topdraw.business.module.task.template.service.TaskTemplateService; | 4 | import com.topdraw.business.module.task.template.service.TaskTemplateService; |
6 | import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO; | 5 | import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO; |
7 | import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria; | 6 | import com.topdraw.business.module.task.template.service.dto.TaskTemplateQueryCriteria; |
8 | import com.topdraw.business.module.task.template.service.mapper.TaskTemplateMapper; | ||
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; |
... | @@ -21,6 +19,7 @@ import org.springframework.util.Assert; | ... | @@ -21,6 +19,7 @@ import org.springframework.util.Assert; |
21 | 19 | ||
22 | import java.util.List; | 20 | import java.util.List; |
23 | import java.util.Map; | 21 | import java.util.Map; |
22 | import java.util.Objects; | ||
24 | 23 | ||
25 | /** | 24 | /** |
26 | * @author XiangHan | 25 | * @author XiangHan |
... | @@ -31,10 +30,10 @@ import java.util.Map; | ... | @@ -31,10 +30,10 @@ import java.util.Map; |
31 | public class TaskTemplateServiceImpl implements TaskTemplateService { | 30 | public class TaskTemplateServiceImpl implements TaskTemplateService { |
32 | 31 | ||
33 | @Autowired | 32 | @Autowired |
34 | private TaskTemplateRepository TaskTemplateRepository; | 33 | private com.topdraw.business.module.task.template.repository.TaskTemplateRepository TaskTemplateRepository; |
35 | 34 | ||
36 | @Autowired | 35 | @Autowired |
37 | private TaskTemplateMapper TaskTemplateMapper; | 36 | private com.topdraw.business.module.task.template.service.mapper.TaskTemplateMapper TaskTemplateMapper; |
38 | 37 | ||
39 | @Override | 38 | @Override |
40 | public Map<String, Object> queryAll(TaskTemplateQueryCriteria criteria, Pageable pageable) { | 39 | public Map<String, Object> queryAll(TaskTemplateQueryCriteria criteria, Pageable pageable) { |
... | @@ -49,7 +48,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -49,7 +48,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
49 | 48 | ||
50 | @Override | 49 | @Override |
51 | public TaskTemplateDTO findById(Long id) { | 50 | public TaskTemplateDTO findById(Long id) { |
52 | TaskTemplate TaskTemplate = TaskTemplateRepository.findById(id).orElseGet(TaskTemplate::new); | 51 | TaskTemplate TaskTemplate = TaskTemplateRepository.findById(id).orElseGet(com.topdraw.business.module.task.template.domain.TaskTemplate::new); |
53 | ValidationUtil.isNull(TaskTemplate.getId(),"TaskTemplate","id",id); | 52 | ValidationUtil.isNull(TaskTemplate.getId(),"TaskTemplate","id",id); |
54 | return TaskTemplateMapper.toDto(TaskTemplate); | 53 | return TaskTemplateMapper.toDto(TaskTemplate); |
55 | } | 54 | } |
... | @@ -63,7 +62,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -63,7 +62,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
63 | @Override | 62 | @Override |
64 | @Transactional(rollbackFor = Exception.class) | 63 | @Transactional(rollbackFor = Exception.class) |
65 | public void update(TaskTemplate resources) { | 64 | public void update(TaskTemplate resources) { |
66 | TaskTemplate TaskTemplate = TaskTemplateRepository.findById(resources.getId()).orElseGet(TaskTemplate::new); | 65 | TaskTemplate TaskTemplate = TaskTemplateRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.task.template.domain.TaskTemplate::new); |
67 | ValidationUtil.isNull( TaskTemplate.getId(),"TaskTemplate","id",resources.getId()); | 66 | ValidationUtil.isNull( TaskTemplate.getId(),"TaskTemplate","id",resources.getId()); |
68 | TaskTemplate.copy(resources); | 67 | TaskTemplate.copy(resources); |
69 | TaskTemplateRepository.save(TaskTemplate); | 68 | TaskTemplateRepository.save(TaskTemplate); |
... | @@ -74,7 +73,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -74,7 +73,7 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
74 | public void delete(Long id) { | 73 | public void delete(Long id) { |
75 | Assert.notNull(id, "The given id must not be null!"); | 74 | Assert.notNull(id, "The given id must not be null!"); |
76 | TaskTemplate TaskTemplate = TaskTemplateRepository.findById(id).orElseThrow( | 75 | TaskTemplate TaskTemplate = TaskTemplateRepository.findById(id).orElseThrow( |
77 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TaskTemplate.class, id), 1)); | 76 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.task.template.domain.TaskTemplate.class, id), 1)); |
78 | TaskTemplateRepository.delete(TaskTemplate); | 77 | TaskTemplateRepository.delete(TaskTemplate); |
79 | } | 78 | } |
80 | 79 | ||
... | @@ -85,8 +84,15 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -85,8 +84,15 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
85 | : new TaskTemplateDTO(); | 84 | : new TaskTemplateDTO(); |
86 | } | 85 | } |
87 | 86 | ||
87 | |||
88 | @Override | 88 | @Override |
89 | public TaskTemplate findByEvent(String event) { | 89 | public TaskTemplate findByEvent(String event) { |
90 | return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null; | 90 | return StringUtils.isNotEmpty(event) ? this.TaskTemplateRepository.findByEvent(event) : null; |
91 | } | 91 | } |
92 | |||
93 | // @Cacheable(cacheNames = "uc-admin_taskTemplate" , key = "#event") | ||
94 | @Override | ||
95 | public List<TaskTemplate> findByType(Integer event) { | ||
96 | return Objects.nonNull(event) ? this.TaskTemplateRepository.findByType(event) : null; | ||
97 | } | ||
92 | } | 98 | } | ... | ... |
... | @@ -2,6 +2,9 @@ package com.topdraw.business.module.user.iptv.domain; | ... | @@ -2,6 +2,9 @@ package com.topdraw.business.module.user.iptv.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.CreateGroup; | ||
7 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
5 | import lombok.Data; | 8 | import lombok.Data; |
6 | import lombok.experimental.Accessors; | 9 | import lombok.experimental.Accessors; |
7 | import org.springframework.data.annotation.CreatedDate; | 10 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -12,7 +15,6 @@ import javax.persistence.*; | ... | @@ -12,7 +15,6 @@ import javax.persistence.*; |
12 | import javax.validation.constraints.NotNull; | 15 | import javax.validation.constraints.NotNull; |
13 | import java.io.Serializable; | 16 | import java.io.Serializable; |
14 | import java.sql.Timestamp; | 17 | import java.sql.Timestamp; |
15 | import java.time.LocalDateTime; | ||
16 | 18 | ||
17 | /** | 19 | /** |
18 | * @author XiangHan | 20 | * @author XiangHan |
... | @@ -23,8 +25,9 @@ import java.time.LocalDateTime; | ... | @@ -23,8 +25,9 @@ import java.time.LocalDateTime; |
23 | @EntityListeners(AuditingEntityListener.class) | 25 | @EntityListeners(AuditingEntityListener.class) |
24 | @Accessors(chain = true) | 26 | @Accessors(chain = true) |
25 | @Table(name="uc_user_tv") | 27 | @Table(name="uc_user_tv") |
26 | public class UserTv implements Serializable { | 28 | public class UserTv extends AsyncMqModule implements Serializable { |
27 | 29 | ||
30 | @NotNull(message = "visUserId can't be null !",groups = {CreateGroup.class}) | ||
28 | @Column(name = "vis_user_id") | 31 | @Column(name = "vis_user_id") |
29 | private Long visUserId; | 32 | private Long visUserId; |
30 | 33 | ||
... | @@ -32,102 +35,100 @@ public class UserTv implements Serializable { | ... | @@ -32,102 +35,100 @@ public class UserTv implements Serializable { |
32 | @Column(name = "priority_member_code") | 35 | @Column(name = "priority_member_code") |
33 | private String priorityMemberCode; | 36 | private String priorityMemberCode; |
34 | 37 | ||
35 | @Transient | 38 | /** ID */ |
36 | private String memberCode; | ||
37 | |||
38 | // ID | ||
39 | @Id | 39 | @Id |
40 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 40 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
41 | @Column(name = "id") | 41 | @Column(name = "id") |
42 | private Long id; | 42 | private Long id; |
43 | 43 | ||
44 | // 人ID | 44 | /** 人ID */ |
45 | @Column(name = "`person_id`") | 45 | @Column(name = "person_id") |
46 | private Long personId; | 46 | private Long personId; |
47 | 47 | ||
48 | // 运营商平台 | 48 | /** 运营商平台 */ |
49 | @Column(name = "`platform`") | 49 | @Column(name = "platform") |
50 | private String platform; | 50 | private String platform; |
51 | 51 | ||
52 | // 运营商平台账号 | 52 | /** 运营商平台账号 */ |
53 | @Column(name = "`platform_account`") | 53 | @Column(name = "platform_account") |
54 | @NotNull(message = "platformAccount can't be null !",groups = {CreateGroup.class, UpdateGroup.class}) | ||
54 | private String platformAccount; | 55 | private String platformAccount; |
55 | 56 | ||
56 | // 手机号 | 57 | /** 手机号 */ |
57 | @Column(name = "`cellphone`") | 58 | @Column(name = "cellphone") |
58 | private String cellphone; | 59 | private String cellphone; |
59 | 60 | ||
60 | // 用户名 | 61 | /** 用户名 */ |
61 | @Column(name = "`username`") | 62 | @Column(name = "username") |
62 | private String username; | 63 | private String username; |
63 | 64 | ||
64 | // 密码 MD5 | 65 | /** 密码 MD5 */ |
65 | @Column(name = "`password`") | 66 | @Column(name = "password") |
66 | private String password; | 67 | private String password; |
67 | 68 | ||
68 | // 昵称 Base64 | 69 | /** 昵称 Base64 */ |
69 | @Column(name = "`nickname`") | 70 | @Column(name = "nickname") |
70 | private String nickname; | 71 | private String nickname; |
71 | 72 | ||
72 | // 头像 | 73 | /** 头像 */ |
73 | @Column(name = "`image`") | 74 | @Column(name = "image") |
74 | private String image; | 75 | private String image; |
75 | 76 | ||
76 | // 登录天数(总天数) | 77 | /** 登录天数(总天数) */ |
77 | @Column(name = "`login_days`") | 78 | @Column(name = "login_days") |
78 | private Integer loginDays; | 79 | private Integer loginDays; |
79 | 80 | ||
80 | // 连续登录天数 | 81 | /** 连续登录天数 */ |
81 | @Column(name = "`continue_days`") | 82 | @Column(name = "continue_days") |
82 | private Integer continueDays; | 83 | private Integer continueDays; |
83 | 84 | ||
84 | /** 活跃时间 */ | 85 | /** 活跃时间 */ |
85 | @Column(name = "active_time") | 86 | @Column(name = "active_time") |
86 | private Timestamp activeTime; | 87 | private Timestamp activeTime; |
87 | 88 | ||
88 | // 分组 分组ID用逗号分隔 | 89 | /** 分组 分组ID用逗号分隔 */ |
89 | @Column(name = "`groups`") | 90 | @Column(name = "groups") |
90 | private String groups; | 91 | private String groups; |
91 | 92 | ||
92 | // 标签 标签用逗号分隔 | 93 | /** 标签 标签用逗号分隔 */ |
93 | @Column(name = "`tags`") | 94 | @Column(name = "tags") |
94 | private String tags; | 95 | private String tags; |
95 | 96 | ||
96 | // 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 | 97 | /** 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 */ |
97 | @Column(name = "`login_type`") | 98 | @Column(name = "login_type") |
98 | private Integer loginType; | 99 | private Integer loginType; |
99 | 100 | ||
100 | // 状态 0-下线 1-上线 | 101 | /** 状态 0-下线 1-上线 */ |
101 | @Column(name = "`status`") | 102 | @Column(name = "status") |
102 | private Integer status; | 103 | private Integer status; |
103 | 104 | ||
104 | // 描述 | 105 | /** 描述 */ |
105 | @Column(name = "`description`") | 106 | @Column(name = "description") |
106 | private String description; | 107 | private String description; |
107 | 108 | ||
108 | // 创建者 | 109 | /** 创建者 */ |
109 | @Column(name = "`create_by`") | 110 | @Column(name = "create_by") |
110 | private String createBy; | 111 | private String createBy; |
111 | 112 | ||
112 | // 创建时间 | 113 | /** 创建时间 */ |
113 | @CreatedDate | 114 | @CreatedDate |
114 | @Column(name = "`create_time`") | 115 | @Column(name = "create_time") |
115 | private LocalDateTime createTime; | 116 | private Timestamp createTime; |
116 | 117 | ||
117 | // 更新者 | 118 | /** 更新者 */ |
118 | @Column(name = "`update_by`") | 119 | @Column(name = "update_by") |
119 | private String updateBy; | 120 | private String updateBy; |
120 | 121 | ||
121 | // 更新时间 | 122 | /** 更新时间 */ |
122 | @LastModifiedDate | 123 | @LastModifiedDate |
123 | @Column(name = "`update_time`") | 124 | @Column(name = "update_time") |
124 | private LocalDateTime updateTime; | 125 | private Timestamp updateTime; |
125 | 126 | ||
126 | // 会员id | 127 | /** 会员id */ |
127 | @Column(name = "`member_id`") | 128 | @Column(name = "member_id") |
128 | private Long memberId; | 129 | private Long memberId; |
129 | 130 | ||
130 | public void copy(UserTv source){ | 131 | public void copy(UserTv source){ |
131 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | 132 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false)); |
132 | } | 133 | } |
133 | } | 134 | } | ... | ... |
... | @@ -44,7 +44,7 @@ public class UserTvBuilder { | ... | @@ -44,7 +44,7 @@ public class UserTvBuilder { |
44 | } | 44 | } |
45 | 45 | ||
46 | public static UserTv build(Long memberId , String memberCode , Long id , String platformAccount , String nickname , String username, | 46 | public static UserTv build(Long memberId , String memberCode , Long id , String platformAccount , String nickname , String username, |
47 | Integer loginDays , Integer status , Integer continueDays , String createBy , String updateBy, Long visUserId){ | 47 | Integer loginDays , Integer status ,Integer continueDays , String createBy , String updateBy,Long visUserId){ |
48 | Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL); | 48 | Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL); |
49 | Assert.notNull(memberCode, GlobeExceptionMsg.MEMBER_CODE_IS_NULL); | 49 | Assert.notNull(memberCode, GlobeExceptionMsg.MEMBER_CODE_IS_NULL); |
50 | Assert.notNull(platformAccount, GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); | 50 | Assert.notNull(platformAccount, GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); | ... | ... |
... | @@ -11,6 +11,7 @@ import java.util.Optional; | ... | @@ -11,6 +11,7 @@ import java.util.Optional; |
11 | * @date 2021-12-16 | 11 | * @date 2021-12-16 |
12 | */ | 12 | */ |
13 | public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecificationExecutor<UserTv> { | 13 | public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecificationExecutor<UserTv> { |
14 | |||
14 | Optional<UserTv> findByPlatformAccount(String platformAccount); | 15 | Optional<UserTv> findByPlatformAccount(String platformAccount); |
15 | 16 | ||
16 | Optional<UserTv> findByPriorityMemberCode(String memberCode); | 17 | Optional<UserTv> findByPriorityMemberCode(String memberCode); | ... | ... |
... | @@ -22,13 +22,13 @@ public interface UserTvService { | ... | @@ -22,13 +22,13 @@ public interface UserTvService { |
22 | * @param resources | 22 | * @param resources |
23 | * @return | 23 | * @return |
24 | */ | 24 | */ |
25 | UserTv create(UserTv resources); | 25 | UserTvDTO create(UserTv resources); |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * | 28 | * |
29 | * @param resources | 29 | * @param resources |
30 | */ | 30 | */ |
31 | void update(UserTv resources); | 31 | UserTvDTO update(UserTv resources); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * | 34 | * |
... | @@ -69,7 +69,7 @@ public interface UserTvService { | ... | @@ -69,7 +69,7 @@ public interface UserTvService { |
69 | * @param memberCode | 69 | * @param memberCode |
70 | * @return | 70 | * @return |
71 | */ | 71 | */ |
72 | boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId,String memberCode); | 72 | boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode); |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * | 75 | * |
... | @@ -77,5 +77,4 @@ public interface UserTvService { | ... | @@ -77,5 +77,4 @@ public interface UserTvService { |
77 | * @return | 77 | * @return |
78 | */ | 78 | */ |
79 | MemberDTO findMemberByPlatformAccount(String platformAccount); | 79 | MemberDTO findMemberByPlatformAccount(String platformAccount); |
80 | |||
81 | } | 80 | } | ... | ... |
... | @@ -4,7 +4,6 @@ import lombok.Data; | ... | @@ -4,7 +4,6 @@ import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
7 | import java.time.LocalDateTime; | ||
8 | 7 | ||
9 | 8 | ||
10 | /** | 9 | /** |
... | @@ -21,70 +20,70 @@ public class UserTvDTO implements Serializable { | ... | @@ -21,70 +20,70 @@ public class UserTvDTO implements Serializable { |
21 | /** 绑定的小屏账户会员编码 */ | 20 | /** 绑定的小屏账户会员编码 */ |
22 | private String priorityMemberCode; | 21 | private String priorityMemberCode; |
23 | 22 | ||
24 | // ID | 23 | /** ID */ |
25 | private Long id; | 24 | private Long id; |
26 | 25 | ||
27 | // 人ID | 26 | /** 人ID */ |
28 | private Long personId; | 27 | private Long personId; |
29 | 28 | ||
30 | // 运营商平台 | 29 | /** 运营商平台 */ |
31 | private String platform; | 30 | private String platform; |
32 | 31 | ||
33 | // 运营商平台账号 | 32 | /** 运营商平台账号 */ |
34 | private String platformAccount; | 33 | private String platformAccount; |
35 | 34 | ||
36 | // 手机号 | 35 | /** 手机号 */ |
37 | private String cellphone; | 36 | private String cellphone; |
38 | 37 | ||
39 | // 用户名 | 38 | /** 用户名 */ |
40 | private String username; | 39 | private String username; |
41 | 40 | ||
42 | // 密码 MD5 | 41 | /** 密码 MD5 */ |
43 | private String password; | 42 | private String password; |
44 | 43 | ||
45 | // 昵称 Base64 | 44 | /** 昵称 Base64 */ |
46 | private String nickname; | 45 | private String nickname; |
47 | 46 | ||
48 | // 头像 | 47 | /** 头像 */ |
49 | private String image; | 48 | private String image; |
50 | 49 | ||
51 | // 登录天数(总天数) | 50 | /** 登录天数(总天数) */ |
52 | private Integer loginDays; | 51 | private Integer loginDays; |
53 | 52 | ||
54 | // 连续登录天数 | 53 | /** 连续登录天数 */ |
55 | private Integer continueDays; | 54 | private Integer continueDays; |
56 | 55 | ||
57 | // 活跃时间 | 56 | /** 活跃时间 */ |
58 | private Timestamp activeTime; | 57 | private Timestamp activeTime; |
59 | 58 | ||
60 | // 分组 分组ID用逗号分隔 | 59 | /** 分组 分组ID用逗号分隔 */ |
61 | private String groups; | 60 | private String groups; |
62 | 61 | ||
63 | // 标签 标签用逗号分隔 | 62 | /** 标签 标签用逗号分隔 */ |
64 | private String tags; | 63 | private String tags; |
65 | 64 | ||
66 | // 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 | 65 | /** 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 */ |
67 | private Integer loginType; | 66 | private Integer loginType; |
68 | 67 | ||
69 | // 状态 0-下线 1-上线 | 68 | /** 状态 0-下线 1-上线 */ |
70 | private Integer status; | 69 | private Integer status; |
71 | 70 | ||
72 | // 描述 | 71 | /** 描述 */ |
73 | private String description; | 72 | private String description; |
74 | 73 | ||
75 | // 创建者 | 74 | /** 创建者 */ |
76 | private String createBy; | 75 | private String createBy; |
77 | 76 | ||
78 | // 创建时间 | 77 | /** 创建时间 */ |
79 | private LocalDateTime createTime; | 78 | private Timestamp createTime; |
80 | 79 | ||
81 | // 更新者 | 80 | /** 更新者 */ |
82 | private String updateBy; | 81 | private String updateBy; |
83 | 82 | ||
84 | // 更新时间 | 83 | /** 更新时间 */ |
85 | private LocalDateTime updateTime; | 84 | private Timestamp updateTime; |
86 | 85 | ||
87 | // 会员id | 86 | /** 会员id */ |
88 | private Long memberId; | 87 | private Long memberId; |
89 | } | 88 | } |
90 | 89 | ... | ... |
... | @@ -29,6 +29,7 @@ import java.util.Optional; | ... | @@ -29,6 +29,7 @@ import java.util.Optional; |
29 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 29 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
30 | public class UserTvServiceImpl implements UserTvService { | 30 | public class UserTvServiceImpl implements UserTvService { |
31 | 31 | ||
32 | |||
32 | @Autowired | 33 | @Autowired |
33 | private UserTvMapper userTvMapper; | 34 | private UserTvMapper userTvMapper; |
34 | @Autowired | 35 | @Autowired |
... | @@ -73,37 +74,38 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -73,37 +74,38 @@ public class UserTvServiceImpl implements UserTvService { |
73 | 74 | ||
74 | @Override | 75 | @Override |
75 | public UserTvDTO findById(Long id) { | 76 | public UserTvDTO findById(Long id) { |
76 | UserTv UserTv = this.userTvRepository.findById(id).orElseGet(UserTv::new); | 77 | UserTv UserTv = this.userTvRepository.findById(id).orElseGet(com.topdraw.business.module.user.iptv.domain.UserTv::new); |
77 | ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); | 78 | ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); |
78 | return this.userTvMapper.toDto(UserTv); | 79 | return this.userTvMapper.toDto(UserTv); |
79 | } | 80 | } |
80 | 81 | ||
81 | @Override | 82 | @Override |
82 | @Transactional(rollbackFor = Exception.class) | 83 | @Transactional(rollbackFor = Exception.class) |
83 | public UserTv create(UserTv resources) { | 84 | public UserTvDTO create(UserTv resources) { |
84 | MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode()); | 85 | MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode()); |
85 | if (Objects.nonNull(memberDTO)) { | 86 | if (Objects.nonNull(memberDTO)) { |
86 | Long id = memberDTO.getId(); | 87 | Long id = memberDTO.getId(); |
87 | resources.setMemberId(id); | 88 | resources.setMemberId(id); |
88 | this.userTvRepository.save(resources); | 89 | UserTv userTv = this.userTvRepository.save(resources); |
89 | return resources; | 90 | return this.userTvMapper.toDto(userTv); |
90 | } | 91 | } |
91 | return null; | 92 | return null; |
92 | } | 93 | } |
93 | 94 | ||
94 | @Override | 95 | @Override |
95 | @Transactional(rollbackFor = Exception.class) | 96 | @Transactional(rollbackFor = Exception.class) |
96 | public void update(UserTv resources) { | 97 | public UserTvDTO update(UserTv resources) { |
97 | UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | 98 | UserTv userTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); |
98 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); | 99 | ValidationUtil.isNull(userTv.getId(),"UserTv","id",resources.getId()); |
99 | UserTv.copy(resources); | 100 | userTv.copy(resources); |
100 | this.userTvRepository.save(UserTv); | 101 | UserTv _userTv = this.userTvRepository.save(userTv); |
102 | return this.userTvMapper.toDto(_userTv); | ||
101 | } | 103 | } |
102 | 104 | ||
103 | @Override | 105 | @Override |
104 | @Transactional(rollbackFor = Exception.class) | 106 | @Transactional(rollbackFor = Exception.class) |
105 | public void unbindPriorityMemberCode(UserTv resources) { | 107 | public void unbindPriorityMemberCode(UserTv resources) { |
106 | UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | 108 | UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.user.iptv.domain.UserTv::new); |
107 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); | 109 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); |
108 | UserTv.copy(resources); | 110 | UserTv.copy(resources); |
109 | this.userTvRepository.save(UserTv); | 111 | this.userTvRepository.save(UserTv); |
... | @@ -114,7 +116,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -114,7 +116,7 @@ public class UserTvServiceImpl implements UserTvService { |
114 | public void delete(Long id) { | 116 | public void delete(Long id) { |
115 | Assert.notNull(id, "The given id must not be null!"); | 117 | Assert.notNull(id, "The given id must not be null!"); |
116 | UserTv UserTv = this.userTvRepository.findById(id).orElseThrow( | 118 | UserTv UserTv = this.userTvRepository.findById(id).orElseThrow( |
117 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserTv.class, id), 1)); | 119 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.user.iptv.domain.UserTv.class, id), 1)); |
118 | this.userTvRepository.delete(UserTv); | 120 | this.userTvRepository.delete(UserTv); |
119 | } | 121 | } |
120 | 122 | ... | ... |
... | @@ -23,38 +23,38 @@ import java.sql.Timestamp; | ... | @@ -23,38 +23,38 @@ import java.sql.Timestamp; |
23 | @Table(name="uc_user_collection") | 23 | @Table(name="uc_user_collection") |
24 | public class UserCollection implements Serializable { | 24 | public class UserCollection implements Serializable { |
25 | 25 | ||
26 | // ID | 26 | /** ID */ |
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 | // 应用ID | 32 | /** 应用ID */ |
33 | @Column(name = "app_id") | 33 | @Column(name = "app_id") |
34 | private Long appId; | 34 | private Long appId; |
35 | 35 | ||
36 | // 用户ID | 36 | /** 用户ID */ |
37 | @Column(name = "user_id") | 37 | @Column(name = "user_id") |
38 | private Long userId; | 38 | private Long userId; |
39 | 39 | ||
40 | // 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅 | 40 | /** 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅 */ |
41 | @Column(name = "type") | 41 | @Column(name = "type") |
42 | private Integer type; | 42 | private Integer type; |
43 | 43 | ||
44 | // 收藏夹名称 | 44 | /** 收藏夹名称 */ |
45 | @Column(name = "name") | 45 | @Column(name = "name") |
46 | private String name; | 46 | private String name; |
47 | 47 | ||
48 | // 数量 | 48 | /** 数量 */ |
49 | @Column(name = "count") | 49 | @Column(name = "count") |
50 | private Integer count; | 50 | private Integer count; |
51 | 51 | ||
52 | // 创建时间 | 52 | /** 创建时间 */ |
53 | @CreatedDate | 53 | @CreatedDate |
54 | @Column(name = "create_time") | 54 | @Column(name = "create_time") |
55 | private Timestamp createTime; | 55 | private Timestamp createTime; |
56 | 56 | ||
57 | // 更新时间 | 57 | /** 更新时间 */ |
58 | @LastModifiedDate | 58 | @LastModifiedDate |
59 | @Column(name = "update_time") | 59 | @Column(name = "update_time") |
60 | private Timestamp updateTime; | 60 | private Timestamp updateTime; | ... | ... |
... | @@ -25,89 +25,89 @@ public class UserCollectionDetail implements Serializable { | ... | @@ -25,89 +25,89 @@ public class UserCollectionDetail implements Serializable { |
25 | @JoinColumn(name = "user_collection_id", insertable = false, updatable = false) | 25 | @JoinColumn(name = "user_collection_id", insertable = false, updatable = false) |
26 | private UserCollection userCollection; | 26 | private UserCollection userCollection; |
27 | 27 | ||
28 | // ID | 28 | /** ID */ |
29 | @Id | 29 | @Id |
30 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 30 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
31 | @Column(name = "id") | 31 | @Column(name = "id") |
32 | private Long id; | 32 | private Long id; |
33 | 33 | ||
34 | // 收藏夹ID | 34 | /** 收藏夹ID */ |
35 | @Column(name = "user_collection_id") | 35 | @Column(name = "user_collection_id") |
36 | private Long userCollectionId; | 36 | private Long userCollectionId; |
37 | 37 | ||
38 | // 自定义收藏内容的类型CODE,默认:DEFAULT | 38 | /** 自定义收藏内容的类型CODE,默认:DEFAULT */ |
39 | @Column(name = "detail_folder_code") | 39 | @Column(name = "detail_folder_code") |
40 | private String detailFolderCode; | 40 | private String detailFolderCode; |
41 | 41 | ||
42 | // 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL | 42 | /** 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL */ |
43 | @Column(name = "detail_type") | 43 | @Column(name = "detail_type") |
44 | private String detailType; | 44 | private String detailType; |
45 | 45 | ||
46 | // 收藏内容的ID | 46 | /** 收藏内容的ID */ |
47 | @Column(name = "detail_id") | 47 | @Column(name = "detail_id") |
48 | private Long detailId; | 48 | private Long detailId; |
49 | 49 | ||
50 | // 收藏内容的CODE | 50 | /** 收藏内容的CODE */ |
51 | @Column(name = "detail_code") | 51 | @Column(name = "detail_code") |
52 | private String detailCode; | 52 | private String detailCode; |
53 | 53 | ||
54 | // 收藏内容的剧集ID | 54 | /** 收藏内容的剧集ID */ |
55 | @Column(name = "detail_episode_id") | 55 | @Column(name = "detail_episode_id") |
56 | private Long detailEpisodeId; | 56 | private Long detailEpisodeId; |
57 | 57 | ||
58 | // 收藏内容的剧集CODE | 58 | /** 收藏内容的剧集CODE */ |
59 | @Column(name = "detail_episode_code") | 59 | @Column(name = "detail_episode_code") |
60 | private String detailEpisodeCode; | 60 | private String detailEpisodeCode; |
61 | 61 | ||
62 | // 收藏内容的名称 | 62 | /** 收藏内容的名称 */ |
63 | @Column(name = "detail_name") | 63 | @Column(name = "detail_name") |
64 | private String detailName; | 64 | private String detailName; |
65 | 65 | ||
66 | // 收藏内容的标记 | 66 | /** 收藏内容的标记 */ |
67 | @Column(name = "detail_mark") | 67 | @Column(name = "detail_mark") |
68 | private Integer detailMark; | 68 | private Integer detailMark; |
69 | 69 | ||
70 | // 收藏内容的图片 | 70 | /** 收藏内容的图片 */ |
71 | @Column(name = "detail_img") | 71 | @Column(name = "detail_img") |
72 | private String detailImg; | 72 | private String detailImg; |
73 | 73 | ||
74 | // 收藏内容的剧集序号 | 74 | /** 收藏内容的剧集序号 */ |
75 | @Column(name = "detail_index") | 75 | @Column(name = "detail_index") |
76 | private Integer detailIndex; | 76 | private Integer detailIndex; |
77 | 77 | ||
78 | // 收藏内容的剧集总数 | 78 | /** 收藏内容的剧集总数 */ |
79 | @Column(name = "detail_total_index") | 79 | @Column(name = "detail_total_index") |
80 | private Integer detailTotalIndex; | 80 | private Integer detailTotalIndex; |
81 | 81 | ||
82 | // 收藏内容的播放时间 | 82 | /** 收藏内容的播放时间 */ |
83 | @Column(name = "detail_play_time") | 83 | @Column(name = "detail_play_time") |
84 | private Integer detailPlayTime; | 84 | private Integer detailPlayTime; |
85 | 85 | ||
86 | // 收藏内容的总时间 | 86 | /** 收藏内容的总时间 */ |
87 | @Column(name = "detail_total_time") | 87 | @Column(name = "detail_total_time") |
88 | private Integer detailTotalTime; | 88 | private Integer detailTotalTime; |
89 | 89 | ||
90 | // 收藏内容在同一folder中的顺序 | 90 | /** 收藏内容在同一folder中的顺序 */ |
91 | @Column(name = "detail_sequence") | 91 | @Column(name = "detail_sequence") |
92 | private Integer detailSequence; | 92 | private Integer detailSequence; |
93 | 93 | ||
94 | // 收藏内容的评分 | 94 | /** 收藏内容的评分 */ |
95 | @Column(name = "detail_score") | 95 | @Column(name = "detail_score") |
96 | private Float detailScore; | 96 | private Float detailScore; |
97 | 97 | ||
98 | // 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅 | 98 | /** 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅 */ |
99 | @Column(name = "detail_like") | 99 | @Column(name = "detail_like") |
100 | private Integer detailLike; | 100 | private Integer detailLike; |
101 | 101 | ||
102 | // 收藏内容的扩展数据 | 102 | /** 收藏内容的扩展数据 */ |
103 | @Column(name = "detail_ext_data") | 103 | @Column(name = "detail_ext_data") |
104 | private String detailExtData; | 104 | private String detailExtData; |
105 | 105 | ||
106 | // 创建时间 | 106 | /** 创建时间 */ |
107 | @Column(name = "create_time") | 107 | @Column(name = "create_time") |
108 | private Timestamp createTime; | 108 | private Timestamp createTime; |
109 | 109 | ||
110 | // 更新时间 | 110 | /** 更新时间 */ |
111 | @Column(name = "update_time") | 111 | @Column(name = "update_time") |
112 | private Timestamp updateTime; | 112 | private Timestamp updateTime; |
113 | 113 | ... | ... |
... | @@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.JpaRepository; | ... | @@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.JpaRepository; |
6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
7 | 7 | ||
8 | import java.util.List; | 8 | import java.util.List; |
9 | import java.util.Optional; | ||
10 | 9 | ||
11 | /** | 10 | /** |
12 | * @author pengmengqing | 11 | * @author pengmengqing |
... | @@ -14,8 +13,6 @@ import java.util.Optional; | ... | @@ -14,8 +13,6 @@ import java.util.Optional; |
14 | */ | 13 | */ |
15 | public interface UserCollectionRepository extends JpaRepository<UserCollection, Long>, JpaSpecificationExecutor<UserCollection> { | 14 | public interface UserCollectionRepository extends JpaRepository<UserCollection, Long>, JpaSpecificationExecutor<UserCollection> { |
16 | 15 | ||
17 | Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long userId, Integer type, String name); | ||
18 | |||
19 | List<UserCollection> findByUserIdAndType(Long userId, Integer type); | 16 | List<UserCollection> findByUserIdAndType(Long userId, Integer type); |
20 | 17 | ||
21 | } | 18 | } | ... | ... |
... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.user.weixin.collection.service; | ... | @@ -2,11 +2,8 @@ package com.topdraw.business.module.user.weixin.collection.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail; | 3 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail; |
4 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO; | 4 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO; |
5 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria; | ||
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 pengmengqing | 9 | * @author pengmengqing |
... | @@ -15,27 +12,40 @@ import java.util.Map; | ... | @@ -15,27 +12,40 @@ import java.util.Map; |
15 | public interface UserCollectionDetailService { | 12 | public interface UserCollectionDetailService { |
16 | 13 | ||
17 | /** | 14 | /** |
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 根据ID查询 | 15 | * 根据ID查询 |
27 | * @param id ID | 16 | * @param id ID |
28 | * @return UserCollectionDetailDTO | 17 | * @return UserCollectionDetailDTO |
29 | */ | 18 | */ |
30 | UserCollectionDetailDTO findById(Long id); | 19 | UserCollectionDetailDTO findById(Long id); |
31 | 20 | ||
21 | /** | ||
22 | * | ||
23 | * @param resources | ||
24 | * @return | ||
25 | */ | ||
32 | UserCollectionDetailDTO create(UserCollectionDetail resources); | 26 | UserCollectionDetailDTO create(UserCollectionDetail resources); |
33 | 27 | ||
28 | /** | ||
29 | * | ||
30 | * @param resources | ||
31 | */ | ||
34 | void update(UserCollectionDetail resources); | 32 | void update(UserCollectionDetail resources); |
35 | 33 | ||
34 | /** | ||
35 | * | ||
36 | * @param id | ||
37 | */ | ||
36 | void delete(Long id); | 38 | void delete(Long id); |
37 | 39 | ||
40 | /** | ||
41 | * | ||
42 | * @param id | ||
43 | */ | ||
38 | void deleteAllByUserCollectionId(Long id); | 44 | void deleteAllByUserCollectionId(Long id); |
39 | 45 | ||
46 | /** | ||
47 | * | ||
48 | * @param userCollectionDetailOptional | ||
49 | */ | ||
40 | void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional); | 50 | void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional); |
41 | } | 51 | } | ... | ... |
... | @@ -2,13 +2,10 @@ package com.topdraw.business.module.user.weixin.collection.service; | ... | @@ -2,13 +2,10 @@ package com.topdraw.business.module.user.weixin.collection.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollection; | 3 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollection; |
4 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO; | 4 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO; |
5 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | 5 | ||
8 | import javax.servlet.http.HttpServletResponse; | 6 | import javax.servlet.http.HttpServletResponse; |
9 | import java.io.IOException; | 7 | import java.io.IOException; |
10 | import java.util.List; | 8 | import java.util.List; |
11 | import java.util.Map; | ||
12 | import java.util.Optional; | 9 | import java.util.Optional; |
13 | 10 | ||
14 | /** | 11 | /** |
... | @@ -18,38 +15,60 @@ import java.util.Optional; | ... | @@ -18,38 +15,60 @@ import java.util.Optional; |
18 | public interface UserCollectionService { | 15 | public interface UserCollectionService { |
19 | 16 | ||
20 | /** | 17 | /** |
21 | * 查询数据分页 | ||
22 | * @param criteria 条件参数 | ||
23 | * @param pageable 分页参数 | ||
24 | * @return Map<String,Object> | ||
25 | */ | ||
26 | Map<String,Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable); | ||
27 | |||
28 | /** | ||
29 | * 查询所有数据不分页 | ||
30 | * @param criteria 条件参数 | ||
31 | * @return List<UserCollectionDTO> | ||
32 | */ | ||
33 | List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria); | ||
34 | |||
35 | /** | ||
36 | * 根据ID查询 | 18 | * 根据ID查询 |
37 | * @param id ID | 19 | * @param id ID |
38 | * @return UserCollectionDTO | 20 | * @return UserCollectionDTO |
39 | */ | 21 | */ |
40 | UserCollectionDTO findById(Long id); | 22 | UserCollectionDTO findById(Long id); |
41 | 23 | ||
24 | /** | ||
25 | * | ||
26 | * @param resources | ||
27 | * @return | ||
28 | */ | ||
42 | UserCollectionDTO create(UserCollection resources); | 29 | UserCollectionDTO create(UserCollection resources); |
43 | 30 | ||
31 | /** | ||
32 | * | ||
33 | * @param resources | ||
34 | */ | ||
44 | void update(UserCollection resources); | 35 | void update(UserCollection resources); |
45 | 36 | ||
37 | /** | ||
38 | * | ||
39 | * @param id | ||
40 | */ | ||
46 | void delete(Long id); | 41 | void delete(Long id); |
47 | 42 | ||
43 | /** | ||
44 | * | ||
45 | * @param all | ||
46 | * @param response | ||
47 | * @throws IOException | ||
48 | */ | ||
48 | void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException; | 49 | void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException; |
49 | 50 | ||
51 | /** | ||
52 | * | ||
53 | * @param id | ||
54 | * @param type | ||
55 | * @return | ||
56 | */ | ||
50 | List<UserCollection> findByUserIdAndType(Long id, Integer type); | 57 | List<UserCollection> findByUserIdAndType(Long id, Integer type); |
51 | 58 | ||
59 | /** | ||
60 | * | ||
61 | * @param id | ||
62 | * @param type | ||
63 | * @param name | ||
64 | * @return | ||
65 | */ | ||
52 | Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name); | 66 | Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name); |
53 | 67 | ||
68 | /** | ||
69 | * | ||
70 | * @param userCollection | ||
71 | * @return | ||
72 | */ | ||
54 | UserCollection save(UserCollection userCollection); | 73 | UserCollection save(UserCollection userCollection); |
55 | } | 74 | } | ... | ... |
... | @@ -13,27 +13,27 @@ import java.sql.Timestamp; | ... | @@ -13,27 +13,27 @@ import java.sql.Timestamp; |
13 | @Data | 13 | @Data |
14 | public class UserCollectionDTO implements Serializable { | 14 | public class UserCollectionDTO implements Serializable { |
15 | 15 | ||
16 | // ID | 16 | /** ID */ |
17 | private Long id; | 17 | private Long id; |
18 | 18 | ||
19 | // 应用ID | 19 | /** 应用ID */ |
20 | private Long appId; | 20 | private Long appId; |
21 | 21 | ||
22 | // 用户ID | 22 | /** 用户ID */ |
23 | private Long userId; | 23 | private Long userId; |
24 | 24 | ||
25 | // 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅 | 25 | /** 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅 */ |
26 | private Integer type; | 26 | private Integer type; |
27 | 27 | ||
28 | // 收藏夹名称 | 28 | /** 收藏夹名称 */ |
29 | private String name; | 29 | private String name; |
30 | 30 | ||
31 | // 数量 | 31 | /** 数量 */ |
32 | private Integer count; | 32 | private Integer count; |
33 | 33 | ||
34 | // 创建时间 | 34 | /** 创建时间 */ |
35 | private Timestamp createTime; | 35 | private Timestamp createTime; |
36 | 36 | ||
37 | // 更新时间 | 37 | /** 更新时间 */ |
38 | private Timestamp updateTime; | 38 | private Timestamp updateTime; |
39 | } | 39 | } | ... | ... |
... | @@ -14,71 +14,71 @@ import java.sql.Timestamp; | ... | @@ -14,71 +14,71 @@ import java.sql.Timestamp; |
14 | @Data | 14 | @Data |
15 | public class UserCollectionDetailDTO implements Serializable { | 15 | public class UserCollectionDetailDTO implements Serializable { |
16 | 16 | ||
17 | // ID | 17 | /** ID */ |
18 | private Long id; | 18 | private Long id; |
19 | 19 | ||
20 | // 收藏夹ID | 20 | /** 收藏夹ID */ |
21 | private Long userCollectionId; | 21 | private Long userCollectionId; |
22 | 22 | ||
23 | // 自定义收藏内容的类型CODE,默认:DEFAULT | 23 | /** 自定义收藏内容的类型CODE,默认:DEFAULT */ |
24 | private String detailFolderCode; | 24 | private String detailFolderCode; |
25 | 25 | ||
26 | // 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL | 26 | /** 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL */ |
27 | private String detailType; | 27 | private String detailType; |
28 | 28 | ||
29 | // 收藏内容的ID | 29 | /** 收藏内容的ID */ |
30 | private Long detailId; | 30 | private Long detailId; |
31 | 31 | ||
32 | // 收藏内容的CODE | 32 | /** 收藏内容的CODE */ |
33 | private String detailCode; | 33 | private String detailCode; |
34 | 34 | ||
35 | // 收藏内容的剧集ID | 35 | /** 收藏内容的剧集ID */ |
36 | private Long detailEpisodeId; | 36 | private Long detailEpisodeId; |
37 | 37 | ||
38 | // 收藏内容的剧集CODE | 38 | /** 收藏内容的剧集CODE */ |
39 | private String detailEpisodeCode; | 39 | private String detailEpisodeCode; |
40 | 40 | ||
41 | // 收藏内容的名称 | 41 | /** 收藏内容的名称 */ |
42 | private String detailName; | 42 | private String detailName; |
43 | 43 | ||
44 | // 收藏内容的标记 | 44 | /** 收藏内容的标记 */ |
45 | private Integer detailMark; | 45 | private Integer detailMark; |
46 | 46 | ||
47 | // 收藏内容的图片 | 47 | /** 收藏内容的图片 */ |
48 | private String detailImg; | 48 | private String detailImg; |
49 | 49 | ||
50 | // 收藏内容的剧集序号 | 50 | /** 收藏内容的剧集序号 */ |
51 | private Integer detailIndex; | 51 | private Integer detailIndex; |
52 | 52 | ||
53 | // 收藏内容的剧集总数 | 53 | /** 收藏内容的剧集总数 */ |
54 | private Integer detailTotalIndex; | 54 | private Integer detailTotalIndex; |
55 | 55 | ||
56 | // 收藏内容的播放时间 | 56 | /** 收藏内容的播放时间 */ |
57 | private Integer detailPlayTime; | 57 | private Integer detailPlayTime; |
58 | 58 | ||
59 | // 收藏内容的总时间 | 59 | /** 收藏内容的总时间 */ |
60 | private Integer detailTotalTime; | 60 | private Integer detailTotalTime; |
61 | 61 | ||
62 | // 收藏内容在同一folder中的顺序 | 62 | /** 收藏内容在同一folder中的顺序 */ |
63 | private Integer detailSequence; | 63 | private Integer detailSequence; |
64 | 64 | ||
65 | // 收藏内容的评分 | 65 | /** 收藏内容的评分 */ |
66 | private Float detailScore; | 66 | private Float detailScore; |
67 | 67 | ||
68 | // 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅 | 68 | /** 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅 */ |
69 | private Integer detailLike; | 69 | private Integer detailLike; |
70 | 70 | ||
71 | // 收藏内容的扩展数据 | 71 | /** 收藏内容的扩展数据 */ |
72 | private String detailExtData; | 72 | private String detailExtData; |
73 | 73 | ||
74 | // 创建时间 | 74 | /** 创建时间 */ |
75 | @JsonFormat( | 75 | @JsonFormat( |
76 | pattern = "MM月dd日 HH:mm", | 76 | pattern = "MM月dd日 HH:mm", |
77 | timezone = "GMT+8" | 77 | timezone = "GMT+8" |
78 | ) | 78 | ) |
79 | private Timestamp createTime; | 79 | private Timestamp createTime; |
80 | 80 | ||
81 | // 更新时间 | 81 | /** 更新时间 */ |
82 | @JsonFormat( | 82 | @JsonFormat( |
83 | pattern = "MM月dd日 HH:mm", | 83 | pattern = "MM月dd日 HH:mm", |
84 | timezone = "GMT+8" | 84 | timezone = "GMT+8" | ... | ... |
1 | package com.topdraw.business.module.user.weixin.collection.service.dto; | ||
2 | |||
3 | import com.topdraw.annotation.Query; | ||
4 | import lombok.Data; | ||
5 | |||
6 | import javax.persistence.criteria.JoinType; | ||
7 | |||
8 | /** | ||
9 | * @author pengmengqing | ||
10 | * @date 2021-04-02 | ||
11 | */ | ||
12 | @Data | ||
13 | public class UserCollectionDetailQueryCriteria{ | ||
14 | |||
15 | private Long userWeixinId; | ||
16 | |||
17 | |||
18 | @Query(joinType = JoinType.INNER, joinName = "userCollection") | ||
19 | private Long userId; | ||
20 | |||
21 | @Query(joinType = JoinType.INNER, joinName = "userCollection") | ||
22 | private Integer type; | ||
23 | |||
24 | private String detailType; | ||
25 | |||
26 | private String detailFolderCode = "DEFAULT"; | ||
27 | |||
28 | private Long detailId; | ||
29 | } |
... | @@ -4,22 +4,16 @@ import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionD | ... | @@ -4,22 +4,16 @@ import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionD |
4 | import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository; | 4 | import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository; |
5 | import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService; | 5 | import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService; |
6 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO; | 6 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO; |
7 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria; | ||
8 | import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionDetailMapper; | 7 | import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionDetailMapper; |
9 | import com.topdraw.utils.PageUtil; | ||
10 | import com.topdraw.utils.QueryHelp; | ||
11 | import com.topdraw.utils.ValidationUtil; | 8 | import com.topdraw.utils.ValidationUtil; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.dao.EmptyResultDataAccessException; | 10 | 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; | 14 | import org.springframework.util.Assert; |
20 | 15 | ||
21 | import java.util.List; | 16 | import java.util.List; |
22 | import java.util.Map; | ||
23 | 17 | ||
24 | /** | 18 | /** |
25 | * @author pengmengqing | 19 | * @author pengmengqing |
... | @@ -31,15 +25,9 @@ public class UserCollectionDetailServiceImpl implements UserCollectionDetailServ | ... | @@ -31,15 +25,9 @@ public class UserCollectionDetailServiceImpl implements UserCollectionDetailServ |
31 | 25 | ||
32 | @Autowired | 26 | @Autowired |
33 | private UserCollectionDetailRepository userCollectionDetailRepository; | 27 | private UserCollectionDetailRepository userCollectionDetailRepository; |
34 | |||
35 | @Autowired | 28 | @Autowired |
36 | private UserCollectionDetailMapper userCollectionDetailMapper; | 29 | private UserCollectionDetailMapper userCollectionDetailMapper; |
37 | 30 | ||
38 | @Override | ||
39 | public Map<String, Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable) { | ||
40 | Page<UserCollectionDetail> page = userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
41 | return PageUtil.toPage(page.map(userCollectionDetailMapper::toDto)); | ||
42 | } | ||
43 | 31 | ||
44 | @Override | 32 | @Override |
45 | public UserCollectionDetailDTO findById(Long id) { | 33 | public UserCollectionDetailDTO findById(Long id) { | ... | ... |
... | @@ -4,16 +4,11 @@ import com.topdraw.business.module.user.weixin.collection.domain.UserCollection; | ... | @@ -4,16 +4,11 @@ import com.topdraw.business.module.user.weixin.collection.domain.UserCollection; |
4 | import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionRepository; | 4 | import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionRepository; |
5 | import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService; | 5 | import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService; |
6 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO; | 6 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO; |
7 | import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria; | ||
8 | import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionMapper; | 7 | import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionMapper; |
9 | import com.topdraw.utils.FileUtil; | 8 | import com.topdraw.utils.FileUtil; |
10 | import com.topdraw.utils.PageUtil; | ||
11 | import com.topdraw.utils.QueryHelp; | ||
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; | 11 | 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; |
... | @@ -37,19 +32,6 @@ public class UserCollectionServiceImpl implements UserCollectionService { | ... | @@ -37,19 +32,6 @@ public class UserCollectionServiceImpl implements UserCollectionService { |
37 | @Autowired | 32 | @Autowired |
38 | private UserCollectionMapper userCollectionMapper; | 33 | private UserCollectionMapper userCollectionMapper; |
39 | 34 | ||
40 | |||
41 | |||
42 | @Override | ||
43 | public Map<String, Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable) { | ||
44 | Page<UserCollection> page = userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
45 | return PageUtil.toPage(page.map(userCollectionMapper::toDto)); | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria) { | ||
50 | return userCollectionMapper.toDto(userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
51 | } | ||
52 | |||
53 | @Override | 35 | @Override |
54 | public UserCollectionDTO findById(Long id) { | 36 | public UserCollectionDTO findById(Long id) { |
55 | UserCollection userCollection = userCollectionRepository.findById(id).orElseGet(UserCollection::new); | 37 | UserCollection userCollection = userCollectionRepository.findById(id).orElseGet(UserCollection::new); | ... | ... |
... | @@ -2,7 +2,9 @@ package com.topdraw.business.module.user.weixin.domain; | ... | @@ -2,7 +2,9 @@ package com.topdraw.business.module.user.weixin.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.fasterxml.jackson.annotation.JsonFormat; |
6 | import com.topdraw.business.module.common.domain.AsyncMqModule; | ||
7 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
6 | import lombok.Data; | 8 | import lombok.Data; |
7 | import lombok.experimental.Accessors; | 9 | import lombok.experimental.Accessors; |
8 | import org.springframework.data.annotation.CreatedDate; | 10 | import org.springframework.data.annotation.CreatedDate; |
... | @@ -10,9 +12,9 @@ import org.springframework.data.annotation.LastModifiedDate; | ... | @@ -10,9 +12,9 @@ import org.springframework.data.annotation.LastModifiedDate; |
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | 12 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
11 | 13 | ||
12 | import javax.persistence.*; | 14 | import javax.persistence.*; |
15 | import javax.validation.constraints.NotNull; | ||
13 | import java.io.Serializable; | 16 | import java.io.Serializable; |
14 | import java.sql.Timestamp; | 17 | import java.sql.Timestamp; |
15 | import java.time.LocalDateTime; | ||
16 | 18 | ||
17 | /** | 19 | /** |
18 | * @author XiangHan | 20 | * @author XiangHan |
... | @@ -23,113 +25,117 @@ import java.time.LocalDateTime; | ... | @@ -23,113 +25,117 @@ import java.time.LocalDateTime; |
23 | @EntityListeners(AuditingEntityListener.class) | 25 | @EntityListeners(AuditingEntityListener.class) |
24 | @Accessors(chain = true) | 26 | @Accessors(chain = true) |
25 | @Table(name="uc_user_weixin") | 27 | @Table(name="uc_user_weixin") |
26 | public class UserWeixin extends DefaultAsyncMqModule implements Serializable { | 28 | public class UserWeixin extends AsyncMqModule implements Serializable { |
27 | 29 | ||
28 | // ID | 30 | /** ID */ |
29 | @Id | 31 | @Id |
30 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
31 | @Column(name = "id") | 33 | @Column(name = "id") |
32 | private Long id; | 34 | private Long id; |
33 | 35 | ||
34 | // 用户ID | 36 | /** 用户ID */ |
35 | @Column(name = "member_id") | 37 | @Column(name = "member_id") |
36 | private Long memberId; | 38 | private Long memberId; |
37 | 39 | ||
38 | // 微信unionid,针对开发者 | 40 | /** 微信unionid,针对开发者 */ |
39 | @Column(name = "unionid") | 41 | @Column(name = "unionid") |
42 | @NotNull(message = "unionid can't be null",groups = {CreateGroup.class}) | ||
40 | private String unionid; | 43 | private String unionid; |
41 | 44 | ||
42 | // 微信appid | 45 | /** 微信appid */ |
43 | @Column(name = "appid") | 46 | @Column(name = "appid") |
47 | @NotNull(message = "appid can't be null",groups = {CreateGroup.class}) | ||
44 | private String appid; | 48 | private String appid; |
45 | 49 | ||
46 | // 微信openid,针对微信app | 50 | /** 微信openid,针对微信app */ |
47 | @Column(name = "openid") | 51 | @Column(name = "openid") |
52 | @NotNull(message = "openid can't be null",groups = {CreateGroup.class}) | ||
48 | private String openid; | 53 | private String openid; |
49 | 54 | ||
50 | // 关注状态 0 -未关注 1 - 已关注 | 55 | /** 关注状态 0 -未关注 1 - 已关注 */ |
51 | @Column(name = "status") | 56 | @Column(name = "status") |
52 | private Integer status; | 57 | private Integer status; |
53 | 58 | ||
54 | // 关注同步状态 0-未同步,1-已同步 | 59 | /** 关注同步状态 0-未同步,1-已同步 */ |
55 | @Column(name = "sync_status") | 60 | @Column(name = "sync_status") |
56 | private Integer syncStatus; | 61 | private Integer syncStatus; |
57 | 62 | ||
58 | // 昵称 | 63 | /** 昵称 */ |
59 | @Column(name = "nickname") | 64 | @Column(name = "nickname") |
60 | private String nickname; | 65 | private String nickname; |
61 | 66 | ||
62 | // 头像地址 | 67 | /** 头像地址 */ |
63 | @Column(name = "headimgurl") | 68 | @Column(name = "headimgurl") |
64 | private String headimgurl; | 69 | private String headimgurl; |
65 | 70 | ||
66 | // 特权信息 | 71 | /** 特权信息 */ |
67 | @Column(name = "privilege") | 72 | @Column(name = "privilege") |
68 | private String privilege; | 73 | private String privilege; |
69 | 74 | ||
70 | // 刷新凭据 | 75 | /** 刷新凭据 */ |
71 | @Column(name = "refresh_token") | 76 | @Column(name = "refresh_token") |
72 | private String refreshToken; | 77 | private String refreshToken; |
73 | 78 | ||
74 | // 凭据 | 79 | /** 凭据 */ |
75 | @Column(name = "access_token") | 80 | @Column(name = "access_token") |
76 | private String accessToken; | 81 | private String accessToken; |
77 | 82 | ||
78 | // 超时(秒) | 83 | /** 超时(秒) */ |
79 | @Column(name = "expires_in") | 84 | @Column(name = "expires_in") |
80 | private Integer expiresIn; | 85 | private Integer expiresIn; |
81 | 86 | ||
82 | // 超时时间 | 87 | /** 超时时间 */ |
83 | @Column(name = "expires_time") | 88 | @Column(name = "expires_time") |
84 | private Timestamp expiresTime; | 89 | private Timestamp expiresTime; |
85 | 90 | ||
86 | // 描述 | 91 | /** 描述 */ |
87 | @Column(name = "description") | 92 | @Column(name = "description") |
88 | private String description; | 93 | private String description; |
89 | 94 | ||
90 | // 创建者 | 95 | /** 创建者 */ |
91 | @Column(name = "create_by") | 96 | @Column(name = "create_by") |
92 | private String createBy; | 97 | private String createBy; |
93 | 98 | ||
94 | // 创建时间 | 99 | /** 创建时间 */ |
95 | @CreatedDate | 100 | @CreatedDate |
96 | @Column(name = "create_time") | 101 | @Column(name = "create_time") |
97 | private LocalDateTime createTime; | 102 | private Timestamp createTime; |
98 | 103 | ||
99 | // 更新者 | 104 | /** 更新者 */ |
100 | @Column(name = "update_by") | 105 | @Column(name = "update_by") |
101 | private String updateBy; | 106 | private String updateBy; |
102 | 107 | ||
103 | // 更新时间 | 108 | /** 更新时间 */ |
104 | @LastModifiedDate | 109 | @LastModifiedDate |
105 | @Column(name = "update_time") | 110 | @Column(name = "update_time") |
106 | private LocalDateTime updateTime; | 111 | private Timestamp updateTime; |
107 | 112 | ||
108 | // 来源类型 | 113 | /** 来源类型 */ |
109 | @Column(name = "source_type") | 114 | @Column(name = "source_type") |
110 | private String sourceType; | 115 | private String sourceType; |
111 | 116 | ||
112 | // 来源id | 117 | /** 来源id */ |
113 | @Column(name = "source_id") | 118 | @Column(name = "source_id") |
114 | private String sourceId; | 119 | private String sourceId; |
115 | 120 | ||
116 | // 来源id | 121 | /** 来源id */ |
117 | @Column(name = "source_desc") | 122 | @Column(name = "source_desc") |
118 | private String sourceDesc; | 123 | private String sourceDesc; |
119 | 124 | ||
120 | // 人id | 125 | /** 人id */ |
121 | @Column(name = "person_id") | 126 | @Column(name = "person_id") |
122 | private Long personId; | 127 | private Long personId; |
123 | 128 | ||
124 | // 来源用户id | 129 | /** 来源用户id */ |
125 | @Column(name = "source_user") | 130 | @Column(name = "source_user") |
126 | private Long sourceUser; | 131 | private Long sourceUser; |
127 | 132 | ||
128 | // 来源实体:活动-activity/商品-item | 133 | /** 来源实体:活动-activity/商品-item */ |
129 | @Column(name = "source_entity") | 134 | @Column(name = "source_entity") |
130 | private String sourceEntity; | 135 | private String sourceEntity; |
131 | 136 | ||
132 | // 授权时间 | 137 | /** 授权时间 */ |
138 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") | ||
133 | @Column(name = "auth_time") | 139 | @Column(name = "auth_time") |
134 | private Timestamp authTime; | 140 | private Timestamp authTime; |
135 | 141 | ... | ... |
... | @@ -20,7 +20,7 @@ import java.util.Objects; | ... | @@ -20,7 +20,7 @@ import java.util.Objects; |
20 | */ | 20 | */ |
21 | public class UserWeixinBuilder { | 21 | public class UserWeixinBuilder { |
22 | 22 | ||
23 | public static UserWeixin build(Long memberId, String appId, String openId, String unionId, String nickname, String headimgurl){ | 23 | public static UserWeixin build(Long memberId,String appId,String openId,String unionId,String nickname,String headimgurl){ |
24 | UserWeixin userWeixin = new UserWeixin(); | 24 | UserWeixin userWeixin = new UserWeixin(); |
25 | userWeixin.setAppid(appId); | 25 | userWeixin.setAppid(appId); |
26 | userWeixin.setOpenid(openId); | 26 | userWeixin.setOpenid(openId); |
... | @@ -30,7 +30,7 @@ public class UserWeixinBuilder { | ... | @@ -30,7 +30,7 @@ public class UserWeixinBuilder { |
30 | return build(memberId,userWeixin); | 30 | return build(memberId,userWeixin); |
31 | } | 31 | } |
32 | 32 | ||
33 | public static UserWeixin build(Long memberId, String appId, String openId, String unionId){ | 33 | public static UserWeixin build(Long memberId,String appId,String openId,String unionId){ |
34 | UserWeixin userWeixin = new UserWeixin(); | 34 | UserWeixin userWeixin = new UserWeixin(); |
35 | userWeixin.setAppid(appId); | 35 | userWeixin.setAppid(appId); |
36 | userWeixin.setOpenid(openId); | 36 | userWeixin.setOpenid(openId); |
... | @@ -98,16 +98,16 @@ public class UserWeixinBuilder { | ... | @@ -98,16 +98,16 @@ public class UserWeixinBuilder { |
98 | public static UserWeixin build(Long id , | 98 | public static UserWeixin build(Long id , |
99 | Long memberId, | 99 | Long memberId, |
100 | String memberCode, | 100 | String memberCode, |
101 | String unionId, String appId, String openId, | 101 | String unionId, String appId,String openId, |
102 | Integer status, Integer syncStatus, | 102 | Integer status, Integer syncStatus, |
103 | String nickname, String headimgurl, | 103 | String nickname,String headimgurl, |
104 | String privilege, String refreshToken, | 104 | String privilege,String refreshToken, |
105 | String accessToken, Integer expiresIn, Timestamp expiresTime, String description, | 105 | String accessToken,Integer expiresIn,Timestamp expiresTime,String description, |
106 | String createBy, String updateBy, | 106 | String createBy,String updateBy, |
107 | String sourceType, String sourceId, | 107 | String sourceType,String sourceId, |
108 | String sourceDesc, | 108 | String sourceDesc, |
109 | Long sourceUser, String sourceEntity, | 109 | Long sourceUser,String sourceEntity, |
110 | String country, String province, String city, | 110 | String country,String province,String city, |
111 | Integer sex){ | 111 | Integer sex){ |
112 | 112 | ||
113 | if (Objects.isNull(memberId)) { | 113 | if (Objects.isNull(memberId)) { | ... | ... |
... | @@ -30,5 +30,4 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J | ... | @@ -30,5 +30,4 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J |
30 | @Transactional | 30 | @Transactional |
31 | @Query(value = "update `uc_user_weixin` set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true) | 31 | @Query(value = "update `uc_user_weixin` set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true) |
32 | void updateTime(@Param("resources") UserWeixin resources); | 32 | void updateTime(@Param("resources") UserWeixin resources); |
33 | |||
34 | } | 33 | } | ... | ... |
... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.user.weixin.service; | ... | @@ -2,11 +2,6 @@ package com.topdraw.business.module.user.weixin.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
4 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 4 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
5 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria; | ||
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 |
... | @@ -85,6 +80,4 @@ public interface UserWeixinService { | ... | @@ -85,6 +80,4 @@ public interface UserWeixinService { |
85 | * @return | 80 | * @return |
86 | */ | 81 | */ |
87 | UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId); | 82 | UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId); |
88 | |||
89 | |||
90 | } | 83 | } | ... | ... |
... | @@ -4,7 +4,6 @@ import lombok.Data; | ... | @@ -4,7 +4,6 @@ import lombok.Data; |
4 | 4 | ||
5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
6 | import java.sql.Timestamp; | 6 | import java.sql.Timestamp; |
7 | import java.time.LocalDateTime; | ||
8 | 7 | ||
9 | 8 | ||
10 | /** | 9 | /** |
... | @@ -14,89 +13,91 @@ import java.time.LocalDateTime; | ... | @@ -14,89 +13,91 @@ import java.time.LocalDateTime; |
14 | @Data | 13 | @Data |
15 | public class UserWeixinDTO implements Serializable { | 14 | public class UserWeixinDTO implements Serializable { |
16 | 15 | ||
17 | // ID | 16 | /** ID */ |
18 | private Long id; | 17 | private Long id; |
19 | 18 | ||
20 | // 用户ID | 19 | /** 用户ID */ |
21 | private Long memberId; | 20 | private Long memberId; |
22 | 21 | ||
23 | // 微信unionid,针对开发者 | 22 | /** 微信unionid,针对开发者 */ |
24 | private String unionid; | 23 | private String unionid; |
25 | 24 | ||
26 | // 微信appid | 25 | /** 微信appid */ |
27 | private String appid; | 26 | private String appid; |
28 | 27 | ||
29 | // 微信openid,针对微信app | 28 | /** 微信openid,针对微信app */ |
30 | private String openid; | 29 | private String openid; |
31 | 30 | ||
32 | // 关注状态 0 -未关注 1 - 已关注 | 31 | /** 关注状态 0 -未关注 1 - 已关注 */ |
33 | private Integer status; | 32 | private Integer status; |
34 | 33 | ||
35 | // 关注同步状态 0-未同步,1-已同步 | 34 | /** 关注同步状态 0-未同步,1-已同步 */ |
36 | private Integer syncStatus; | 35 | private Integer syncStatus; |
37 | 36 | ||
38 | // 昵称 | 37 | /** 昵称 */ |
39 | private String nickname; | 38 | private String nickname; |
40 | 39 | ||
41 | // 头像地址 | 40 | /** 头像地址 */ |
42 | private String headimgurl; | 41 | private String headimgurl; |
43 | 42 | ||
44 | // 特权信息 | 43 | /** 特权信息 */ |
45 | private String privilege; | 44 | private String privilege; |
46 | 45 | ||
47 | // 刷新凭据 | 46 | /** 刷新凭据 */ |
48 | private String refreshToken; | 47 | private String refreshToken; |
49 | 48 | ||
50 | // 凭据 | 49 | /** 凭据 */ |
51 | private String accessToken; | 50 | private String accessToken; |
52 | 51 | ||
53 | // 超时(秒) | 52 | /** 超时(秒) */ |
54 | private Integer expiresIn; | 53 | private Integer expiresIn; |
55 | 54 | ||
56 | // 超时时间 | 55 | /** 超时时间 */ |
57 | private Timestamp expiresTime; | 56 | private Timestamp expiresTime; |
58 | 57 | ||
59 | // 描述 | 58 | /** 描述 */ |
60 | private String description; | 59 | private String description; |
61 | 60 | ||
62 | // 创建者 | 61 | /** 创建者 */ |
63 | private String createBy; | 62 | private String createBy; |
64 | 63 | ||
65 | // 创建时间 | 64 | /** 创建时间 */ |
66 | private LocalDateTime createTime; | 65 | private Timestamp createTime; |
67 | 66 | ||
68 | // 更新者 | 67 | /** 更新者 */ |
69 | private String updateBy; | 68 | private String updateBy; |
70 | 69 | ||
71 | // 更新时间 | 70 | /** 更新时间 */ |
72 | private LocalDateTime updateTime; | 71 | private Timestamp updateTime; |
73 | 72 | ||
74 | // 来源类型 | 73 | /** 来源类型 */ |
75 | private String sourceType; | 74 | private String sourceType; |
76 | 75 | ||
77 | // 来源id | 76 | /** 来源id */ |
78 | private String sourceId; | 77 | private String sourceId; |
79 | 78 | ||
80 | // 来源id | 79 | /** 来源id */ |
81 | private String sourceDesc; | 80 | private String sourceDesc; |
82 | 81 | ||
83 | // 人id | 82 | /** 人id */ |
84 | private Long personId; | 83 | private Long personId; |
85 | 84 | ||
86 | // 来源用户id | 85 | /** 来源用户id */ |
87 | private Long sourceUser; | 86 | private Long sourceUser; |
88 | 87 | ||
89 | // 来源实体:活动-activity/商品-item | 88 | /** 来源实体:活动-activity/商品-item */ |
90 | private String sourceEntity; | 89 | private String sourceEntity; |
91 | 90 | ||
92 | // 授权时间 | 91 | /** 授权时间 */ |
93 | private Timestamp authTime; | 92 | private Timestamp authTime; |
94 | 93 | ||
95 | private Integer sex; | 94 | private Integer gender; |
96 | 95 | ||
97 | private String country; | 96 | private String country; |
98 | 97 | ||
99 | private String province; | 98 | private String province; |
100 | 99 | ||
101 | private String city; | 100 | private String city; |
101 | |||
102 | private Integer sex; | ||
102 | } | 103 | } | ... | ... |
1 | package com.topdraw.business.module.user.weixin.service.dto; | 1 | package com.topdraw.business.module.user.weixin.service.dto; |
2 | 2 | ||
3 | import com.topdraw.annotation.Query; | ||
3 | import lombok.Data; | 4 | import lombok.Data; |
4 | 5 | ||
5 | /** | 6 | /** |
... | @@ -8,4 +9,8 @@ import lombok.Data; | ... | @@ -8,4 +9,8 @@ import lombok.Data; |
8 | */ | 9 | */ |
9 | @Data | 10 | @Data |
10 | public class UserWeixinQueryCriteria{ | 11 | public class UserWeixinQueryCriteria{ |
12 | |||
13 | @Query() | ||
14 | private String unionId; | ||
15 | |||
11 | } | 16 | } | ... | ... |
... | @@ -7,7 +7,6 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService; | ... | @@ -7,7 +7,6 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService; |
7 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 7 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
8 | import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper; | 8 | import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper; |
9 | import com.topdraw.utils.ValidationUtil; | 9 | import com.topdraw.utils.ValidationUtil; |
10 | import lombok.extern.slf4j.Slf4j; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.dao.EmptyResultDataAccessException; | 11 | import org.springframework.dao.EmptyResultDataAccessException; |
13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
... | @@ -21,7 +20,6 @@ import org.springframework.util.Assert; | ... | @@ -21,7 +20,6 @@ import org.springframework.util.Assert; |
21 | */ | 20 | */ |
22 | @Service | 21 | @Service |
23 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 22 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
24 | @Slf4j | ||
25 | public class UserWeixinServiceImpl implements UserWeixinService { | 23 | public class UserWeixinServiceImpl implements UserWeixinService { |
26 | 24 | ||
27 | @Autowired | 25 | @Autowired |
... | @@ -32,7 +30,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -32,7 +30,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
32 | 30 | ||
33 | @Override | 31 | @Override |
34 | public UserWeixinDTO findById(Long id) { | 32 | public UserWeixinDTO findById(Long id) { |
35 | UserWeixin UserWeixin = this.userWeixinRepository.findById(id).orElseGet(UserWeixin::new); | 33 | UserWeixin UserWeixin = this.userWeixinRepository.findById(id).orElseGet(com.topdraw.business.module.user.weixin.domain.UserWeixin::new); |
36 | ValidationUtil.isNull(UserWeixin.getId(),"UserWeixin","id",id); | 34 | ValidationUtil.isNull(UserWeixin.getId(),"UserWeixin","id",id); |
37 | return this.userWeixinMapper.toDto(UserWeixin); | 35 | return this.userWeixinMapper.toDto(UserWeixin); |
38 | } | 36 | } |
... | @@ -48,7 +46,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -48,7 +46,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
48 | @Override | 46 | @Override |
49 | @Transactional(rollbackFor = Exception.class) | 47 | @Transactional(rollbackFor = Exception.class) |
50 | public void update(UserWeixin resources) { | 48 | public void update(UserWeixin resources) { |
51 | UserWeixin UserWeixin = this.userWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); | 49 | UserWeixin UserWeixin = this.userWeixinRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.user.weixin.domain.UserWeixin::new); |
52 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); | 50 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); |
53 | UserWeixin.copy(resources); | 51 | UserWeixin.copy(resources); |
54 | this.userWeixinRepository.save(UserWeixin); | 52 | this.userWeixinRepository.save(UserWeixin); |
... | @@ -64,7 +62,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -64,7 +62,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
64 | public void delete(Long id) { | 62 | public void delete(Long id) { |
65 | Assert.notNull(id, "The given id must not be null!"); | 63 | Assert.notNull(id, "The given id must not be null!"); |
66 | UserWeixin UserWeixin = this.userWeixinRepository.findById(id).orElseThrow( | 64 | UserWeixin UserWeixin = this.userWeixinRepository.findById(id).orElseThrow( |
67 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserWeixin.class, id), 1)); | 65 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.user.weixin.domain.UserWeixin.class, id), 1)); |
68 | this.userWeixinRepository.delete(UserWeixin); | 66 | this.userWeixinRepository.delete(UserWeixin); |
69 | } | 67 | } |
70 | 68 | ... | ... |
... | @@ -36,8 +36,6 @@ import java.util.concurrent.Executors; | ... | @@ -36,8 +36,6 @@ import java.util.concurrent.Executors; |
36 | @Slf4j | 36 | @Slf4j |
37 | public class RightsOperationServiceImpl implements RightsOperationService { | 37 | public class RightsOperationServiceImpl implements RightsOperationService { |
38 | 38 | ||
39 | private static final Logger LOG = LoggerFactory.getLogger(RightsOperationServiceImpl.class); | ||
40 | |||
41 | @Autowired | 39 | @Autowired |
42 | RightsHistoryService rightsHistoryService; | 40 | RightsHistoryService rightsHistoryService; |
43 | @Autowired | 41 | @Autowired |
... | @@ -101,7 +99,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -101,7 +99,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
101 | 99 | ||
102 | values.forEach(value -> { | 100 | values.forEach(value -> { |
103 | RightsHistory rightsHistory = new RightsHistory(); | 101 | RightsHistory rightsHistory = new RightsHistory(); |
104 | rightsHistory.setSendTime(LocalDateTime.now()); | 102 | rightsHistory.setSendTime(TimestampUtil.now()); |
105 | rightsHistory.setRightsId(value.getId()); | 103 | rightsHistory.setRightsId(value.getId()); |
106 | rightsHistory.setMemberId(value.getMemberId()); | 104 | rightsHistory.setMemberId(value.getMemberId()); |
107 | rightsHistory.setExpireTime(value.getExpireTime()); | 105 | rightsHistory.setExpireTime(value.getExpireTime()); |
... | @@ -306,7 +304,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -306,7 +304,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
306 | for (RightsHistory rightsHistory : rightsHistories) { | 304 | for (RightsHistory rightsHistory : rightsHistories) { |
307 | Long operatorId = rightsHistory.getOperatorId(); | 305 | Long operatorId = rightsHistory.getOperatorId(); |
308 | String operatorName = rightsHistory.getOperatorName(); | 306 | String operatorName = rightsHistory.getOperatorName(); |
309 | rightsHistory.setSendTime(LocalDateTime.now()); | 307 | rightsHistory.setSendTime(TimestampUtil.now()); |
310 | rightsHistory.setOperatorId(Objects.nonNull(operatorId)?operatorId:0); | 308 | rightsHistory.setOperatorId(Objects.nonNull(operatorId)?operatorId:0); |
311 | rightsHistory.setOperatorName(!StringUtils.isEmpty(operatorName)?operatorName:"系统发放"); | 309 | rightsHistory.setOperatorName(!StringUtils.isEmpty(operatorName)?operatorName:"系统发放"); |
312 | this.rightsHistoryService.create(rightsHistory); | 310 | this.rightsHistoryService.create(rightsHistory); | ... | ... |
1 | package com.topdraw.util; | ||
2 | |||
3 | import java.nio.charset.StandardCharsets; | ||
4 | import java.util.Base64; | ||
5 | |||
6 | public class Base64Util { | ||
7 | |||
8 | public static String encode(String name){ | ||
9 | String name1 = new String(Base64.getEncoder().encode(name.getBytes(StandardCharsets.UTF_8))); | ||
10 | return name1; | ||
11 | } | ||
12 | |||
13 | public static void main(String[] args) { | ||
14 | // String name = "test005@itv"; | ||
15 | String name = "18580619168a@iptv"; | ||
16 | String encode = encode(name); | ||
17 | System.out.println(encode); | ||
18 | } | ||
19 | } |
1 | package com.topdraw.util; | 1 | package com.topdraw.util; |
2 | 2 | ||
3 | import org.apache.commons.lang3.StringUtils; | ||
3 | import org.slf4j.Logger; | 4 | import org.slf4j.Logger; |
4 | import org.slf4j.LoggerFactory; | 5 | import org.slf4j.LoggerFactory; |
5 | 6 | ||
... | @@ -149,6 +150,14 @@ public class IdWorker { | ... | @@ -149,6 +150,14 @@ public class IdWorker { |
149 | return idWorker.nextId(); | 150 | return idWorker.nextId(); |
150 | } | 151 | } |
151 | 152 | ||
153 | public static String generatorCode(String prefix){ | ||
154 | IdWorker idWorker = new IdWorker(); | ||
155 | if (StringUtils.isNotBlank(prefix)) { | ||
156 | return prefix+"_"+String.valueOf(idWorker.nextId()); | ||
157 | } | ||
158 | return String.valueOf(idWorker.nextId()); | ||
159 | } | ||
160 | |||
152 | public static void main(String[] args) { | 161 | public static void main(String[] args) { |
153 | IdWorker idWorker = new IdWorker(); | 162 | IdWorker idWorker = new IdWorker(); |
154 | System.out.println(idWorker.nextId()); | 163 | System.out.println(idWorker.nextId()); | ... | ... |
-
Please register or sign in to post a comment