初始化项目
;
Showing
268 changed files
with
4768 additions
and
0 deletions
document/sql/structure/structure_10.22.sql
0 → 100644
1 | # 积分台账表 | ||
2 | CREATE TABLE `uc_points_standing_book` ( | ||
3 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', | ||
4 | `points_produce` bigint(20) NOT NULL COMMENT '积分生产', | ||
5 | `points_consume` bigint(20) NOT NULL COMMENT '积分消耗', | ||
6 | `points_available` bigint(20) NOT NULL COMMENT '可用总积分', | ||
7 | `points_expire` bigint(20) NOT NULL COMMENT '积分过期', | ||
8 | `day` varchar(16) DEFAULT NULL COMMENT '日期', | ||
9 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
10 | `update_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
11 | PRIMARY KEY (`id`) | ||
12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分台账表'; | ||
13 | |||
14 | # 永久权益表 | ||
15 | CREATE TABLE `uc_permanent_rights` ( | ||
16 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', | ||
17 | `code` varchar(64) NOT NULL COMMENT '标识', | ||
18 | `name` varchar(255) NOT NULL COMMENT '名称', | ||
19 | `type` tinyint(4) DEFAULT NULL COMMENT '永久权益类型 0:vip;1:会员等级', | ||
20 | `level` tinyint(4) DEFAULT NULL COMMENT '等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index)', | ||
21 | `item_discount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品折扣,10代表10% off,范围为0-100', | ||
22 | `extra_points` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '额外积分比率,范围为0-1000', | ||
23 | `ad_disabled` tinyint(4) NOT NULL DEFAULT '0' COMMENT '免广告', | ||
24 | `extra_activity_ticket` tinyint(4) NOT NULL DEFAULT '0' COMMENT '额外活动参与机会', | ||
25 | `free_trial` tinyint(4) NOT NULL DEFAULT '0' COMMENT '免费试看', | ||
26 | `zone_sds` tinyint(4) NOT NULL DEFAULT '0' COMMENT '上电视专区权益', | ||
27 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
28 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', | ||
29 | PRIMARY KEY (`id`) | ||
30 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='永久权益表'; | ||
31 | |||
32 | CREATE TABLE `uc_points_standing_book` ( | ||
33 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', | ||
34 | `points_produce` bigint NOT NULL COMMENT '积分生产', | ||
35 | `points_consume` bigint NOT NULL COMMENT '积分消耗', | ||
36 | `points_available` bigint NOT NULL COMMENT '可用总积分', | ||
37 | `points_expire` bigint NOT NULL COMMENT '积分过期', | ||
38 | `day` varchar(16) DEFAULT NULL COMMENT '日期', | ||
39 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
40 | `update_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
41 | PRIMARY KEY (`id`) | ||
42 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='积分台账表' | ||
43 | |||
44 | #优惠券表 | ||
45 | CREATE TABLE `m_coupon` ( | ||
46 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', | ||
47 | `code` varchar(64) NOT NULL COMMENT '标识', | ||
48 | `title` varchar(255) NOT NULL COMMENT '名称', | ||
49 | `images` varchar(1024) DEFAULT NULL COMMENT '图片', | ||
50 | `stock` int(11) DEFAULT '-1' COMMENT '发行量,-1代表不限量', | ||
51 | `remain_stock` int(11) '-1' NULL COMMENT '剩余量,-1代表不限量', | ||
52 | `use_type` tinyint(4) DEFAULT '1' COMMENT '优惠形式:1:金额;2:折扣', | ||
53 | `denomination` decimal(10,2) DEFAULT NULL COMMENT '面额', | ||
54 | `discount` decimal(10,2) DEFAULT NULL COMMENT '折扣', | ||
55 | `user_range` tinyint(4) DEFAULT '2' COMMENT '适用用户范围:1:新用户;2:全体用户;3:指定用户分组', | ||
56 | `groups` varchar(1024) DEFAULT NULL COMMENT '用户分组,逗号分隔', | ||
57 | `collect_limit` tinyint(4) DEFAULT '1' COMMENT '限领次数 -1:无限次; >0:具体次数', | ||
58 | `threshold_type` tinyint(4) DEFAULT '1' COMMENT '适用门槛:1:无门槛;2:满减形式', | ||
59 | `amount_threshold` decimal(10,2) DEFAULT null COMMENT '满减门槛', | ||
60 | `item_range` tinyint(4) DEFAULT '1' COMMENT '产品范围:1:全部商品;2:指定商品', | ||
61 | `effect_type` tinyint(4) DEFAULT null COMMENT '生效形式:1:固定日期;2:相对日期', | ||
62 | `start_time` datetime DEFAULT NULL COMMENT '生效时间', | ||
63 | `expire_time` datetime DEFAULT NULL COMMENT '过期时间', | ||
64 | `valid_days` int(11) DEFAULT NULL COMMENT '自领取当日,几天内有效', | ||
65 | `description` varchar(255) DEFAULT NULL COMMENT '使用说明', | ||
66 | `status` tinyint(4) DEFAULT null COMMENT '状态 0:未开始,1:启用;2:停用', | ||
67 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
68 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', | ||
69 | PRIMARY KEY (`id`) | ||
70 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT=' 优惠券表'; | ||
71 | |||
72 | |||
73 | #优惠券 | ||
74 | CREATE TABLE `m_coupon_history` ( | ||
75 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', | ||
76 | `coupon_id` bigint DEFAULT NULL COMMENT '优惠券id', | ||
77 | `user_id` bigint DEFAULT NULL COMMENT '领券用户id', | ||
78 | `coupon_code` varchar(64) DEFAULT NULL COMMENT '优惠券code', | ||
79 | `user_nickname` varchar(255) DEFAULT NULL COMMENT '领取人昵称', | ||
80 | `receive_time` datetime DEFAULT NULL COMMENT '领取时间', | ||
81 | `expire_time` datetime DEFAULT NULL COMMENT '失效时间', | ||
82 | `use_status` int DEFAULT NULL COMMENT '使用状态 0:未使用;1:已使用;-1:已过期', | ||
83 | `use_time` datetime DEFAULT NULL COMMENT '使用时间', | ||
84 | `order_detail_id` bigint DEFAULT NULL COMMENT '订单详情id', | ||
85 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', | ||
86 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', | ||
87 | PRIMARY KEY (`id`) USING BTREE, | ||
88 | KEY `idx_member_id` (`user_id`) USING BTREE, | ||
89 | KEY `idx_coupon_id` (`coupon_id`) USING BTREE | ||
90 | ) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='优惠券领取、使用历史记录表' | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
document/sql/structure/新增的表结构名称
0 → 100644
1 | |||
2 | |||
3 | m_coupon | ||
4 | m_coupon_history | ||
5 | |||
6 | tr_rights | ||
7 | tr_rights_histroy | ||
8 | |||
9 | tr_task | ||
10 | tr_task_template | ||
11 | |||
12 | uc_exp_history | ||
13 | uc_exp_detail | ||
14 | |||
15 | uc_permanent_rights | ||
16 | |||
17 | uc_member_related_info | ||
18 | uc_member_address | ||
19 | uc_member_profile | ||
20 | uc_member_level | ||
21 | uc_member | ||
22 | |||
23 | uc_points_standing_book | ||
24 | uc_points_available | ||
25 | uc_points_detail_history | ||
26 | uc_points_detail | ||
27 | |||
28 | |||
29 | uc_user_weixin | ||
30 | uc_user_tv | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
document/需求文档/会员系统概要设计1022.md
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-api/pom.xml
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
5 | <parent> | ||
6 | <artifactId>member-service</artifactId> | ||
7 | <groupId>com.topdraw</groupId> | ||
8 | <version>0.0.1-SNAPSHOT</version> | ||
9 | </parent> | ||
10 | <modelVersion>4.0.0</modelVersion> | ||
11 | |||
12 | <artifactId>member-service-api</artifactId> | ||
13 | |||
14 | <properties> | ||
15 | |||
16 | </properties> | ||
17 | |||
18 | <dependencies> | ||
19 | <!--代码生成器--> | ||
20 | <dependency> | ||
21 | <groupId>com.topdraw</groupId> | ||
22 | <artifactId>code-generator</artifactId> | ||
23 | <version>3.1.0</version> | ||
24 | </dependency> | ||
25 | </dependencies> | ||
26 | |||
27 | </project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.topdraw.module.mq; | ||
2 | |||
3 | import lombok.AllArgsConstructor; | ||
4 | import lombok.Data; | ||
5 | import lombok.NoArgsConstructor; | ||
6 | |||
7 | import javax.validation.constraints.NotNull; | ||
8 | import java.io.Serializable; | ||
9 | |||
10 | /** | ||
11 | * | ||
12 | */ | ||
13 | @Data | ||
14 | @AllArgsConstructor | ||
15 | @NoArgsConstructor | ||
16 | public class DataSyncMsg implements Serializable { | ||
17 | |||
18 | // 事件类型(用户的实际操作) | ||
19 | @NotNull | ||
20 | private String eventType; | ||
21 | |||
22 | // 消息体 | ||
23 | private MsgData msg; | ||
24 | |||
25 | // 其他属性 | ||
26 | private String extraData; | ||
27 | |||
28 | |||
29 | /** | ||
30 | * 消息体 | ||
31 | */ | ||
32 | @Data | ||
33 | @AllArgsConstructor | ||
34 | @NoArgsConstructor | ||
35 | public static class MsgData { | ||
36 | private String remarks; //备注 | ||
37 | @NotNull | ||
38 | private Integer event; // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | ||
39 | @NotNull | ||
40 | private Long memberId; // 会员id | ||
41 | @NotNull | ||
42 | private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
43 | @NotNull | ||
44 | private String appCode; //用户对应的应用code | ||
45 | private Long accountId; // 账号id | ||
46 | private Long orderId; | ||
47 | private Long activityId; | ||
48 | private Long mediaId; | ||
49 | private Long itemId; | ||
50 | } | ||
51 | |||
52 | } |
1 | package com.topdraw.module.mq; | ||
2 | |||
3 | // 关注的事件 | ||
4 | public enum EventType { | ||
5 | |||
6 | // 关注 | ||
7 | SUBSCRIBE, | ||
8 | // 取消关注 | ||
9 | UN_SUBSCRIBE, | ||
10 | // 绑定 | ||
11 | BIND, | ||
12 | // 取消绑定 | ||
13 | UN_BIND, | ||
14 | // 变更主账号 | ||
15 | C_M_ACCOUNT, | ||
16 | // 获取积分 | ||
17 | GAIN_POINT, | ||
18 | // 消耗积分 | ||
19 | CONSUME_POINT, | ||
20 | // 观影 | ||
21 | VIEWING, | ||
22 | // 登录 | ||
23 | LOGIN, | ||
24 | // 订购产品包 | ||
25 | SUBSCRIBE_PRODUCT_PACKAGE | ||
26 | |||
27 | |||
28 | } |
member-service-impl/pom.xml
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
5 | <parent> | ||
6 | <artifactId>member-service</artifactId> | ||
7 | <groupId>com.topdraw</groupId> | ||
8 | <version>0.0.1-SNAPSHOT</version> | ||
9 | </parent> | ||
10 | <modelVersion>4.0.0</modelVersion> | ||
11 | |||
12 | <artifactId>member-service-impl</artifactId> | ||
13 | |||
14 | <properties> | ||
15 | <maven.compiler.source>8</maven.compiler.source> | ||
16 | <maven.compiler.target>8</maven.compiler.target> | ||
17 | <jjwt.version>0.9.1</jjwt.version> | ||
18 | </properties> | ||
19 | |||
20 | |||
21 | <dependencies> | ||
22 | |||
23 | <!--redisson--> | ||
24 | <dependency> | ||
25 | <groupId>org.redisson</groupId> | ||
26 | <artifactId>redisson</artifactId> | ||
27 | <version>3.16.3</version> | ||
28 | </dependency> | ||
29 | |||
30 | <!--api--> | ||
31 | <dependency> | ||
32 | <groupId>com.topdraw</groupId> | ||
33 | <artifactId>member-service-api</artifactId> | ||
34 | <version>${parent.version}</version> | ||
35 | </dependency> | ||
36 | |||
37 | <!--代码生成器--> | ||
38 | <dependency> | ||
39 | <groupId>com.topdraw</groupId> | ||
40 | <artifactId>code-generator</artifactId> | ||
41 | <version>3.1.0</version> | ||
42 | </dependency> | ||
43 | |||
44 | <!-- Spring boot 热部署 : 此热部署会遇到 java.lang.ClassCastException 异常 --> | ||
45 | <dependency> | ||
46 | <groupId>org.springframework.boot</groupId> | ||
47 | <artifactId>spring-boot-devtools</artifactId> | ||
48 | <optional>true</optional> | ||
49 | <scope>runtime</scope> | ||
50 | </dependency> | ||
51 | |||
52 | <dependency> | ||
53 | <groupId>org.springframework.boot</groupId> | ||
54 | <artifactId>spring-boot-starter-test</artifactId> | ||
55 | </dependency> | ||
56 | |||
57 | <!--Mysql依赖包,版本差异,需单独引入--> | ||
58 | <dependency> | ||
59 | <groupId>mysql</groupId> | ||
60 | <artifactId>mysql-connector-java</artifactId> | ||
61 | <version>8.0.26</version> | ||
62 | </dependency> | ||
63 | |||
64 | <dependency> | ||
65 | <groupId>junit</groupId> | ||
66 | <artifactId>junit</artifactId> | ||
67 | <version>4.12</version> | ||
68 | <scope>test</scope> | ||
69 | </dependency> | ||
70 | |||
71 | <!-- 支持AES/CBC/PKCS7Padding,用于微信小程序登录数据解密 --> | ||
72 | <dependency> | ||
73 | <groupId>org.bouncycastle</groupId> | ||
74 | <artifactId>bcprov-jdk16</artifactId> | ||
75 | <version>1.46</version> | ||
76 | </dependency> | ||
77 | |||
78 | <!--消息队列相关依赖--> | ||
79 | <dependency> | ||
80 | <groupId>org.springframework.boot</groupId> | ||
81 | <artifactId>spring-boot-starter-amqp</artifactId> | ||
82 | </dependency> | ||
83 | |||
84 | <!--重试--> | ||
85 | <dependency> | ||
86 | <groupId>org.springframework.retry</groupId> | ||
87 | <artifactId>spring-retry</artifactId> | ||
88 | </dependency> | ||
89 | |||
90 | <dependency> | ||
91 | <groupId>org.aspectj</groupId> | ||
92 | <artifactId>aspectjweaver</artifactId> | ||
93 | </dependency> | ||
94 | |||
95 | <dependency> | ||
96 | <groupId>commons-codec</groupId> | ||
97 | <artifactId>commons-codec</artifactId> | ||
98 | <version>1.9</version> | ||
99 | </dependency> | ||
100 | |||
101 | </dependencies> | ||
102 | |||
103 | |||
104 | <profiles> | ||
105 | <profile> | ||
106 | <!-- 本地开发环境 --> | ||
107 | <id>dev</id> | ||
108 | <properties> | ||
109 | <profiles.active>dev</profiles.active> | ||
110 | </properties> | ||
111 | <activation> | ||
112 | <!-- 默认的,不加参数时执行这个profile --> | ||
113 | <activeByDefault>true</activeByDefault> | ||
114 | </activation> | ||
115 | </profile> | ||
116 | <profile> | ||
117 | <!-- 生产环境 --> | ||
118 | <id>prod</id> | ||
119 | <properties> | ||
120 | <profiles.active>prod</profiles.active> | ||
121 | <modifier>-prod</modifier> | ||
122 | </properties> | ||
123 | </profile> | ||
124 | </profiles> | ||
125 | |||
126 | <build> | ||
127 | <finalName>member-service</finalName> | ||
128 | <plugins> | ||
129 | <plugin> | ||
130 | <groupId>org.springframework.boot</groupId> | ||
131 | <artifactId>spring-boot-maven-plugin</artifactId> | ||
132 | <configuration> | ||
133 | <fork>true</fork> | ||
134 | </configuration> | ||
135 | </plugin> | ||
136 | <!-- 跳过单元测试 --> | ||
137 | <plugin> | ||
138 | <groupId>org.apache.maven.plugins</groupId> | ||
139 | <artifactId>maven-surefire-plugin</artifactId> | ||
140 | <configuration> | ||
141 | <skipTests>true</skipTests> | ||
142 | </configuration> | ||
143 | </plugin> | ||
144 | <!-- 复制指定配置文件到指定目录 --> | ||
145 | <plugin> | ||
146 | <artifactId>maven-resources-plugin</artifactId> | ||
147 | <executions> | ||
148 | <execution> | ||
149 | <id>copy-resources</id> | ||
150 | <phase>package</phase> | ||
151 | <goals> | ||
152 | <goal>copy-resources</goal> | ||
153 | </goals> | ||
154 | <configuration> | ||
155 | <resources> | ||
156 | <resource> | ||
157 | <directory>src/main/resources/config</directory> | ||
158 | <includes> | ||
159 | <include>application.yml</include> | ||
160 | <include>application-${profiles.active}.yml</include> | ||
161 | </includes> | ||
162 | </resource> | ||
163 | </resources> | ||
164 | <outputDirectory>${project.build.directory}/config</outputDirectory> | ||
165 | </configuration> | ||
166 | </execution> | ||
167 | </executions> | ||
168 | </plugin> | ||
169 | <!-- jar包内剔除所有配置文件 --> | ||
170 | <plugin> | ||
171 | <artifactId>maven-jar-plugin</artifactId> | ||
172 | <configuration> | ||
173 | <!--不打入jar包的文件类型或者路径--> | ||
174 | <excludes> | ||
175 | <exclude>config/**</exclude> | ||
176 | </excludes> | ||
177 | </configuration> | ||
178 | </plugin> | ||
179 | </plugins> | ||
180 | </build> | ||
181 | |||
182 | </project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.topdraw; | ||
2 | |||
3 | import com.topdraw.utils.SpringContextHolder; | ||
4 | import org.springframework.boot.SpringApplication; | ||
5 | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
6 | import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; | ||
7 | import org.springframework.boot.builder.SpringApplicationBuilder; | ||
8 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
9 | import org.springframework.context.annotation.Bean; | ||
10 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
11 | import org.springframework.retry.annotation.EnableRetry; | ||
12 | import org.springframework.scheduling.annotation.EnableAsync; | ||
13 | import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @version 0.0.1 | ||
18 | */ | ||
19 | @EnableJpaAuditing | ||
20 | @EnableAsync | ||
21 | @SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) | ||
22 | @EnableTransactionManagement | ||
23 | @EnableRetry | ||
24 | public class MemberServiceApplication extends SpringBootServletInitializer { | ||
25 | |||
26 | public static void main(String[] args) { | ||
27 | SpringApplication.run(MemberServiceApplication.class, args); | ||
28 | } | ||
29 | |||
30 | @Override | ||
31 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { | ||
32 | return builder.sources(MemberServiceApplication.class); | ||
33 | } | ||
34 | |||
35 | @Bean | ||
36 | public SpringContextHolder springContextHolder() { | ||
37 | return new SpringContextHolder(); | ||
38 | } | ||
39 | } |
1 | package com.topdraw.aspect; | ||
2 | |||
3 | |||
4 | import com.alibaba.fastjson.JSON; | ||
5 | import com.topdraw.mq.domain.TableOperationMsg; | ||
6 | import com.topdraw.mq.producer.MessageProducer; | ||
7 | import lombok.extern.slf4j.Slf4j; | ||
8 | import org.aspectj.lang.JoinPoint; | ||
9 | import org.aspectj.lang.annotation.*; | ||
10 | import org.aspectj.lang.reflect.MethodSignature; | ||
11 | import org.slf4j.Logger; | ||
12 | import org.slf4j.LoggerFactory; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | ||
14 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
15 | import org.springframework.stereotype.Component; | ||
16 | import org.springframework.util.StringUtils; | ||
17 | |||
18 | import javax.annotation.Resource; | ||
19 | import java.lang.reflect.Method; | ||
20 | |||
21 | @Component | ||
22 | @Slf4j | ||
23 | @Aspect | ||
24 | public class AsyncMqProducer { | ||
25 | |||
26 | private static final Logger LOG = LoggerFactory.getLogger(AsyncMqProducer.class); | ||
27 | |||
28 | @Autowired | ||
29 | MessageProducer messageProducer; | ||
30 | |||
31 | @Resource(name = "executorTask") | ||
32 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
33 | |||
34 | @Pointcut(value = "@annotation(asyncMqSend)") | ||
35 | public void sendMqMsg(AsyncMqSend asyncMqSend){ | ||
36 | LOG.info("AsyncMqProducer ===>>> sendMqMsg ====>> start"); | ||
37 | } | ||
38 | |||
39 | @After("sendMqMsg(asyncMqSend)") | ||
40 | public void doAfter(JoinPoint joinPoint, AsyncMqSend asyncMqSend){ | ||
41 | LOG.info("AsyncMqProducer ===>>> doAfter ====>> start"); | ||
42 | boolean open = asyncMqSend.open(); | ||
43 | if (open) { | ||
44 | try { | ||
45 | this.doTask(joinPoint,asyncMqSend); | ||
46 | } catch (Throwable e) { | ||
47 | e.printStackTrace(); | ||
48 | } | ||
49 | } | ||
50 | LOG.info("AsyncMqProducer ===>>> doAfter ====>> end ===>> " ); | ||
51 | } | ||
52 | |||
53 | private void doTask(JoinPoint joinPoint, AsyncMqSend asyncMqSend) { | ||
54 | LOG.info("AsyncMqProducer ===>>> doTask ====>> start ===>> " ); | ||
55 | |||
56 | String entityName = asyncMqSend.entityName(); | ||
57 | String methodName = asyncMqSend.method(); | ||
58 | |||
59 | Object defaultServiceImpl = joinPoint.getTarget(); | ||
60 | String defaultServiceImplName = defaultServiceImpl.getClass().getName(); | ||
61 | |||
62 | MethodSignature signature = (MethodSignature)joinPoint.getSignature(); | ||
63 | Method method = signature.getMethod(); | ||
64 | String defaultMethodName = method.getName(); | ||
65 | |||
66 | Object[] args = joinPoint.getArgs(); | ||
67 | Object arg = args[0]; | ||
68 | String defaultEntityName = arg.getClass().getName(); | ||
69 | |||
70 | TableOperationMsg tableOperationMsg = new TableOperationMsg(); | ||
71 | tableOperationMsg.setMethodName(StringUtils.isEmpty(methodName)?defaultMethodName:methodName); | ||
72 | tableOperationMsg.setEntityBody(JSON.toJSONString(arg)); | ||
73 | tableOperationMsg.setInterfaceName(defaultServiceImplName); | ||
74 | tableOperationMsg.setEntityName(StringUtils.isEmpty(entityName)?defaultEntityName:entityName); | ||
75 | |||
76 | boolean async = asyncMqSend.async(); | ||
77 | if (async) { | ||
78 | // 异步 | ||
79 | this.sendMqMessage(tableOperationMsg); | ||
80 | } else { | ||
81 | // 同步 | ||
82 | this.sendMqMessage(tableOperationMsg); | ||
83 | } | ||
84 | |||
85 | LOG.info("AsyncMqProducer ===>>> doTask ====>> end ===>> " ); | ||
86 | } | ||
87 | |||
88 | private void sendMqMessage(TableOperationMsg tableOperationMsg){ | ||
89 | this.messageProducer.sendFanoutMessage(JSON.toJSONString(tableOperationMsg)); | ||
90 | } | ||
91 | |||
92 | } |
1 | package com.topdraw.aspect; | ||
2 | |||
3 | import org.springframework.amqp.core.ExchangeTypes; | ||
4 | |||
5 | import java.lang.annotation.*; | ||
6 | |||
7 | /** | ||
8 | * 在对应的方法上添加此注解,表示对应方法结束后 | ||
9 | * 进行异步发送消息到mq中 | ||
10 | * | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-30 | ||
13 | */ | ||
14 | @Documented | ||
15 | @Target({ElementType.METHOD}) | ||
16 | @Retention(RetentionPolicy.RUNTIME) | ||
17 | public @interface AsyncMqSend { | ||
18 | /** true:开启 false:关闭 */ | ||
19 | boolean open() default true; | ||
20 | /** true:异步 false:同步 */ | ||
21 | boolean async() default true; | ||
22 | /** 接口实现 */ | ||
23 | String serviceImpl() default ""; | ||
24 | /** 对应的方法 */ | ||
25 | String method() default ""; | ||
26 | /** 实体名 */ | ||
27 | String entityName() default ""; | ||
28 | /** 交换机 */ | ||
29 | String exchangeName() default ""; | ||
30 | /** 队列名 */ | ||
31 | String routeKeyName() default ""; | ||
32 | /**交换机类型 */ | ||
33 | String exchangeType() default ExchangeTypes.DIRECT; | ||
34 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/coupon/domain/Coupon.java
0 → 100644
1 | package com.topdraw.business.basicdata.coupon.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | import java.math.BigDecimal; | ||
13 | |||
14 | import java.io.Serializable; | ||
15 | |||
16 | /** | ||
17 | * @author XiangHan | ||
18 | * @date 2021-10-22 | ||
19 | */ | ||
20 | @Entity | ||
21 | @Data | ||
22 | @EntityListeners(AuditingEntityListener.class) | ||
23 | @Accessors(chain = true) | ||
24 | @Table(name="m_coupon") | ||
25 | public class Coupon implements Serializable { | ||
26 | |||
27 | // id | ||
28 | @Id | ||
29 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
30 | @Column(name = "id") | ||
31 | private Long id; | ||
32 | |||
33 | // 标识 | ||
34 | @Column(name = "code", nullable = false) | ||
35 | private String code; | ||
36 | |||
37 | // 名称 | ||
38 | @Column(name = "title", nullable = false) | ||
39 | private String title; | ||
40 | |||
41 | // 图片 | ||
42 | @Column(name = "images") | ||
43 | private String images; | ||
44 | |||
45 | // 发行量,-1代表不限量 | ||
46 | @Column(name = "stock") | ||
47 | private Integer stock; | ||
48 | |||
49 | // 剩余量,-1代表不限量 | ||
50 | @Column(name = "remain_stock") | ||
51 | private Integer remainStock; | ||
52 | |||
53 | // 优惠形式:1:现金;2:折扣 | ||
54 | @Column(name = "use_type") | ||
55 | private Integer useType; | ||
56 | |||
57 | // 面额 | ||
58 | @Column(name = "denomination") | ||
59 | private BigDecimal denomination; | ||
60 | |||
61 | // 折扣 | ||
62 | @Column(name = "discount") | ||
63 | private BigDecimal discount; | ||
64 | |||
65 | // 适用用户范围:1:新用户;2:全体用户 | ||
66 | @Column(name = "user_range") | ||
67 | private Integer userRange; | ||
68 | |||
69 | // 限领次数 -1:无限次; >0:具体次数 | ||
70 | @Column(name = "collect_limit") | ||
71 | private Integer collectLimit; | ||
72 | |||
73 | // 适用门槛:1:无门槛;2:满减形式 | ||
74 | @Column(name = "threshold_type") | ||
75 | private Integer thresholdType; | ||
76 | |||
77 | // 满减门槛 | ||
78 | @Column(name = "amount_threshold") | ||
79 | private BigDecimal amountThreshold; | ||
80 | |||
81 | // 产品范围:1:全部商品;2:指定商品 | ||
82 | @Column(name = "item_range") | ||
83 | private Integer itemRange; | ||
84 | |||
85 | // 生效形式:1:固定日期;2:相对日期 | ||
86 | @Column(name = "effect_type") | ||
87 | private Integer effectType; | ||
88 | |||
89 | // 生效时间 | ||
90 | @Column(name = "start_time") | ||
91 | private Timestamp startTime; | ||
92 | |||
93 | // 过期时间 | ||
94 | @Column(name = "expire_time") | ||
95 | private Timestamp expireTime; | ||
96 | |||
97 | // 自领取当日,几天内有效 | ||
98 | @Column(name = "valid_days") | ||
99 | private Integer validDays; | ||
100 | |||
101 | // 使用说明 | ||
102 | @Column(name = "description") | ||
103 | private String description; | ||
104 | |||
105 | // 状态0:未开始,1:启用;2:停用 | ||
106 | @Column(name = "status") | ||
107 | private Integer status; | ||
108 | |||
109 | // 创建时间 | ||
110 | @CreatedDate | ||
111 | @Column(name = "create_time") | ||
112 | private Timestamp createTime; | ||
113 | |||
114 | // 更新时间 | ||
115 | @LastModifiedDate | ||
116 | @Column(name = "update_time") | ||
117 | private Timestamp updateTime; | ||
118 | |||
119 | public void copy(Coupon source){ | ||
120 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
121 | } | ||
122 | } |
1 | package com.topdraw.business.basicdata.coupon.history.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-10-23 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="m_coupon_history") | ||
24 | public class CouponHistory implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 优惠券id | ||
33 | @Column(name = "coupon_id") | ||
34 | private Long couponId; | ||
35 | |||
36 | // 领券用户id(对应账号) | ||
37 | @Column(name = "user_id") | ||
38 | private Long userId; | ||
39 | |||
40 | // 优惠券code | ||
41 | @Column(name = "coupon_code") | ||
42 | private String couponCode; | ||
43 | |||
44 | // 领取人昵称 | ||
45 | @Column(name = "user_nickname") | ||
46 | private String userNickname; | ||
47 | |||
48 | // 领取时间 | ||
49 | @Column(name = "receive_time") | ||
50 | private Timestamp receiveTime; | ||
51 | |||
52 | // 失效时间 | ||
53 | @Column(name = "expire_time") | ||
54 | private Timestamp expireTime; | ||
55 | |||
56 | // 使用状态 0:未使用;1:已使用;-1:已过期 | ||
57 | @Column(name = "use_status") | ||
58 | private Integer useStatus; | ||
59 | |||
60 | // 使用时间 | ||
61 | @Column(name = "use_time") | ||
62 | private Timestamp useTime; | ||
63 | |||
64 | // 订单详情id | ||
65 | @Column(name = "order_detail_id") | ||
66 | private Long orderDetailId; | ||
67 | |||
68 | // 创建时间 | ||
69 | @CreatedDate | ||
70 | @Column(name = "create_time") | ||
71 | private Timestamp createTime; | ||
72 | |||
73 | // 更新时间 | ||
74 | @LastModifiedDate | ||
75 | @Column(name = "update_time") | ||
76 | private Timestamp updateTime; | ||
77 | |||
78 | public void copy(CouponHistory source){ | ||
79 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
80 | } | ||
81 | } |
1 | package com.topdraw.business.basicdata.coupon.history.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | |||
7 | import java.sql.Timestamp; | ||
8 | import java.util.Optional; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-23 | ||
13 | */ | ||
14 | public interface CouponHistoryRepository extends JpaRepository<CouponHistory, Long>, JpaSpecificationExecutor<CouponHistory> { | ||
15 | |||
16 | Long countByUserId(Long userId); | ||
17 | |||
18 | Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now); | ||
19 | |||
20 | Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime); | ||
21 | } |
1 | package com.topdraw.business.basicdata.coupon.history.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; | ||
6 | import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService; | ||
7 | import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.http.HttpStatus; | ||
11 | import org.springframework.http.ResponseEntity; | ||
12 | import org.springframework.validation.annotation.Validated; | ||
13 | import org.springframework.web.bind.annotation.*; | ||
14 | import io.swagger.annotations.*; | ||
15 | import java.io.IOException; | ||
16 | import javax.servlet.http.HttpServletResponse; | ||
17 | |||
18 | /** | ||
19 | * @author XiangHan | ||
20 | * @date 2021-10-23 | ||
21 | */ | ||
22 | @Api(tags = "CouponHistory管理") | ||
23 | @RestController | ||
24 | @RequestMapping("/api/CouponHistory") | ||
25 | public class CouponHistoryController { | ||
26 | |||
27 | @Autowired | ||
28 | private CouponHistoryService CouponHistoryService; | ||
29 | |||
30 | @GetMapping | ||
31 | @ApiOperation("查询CouponHistory") | ||
32 | public ResultInfo getCouponHistorys(CouponHistoryQueryCriteria criteria, Pageable pageable) { | ||
33 | return ResultInfo.successPage(CouponHistoryService.queryAll(criteria,pageable)); | ||
34 | } | ||
35 | |||
36 | @GetMapping(value = "/all") | ||
37 | @ApiOperation("查询所有CouponHistory") | ||
38 | public ResultInfo getCouponHistorys(CouponHistoryQueryCriteria criteria) { | ||
39 | return ResultInfo.success(CouponHistoryService.queryAll(criteria)); | ||
40 | } | ||
41 | |||
42 | @Log | ||
43 | @PostMapping | ||
44 | @ApiOperation("新增CouponHistory") | ||
45 | public ResultInfo create(@Validated @RequestBody CouponHistory resources) { | ||
46 | CouponHistoryService.create(resources); | ||
47 | return ResultInfo.success(); | ||
48 | } | ||
49 | |||
50 | @Log | ||
51 | @PutMapping | ||
52 | @ApiOperation("修改CouponHistory") | ||
53 | public ResultInfo update(@Validated @RequestBody CouponHistory resources) { | ||
54 | CouponHistoryService.update(resources); | ||
55 | return ResultInfo.success(); | ||
56 | } | ||
57 | |||
58 | |||
59 | @Log | ||
60 | @DeleteMapping(value = "/{id}") | ||
61 | @ApiOperation("删除CouponHistory") | ||
62 | public ResultInfo delete(@PathVariable Long id) { | ||
63 | CouponHistoryService.delete(id); | ||
64 | return ResultInfo.success(); | ||
65 | } | ||
66 | |||
67 | } |
1 | package com.topdraw.business.basicdata.coupon.history.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; | ||
4 | import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO; | ||
5 | import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | |||
8 | import java.sql.Timestamp; | ||
9 | import java.util.Map; | ||
10 | import java.util.List; | ||
11 | import java.io.IOException; | ||
12 | import javax.servlet.http.HttpServletResponse; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-23 | ||
17 | */ | ||
18 | public interface CouponHistoryService { | ||
19 | |||
20 | /** | ||
21 | * 查询数据分页 | ||
22 | * @param criteria 条件参数 | ||
23 | * @param pageable 分页参数 | ||
24 | * @return Map<String,Object> | ||
25 | */ | ||
26 | Map<String,Object> queryAll(CouponHistoryQueryCriteria criteria, Pageable pageable); | ||
27 | |||
28 | /** | ||
29 | * 查询所有数据不分页 | ||
30 | * @param criteria 条件参数 | ||
31 | * @return List<CouponHistoryDTO> | ||
32 | */ | ||
33 | List<CouponHistoryDTO> queryAll(CouponHistoryQueryCriteria criteria); | ||
34 | |||
35 | /** | ||
36 | * 根据ID查询 | ||
37 | * @param id ID | ||
38 | * @return CouponHistoryDTO | ||
39 | */ | ||
40 | CouponHistoryDTO findById(Long id); | ||
41 | |||
42 | void create(CouponHistory resources); | ||
43 | |||
44 | void update(CouponHistory resources); | ||
45 | |||
46 | void delete(Long id); | ||
47 | |||
48 | Long countByUserId(Long userId); | ||
49 | |||
50 | Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now); | ||
51 | |||
52 | Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime); | ||
53 | } |
1 | package com.topdraw.business.basicdata.coupon.history.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-23 | ||
11 | */ | ||
12 | @Data | ||
13 | public class CouponHistoryDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 优惠券id | ||
19 | private Long couponId; | ||
20 | |||
21 | // 领券用户id(对应账号) | ||
22 | private Long userId; | ||
23 | |||
24 | // 优惠券code | ||
25 | private String couponCode; | ||
26 | |||
27 | // 领取人昵称 | ||
28 | private String userNickname; | ||
29 | |||
30 | // 领取时间 | ||
31 | private Timestamp receiveTime; | ||
32 | |||
33 | // 失效时间 | ||
34 | private Timestamp expireTime; | ||
35 | |||
36 | // 使用状态 0:未使用;1:已使用;-1:已过期 | ||
37 | private Integer useStatus; | ||
38 | |||
39 | // 使用时间 | ||
40 | private Timestamp useTime; | ||
41 | |||
42 | // 订单详情id | ||
43 | private Long orderDetailId; | ||
44 | |||
45 | // 创建时间 | ||
46 | private Timestamp createTime; | ||
47 | |||
48 | // 更新时间 | ||
49 | private Timestamp updateTime; | ||
50 | } |
1 | package com.topdraw.business.basicdata.coupon.history.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.coupon.history.repository.CouponHistoryRepository; | ||
7 | import com.topdraw.business.basicdata.coupon.history.service.CouponHistoryService; | ||
8 | import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO; | ||
9 | import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.coupon.history.service.mapper.CouponHistoryMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | |||
22 | import java.sql.Timestamp; | ||
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | |||
26 | /** | ||
27 | * @author XiangHan | ||
28 | * @date 2021-10-23 | ||
29 | */ | ||
30 | @Service | ||
31 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
32 | public class CouponHistoryServiceImpl implements CouponHistoryService { | ||
33 | |||
34 | @Autowired | ||
35 | private CouponHistoryRepository CouponHistoryRepository; | ||
36 | |||
37 | @Autowired | ||
38 | private CouponHistoryMapper CouponHistoryMapper; | ||
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 | |||
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 | |||
51 | @Override | ||
52 | public CouponHistoryDTO findById(Long id) { | ||
53 | CouponHistory CouponHistory = CouponHistoryRepository.findById(id).orElseGet(CouponHistory::new); | ||
54 | ValidationUtil.isNull(CouponHistory.getId(),"CouponHistory","id",id); | ||
55 | return CouponHistoryMapper.toDto(CouponHistory); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | @Transactional(rollbackFor = Exception.class) | ||
60 | @AsyncMqSend() | ||
61 | public void create(CouponHistory resources) { | ||
62 | CouponHistoryRepository.save(resources); | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | @Transactional(rollbackFor = Exception.class) | ||
67 | @AsyncMqSend() | ||
68 | public void update(CouponHistory resources) { | ||
69 | CouponHistory CouponHistory = CouponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new); | ||
70 | ValidationUtil.isNull( CouponHistory.getId(),"CouponHistory","id",resources.getId()); | ||
71 | CouponHistory.copy(resources); | ||
72 | CouponHistoryRepository.save(CouponHistory); | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | @Transactional(rollbackFor = Exception.class) | ||
77 | public void delete(Long id) { | ||
78 | Assert.notNull(id, "The given id must not be null!"); | ||
79 | CouponHistory CouponHistory = CouponHistoryRepository.findById(id).orElseThrow( | ||
80 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", CouponHistory.class, id), 1)); | ||
81 | CouponHistoryRepository.delete(CouponHistory); | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Long countByUserId(Long userId) { | ||
86 | return this.CouponHistoryRepository.countByUserId(userId); | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Long countByUserIdAndExpireTimeBefore(Long userId, Timestamp now) { | ||
91 | return this.CouponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now); | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Long countByUserIdAndExpireTimeBetween(Long userId, Timestamp now, Timestamp expireTime) { | ||
96 | return this.CouponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime); | ||
97 | } | ||
98 | |||
99 | |||
100 | } |
1 | package com.topdraw.business.basicdata.coupon.history.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.coupon.history.domain.CouponHistory; | ||
5 | import com.topdraw.business.basicdata.coupon.history.service.dto.CouponHistoryDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-23 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface CouponHistoryMapper extends BaseMapper<CouponHistoryDTO, CouponHistory> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.basicdata.coupon.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.coupon.domain.Coupon; | ||
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 2021-10-22 | ||
12 | */ | ||
13 | public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecificationExecutor<Coupon> { | ||
14 | |||
15 | Optional<Coupon> findFirstByCode(String code); | ||
16 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/coupon/rest/CouponController.java
0 → 100644
1 | package com.topdraw.business.basicdata.coupon.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.coupon.domain.Coupon; | ||
6 | import com.topdraw.business.basicdata.coupon.service.CouponService; | ||
7 | import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-22 | ||
17 | */ | ||
18 | @Api(tags = "Coupon管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/api/Coupon") | ||
21 | public class CouponController { | ||
22 | |||
23 | @Autowired | ||
24 | private CouponService CouponService; | ||
25 | |||
26 | @GetMapping | ||
27 | @ApiOperation("查询Coupon") | ||
28 | public ResultInfo getCoupons(CouponQueryCriteria criteria, Pageable pageable) { | ||
29 | return ResultInfo.successPage(CouponService.queryAll(criteria,pageable)); | ||
30 | } | ||
31 | |||
32 | @GetMapping(value = "/all") | ||
33 | @ApiOperation("查询所有Coupon") | ||
34 | public ResultInfo getCoupons(CouponQueryCriteria criteria) { | ||
35 | return ResultInfo.success(CouponService.queryAll(criteria)); | ||
36 | } | ||
37 | |||
38 | @Log | ||
39 | @PostMapping | ||
40 | @ApiOperation("新增Coupon") | ||
41 | public ResultInfo create(@Validated @RequestBody Coupon resources) { | ||
42 | CouponService.create(resources); | ||
43 | return ResultInfo.success(); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PutMapping | ||
48 | @ApiOperation("修改Coupon") | ||
49 | public ResultInfo update(@Validated @RequestBody Coupon resources) { | ||
50 | CouponService.update(resources); | ||
51 | return ResultInfo.success(); | ||
52 | } | ||
53 | |||
54 | |||
55 | @Log | ||
56 | @DeleteMapping(value = "/{id}") | ||
57 | @ApiOperation("删除Coupon") | ||
58 | public ResultInfo delete(@PathVariable Long id) { | ||
59 | CouponService.delete(id); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | @GetMapping(value = "/getByCode/{code}") | ||
64 | @ApiOperation(value = "根据标识查询") | ||
65 | public ResultInfo getByCode(@PathVariable String code) { | ||
66 | return ResultInfo.success(CouponService.getByCode(code)); | ||
67 | } | ||
68 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/coupon/service/CouponService.java
0 → 100644
1 | package com.topdraw.business.basicdata.coupon.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.coupon.domain.Coupon; | ||
4 | import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; | ||
5 | import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface CouponService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(CouponQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<CouponDTO> | ||
28 | */ | ||
29 | List<CouponDTO> queryAll(CouponQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return CouponDTO | ||
35 | */ | ||
36 | CouponDTO findById(Long id); | ||
37 | |||
38 | void create(Coupon resources); | ||
39 | |||
40 | void update(Coupon resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | /** | ||
45 | * Code校验 | ||
46 | * @param code | ||
47 | * @return CouponDTO | ||
48 | */ | ||
49 | CouponDTO getByCode(String code); | ||
50 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/coupon/service/dto/CouponDTO.java
0 → 100644
1 | package com.topdraw.business.basicdata.coupon.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.math.BigDecimal; | ||
6 | import java.io.Serializable; | ||
7 | |||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Data | ||
14 | public class CouponDTO implements Serializable { | ||
15 | |||
16 | // id | ||
17 | private Long id; | ||
18 | |||
19 | // 标识 | ||
20 | private String code; | ||
21 | |||
22 | // 名称 | ||
23 | private String title; | ||
24 | |||
25 | // 图片 | ||
26 | private String images; | ||
27 | |||
28 | // 发行量,-1代表不限量 | ||
29 | private Integer stock; | ||
30 | |||
31 | // 剩余量,-1代表不限量 | ||
32 | private Integer remainStock; | ||
33 | |||
34 | // 优惠形式:1:现金;2:折扣 | ||
35 | private Integer useType; | ||
36 | |||
37 | // 面额 | ||
38 | private BigDecimal denomination; | ||
39 | |||
40 | // 折扣 | ||
41 | private BigDecimal discount; | ||
42 | |||
43 | // 适用用户范围:1:新用户;2:全体用户 | ||
44 | private Integer userRange; | ||
45 | |||
46 | // 限领次数 -1:无限次; >0:具体次数 | ||
47 | private Integer collectLimit; | ||
48 | |||
49 | // 适用门槛:1:无门槛;2:满减形式 | ||
50 | private Integer thresholdType; | ||
51 | |||
52 | // 满减门槛 | ||
53 | private BigDecimal amountThreshold; | ||
54 | |||
55 | // 产品范围:1:全部商品;2:指定商品 | ||
56 | private Integer itemRange; | ||
57 | |||
58 | // 生效形式:1:固定日期;2:相对日期 | ||
59 | private Integer effectType; | ||
60 | |||
61 | // 生效时间 | ||
62 | private Timestamp startTime; | ||
63 | |||
64 | // 过期时间 | ||
65 | private Timestamp expireTime; | ||
66 | |||
67 | // 自领取当日,几天内有效 | ||
68 | private Integer validDays; | ||
69 | |||
70 | // 使用说明 | ||
71 | private String description; | ||
72 | |||
73 | // 状态0:未开始,1:启用;2:停用 | ||
74 | private Integer status; | ||
75 | |||
76 | // 创建时间 | ||
77 | private Timestamp createTime; | ||
78 | |||
79 | // 更新时间 | ||
80 | private Timestamp updateTime; | ||
81 | } |
1 | package com.topdraw.business.basicdata.coupon.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.coupon.domain.Coupon; | ||
5 | import com.topdraw.util.RedissonUtil; | ||
6 | import com.topdraw.utils.ValidationUtil; | ||
7 | import com.topdraw.business.basicdata.coupon.repository.CouponRepository; | ||
8 | import com.topdraw.business.basicdata.coupon.service.CouponService; | ||
9 | import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; | ||
10 | import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria; | ||
11 | import com.topdraw.business.basicdata.coupon.service.mapper.CouponMapper; | ||
12 | import org.redisson.api.RLock; | ||
13 | import org.redisson.api.RedissonClient; | ||
14 | import org.springframework.beans.factory.annotation.Autowired; | ||
15 | import org.springframework.stereotype.Service; | ||
16 | import org.springframework.transaction.annotation.Propagation; | ||
17 | import org.springframework.transaction.annotation.Transactional; | ||
18 | import org.springframework.dao.EmptyResultDataAccessException; | ||
19 | import org.springframework.data.domain.Page; | ||
20 | import org.springframework.data.domain.Pageable; | ||
21 | import org.springframework.util.Assert; | ||
22 | import com.topdraw.utils.PageUtil; | ||
23 | import com.topdraw.utils.QueryHelp; | ||
24 | import com.topdraw.utils.StringUtils; | ||
25 | |||
26 | import java.util.List; | ||
27 | import java.util.Map; | ||
28 | |||
29 | /** | ||
30 | * @author XiangHan | ||
31 | * @date 2021-10-22 | ||
32 | */ | ||
33 | @Service | ||
34 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
35 | public class CouponServiceImpl implements CouponService { | ||
36 | |||
37 | @Autowired | ||
38 | private CouponRepository CouponRepository; | ||
39 | |||
40 | @Autowired | ||
41 | private CouponMapper CouponMapper; | ||
42 | |||
43 | @Autowired | ||
44 | private RedissonClient redissonClient; | ||
45 | |||
46 | @Override | ||
47 | public Map<String, Object> queryAll(CouponQueryCriteria criteria, Pageable pageable) { | ||
48 | Page<Coupon> page = CouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
49 | return PageUtil.toPage(page.map(CouponMapper::toDto)); | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | public List<CouponDTO> queryAll(CouponQueryCriteria criteria) { | ||
54 | return CouponMapper.toDto(CouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
55 | } | ||
56 | |||
57 | @Override | ||
58 | public CouponDTO findById(Long id) { | ||
59 | Coupon Coupon = CouponRepository.findById(id).orElseGet(Coupon::new); | ||
60 | ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id); | ||
61 | return CouponMapper.toDto(Coupon); | ||
62 | } | ||
63 | |||
64 | @Override | ||
65 | @Transactional(rollbackFor = Exception.class) | ||
66 | @AsyncMqSend() | ||
67 | public void create(Coupon resources) { | ||
68 | CouponRepository.save(resources); | ||
69 | } | ||
70 | |||
71 | @Override | ||
72 | @Transactional(rollbackFor = Exception.class) | ||
73 | @AsyncMqSend() | ||
74 | public void update(Coupon resources) { | ||
75 | RLock rLock = this.redissonClient.getLock(resources.getId().toString()); | ||
76 | try { | ||
77 | RedissonUtil.lock(rLock); | ||
78 | Coupon Coupon = CouponRepository.findById(resources.getId()).orElseGet(Coupon::new); | ||
79 | ValidationUtil.isNull( Coupon.getId(),"Coupon","id",resources.getId()); | ||
80 | Coupon.copy(resources); | ||
81 | CouponRepository.save(Coupon); | ||
82 | } catch (Exception e) { | ||
83 | e.printStackTrace(); | ||
84 | throw e; | ||
85 | } finally { | ||
86 | RedissonUtil.unlock(rLock); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | @Transactional(rollbackFor = Exception.class) | ||
92 | @AsyncMqSend() | ||
93 | public void delete(Long id) { | ||
94 | Assert.notNull(id, "The given id must not be null!"); | ||
95 | Coupon Coupon = CouponRepository.findById(id).orElseThrow( | ||
96 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Coupon.class, id), 1)); | ||
97 | CouponRepository.delete(Coupon); | ||
98 | } | ||
99 | |||
100 | |||
101 | @Override | ||
102 | public CouponDTO getByCode(String code) { | ||
103 | return StringUtils.isNotEmpty(code) ? CouponMapper.toDto(CouponRepository.findFirstByCode(code).orElseGet(Coupon::new)) | ||
104 | : new CouponDTO(); | ||
105 | } | ||
106 | } |
1 | package com.topdraw.business.basicdata.coupon.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.coupon.domain.Coupon; | ||
5 | import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface CouponMapper extends BaseMapper<CouponDTO, Coupon> { | ||
15 | |||
16 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/exp/detail/domain/ExpDetail.java
0 → 100644
1 | package com.topdraw.business.basicdata.exp.detail.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-10-22 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_exp_detail") | ||
24 | public class ExpDetail implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 标识 | ||
33 | @Column(name = "code", nullable = false) | ||
34 | private String code; | ||
35 | |||
36 | // 应用code | ||
37 | @Column(name = "app_code") | ||
38 | private String appCode; | ||
39 | |||
40 | // 会员id | ||
41 | @Column(name = "member_id", nullable = false) | ||
42 | private Long memberId; | ||
43 | |||
44 | // 账号id | ||
45 | @Column(name = "account_id") | ||
46 | private Long accountId; | ||
47 | |||
48 | // 原始成长值 | ||
49 | @Column(name = "original_exp", nullable = false) | ||
50 | private Long originalExp; | ||
51 | |||
52 | // 结果成长值 | ||
53 | @Column(name = "result_exp", nullable = false) | ||
54 | private Long resultExp; | ||
55 | |||
56 | // 成长值变化,一般为正数 | ||
57 | @Column(name = "exp", nullable = false) | ||
58 | private Long exp; | ||
59 | |||
60 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
61 | @Column(name = "device_type", nullable = false) | ||
62 | private Integer deviceType; | ||
63 | |||
64 | // 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 | ||
65 | @Column(name = "evt_type", nullable = false) | ||
66 | private Integer evtType; | ||
67 | |||
68 | // 订单id(针对订购操作) | ||
69 | @Column(name = "order_id") | ||
70 | private Long orderId; | ||
71 | |||
72 | // 节目id(针对观影操作) | ||
73 | @Column(name = "media_id") | ||
74 | private Long mediaId; | ||
75 | |||
76 | // 活动id(针对参与活动) | ||
77 | @Column(name = "activity_id") | ||
78 | private Long activityId; | ||
79 | |||
80 | // 成长值变化描述,用于管理侧显示 | ||
81 | @Column(name = "description", nullable = false) | ||
82 | private String description; | ||
83 | |||
84 | // 创建时间 | ||
85 | @CreatedDate | ||
86 | @Column(name = "create_time") | ||
87 | private Timestamp createTime; | ||
88 | |||
89 | // 更新时间 | ||
90 | @LastModifiedDate | ||
91 | @Column(name = "update_time") | ||
92 | private Timestamp updateTime; | ||
93 | |||
94 | public void copy(ExpDetail source){ | ||
95 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
96 | } | ||
97 | } |
1 | package com.topdraw.business.basicdata.exp.detail.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; | ||
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 2021-10-22 | ||
12 | */ | ||
13 | public interface ExpDetailRepository extends JpaRepository<ExpDetail, Long>, JpaSpecificationExecutor<ExpDetail> { | ||
14 | |||
15 | Optional<ExpDetail> findFirstByCode(String code); | ||
16 | } |
1 | package com.topdraw.business.basicdata.exp.detail.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; | ||
6 | import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService; | ||
7 | import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-22 | ||
17 | */ | ||
18 | @Api(tags = "ExpDetail管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/api/ExpDetail") | ||
21 | public class ExpDetailController { | ||
22 | |||
23 | @Autowired | ||
24 | private ExpDetailService ExpDetailService; | ||
25 | |||
26 | @GetMapping | ||
27 | @ApiOperation("查询ExpDetail") | ||
28 | public ResultInfo getExpDetails(ExpDetailQueryCriteria criteria, Pageable pageable) { | ||
29 | return ResultInfo.successPage(ExpDetailService.queryAll(criteria,pageable)); | ||
30 | } | ||
31 | |||
32 | @GetMapping(value = "/all") | ||
33 | @ApiOperation("查询所有ExpDetail") | ||
34 | public ResultInfo getExpDetails(ExpDetailQueryCriteria criteria) { | ||
35 | return ResultInfo.success(ExpDetailService.queryAll(criteria)); | ||
36 | } | ||
37 | |||
38 | @Log | ||
39 | @PostMapping | ||
40 | @ApiOperation("新增ExpDetail") | ||
41 | public ResultInfo create(@Validated @RequestBody ExpDetail resources) { | ||
42 | ExpDetailService.create(resources); | ||
43 | return ResultInfo.success(); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PutMapping | ||
48 | @ApiOperation("修改ExpDetail") | ||
49 | public ResultInfo update(@Validated @RequestBody ExpDetail resources) { | ||
50 | ExpDetailService.update(resources); | ||
51 | return ResultInfo.success(); | ||
52 | } | ||
53 | |||
54 | |||
55 | @Log | ||
56 | @DeleteMapping(value = "/{id}") | ||
57 | @ApiOperation("删除ExpDetail") | ||
58 | public ResultInfo delete(@PathVariable Long id) { | ||
59 | ExpDetailService.delete(id); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | @GetMapping(value = "/getByCode/{code}") | ||
64 | @ApiOperation(value = "根据标识查询") | ||
65 | public ResultInfo getByCode(@PathVariable String code) { | ||
66 | return ResultInfo.success(ExpDetailService.getByCode(code)); | ||
67 | } | ||
68 | } |
1 | package com.topdraw.business.basicdata.exp.detail.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; | ||
4 | import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO; | ||
5 | import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface ExpDetailService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<ExpDetailDTO> | ||
28 | */ | ||
29 | List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return ExpDetailDTO | ||
35 | */ | ||
36 | ExpDetailDTO findById(Long id); | ||
37 | |||
38 | void create(ExpDetail resources); | ||
39 | |||
40 | void update(ExpDetail resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | /** | ||
45 | * Code校验 | ||
46 | * @param code | ||
47 | * @return ExpDetailDTO | ||
48 | */ | ||
49 | ExpDetailDTO getByCode(String code); | ||
50 | } |
1 | package com.topdraw.business.basicdata.exp.detail.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class ExpDetailDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 标识 | ||
19 | private String code; | ||
20 | |||
21 | // 应用code | ||
22 | private String appCode; | ||
23 | |||
24 | // 会员id | ||
25 | private Long memberId; | ||
26 | |||
27 | // 账号id | ||
28 | private Long accountId; | ||
29 | |||
30 | // 原始成长值 | ||
31 | private Long originalExp; | ||
32 | |||
33 | // 结果成长值 | ||
34 | private Long resultExp; | ||
35 | |||
36 | // 成长值变化,一般为正数 | ||
37 | private Long exp; | ||
38 | |||
39 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
40 | private Integer deviceType; | ||
41 | |||
42 | // 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 | ||
43 | private Integer evtType; | ||
44 | |||
45 | // 订单id(针对订购操作) | ||
46 | private Long orderId; | ||
47 | |||
48 | // 节目id(针对观影操作) | ||
49 | private Long mediaId; | ||
50 | |||
51 | // 活动id(针对参与活动) | ||
52 | private Long activityId; | ||
53 | |||
54 | // 成长值变化描述,用于管理侧显示 | ||
55 | private String description; | ||
56 | |||
57 | // 创建时间 | ||
58 | private Timestamp createTime; | ||
59 | |||
60 | // 更新时间 | ||
61 | private Timestamp updateTime; | ||
62 | } |
1 | package com.topdraw.business.basicdata.exp.detail.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.exp.detail.repository.ExpDetailRepository; | ||
7 | import com.topdraw.business.basicdata.exp.detail.service.ExpDetailService; | ||
8 | import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO; | ||
9 | import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.exp.detail.service.mapper.ExpDetailMapper; | ||
11 | import org.redisson.api.RLock; | ||
12 | import org.redisson.api.RedissonClient; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | ||
14 | import org.springframework.stereotype.Service; | ||
15 | import org.springframework.transaction.annotation.Propagation; | ||
16 | import org.springframework.transaction.annotation.Transactional; | ||
17 | import org.springframework.dao.EmptyResultDataAccessException; | ||
18 | import org.springframework.data.domain.Page; | ||
19 | import org.springframework.data.domain.Pageable; | ||
20 | import org.springframework.util.Assert; | ||
21 | import com.topdraw.utils.PageUtil; | ||
22 | import com.topdraw.utils.QueryHelp; | ||
23 | import com.topdraw.utils.StringUtils; | ||
24 | |||
25 | import java.util.List; | ||
26 | import java.util.Map; | ||
27 | |||
28 | /** | ||
29 | * @author XiangHan | ||
30 | * @date 2021-10-22 | ||
31 | */ | ||
32 | @Service | ||
33 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
34 | public class ExpDetailServiceImpl implements ExpDetailService { | ||
35 | |||
36 | @Autowired | ||
37 | private ExpDetailRepository ExpDetailRepository; | ||
38 | |||
39 | @Autowired | ||
40 | private ExpDetailMapper ExpDetailMapper; | ||
41 | |||
42 | @Autowired | ||
43 | private RedissonClient redissonClient; | ||
44 | |||
45 | @Override | ||
46 | public Map<String, Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable) { | ||
47 | Page<ExpDetail> page = ExpDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
48 | return PageUtil.toPage(page.map(ExpDetailMapper::toDto)); | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria) { | ||
53 | return ExpDetailMapper.toDto(ExpDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | public ExpDetailDTO findById(Long id) { | ||
58 | ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseGet(ExpDetail::new); | ||
59 | ValidationUtil.isNull(ExpDetail.getId(),"ExpDetail","id",id); | ||
60 | return ExpDetailMapper.toDto(ExpDetail); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | @Transactional(rollbackFor = Exception.class) | ||
65 | @AsyncMqSend() | ||
66 | public void create(ExpDetail resources) { | ||
67 | ExpDetailRepository.save(resources); | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | @Transactional(rollbackFor = Exception.class) | ||
72 | @AsyncMqSend() | ||
73 | public void update(ExpDetail resources) { | ||
74 | RLock rLock = this.redissonClient.getLock(resources.getId().toString()); | ||
75 | try { | ||
76 | ExpDetail ExpDetail = ExpDetailRepository.findById(resources.getId()).orElseGet(ExpDetail::new); | ||
77 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); | ||
78 | ExpDetail.copy(resources); | ||
79 | ExpDetailRepository.save(ExpDetail); | ||
80 | } catch (Exception e) { | ||
81 | e.printStackTrace(); | ||
82 | throw e; | ||
83 | } finally { | ||
84 | rLock.unlock(); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | @Override | ||
89 | @Transactional(rollbackFor = Exception.class) | ||
90 | @AsyncMqSend() | ||
91 | public void delete(Long id) { | ||
92 | Assert.notNull(id, "The given id must not be null!"); | ||
93 | ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseThrow( | ||
94 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ExpDetail.class, id), 1)); | ||
95 | ExpDetailRepository.delete(ExpDetail); | ||
96 | } | ||
97 | |||
98 | |||
99 | @Override | ||
100 | public ExpDetailDTO getByCode(String code) { | ||
101 | return StringUtils.isNotEmpty(code) ? ExpDetailMapper.toDto(ExpDetailRepository.findFirstByCode(code).orElseGet(ExpDetail::new)) | ||
102 | : new ExpDetailDTO(); | ||
103 | } | ||
104 | } |
1 | package com.topdraw.business.basicdata.exp.detail.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.exp.detail.domain.ExpDetail; | ||
5 | import com.topdraw.business.basicdata.exp.detail.service.dto.ExpDetailDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface ExpDetailMapper extends BaseMapper<ExpDetailDTO, ExpDetail> { | ||
15 | |||
16 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/exp/history/domain/ExpHistory.java
0 → 100644
1 | package com.topdraw.business.basicdata.exp.history.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-10-22 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_exp_history") | ||
24 | public class ExpHistory implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 标识 | ||
33 | @Column(name = "code", nullable = false) | ||
34 | private String code; | ||
35 | |||
36 | // 会员id | ||
37 | @Column(name = "member_id", nullable = false) | ||
38 | private Long memberId; | ||
39 | |||
40 | // 账号id | ||
41 | @Column(name = "account_id") | ||
42 | private Long accountId; | ||
43 | |||
44 | // 原始成长值 | ||
45 | @Column(name = "original_exp", nullable = false) | ||
46 | private Long originalExp; | ||
47 | |||
48 | // 结果成长值 | ||
49 | @Column(name = "result_exp", nullable = false) | ||
50 | private Long resultExp; | ||
51 | |||
52 | // 成长值变化,一般为正数 | ||
53 | @Column(name = "exp", nullable = false) | ||
54 | private Long exp; | ||
55 | |||
56 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)4.系统赠送 | ||
57 | @Column(name = "device_type", nullable = false) | ||
58 | private Integer deviceType; | ||
59 | |||
60 | // 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 | ||
61 | @Column(name = "evt_type", nullable = false) | ||
62 | private Integer evtType; | ||
63 | |||
64 | // 订单id(针对订购操作) | ||
65 | @Column(name = "order_id") | ||
66 | private Long orderId; | ||
67 | |||
68 | // 节目id(针对观影操作) | ||
69 | @Column(name = "media_id") | ||
70 | private Long mediaId; | ||
71 | |||
72 | // 活动id(针对参与活动) | ||
73 | @Column(name = "activity_id") | ||
74 | private Long activityId; | ||
75 | |||
76 | // 成长值变化描述,用于管理侧显示 | ||
77 | @Column(name = "description", nullable = false) | ||
78 | private String description; | ||
79 | |||
80 | // 创建时间 | ||
81 | @CreatedDate | ||
82 | @Column(name = "create_time") | ||
83 | private Timestamp createTime; | ||
84 | |||
85 | // 更新时间 | ||
86 | @LastModifiedDate | ||
87 | @Column(name = "update_time") | ||
88 | private Timestamp updateTime; | ||
89 | |||
90 | public void copy(ExpHistory source){ | ||
91 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
92 | } | ||
93 | } |
1 | package com.topdraw.business.basicdata.exp.history.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; | ||
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 2021-10-22 | ||
12 | */ | ||
13 | public interface ExpHistoryRepository extends JpaRepository<ExpHistory, Long>, JpaSpecificationExecutor<ExpHistory> { | ||
14 | |||
15 | Optional<ExpHistory> findFirstByCode(String code); | ||
16 | } |
1 | package com.topdraw.business.basicdata.exp.history.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; | ||
6 | import com.topdraw.business.basicdata.exp.history.service.ExpHistoryService; | ||
7 | import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-22 | ||
17 | */ | ||
18 | @Api(tags = "ExpHistory管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/api/ExpHistory") | ||
21 | public class ExpHistoryController { | ||
22 | |||
23 | @Autowired | ||
24 | private ExpHistoryService ExpHistoryService; | ||
25 | |||
26 | @GetMapping | ||
27 | @ApiOperation("查询ExpHistory") | ||
28 | public ResultInfo getExpHistorys(ExpHistoryQueryCriteria criteria, Pageable pageable) { | ||
29 | return ResultInfo.successPage(ExpHistoryService.queryAll(criteria,pageable)); | ||
30 | } | ||
31 | |||
32 | @GetMapping(value = "/all") | ||
33 | @ApiOperation("查询所有ExpHistory") | ||
34 | public ResultInfo getExpHistorys(ExpHistoryQueryCriteria criteria) { | ||
35 | return ResultInfo.success(ExpHistoryService.queryAll(criteria)); | ||
36 | } | ||
37 | |||
38 | @Log | ||
39 | @PostMapping | ||
40 | @ApiOperation("新增ExpHistory") | ||
41 | public ResultInfo create(@Validated @RequestBody ExpHistory resources) { | ||
42 | ExpHistoryService.create(resources); | ||
43 | return ResultInfo.success(); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PutMapping | ||
48 | @ApiOperation("修改ExpHistory") | ||
49 | public ResultInfo update(@Validated @RequestBody ExpHistory resources) { | ||
50 | ExpHistoryService.update(resources); | ||
51 | return ResultInfo.success(); | ||
52 | } | ||
53 | |||
54 | |||
55 | @Log | ||
56 | @DeleteMapping(value = "/{id}") | ||
57 | @ApiOperation("删除ExpHistory") | ||
58 | public ResultInfo delete(@PathVariable Long id) { | ||
59 | ExpHistoryService.delete(id); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | @GetMapping(value = "/getByCode/{code}") | ||
64 | @ApiOperation(value = "根据标识查询") | ||
65 | public ResultInfo getByCode(@PathVariable String code) { | ||
66 | return ResultInfo.success(ExpHistoryService.getByCode(code)); | ||
67 | } | ||
68 | } |
1 | package com.topdraw.business.basicdata.exp.history.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; | ||
4 | import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO; | ||
5 | import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface ExpHistoryService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(ExpHistoryQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<ExpHistoryDTO> | ||
28 | */ | ||
29 | List<ExpHistoryDTO> queryAll(ExpHistoryQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return ExpHistoryDTO | ||
35 | */ | ||
36 | ExpHistoryDTO findById(Long id); | ||
37 | |||
38 | void create(ExpHistory resources); | ||
39 | |||
40 | void update(ExpHistory resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | /** | ||
45 | * Code校验 | ||
46 | * @param code | ||
47 | * @return ExpHistoryDTO | ||
48 | */ | ||
49 | ExpHistoryDTO getByCode(String code); | ||
50 | } |
1 | package com.topdraw.business.basicdata.exp.history.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class ExpHistoryDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 标识 | ||
19 | private String code; | ||
20 | |||
21 | // 会员id | ||
22 | private Long memberId; | ||
23 | |||
24 | // 账号id | ||
25 | private Long accountId; | ||
26 | |||
27 | // 原始成长值 | ||
28 | private Long originalExp; | ||
29 | |||
30 | // 结果成长值 | ||
31 | private Long resultExp; | ||
32 | |||
33 | // 成长值变化,一般为正数 | ||
34 | private Long exp; | ||
35 | |||
36 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)4.系统赠送 | ||
37 | private Integer deviceType; | ||
38 | |||
39 | // 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 | ||
40 | private Integer evtType; | ||
41 | |||
42 | // 订单id(针对订购操作) | ||
43 | private Long orderId; | ||
44 | |||
45 | // 节目id(针对观影操作) | ||
46 | private Long mediaId; | ||
47 | |||
48 | // 活动id(针对参与活动) | ||
49 | private Long activityId; | ||
50 | |||
51 | // 成长值变化描述,用于管理侧显示 | ||
52 | private String description; | ||
53 | |||
54 | // 创建时间 | ||
55 | private Timestamp createTime; | ||
56 | |||
57 | // 更新时间 | ||
58 | private Timestamp updateTime; | ||
59 | } |
1 | package com.topdraw.business.basicdata.exp.history.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.exp.history.repository.ExpHistoryRepository; | ||
7 | import com.topdraw.business.basicdata.exp.history.service.ExpHistoryService; | ||
8 | import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO; | ||
9 | import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.exp.history.service.mapper.ExpHistoryMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | import com.topdraw.utils.StringUtils; | ||
22 | |||
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | |||
26 | /** | ||
27 | * @author XiangHan | ||
28 | * @date 2021-10-22 | ||
29 | */ | ||
30 | @Service | ||
31 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
32 | public class ExpHistoryServiceImpl implements ExpHistoryService { | ||
33 | |||
34 | @Autowired | ||
35 | private ExpHistoryRepository ExpHistoryRepository; | ||
36 | |||
37 | @Autowired | ||
38 | private ExpHistoryMapper ExpHistoryMapper; | ||
39 | |||
40 | @Override | ||
41 | public Map<String, Object> queryAll(ExpHistoryQueryCriteria criteria, Pageable pageable) { | ||
42 | Page<ExpHistory> page = ExpHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
43 | return PageUtil.toPage(page.map(ExpHistoryMapper::toDto)); | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public List<ExpHistoryDTO> queryAll(ExpHistoryQueryCriteria criteria) { | ||
48 | return ExpHistoryMapper.toDto(ExpHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public ExpHistoryDTO findById(Long id) { | ||
53 | ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseGet(ExpHistory::new); | ||
54 | ValidationUtil.isNull(ExpHistory.getId(),"ExpHistory","id",id); | ||
55 | return ExpHistoryMapper.toDto(ExpHistory); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | @Transactional(rollbackFor = Exception.class) | ||
60 | // @AsyncMqSend() | ||
61 | public void create(ExpHistory resources) { | ||
62 | ExpHistoryRepository.save(resources); | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | @Transactional(rollbackFor = Exception.class) | ||
67 | @AsyncMqSend() | ||
68 | public void update(ExpHistory resources) { | ||
69 | ExpHistory ExpHistory = ExpHistoryRepository.findById(resources.getId()).orElseGet(ExpHistory::new); | ||
70 | ValidationUtil.isNull( ExpHistory.getId(),"ExpHistory","id",resources.getId()); | ||
71 | ExpHistory.copy(resources); | ||
72 | ExpHistoryRepository.save(ExpHistory); | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | @Transactional(rollbackFor = Exception.class) | ||
77 | @AsyncMqSend() | ||
78 | public void delete(Long id) { | ||
79 | Assert.notNull(id, "The given id must not be null!"); | ||
80 | ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseThrow( | ||
81 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ExpHistory.class, id), 1)); | ||
82 | ExpHistoryRepository.delete(ExpHistory); | ||
83 | } | ||
84 | |||
85 | |||
86 | @Override | ||
87 | public ExpHistoryDTO getByCode(String code) { | ||
88 | return StringUtils.isNotEmpty(code) ? ExpHistoryMapper.toDto(ExpHistoryRepository.findFirstByCode(code).orElseGet(ExpHistory::new)) | ||
89 | : new ExpHistoryDTO(); | ||
90 | } | ||
91 | } |
1 | package com.topdraw.business.basicdata.exp.history.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.exp.history.domain.ExpHistory; | ||
5 | import com.topdraw.business.basicdata.exp.history.service.dto.ExpHistoryDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface ExpHistoryMapper extends BaseMapper<ExpHistoryDTO, ExpHistory> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.basicdata.member.address.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-10-22 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_member_address") | ||
24 | public class MemberAddress implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 会员id | ||
33 | @Column(name = "member_id", nullable = false) | ||
34 | private Long memberId; | ||
35 | |||
36 | // 类型 1:家;2:公司;3:学校 | ||
37 | @Column(name = "type", nullable = false) | ||
38 | private Integer type; | ||
39 | |||
40 | // 是否默认地址 | ||
41 | @Column(name = "is_default", nullable = false) | ||
42 | private Integer isDefault; | ||
43 | |||
44 | // 显示顺序 | ||
45 | @Column(name = "sequence") | ||
46 | private Integer sequence; | ||
47 | |||
48 | // 状态 0:不可用;1-可用 | ||
49 | @Column(name = "status", nullable = false) | ||
50 | private Integer status; | ||
51 | |||
52 | // 联系人姓名 | ||
53 | @Column(name = "contactor", nullable = false) | ||
54 | private String contactor; | ||
55 | |||
56 | // 联系人电话 | ||
57 | @Column(name = "cellphone", nullable = false) | ||
58 | private String cellphone; | ||
59 | |||
60 | // 国家 | ||
61 | @Column(name = "country", nullable = false) | ||
62 | private String country; | ||
63 | |||
64 | // 省份 | ||
65 | @Column(name = "province", nullable = false) | ||
66 | private String province; | ||
67 | |||
68 | // 城市 | ||
69 | @Column(name = "city", nullable = false) | ||
70 | private String city; | ||
71 | |||
72 | // 区县 | ||
73 | @Column(name = "district", nullable = false) | ||
74 | private String district; | ||
75 | |||
76 | // 地址 | ||
77 | @Column(name = "address", nullable = false) | ||
78 | private String address; | ||
79 | |||
80 | // 邮编 | ||
81 | @Column(name = "zip_code") | ||
82 | private String zipCode; | ||
83 | |||
84 | // 创建时间 | ||
85 | @CreatedDate | ||
86 | @Column(name = "create_time") | ||
87 | private Timestamp createTime; | ||
88 | |||
89 | // 更新时间 | ||
90 | @LastModifiedDate | ||
91 | @Column(name = "update_time") | ||
92 | private Timestamp updateTime; | ||
93 | |||
94 | public void copy(MemberAddress source){ | ||
95 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
96 | } | ||
97 | } |
1 | package com.topdraw.business.basicdata.member.address.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; | ||
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-22 | ||
10 | */ | ||
11 | public interface MemberAddressRepository extends JpaRepository<MemberAddress, Long>, JpaSpecificationExecutor<MemberAddress> { | ||
12 | |||
13 | } |
1 | package com.topdraw.business.basicdata.member.address.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; | ||
6 | import com.topdraw.business.basicdata.member.address.service.MemberAddressService; | ||
7 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-22 | ||
17 | */ | ||
18 | @Api(tags = "MemberAddress管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/api/MemberAddress") | ||
21 | public class MemberAddressController { | ||
22 | |||
23 | @Autowired | ||
24 | private MemberAddressService MemberAddressService; | ||
25 | |||
26 | @GetMapping(value = "/pageMemberAddress") | ||
27 | @ApiOperation("查询MemberAddress") | ||
28 | public ResultInfo pageMemberAddress(MemberAddressQueryCriteria criteria, Pageable pageable) { | ||
29 | return ResultInfo.successPage(MemberAddressService.queryAll(criteria,pageable)); | ||
30 | } | ||
31 | |||
32 | @GetMapping(value = "/findById/{id}") | ||
33 | @ApiOperation("查询指定MemberAddress") | ||
34 | public ResultInfo findById(@PathVariable(value = "id") Long id) { | ||
35 | return ResultInfo.success(MemberAddressService.findById(id)); | ||
36 | } | ||
37 | |||
38 | @Log | ||
39 | @PostMapping(value = "/create") | ||
40 | @ApiOperation("新增MemberAddress") | ||
41 | public ResultInfo create(@Validated @RequestBody MemberAddress resources) { | ||
42 | MemberAddressService.create(resources); | ||
43 | return ResultInfo.success(); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PutMapping(value = "/update") | ||
48 | @ApiOperation("修改MemberAddress") | ||
49 | public ResultInfo update(@Validated @RequestBody MemberAddress resources) { | ||
50 | MemberAddressService.update(resources); | ||
51 | return ResultInfo.success(); | ||
52 | } | ||
53 | |||
54 | @Log | ||
55 | @DeleteMapping(value = "/delete/{id}") | ||
56 | @ApiOperation("删除MemberAddress") | ||
57 | public ResultInfo delete(@PathVariable Long id) { | ||
58 | MemberAddressService.delete(id); | ||
59 | return ResultInfo.success(); | ||
60 | } | ||
61 | |||
62 | } |
1 | package com.topdraw.business.basicdata.member.address.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; | ||
4 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO; | ||
5 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface MemberAddressService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(MemberAddressQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<MemberAddressDTO> | ||
28 | */ | ||
29 | List<MemberAddressDTO> queryAll(MemberAddressQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return MemberAddressDTO | ||
35 | */ | ||
36 | MemberAddressDTO findById(Long id); | ||
37 | |||
38 | void create(MemberAddress resources); | ||
39 | |||
40 | void update(MemberAddress resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | } |
1 | package com.topdraw.business.basicdata.member.address.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class MemberAddressDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 会员id | ||
19 | private Long memberId; | ||
20 | |||
21 | // 类型 1:家;2:公司;3:学校 | ||
22 | private Integer type; | ||
23 | |||
24 | // 是否默认地址 | ||
25 | private Integer isDefault; | ||
26 | |||
27 | // 显示顺序 | ||
28 | private Integer sequence; | ||
29 | |||
30 | // 状态 0:不可用;1-可用 | ||
31 | private Integer status; | ||
32 | |||
33 | // 联系人姓名 | ||
34 | private String contactor; | ||
35 | |||
36 | // 联系人电话 | ||
37 | private String cellphone; | ||
38 | |||
39 | // 国家 | ||
40 | private String country; | ||
41 | |||
42 | // 省份 | ||
43 | private String province; | ||
44 | |||
45 | // 城市 | ||
46 | private String city; | ||
47 | |||
48 | // 区县 | ||
49 | private String district; | ||
50 | |||
51 | // 地址 | ||
52 | private String address; | ||
53 | |||
54 | // 邮编 | ||
55 | private String zipCode; | ||
56 | |||
57 | // 创建时间 | ||
58 | private Timestamp createTime; | ||
59 | |||
60 | // 更新时间 | ||
61 | private Timestamp updateTime; | ||
62 | } |
1 | package com.topdraw.business.basicdata.member.address.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.member.address.repository.MemberAddressRepository; | ||
7 | import com.topdraw.business.basicdata.member.address.service.MemberAddressService; | ||
8 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO; | ||
9 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.member.address.service.mapper.MemberAddressMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | |||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | |||
25 | /** | ||
26 | * @author XiangHan | ||
27 | * @date 2021-10-22 | ||
28 | */ | ||
29 | @Service | ||
30 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
31 | public class MemberAddressServiceImpl implements MemberAddressService { | ||
32 | |||
33 | @Autowired | ||
34 | private MemberAddressRepository MemberAddressRepository; | ||
35 | |||
36 | @Autowired | ||
37 | private MemberAddressMapper MemberAddressMapper; | ||
38 | |||
39 | @Override | ||
40 | public Map<String, Object> queryAll(MemberAddressQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<MemberAddress> page = MemberAddressRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(MemberAddressMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<MemberAddressDTO> queryAll(MemberAddressQueryCriteria criteria) { | ||
47 | return MemberAddressMapper.toDto(MemberAddressRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | public MemberAddressDTO findById(Long id) { | ||
52 | MemberAddress MemberAddress = MemberAddressRepository.findById(id).orElseGet(MemberAddress::new); | ||
53 | ValidationUtil.isNull(MemberAddress.getId(),"MemberAddress","id",id); | ||
54 | return MemberAddressMapper.toDto(MemberAddress); | ||
55 | } | ||
56 | |||
57 | @Override | ||
58 | @Transactional(rollbackFor = Exception.class) | ||
59 | @AsyncMqSend() | ||
60 | public void create(MemberAddress resources) { | ||
61 | MemberAddressRepository.save(resources); | ||
62 | } | ||
63 | |||
64 | @Override | ||
65 | @Transactional(rollbackFor = Exception.class) | ||
66 | @AsyncMqSend() | ||
67 | public void update(MemberAddress resources) { | ||
68 | MemberAddress MemberAddress = MemberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new); | ||
69 | ValidationUtil.isNull( MemberAddress.getId(),"MemberAddress","id",resources.getId()); | ||
70 | MemberAddress.copy(resources); | ||
71 | MemberAddressRepository.save(MemberAddress); | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | @Transactional(rollbackFor = Exception.class) | ||
76 | @AsyncMqSend() | ||
77 | public void delete(Long id) { | ||
78 | Assert.notNull(id, "The given id must not be null!"); | ||
79 | MemberAddress MemberAddress = MemberAddressRepository.findById(id).orElseThrow( | ||
80 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberAddress.class, id), 1)); | ||
81 | MemberAddressRepository.delete(MemberAddress); | ||
82 | } | ||
83 | |||
84 | |||
85 | } |
1 | package com.topdraw.business.basicdata.member.address.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.member.address.domain.MemberAddress; | ||
5 | import com.topdraw.business.basicdata.member.address.service.dto.MemberAddressDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberAddressMapper extends BaseMapper<MemberAddressDTO, MemberAddress> { | ||
15 | |||
16 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/member/domain/Member.java
0 → 100644
1 | package com.topdraw.business.basicdata.member.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-10-22 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_member") | ||
24 | public class Member implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 标识 | ||
33 | @Column(name = "code", nullable = false) | ||
34 | private String code; | ||
35 | |||
36 | // 类型 1:大屏;2:小屏 | ||
37 | @Column(name = "`type`", nullable = false) | ||
38 | private Integer type; | ||
39 | |||
40 | // 状态 0:不可用;1:可用 | ||
41 | @Column(name = "`status`", nullable = false) | ||
42 | private Integer status; | ||
43 | |||
44 | // 昵称 base64 | ||
45 | @Column(name = "nickname") | ||
46 | private String nickname; | ||
47 | |||
48 | // 描述 | ||
49 | @Column(name = "description") | ||
50 | private String description; | ||
51 | |||
52 | // 性别 0:女;1:男;-1:未知 | ||
53 | @Column(name = "gender", nullable = false) | ||
54 | private Integer gender; | ||
55 | |||
56 | // 生日 | ||
57 | @Column(name = "birthday") | ||
58 | private String birthday; | ||
59 | |||
60 | // 头像 | ||
61 | @Column(name = "avatar_url") | ||
62 | private String avatarUrl; | ||
63 | |||
64 | // 分组信息 | ||
65 | @Column(name = "`groups`") | ||
66 | private String groups; | ||
67 | |||
68 | // 标签 | ||
69 | @Column(name = "tags") | ||
70 | private String tags; | ||
71 | |||
72 | // 是否会员 0:非会员;1:会员 | ||
73 | @Column(name = "vip", nullable = false) | ||
74 | private Integer vip; | ||
75 | |||
76 | // 会员等级(对应level表的level字段,非id) | ||
77 | @Column(name = "`level`", nullable = false) | ||
78 | private Integer level; | ||
79 | |||
80 | // 成长值 | ||
81 | @Column(name = "`exp`") | ||
82 | private Long exp; | ||
83 | |||
84 | // 当前积分 | ||
85 | @Column(name = "`points`") | ||
86 | private Long points; | ||
87 | |||
88 | // 即将到期积分(一个月内) | ||
89 | @Column(name = "due_points") | ||
90 | private Long duePoints; | ||
91 | |||
92 | // 优惠券数量 | ||
93 | @Column(name = "coupon_amount") | ||
94 | private Long couponAmount; | ||
95 | |||
96 | // 即将过期优惠券数量 | ||
97 | @Column(name = "due_coupon_amount") | ||
98 | private Long dueCouponAmount; | ||
99 | |||
100 | // iptv账号id | ||
101 | @Column(name = "user_iptv_id") | ||
102 | private Long userIptvId; | ||
103 | |||
104 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | ||
105 | @Column(name = "bind_iptv_platform_type") | ||
106 | private Integer bindIptvPlatformType; | ||
107 | |||
108 | // iptv账号绑定时间 | ||
109 | @Column(name = "bind_iptv_time") | ||
110 | private Timestamp bindIptvTime; | ||
111 | |||
112 | // 创建时间 | ||
113 | @CreatedDate | ||
114 | @Column(name = "create_time") | ||
115 | private Timestamp createTime; | ||
116 | |||
117 | // 更新时间 | ||
118 | @LastModifiedDate | ||
119 | @Column(name = "update_time") | ||
120 | private Timestamp updateTime; | ||
121 | |||
122 | // 是否在黑名单 1:是;0否 | ||
123 | // @Column(name = "black_status") | ||
124 | // private Integer blackStatus; | ||
125 | |||
126 | public void copy(Member source){ | ||
127 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
128 | } | ||
129 | } |
1 | package com.topdraw.business.basicdata.member.level.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-10-22 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_member_level") | ||
24 | public class MemberLevel implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 标识 | ||
33 | @Column(name = "code", nullable = false) | ||
34 | private String code; | ||
35 | |||
36 | // 名称 | ||
37 | @Column(name = "name", nullable = false) | ||
38 | private String name; | ||
39 | |||
40 | // 状态 0:未启用;1:启用 | ||
41 | @Column(name = "status", nullable = false) | ||
42 | private Integer status; | ||
43 | |||
44 | // 对应成长值 | ||
45 | @Column(name = "exp_value", nullable = false) | ||
46 | private Long expValue; | ||
47 | |||
48 | // 等级(不可重复,数字越大等级越高) | ||
49 | @Column(name = "level", nullable = false) | ||
50 | private Integer level; | ||
51 | |||
52 | // 会员徽标 | ||
53 | @Column(name = "icon_url") | ||
54 | private String iconUrl; | ||
55 | |||
56 | // 描述 | ||
57 | @Column(name = "description") | ||
58 | private String description; | ||
59 | |||
60 | // 对应任务id,通过此字段可获得该等级所对应的权益 | ||
61 | @Column(name = "task_id") | ||
62 | private Long taskId; | ||
63 | |||
64 | // 创建时间 | ||
65 | @CreatedDate | ||
66 | @Column(name = "create_time") | ||
67 | private Timestamp createTime; | ||
68 | |||
69 | // 更新时间 | ||
70 | @LastModifiedDate | ||
71 | @Column(name = "update_time") | ||
72 | private Timestamp updateTime; | ||
73 | |||
74 | public void copy(MemberLevel source){ | ||
75 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
76 | } | ||
77 | } |
1 | package com.topdraw.business.basicdata.member.level.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.level.domain.MemberLevel; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | |||
7 | import java.util.List; | ||
8 | import java.util.Optional; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface MemberLevelRepository extends JpaRepository<MemberLevel, Long>, JpaSpecificationExecutor<MemberLevel> { | ||
15 | |||
16 | Optional<MemberLevel> findFirstByCode(String code); | ||
17 | |||
18 | List<MemberLevel> findByLevelAndStatus(Integer level, Integer status); | ||
19 | } |
1 | package com.topdraw.business.basicdata.member.level.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.member.level.domain.MemberLevel; | ||
6 | import com.topdraw.business.basicdata.member.level.service.MemberLevelService; | ||
7 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-22 | ||
17 | */ | ||
18 | @Api(tags = "MemberLevel管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/api/MemberLevel") | ||
21 | public class MemberLevelController { | ||
22 | |||
23 | @Autowired | ||
24 | private MemberLevelService MemberLevelService; | ||
25 | |||
26 | @GetMapping | ||
27 | @ApiOperation("查询MemberLevel") | ||
28 | public ResultInfo getMemberLevels(MemberLevelQueryCriteria criteria, Pageable pageable) { | ||
29 | return ResultInfo.successPage(MemberLevelService.queryAll(criteria,pageable)); | ||
30 | } | ||
31 | |||
32 | @GetMapping(value = "/all") | ||
33 | @ApiOperation("查询所有MemberLevel") | ||
34 | public ResultInfo getMemberLevels(MemberLevelQueryCriteria criteria) { | ||
35 | return ResultInfo.success(MemberLevelService.queryAll(criteria)); | ||
36 | } | ||
37 | |||
38 | @Log | ||
39 | @PostMapping | ||
40 | @ApiOperation("新增MemberLevel") | ||
41 | public ResultInfo create(@Validated @RequestBody MemberLevel resources) { | ||
42 | MemberLevelService.create(resources); | ||
43 | return ResultInfo.success(); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PutMapping | ||
48 | @ApiOperation("修改MemberLevel") | ||
49 | public ResultInfo update(@Validated @RequestBody MemberLevel resources) { | ||
50 | MemberLevelService.update(resources); | ||
51 | return ResultInfo.success(); | ||
52 | } | ||
53 | |||
54 | |||
55 | @Log | ||
56 | @DeleteMapping(value = "/{id}") | ||
57 | @ApiOperation("删除MemberLevel") | ||
58 | public ResultInfo delete(@PathVariable Long id) { | ||
59 | MemberLevelService.delete(id); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | @GetMapping(value = "/getByCode/{code}") | ||
64 | @ApiOperation(value = "根据标识查询") | ||
65 | public ResultInfo getByCode(@PathVariable String code) { | ||
66 | return ResultInfo.success(MemberLevelService.getByCode(code)); | ||
67 | } | ||
68 | } |
1 | package com.topdraw.business.basicdata.member.level.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.level.domain.MemberLevel; | ||
4 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; | ||
5 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface MemberLevelService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(MemberLevelQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<MemberLevelDTO> | ||
28 | */ | ||
29 | List<MemberLevelDTO> queryAll(MemberLevelQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return MemberLevelDTO | ||
35 | */ | ||
36 | MemberLevelDTO findById(Long id); | ||
37 | |||
38 | void create(MemberLevel resources); | ||
39 | |||
40 | void update(MemberLevel resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | /** | ||
45 | * Code校验 | ||
46 | * @param code | ||
47 | * @return MemberLevelDTO | ||
48 | */ | ||
49 | MemberLevelDTO getByCode(String code); | ||
50 | |||
51 | List<MemberLevelDTO> findLevelAndStatus(Integer i, Integer status); | ||
52 | } |
1 | package com.topdraw.business.basicdata.member.level.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class MemberLevelDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 标识 | ||
19 | private String code; | ||
20 | |||
21 | // 名称 | ||
22 | private String name; | ||
23 | |||
24 | // 状态 0:未启用;1:启用 | ||
25 | private Integer status; | ||
26 | |||
27 | // 对应成长值 | ||
28 | private Long expValue; | ||
29 | |||
30 | // 等级(不可重复,数字越大等级越高) | ||
31 | private Integer level; | ||
32 | |||
33 | // 会员徽标 | ||
34 | private String iconUrl; | ||
35 | |||
36 | // 描述 | ||
37 | private String description; | ||
38 | |||
39 | // 对应任务id,通过此字段可获得该等级所对应的权益 | ||
40 | private Long taskId; | ||
41 | |||
42 | // 创建时间 | ||
43 | private Timestamp createTime; | ||
44 | |||
45 | // 更新时间 | ||
46 | private Timestamp updateTime; | ||
47 | } |
1 | package com.topdraw.business.basicdata.member.level.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.level.domain.MemberLevel; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.member.level.repository.MemberLevelRepository; | ||
7 | import com.topdraw.business.basicdata.member.level.service.MemberLevelService; | ||
8 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; | ||
9 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.member.level.service.mapper.MemberLevelMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | import com.topdraw.utils.StringUtils; | ||
22 | |||
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | |||
26 | /** | ||
27 | * @author XiangHan | ||
28 | * @date 2021-10-22 | ||
29 | */ | ||
30 | @Service | ||
31 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
32 | public class MemberLevelServiceImpl implements MemberLevelService { | ||
33 | |||
34 | @Autowired | ||
35 | private MemberLevelRepository MemberLevelRepository; | ||
36 | |||
37 | @Autowired | ||
38 | private MemberLevelMapper MemberLevelMapper; | ||
39 | |||
40 | @Override | ||
41 | public Map<String, Object> queryAll(MemberLevelQueryCriteria criteria, Pageable pageable) { | ||
42 | Page<MemberLevel> page = MemberLevelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
43 | return PageUtil.toPage(page.map(MemberLevelMapper::toDto)); | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public List<MemberLevelDTO> queryAll(MemberLevelQueryCriteria criteria) { | ||
48 | return MemberLevelMapper.toDto(MemberLevelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public MemberLevelDTO findById(Long id) { | ||
53 | MemberLevel MemberLevel = MemberLevelRepository.findById(id).orElseGet(MemberLevel::new); | ||
54 | ValidationUtil.isNull(MemberLevel.getId(),"MemberLevel","id",id); | ||
55 | return MemberLevelMapper.toDto(MemberLevel); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | @Transactional(rollbackFor = Exception.class) | ||
60 | @AsyncMqSend() | ||
61 | public void create(MemberLevel resources) { | ||
62 | MemberLevelRepository.save(resources); | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | @Transactional(rollbackFor = Exception.class) | ||
67 | @AsyncMqSend() | ||
68 | public void update(MemberLevel resources) { | ||
69 | MemberLevel MemberLevel = MemberLevelRepository.findById(resources.getId()).orElseGet(MemberLevel::new); | ||
70 | ValidationUtil.isNull( MemberLevel.getId(),"MemberLevel","id",resources.getId()); | ||
71 | MemberLevel.copy(resources); | ||
72 | MemberLevelRepository.save(MemberLevel); | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | @Transactional(rollbackFor = Exception.class) | ||
77 | @AsyncMqSend() | ||
78 | public void delete(Long id) { | ||
79 | Assert.notNull(id, "The given id must not be null!"); | ||
80 | MemberLevel MemberLevel = MemberLevelRepository.findById(id).orElseThrow( | ||
81 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberLevel.class, id), 1)); | ||
82 | MemberLevelRepository.delete(MemberLevel); | ||
83 | } | ||
84 | |||
85 | |||
86 | @Override | ||
87 | public MemberLevelDTO getByCode(String code) { | ||
88 | return StringUtils.isNotEmpty(code) ? MemberLevelMapper.toDto(MemberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new)) | ||
89 | : new MemberLevelDTO(); | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { | ||
94 | return MemberLevelMapper.toDto(MemberLevelRepository.findByLevelAndStatus(level,status)); | ||
95 | } | ||
96 | } |
1 | package com.topdraw.business.basicdata.member.level.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.member.level.domain.MemberLevel; | ||
5 | import com.topdraw.business.basicdata.member.level.service.dto.MemberLevelDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberLevelMapper extends BaseMapper<MemberLevelDTO, MemberLevel> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.basicdata.member.profile.domain; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.profile.DoSaveMemberProfileGroup; | ||
4 | import com.topdraw.business.basicdata.member.profile.DoUpdateMemberProfileGroup; | ||
5 | import lombok.Data; | ||
6 | import lombok.experimental.Accessors; | ||
7 | import cn.hutool.core.bean.BeanUtil; | ||
8 | import cn.hutool.core.bean.copier.CopyOptions; | ||
9 | import javax.persistence.*; | ||
10 | import javax.validation.constraints.NotNull; | ||
11 | |||
12 | import org.springframework.data.annotation.CreatedDate; | ||
13 | import org.springframework.data.annotation.LastModifiedDate; | ||
14 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
15 | import java.sql.Timestamp; | ||
16 | |||
17 | import java.io.Serializable; | ||
18 | |||
19 | /** | ||
20 | * @author XiangHan | ||
21 | * @date 2021-10-22 | ||
22 | */ | ||
23 | @Entity | ||
24 | @Data | ||
25 | @EntityListeners(AuditingEntityListener.class) | ||
26 | @Accessors(chain = true) | ||
27 | @Table(name="uc_member_profile") | ||
28 | public class MemberProfile implements Serializable { | ||
29 | |||
30 | // 主键 | ||
31 | @Id | ||
32 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
33 | @Column(name = "id") | ||
34 | @NotNull(message = "【id】 not be null!!" , groups = DoUpdateMemberProfileGroup.class) | ||
35 | private Long id; | ||
36 | |||
37 | // 会员id | ||
38 | @NotNull(message = "【memberId】 not be null!!" , groups = DoSaveMemberProfileGroup.class) | ||
39 | @Column(name = "member_id", nullable = false) | ||
40 | private Long memberId; | ||
41 | |||
42 | // 姓名 | ||
43 | @Column(name = "realname") | ||
44 | private String realname; | ||
45 | |||
46 | // 性别 0:女; 1:男 -1:未知 | ||
47 | @Column(name = "gender", nullable = false) | ||
48 | @NotNull(message = "【gender】 not be null!!" , groups = {DoSaveMemberProfileGroup.class}) | ||
49 | private Integer gender; | ||
50 | |||
51 | // 生日 | ||
52 | @NotNull(message = "【memberId】 not be null!!" , groups = DoSaveMemberProfileGroup.class) | ||
53 | @Column(name = "birthday", nullable = false) | ||
54 | private Timestamp birthday; | ||
55 | |||
56 | // 星座 | ||
57 | @Column(name = "constellation") | ||
58 | private String constellation; | ||
59 | |||
60 | // 身份证 | ||
61 | @NotNull(message = "【idCard】 not be null!!" , groups = DoSaveMemberProfileGroup.class) | ||
62 | @Column(name = "id_card", nullable = false) | ||
63 | private String idCard; | ||
64 | |||
65 | // 电子邮件 | ||
66 | @Column(name = "email") | ||
67 | private String email; | ||
68 | |||
69 | // 国家 | ||
70 | @Column(name = "country") | ||
71 | private String country; | ||
72 | |||
73 | // 省份 | ||
74 | @Column(name = "province") | ||
75 | private String province; | ||
76 | |||
77 | // 城市 | ||
78 | @Column(name = "city") | ||
79 | private String city; | ||
80 | |||
81 | // 区县 | ||
82 | @Column(name = "district") | ||
83 | private String district; | ||
84 | |||
85 | // 描述 | ||
86 | @Column(name = "description") | ||
87 | private String description; | ||
88 | |||
89 | // 创建时间 | ||
90 | @CreatedDate | ||
91 | @Column(name = "create_time") | ||
92 | private Timestamp createTime; | ||
93 | |||
94 | // 更新时间 | ||
95 | @LastModifiedDate | ||
96 | @Column(name = "update_time") | ||
97 | private Timestamp updateTime; | ||
98 | |||
99 | public void copy(MemberProfile source){ | ||
100 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
101 | } | ||
102 | } |
1 | package com.topdraw.business.basicdata.member.profile.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ||
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-22 | ||
10 | */ | ||
11 | public interface MemberProfileRepository extends JpaRepository<MemberProfile, Long>, JpaSpecificationExecutor<MemberProfile> { | ||
12 | |||
13 | } |
1 | package com.topdraw.business.basicdata.member.profile.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ||
6 | import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; | ||
7 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2021-10-22 | ||
17 | */ | ||
18 | @Api(tags = "MemberProfile管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/api/MemberProfile") | ||
21 | public class MemberProfileController { | ||
22 | |||
23 | @Autowired | ||
24 | private MemberProfileService MemberProfileService; | ||
25 | |||
26 | /*@GetMapping | ||
27 | @ApiOperation("查询MemberProfile") | ||
28 | public ResultInfo getMemberProfiles(MemberProfileQueryCriteria criteria, Pageable pageable) { | ||
29 | return ResultInfo.successPage(MemberProfileService.queryAll(criteria,pageable)); | ||
30 | } | ||
31 | |||
32 | @GetMapping(value = "/all") | ||
33 | @ApiOperation("查询所有MemberProfile") | ||
34 | public ResultInfo getMemberProfiles(MemberProfileQueryCriteria criteria) { | ||
35 | return ResultInfo.success(MemberProfileService.queryAll(criteria)); | ||
36 | }*/ | ||
37 | |||
38 | @Log | ||
39 | @PostMapping | ||
40 | @ApiOperation("新增MemberProfile") | ||
41 | public ResultInfo create(@Validated @RequestBody MemberProfile resources) { | ||
42 | MemberProfileService.create(resources); | ||
43 | return ResultInfo.success(); | ||
44 | } | ||
45 | |||
46 | @Log | ||
47 | @PutMapping | ||
48 | @ApiOperation("修改MemberProfile") | ||
49 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { | ||
50 | MemberProfileService.update(resources); | ||
51 | return ResultInfo.success(); | ||
52 | } | ||
53 | |||
54 | |||
55 | @Log | ||
56 | @DeleteMapping(value = "/{id}") | ||
57 | @ApiOperation("删除MemberProfile") | ||
58 | public ResultInfo delete(@PathVariable Long id) { | ||
59 | MemberProfileService.delete(id); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | } |
1 | package com.topdraw.business.basicdata.member.profile.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ||
4 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; | ||
5 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface MemberProfileService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(MemberProfileQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<MemberProfileDTO> | ||
28 | */ | ||
29 | List<MemberProfileDTO> queryAll(MemberProfileQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return MemberProfileDTO | ||
35 | */ | ||
36 | MemberProfileDTO findById(Long id); | ||
37 | |||
38 | void create(MemberProfile resources); | ||
39 | |||
40 | void update(MemberProfile resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | } |
1 | package com.topdraw.business.basicdata.member.profile.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class MemberProfileDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 会员id | ||
19 | private Long memberId; | ||
20 | |||
21 | // 姓名 | ||
22 | private String realname; | ||
23 | |||
24 | // 性别 0:女; 1:男 -1:未知 | ||
25 | private Integer gender; | ||
26 | |||
27 | // 生日 | ||
28 | private Timestamp birthday; | ||
29 | |||
30 | // 星座 | ||
31 | private String constellation; | ||
32 | |||
33 | // 身份证 | ||
34 | private String idCard; | ||
35 | |||
36 | // 电子邮件 | ||
37 | private String email; | ||
38 | |||
39 | // 国家 | ||
40 | private String country; | ||
41 | |||
42 | // 省份 | ||
43 | private String province; | ||
44 | |||
45 | // 城市 | ||
46 | private String city; | ||
47 | |||
48 | // 区县 | ||
49 | private String district; | ||
50 | |||
51 | // 描述 | ||
52 | private String description; | ||
53 | |||
54 | // 创建时间 | ||
55 | private Timestamp createTime; | ||
56 | |||
57 | // 更新时间 | ||
58 | private Timestamp updateTime; | ||
59 | } |
1 | package com.topdraw.business.basicdata.member.profile.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.member.profile.repository.MemberProfileRepository; | ||
7 | import com.topdraw.business.basicdata.member.profile.service.MemberProfileService; | ||
8 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; | ||
9 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.member.profile.service.mapper.MemberProfileMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | |||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | |||
25 | /** | ||
26 | * @author XiangHan | ||
27 | * @date 2021-10-22 | ||
28 | */ | ||
29 | @Service | ||
30 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
31 | public class MemberProfileServiceImpl implements MemberProfileService { | ||
32 | |||
33 | @Autowired | ||
34 | private MemberProfileRepository MemberProfileRepository; | ||
35 | |||
36 | @Autowired | ||
37 | private MemberProfileMapper MemberProfileMapper; | ||
38 | |||
39 | @Override | ||
40 | public Map<String, Object> queryAll(MemberProfileQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<MemberProfile> page = MemberProfileRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(MemberProfileMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<MemberProfileDTO> queryAll(MemberProfileQueryCriteria criteria) { | ||
47 | return MemberProfileMapper.toDto(MemberProfileRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | public MemberProfileDTO findById(Long id) { | ||
52 | MemberProfile MemberProfile = MemberProfileRepository.findById(id).orElseGet(MemberProfile::new); | ||
53 | ValidationUtil.isNull(MemberProfile.getId(),"MemberProfile","id",id); | ||
54 | return MemberProfileMapper.toDto(MemberProfile); | ||
55 | } | ||
56 | |||
57 | @Override | ||
58 | @Transactional(rollbackFor = Exception.class) | ||
59 | @AsyncMqSend() | ||
60 | public void create(MemberProfile resources) { | ||
61 | MemberProfileRepository.save(resources); | ||
62 | } | ||
63 | |||
64 | @Override | ||
65 | @Transactional(rollbackFor = Exception.class) | ||
66 | @AsyncMqSend() | ||
67 | public void update(MemberProfile resources) { | ||
68 | MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new); | ||
69 | ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId()); | ||
70 | MemberProfile.copy(resources); | ||
71 | MemberProfileRepository.save(MemberProfile); | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | @Transactional(rollbackFor = Exception.class) | ||
76 | @AsyncMqSend() | ||
77 | public void delete(Long id) { | ||
78 | Assert.notNull(id, "The given id must not be null!"); | ||
79 | MemberProfile MemberProfile = MemberProfileRepository.findById(id).orElseThrow( | ||
80 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberProfile.class, id), 1)); | ||
81 | MemberProfileRepository.delete(MemberProfile); | ||
82 | } | ||
83 | |||
84 | |||
85 | } |
1 | package com.topdraw.business.basicdata.member.profile.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.member.profile.domain.MemberProfile; | ||
5 | import com.topdraw.business.basicdata.member.profile.service.dto.MemberProfileDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberProfileMapper extends BaseMapper<MemberProfileDTO, MemberProfile> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.domain; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import lombok.experimental.Accessors; | ||
5 | import cn.hutool.core.bean.BeanUtil; | ||
6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
7 | import javax.persistence.*; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | import java.sql.Timestamp; | ||
12 | |||
13 | import java.io.Serializable; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan | ||
17 | * @date 2021-10-22 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_member_related_info") | ||
24 | public class MemberRelatedInfo 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 = "member_id", nullable = false) | ||
34 | private Long memberId; | ||
35 | |||
36 | // 人物关系 0:子女;1:父母 | ||
37 | @Column(name = "type") | ||
38 | private Integer type; | ||
39 | |||
40 | // 手机号 | ||
41 | @Column(name = "cellphone") | ||
42 | private String cellphone; | ||
43 | |||
44 | // 身份证号 | ||
45 | @Column(name = "id_card") | ||
46 | private String idCard; | ||
47 | |||
48 | // 姓名 | ||
49 | @Column(name = "name") | ||
50 | private String name; | ||
51 | |||
52 | // 性别 0:女;1:男;-1:未知 | ||
53 | @Column(name = "sex") | ||
54 | private Integer sex; | ||
55 | |||
56 | // 创建时间 | ||
57 | @CreatedDate | ||
58 | @Column(name = "create_time") | ||
59 | private Timestamp createTime; | ||
60 | |||
61 | // 更新时间 | ||
62 | @LastModifiedDate | ||
63 | @Column(name = "update_time") | ||
64 | private Timestamp updateTime; | ||
65 | |||
66 | public void copy(MemberRelatedInfo source){ | ||
67 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
68 | } | ||
69 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; | ||
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-22 | ||
10 | */ | ||
11 | public interface MemberRelatedInfoRepository extends JpaRepository<MemberRelatedInfo, Long>, JpaSpecificationExecutor<MemberRelatedInfo> { | ||
12 | |||
13 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; | ||
6 | import com.topdraw.business.basicdata.member.relatedinfo.service.MemberRelatedInfoService; | ||
7 | import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.PageRequest; | ||
10 | import org.springframework.data.domain.Pageable; | ||
11 | import org.springframework.validation.annotation.Validated; | ||
12 | import org.springframework.web.bind.annotation.*; | ||
13 | import io.swagger.annotations.*; | ||
14 | |||
15 | /** | ||
16 | * @author XiangHan /api/MemberRelatedInfo | ||
17 | * @date 2021-10-22 | ||
18 | */ | ||
19 | @Api(tags = "MemberRelatedInfo管理") | ||
20 | @RestController | ||
21 | @RequestMapping("/api/MemberRelatedInfo") | ||
22 | public class MemberRelatedInfoController { | ||
23 | |||
24 | @Autowired | ||
25 | private MemberRelatedInfoService MemberRelatedInfoService; | ||
26 | |||
27 | @GetMapping(value = "/pageMemberRelatedInfos") | ||
28 | @ApiOperation("查询MemberRelatedInfo") | ||
29 | public ResultInfo pageMemberRelatedInfos(@Validated MemberRelatedInfoQueryCriteria criteria, Pageable pageable) { | ||
30 | return ResultInfo.successPage(MemberRelatedInfoService.queryAll(criteria,pageable)); | ||
31 | } | ||
32 | |||
33 | @Log | ||
34 | @PostMapping(value = "/create") | ||
35 | @ApiOperation("新增MemberRelatedInfo") | ||
36 | public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) { | ||
37 | MemberRelatedInfoService.create(resources); | ||
38 | return ResultInfo.success(); | ||
39 | } | ||
40 | |||
41 | @Log | ||
42 | @PutMapping(value = "/update") | ||
43 | @ApiOperation("修改MemberRelatedInfo") | ||
44 | public ResultInfo update(@Validated @RequestBody MemberRelatedInfo resources) { | ||
45 | MemberRelatedInfoService.update(resources); | ||
46 | return ResultInfo.success(); | ||
47 | } | ||
48 | |||
49 | @GetMapping(value = "/findById/{id}") | ||
50 | @ApiOperation("查询指定MemberRelatedInfo") | ||
51 | public ResultInfo findById(@PathVariable("id") Long id) { | ||
52 | return ResultInfo.success(MemberRelatedInfoService.findById(id)); | ||
53 | } | ||
54 | |||
55 | @Log | ||
56 | @DeleteMapping(value = "/delete//{id}") | ||
57 | @ApiOperation("删除MemberRelatedInfo") | ||
58 | public ResultInfo delete(@PathVariable Long id) { | ||
59 | MemberRelatedInfoService.delete(id); | ||
60 | return ResultInfo.success(); | ||
61 | } | ||
62 | |||
63 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; | ||
4 | import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO; | ||
5 | import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; | ||
6 | import org.springframework.data.domain.Pageable; | ||
7 | import java.util.Map; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface MemberRelatedInfoService { | ||
15 | |||
16 | /** | ||
17 | * 查询数据分页 | ||
18 | * @param criteria 条件参数 | ||
19 | * @param pageable 分页参数 | ||
20 | * @return Map<String,Object> | ||
21 | */ | ||
22 | Map<String,Object> queryAll(MemberRelatedInfoQueryCriteria criteria, Pageable pageable); | ||
23 | |||
24 | /** | ||
25 | * 查询所有数据不分页 | ||
26 | * @param criteria 条件参数 | ||
27 | * @return List<MemberRelatedInfoDTO> | ||
28 | */ | ||
29 | List<MemberRelatedInfoDTO> queryAll(MemberRelatedInfoQueryCriteria criteria); | ||
30 | |||
31 | /** | ||
32 | * 根据ID查询 | ||
33 | * @param id ID | ||
34 | * @return MemberRelatedInfoDTO | ||
35 | */ | ||
36 | MemberRelatedInfoDTO findById(Long id); | ||
37 | |||
38 | void create(MemberRelatedInfo resources); | ||
39 | |||
40 | void update(MemberRelatedInfo resources); | ||
41 | |||
42 | void delete(Long id); | ||
43 | |||
44 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | import java.sql.Timestamp; | ||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class MemberRelatedInfoDTO implements Serializable { | ||
14 | |||
15 | // ID | ||
16 | private Long id; | ||
17 | |||
18 | // 会员id | ||
19 | private Long memberId; | ||
20 | |||
21 | // 人物关系 0:子女;1:父母 | ||
22 | private Integer type; | ||
23 | |||
24 | // 手机号 | ||
25 | private String cellphone; | ||
26 | |||
27 | // 身份证号 | ||
28 | private String idCard; | ||
29 | |||
30 | // 姓名 | ||
31 | private String name; | ||
32 | |||
33 | // 性别 0:女;1:男;-1:未知 | ||
34 | private Integer sex; | ||
35 | |||
36 | // 创建时间 | ||
37 | private Timestamp createTime; | ||
38 | |||
39 | // 更新时间 | ||
40 | private Timestamp updateTime; | ||
41 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.service.dto; | ||
2 | |||
3 | import com.topdraw.annotation.Query; | ||
4 | import lombok.Data; | ||
5 | |||
6 | import javax.validation.constraints.NotNull; | ||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-10-22 | ||
11 | */ | ||
12 | @Data | ||
13 | public class MemberRelatedInfoQueryCriteria{ | ||
14 | |||
15 | @Query | ||
16 | private Long memberId; | ||
17 | |||
18 | |||
19 | |||
20 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; | ||
5 | import com.topdraw.utils.ValidationUtil; | ||
6 | import com.topdraw.business.basicdata.member.relatedinfo.repository.MemberRelatedInfoRepository; | ||
7 | import com.topdraw.business.basicdata.member.relatedinfo.service.MemberRelatedInfoService; | ||
8 | import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO; | ||
9 | import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria; | ||
10 | import com.topdraw.business.basicdata.member.relatedinfo.service.mapper.MemberRelatedInfoMapper; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | import org.springframework.transaction.annotation.Propagation; | ||
14 | import org.springframework.transaction.annotation.Transactional; | ||
15 | import org.springframework.dao.EmptyResultDataAccessException; | ||
16 | import org.springframework.data.domain.Page; | ||
17 | import org.springframework.data.domain.Pageable; | ||
18 | import org.springframework.util.Assert; | ||
19 | import com.topdraw.utils.PageUtil; | ||
20 | import com.topdraw.utils.QueryHelp; | ||
21 | |||
22 | import java.util.List; | ||
23 | import java.util.Map; | ||
24 | |||
25 | /** | ||
26 | * @author XiangHan | ||
27 | * @date 2021-10-22 | ||
28 | */ | ||
29 | @Service | ||
30 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
31 | public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ||
32 | |||
33 | @Autowired | ||
34 | private MemberRelatedInfoRepository MemberRelatedInfoRepository; | ||
35 | |||
36 | @Autowired | ||
37 | private MemberRelatedInfoMapper MemberRelatedInfoMapper; | ||
38 | |||
39 | @Override | ||
40 | public Map<String, Object> queryAll(MemberRelatedInfoQueryCriteria criteria, Pageable pageable) { | ||
41 | Page<MemberRelatedInfo> page = MemberRelatedInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
42 | return PageUtil.toPage(page.map(MemberRelatedInfoMapper::toDto)); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public List<MemberRelatedInfoDTO> queryAll(MemberRelatedInfoQueryCriteria criteria) { | ||
47 | return MemberRelatedInfoMapper.toDto(MemberRelatedInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | public MemberRelatedInfoDTO findById(Long id) { | ||
52 | MemberRelatedInfo MemberRelatedInfo = MemberRelatedInfoRepository.findById(id).orElseGet(MemberRelatedInfo::new); | ||
53 | ValidationUtil.isNull(MemberRelatedInfo.getId(),"MemberRelatedInfo","id",id); | ||
54 | return MemberRelatedInfoMapper.toDto(MemberRelatedInfo); | ||
55 | } | ||
56 | |||
57 | @Override | ||
58 | @Transactional(rollbackFor = Exception.class) | ||
59 | @AsyncMqSend() | ||
60 | public void create(MemberRelatedInfo resources) { | ||
61 | MemberRelatedInfoRepository.save(resources); | ||
62 | } | ||
63 | |||
64 | @Override | ||
65 | @Transactional(rollbackFor = Exception.class) | ||
66 | @AsyncMqSend() | ||
67 | public void update(MemberRelatedInfo resources) { | ||
68 | MemberRelatedInfo MemberRelatedInfo = MemberRelatedInfoRepository.findById(resources.getId()).orElseGet(MemberRelatedInfo::new); | ||
69 | ValidationUtil.isNull( MemberRelatedInfo.getId(),"MemberRelatedInfo","id",resources.getId()); | ||
70 | MemberRelatedInfo.copy(resources); | ||
71 | MemberRelatedInfoRepository.save(MemberRelatedInfo); | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | @Transactional(rollbackFor = Exception.class) | ||
76 | @AsyncMqSend() | ||
77 | public void delete(Long id) { | ||
78 | Assert.notNull(id, "The given id must not be null!"); | ||
79 | MemberRelatedInfo MemberRelatedInfo = MemberRelatedInfoRepository.findById(id).orElseThrow( | ||
80 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberRelatedInfo.class, id), 1)); | ||
81 | MemberRelatedInfoRepository.delete(MemberRelatedInfo); | ||
82 | } | ||
83 | |||
84 | |||
85 | } |
1 | package com.topdraw.business.basicdata.member.relatedinfo.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.member.relatedinfo.domain.MemberRelatedInfo; | ||
5 | import com.topdraw.business.basicdata.member.relatedinfo.service.dto.MemberRelatedInfoDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberRelatedInfoMapper extends BaseMapper<MemberRelatedInfoDTO, MemberRelatedInfo> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.basicdata.member.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.domain.Member; | ||
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 2021-10-22 | ||
12 | */ | ||
13 | public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecificationExecutor<Member> { | ||
14 | |||
15 | Optional<Member> findFirstByCode(String code); | ||
16 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/member/rest/MemberController.java
0 → 100644
1 | package com.topdraw.business.basicdata.member.rest; | ||
2 | |||
3 | import com.topdraw.annotation.Log; | ||
4 | import com.topdraw.business.basicdata.member.domain.Member; | ||
5 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
6 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; | ||
7 | import com.topdraw.common.ResultInfo; | ||
8 | import io.swagger.annotations.Api; | ||
9 | import io.swagger.annotations.ApiOperation; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | ||
11 | import org.springframework.data.domain.Pageable; | ||
12 | import org.springframework.util.Assert; | ||
13 | import org.springframework.validation.annotation.Validated; | ||
14 | import org.springframework.web.bind.annotation.*; | ||
15 | |||
16 | /** | ||
17 | * @author XiangHan | ||
18 | * @date 2021-10-22 | ||
19 | */ | ||
20 | @Api(tags = "Member管理") | ||
21 | @RestController | ||
22 | @RequestMapping("/api/member") | ||
23 | public class MemberController { | ||
24 | |||
25 | @Autowired | ||
26 | private MemberService memberService; | ||
27 | |||
28 | /* @GetMapping(value = "/pageMembers") | ||
29 | @ApiOperation("查询Member") | ||
30 | public ResultInfo pageMembers(MemberQueryCriteria criteria, Pageable pageable) { | ||
31 | return ResultInfo.successPage(memberService.queryAll(criteria,pageable)); | ||
32 | } | ||
33 | |||
34 | @GetMapping(value = "/findById/{id}") | ||
35 | @ApiOperation("查询指定Member") | ||
36 | public ResultInfo findById(@PathVariable("id") Long id) { | ||
37 | return ResultInfo.success(memberService.findById(id)); | ||
38 | } | ||
39 | */ | ||
40 | @Log | ||
41 | @PostMapping(value = "/create") | ||
42 | @ApiOperation("新增Member") | ||
43 | public ResultInfo create(@Validated @RequestBody Member resources) { | ||
44 | Long id = memberService.create(resources); | ||
45 | return ResultInfo.success(id); | ||
46 | } | ||
47 | |||
48 | @Log | ||
49 | @PutMapping(value = "/doUpdateVip") | ||
50 | @ApiOperation("修改Member等级") | ||
51 | public ResultInfo doUpdateVip(Long memberId , Integer vip) { | ||
52 | Assert.isNull(memberId,"MemberController -->> doUpdateVip -->>【memberId】 not be null!!"); | ||
53 | Assert.isNull(vip,"MemberController -->> doUpdateVip -->>【memberId】 not be null!!"); | ||
54 | Member member = new Member(); | ||
55 | member.setId(memberId); | ||
56 | member.setVip(vip); | ||
57 | memberService.update(member); | ||
58 | return ResultInfo.success(); | ||
59 | } | ||
60 | |||
61 | @Log | ||
62 | @PutMapping(value = "/update") | ||
63 | @ApiOperation("修改Member") | ||
64 | public ResultInfo update(@Validated @RequestBody Member resources) { | ||
65 | memberService.update(resources); | ||
66 | return ResultInfo.success(); | ||
67 | } | ||
68 | |||
69 | @GetMapping(value = "/getByCode/{code}") | ||
70 | @ApiOperation(value = "根据标识查询") | ||
71 | public ResultInfo getByCode(@PathVariable String code) { | ||
72 | return ResultInfo.success(memberService.getByCode(code)); | ||
73 | } | ||
74 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/member/service/MemberService.java
0 → 100644
1 | package com.topdraw.business.basicdata.member.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.member.domain.Member; | ||
4 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
5 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; | ||
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-22 | ||
14 | */ | ||
15 | public interface MemberService { | ||
16 | |||
17 | /** | ||
18 | * 查询数据分页 | ||
19 | * @param criteria 条件参数 | ||
20 | * @param pageable 分页参数 | ||
21 | * @return Map<String,Object> | ||
22 | */ | ||
23 | Map<String,Object> queryAll(MemberQueryCriteria criteria, Pageable pageable); | ||
24 | |||
25 | /** | ||
26 | * 查询所有数据不分页 | ||
27 | * @param criteria 条件参数 | ||
28 | * @return List<MemberDTO> | ||
29 | */ | ||
30 | List<MemberDTO> queryAll(MemberQueryCriteria criteria); | ||
31 | |||
32 | /** | ||
33 | * 根据ID查询 | ||
34 | * @param id ID | ||
35 | * @return MemberDTO | ||
36 | */ | ||
37 | MemberDTO findById(Long id); | ||
38 | |||
39 | Long create(Member resources); | ||
40 | |||
41 | void update(Member resources); | ||
42 | |||
43 | void delete(Long id); | ||
44 | |||
45 | /** | ||
46 | * Code校验 | ||
47 | * @param code | ||
48 | * @return MemberDTO | ||
49 | */ | ||
50 | MemberDTO getByCode(String code); | ||
51 | } |
member-service-impl/src/main/java/com/topdraw/business/basicdata/member/service/dto/MemberDTO.java
0 → 100644
1 | package com.topdraw.business.basicdata.member.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-22 | ||
12 | */ | ||
13 | @Data | ||
14 | public class MemberDTO implements Serializable { | ||
15 | |||
16 | // 主键 | ||
17 | private Long id; | ||
18 | |||
19 | // 标识 | ||
20 | private String code; | ||
21 | |||
22 | // 类型 1:大屏;2:小屏 | ||
23 | private Integer type; | ||
24 | |||
25 | // 状态 0:不可用;1:可用 | ||
26 | private Integer status; | ||
27 | |||
28 | // 昵称 base64 | ||
29 | private String nickname; | ||
30 | |||
31 | // 描述 | ||
32 | private String description; | ||
33 | |||
34 | // 性别 0:女;1:男;-1:未知 | ||
35 | private Integer gender; | ||
36 | |||
37 | // 生日 | ||
38 | private String birthday; | ||
39 | |||
40 | // 头像 | ||
41 | private String avatarUrl; | ||
42 | |||
43 | // 分组信息 | ||
44 | private String groups; | ||
45 | |||
46 | // 标签 | ||
47 | private String tags; | ||
48 | |||
49 | // 是否会员 0:非会员;1:会员 | ||
50 | private Integer vip; | ||
51 | |||
52 | // 会员等级(对应level表的level字段,非id) | ||
53 | private Integer level; | ||
54 | |||
55 | // 成长值 | ||
56 | private Long exp; | ||
57 | |||
58 | // 当前积分 | ||
59 | private Long points; | ||
60 | |||
61 | // 即将到期积分(一个月内) | ||
62 | private Long duePoints; | ||
63 | |||
64 | // 优惠券数量 | ||
65 | private Long couponAmount; | ||
66 | |||
67 | // 即将过期优惠券数量 | ||
68 | private Long dueCouponAmount; | ||
69 | |||
70 | // iptv账号id | ||
71 | private Long userIptvId; | ||
72 | |||
73 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | ||
74 | private Integer bindIptvPlatformType; | ||
75 | |||
76 | // iptv账号绑定时间 | ||
77 | private Timestamp bindIptvTime; | ||
78 | |||
79 | // 创建时间 | ||
80 | private Timestamp createTime; | ||
81 | |||
82 | // 更新时间 | ||
83 | private Timestamp updateTime; | ||
84 | |||
85 | // 是否在黑名单 1:是;0否 | ||
86 | // private Integer blackStatus; | ||
87 | } |
1 | package com.topdraw.business.basicdata.member.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 MemberQueryCriteria{ | ||
12 | |||
13 | @Query(type = Query.Type.LEFT_LIKE) | ||
14 | private String code; | ||
15 | |||
16 | // 类型 1:大屏;2:小屏 | ||
17 | @Query(type = Query.Type.EQUAL) | ||
18 | private Integer type; | ||
19 | |||
20 | // 状态 0:不可用;1:可用 | ||
21 | @Query(type = Query.Type.EQUAL) | ||
22 | private Integer status; | ||
23 | |||
24 | // 昵称 base64 | ||
25 | @Query(type = Query.Type.LEFT_LIKE) | ||
26 | private String nickname; | ||
27 | |||
28 | // 性别 0:女;1:男;-1:未知 | ||
29 | @Query(type = Query.Type.EQUAL) | ||
30 | private Integer gender; | ||
31 | |||
32 | // 分组信息 | ||
33 | @Query(type = Query.Type.EQUAL) | ||
34 | private String groups; | ||
35 | |||
36 | // 标签 | ||
37 | @Query(type = Query.Type.IN) | ||
38 | private String tags; | ||
39 | |||
40 | // 是否会员 0:非会员;1:会员 | ||
41 | @Query(type = Query.Type.EQUAL) | ||
42 | private Integer vip; | ||
43 | |||
44 | // 会员等级(对应level表的level字段,非id) | ||
45 | @Query(type = Query.Type.EQUAL) | ||
46 | private Integer level; | ||
47 | |||
48 | // iptv账号id | ||
49 | @Query(type = Query.Type.EQUAL) | ||
50 | private Long userIptvId; | ||
51 | |||
52 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | ||
53 | @Query(type = Query.Type.IN) | ||
54 | private Integer bindIptvPlatformType; | ||
55 | |||
56 | } |
1 | package com.topdraw.business.basicdata.member.service.impl; | ||
2 | |||
3 | import com.topdraw.aspect.AsyncMqSend; | ||
4 | import com.topdraw.business.basicdata.member.domain.Member; | ||
5 | import com.topdraw.business.basicdata.member.repository.MemberRepository; | ||
6 | import com.topdraw.business.basicdata.member.service.MemberService; | ||
7 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
8 | import com.topdraw.business.basicdata.member.service.dto.MemberQueryCriteria; | ||
9 | import com.topdraw.business.basicdata.member.service.mapper.MemberMapper; | ||
10 | import com.topdraw.mq.config.RabbitMqConfig; | ||
11 | import com.topdraw.util.IdWorker; | ||
12 | import com.topdraw.util.RedissonUtil; | ||
13 | import com.topdraw.util.TimestampUtil; | ||
14 | import com.topdraw.utils.PageUtil; | ||
15 | import com.topdraw.utils.QueryHelp; | ||
16 | import com.topdraw.utils.StringUtils; | ||
17 | import com.topdraw.utils.ValidationUtil; | ||
18 | import org.redisson.api.RLock; | ||
19 | import org.redisson.api.RedissonClient; | ||
20 | import org.springframework.beans.BeanUtils; | ||
21 | import org.springframework.beans.factory.annotation.Autowired; | ||
22 | import org.springframework.dao.EmptyResultDataAccessException; | ||
23 | import org.springframework.data.domain.Page; | ||
24 | import org.springframework.data.domain.Pageable; | ||
25 | import org.springframework.stereotype.Service; | ||
26 | import org.springframework.transaction.annotation.Propagation; | ||
27 | import org.springframework.transaction.annotation.Transactional; | ||
28 | import org.springframework.util.Assert; | ||
29 | |||
30 | import java.util.List; | ||
31 | import java.util.Map; | ||
32 | import java.util.Objects; | ||
33 | |||
34 | /** | ||
35 | * @author XiangHan | ||
36 | * @date 2021-10-22 | ||
37 | */ | ||
38 | @Service | ||
39 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
40 | public class MemberServiceImpl implements MemberService { | ||
41 | |||
42 | @Autowired | ||
43 | private MemberRepository memberRepository; | ||
44 | |||
45 | @Autowired | ||
46 | private MemberMapper memberMapper; | ||
47 | |||
48 | @Autowired | ||
49 | private RedissonClient redissonClient; | ||
50 | |||
51 | @Override | ||
52 | public Map<String, Object> queryAll(MemberQueryCriteria criteria, Pageable pageable) { | ||
53 | Page<Member> page = memberRepository.findAll((root, criteriaQuery, criteriaBuilder) | ||
54 | -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
55 | return PageUtil.toPage(page.map(memberMapper::toDto)); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | public List<MemberDTO> queryAll(MemberQueryCriteria criteria) { | ||
60 | return memberMapper.toDto(memberRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public MemberDTO findById(Long id) { | ||
65 | Member member = memberRepository.findById(id).orElseGet(Member::new); | ||
66 | ValidationUtil.isNull(member.getId(),"Member","id",id); | ||
67 | return memberMapper.toDto(member); | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | @Transactional(rollbackFor = Exception.class) | ||
72 | @AsyncMqSend() | ||
73 | public Long create(Member resources) { | ||
74 | Member member = this.checkMemberData(resources); | ||
75 | memberRepository.save(member); | ||
76 | return member.getId(); | ||
77 | } | ||
78 | |||
79 | private Member checkMemberData(Member member) { | ||
80 | Long defaultValue = 0L; | ||
81 | member.setCode(String.valueOf(IdWorker.generator())); | ||
82 | Integer gender = member.getGender(); | ||
83 | member.setGender(Objects.nonNull(gender) ? gender : 0); | ||
84 | Integer type = member.getType(); | ||
85 | member.setType(Objects.nonNull(type) ? type:-1); | ||
86 | Integer status = member.getStatus(); | ||
87 | member.setStatus(Objects.nonNull(status) ? status:1); | ||
88 | Integer vip = member.getVip(); | ||
89 | member.setVip(Objects.nonNull(vip) ? status:0); | ||
90 | Integer level = member.getLevel(); | ||
91 | member.setLevel(Objects.nonNull(level) ? level:0); | ||
92 | member.setExp(defaultValue); | ||
93 | member.setPoints(defaultValue); | ||
94 | member.setDuePoints(defaultValue); | ||
95 | member.setCouponAmount(defaultValue); | ||
96 | member.setDueCouponAmount(defaultValue); | ||
97 | return member; | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | @Transactional(rollbackFor = Exception.class) | ||
102 | @AsyncMqSend() | ||
103 | public void update(Member resources) { | ||
104 | RLock rLock = this.redissonClient.getLock("updateMember" + resources.getId().toString()); | ||
105 | try { | ||
106 | RedissonUtil.lock(rLock); | ||
107 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); | ||
108 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | ||
109 | member.copy(resources); | ||
110 | memberRepository.save(member); | ||
111 | } catch (Exception e) { | ||
112 | e.printStackTrace(); | ||
113 | throw e; | ||
114 | } finally { | ||
115 | RedissonUtil.unlock(rLock); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | @Transactional(rollbackFor = Exception.class) | ||
121 | @AsyncMqSend() | ||
122 | public void delete(Long id) { | ||
123 | Assert.notNull(id, "The given id must not be null!"); | ||
124 | Member member = memberRepository.findById(id).orElseThrow( | ||
125 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Member.class, id), 1)); | ||
126 | memberRepository.delete(member); | ||
127 | } | ||
128 | |||
129 | |||
130 | @Override | ||
131 | public MemberDTO getByCode(String code) { | ||
132 | return StringUtils.isNotEmpty(code) ? memberMapper.toDto(memberRepository.findFirstByCode(code).orElseGet(Member::new)) | ||
133 | : new MemberDTO(); | ||
134 | } | ||
135 | } |
1 | package com.topdraw.business.basicdata.member.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.basicdata.member.domain.Member; | ||
5 | import com.topdraw.business.basicdata.member.service.dto.MemberDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberMapper extends BaseMapper<MemberDTO, Member> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.basicdata.points.available.domain; | ||
2 | |||
3 | import com.fasterxml.jackson.annotation.JsonFormat; | ||
4 | import lombok.Data; | ||
5 | import lombok.experimental.Accessors; | ||
6 | import cn.hutool.core.bean.BeanUtil; | ||
7 | import cn.hutool.core.bean.copier.CopyOptions; | ||
8 | import javax.persistence.*; | ||
9 | import org.springframework.data.annotation.CreatedDate; | ||
10 | import org.springframework.data.annotation.LastModifiedDate; | ||
11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
12 | import java.sql.Timestamp; | ||
13 | import java.util.UUID; | ||
14 | |||
15 | import java.io.Serializable; | ||
16 | |||
17 | /** | ||
18 | * 每天定时扫描可用积分表,将过期积分删除,并及时更新积分明细表和积分总额表 | ||
19 | * | ||
20 | * @author XiangHan | ||
21 | * @date 2021-10-23 | ||
22 | */ | ||
23 | @Entity | ||
24 | @Data | ||
25 | @EntityListeners(AuditingEntityListener.class) | ||
26 | @Accessors(chain = true) | ||
27 | @Table(name="uc_points_available") | ||
28 | public class PointsAvailable implements Serializable { | ||
29 | |||
30 | // 主键 | ||
31 | @Id | ||
32 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
33 | @Column(name = "id") | ||
34 | private Long id; | ||
35 | |||
36 | // 标识 | ||
37 | @Column(name = "code") | ||
38 | private String code; | ||
39 | |||
40 | // 积分类型 0:通用型 | ||
41 | @Column(name = "points_type") | ||
42 | private Integer pointsType; | ||
43 | |||
44 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
45 | @Column(name = "device_type") | ||
46 | private Integer deviceType; | ||
47 | |||
48 | // 会员id | ||
49 | @Column(name = "member_id", nullable = false) | ||
50 | private Long memberId; | ||
51 | |||
52 | // 积分值 | ||
53 | @Column(name = "points") | ||
54 | private Long points; | ||
55 | |||
56 | // 过期时间 | ||
57 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
58 | @Column(name = "expire_time") | ||
59 | private Timestamp expireTime; | ||
60 | |||
61 | // 描述 | ||
62 | @Column(name = "description") | ||
63 | private String description; | ||
64 | |||
65 | // 创建时间 | ||
66 | @CreatedDate | ||
67 | @Column(name = "create_time") | ||
68 | private Timestamp createTime; | ||
69 | |||
70 | // 更新时间 | ||
71 | @LastModifiedDate | ||
72 | @Column(name = "update_time") | ||
73 | private Timestamp updateTime; | ||
74 | |||
75 | public void copy(PointsAvailable source){ | ||
76 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
77 | } | ||
78 | } |
1 | package com.topdraw.business.basicdata.points.available.repository; | ||
2 | |||
3 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; | ||
4 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; | ||
5 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; | ||
6 | import org.springframework.data.jpa.repository.JpaRepository; | ||
7 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
8 | import org.springframework.data.jpa.repository.Modifying; | ||
9 | import org.springframework.data.jpa.repository.Query; | ||
10 | import org.springframework.transaction.annotation.Transactional; | ||
11 | |||
12 | import java.sql.Timestamp; | ||
13 | import java.util.Date; | ||
14 | import java.util.List; | ||
15 | import java.util.Optional; | ||
16 | |||
17 | /** | ||
18 | * @author XiangHan | ||
19 | * @date 2021-10-23 | ||
20 | */ | ||
21 | public interface PointsAvailableRepository extends JpaRepository<PointsAvailable, Long>, JpaSpecificationExecutor<PointsAvailable> { | ||
22 | |||
23 | Optional<PointsAvailable> findFirstByCode(String code); | ||
24 | |||
25 | List<PointsAvailableDTO> findByMemberId(Long memberId); | ||
26 | |||
27 | List<PointsAvailable> findByMemberIdAndExpireTimeBefore(Long memberId , Date now); | ||
28 | |||
29 | /** | ||
30 | * 即将过期的积分 | ||
31 | * @param memberId | ||
32 | * @param factor | ||
33 | * @return | ||
34 | */ | ||
35 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1 " + | ||
36 | " and (TO_DAYS(expire_time) - TO_DAYS(NOW())) <= ?2 " | ||
37 | ,nativeQuery = true) | ||
38 | Long findSoonExpireTime(Long memberId, Integer factor); | ||
39 | |||
40 | |||
41 | |||
42 | /** | ||
43 | * 总积分 | ||
44 | * @param criteria | ||
45 | * @return | ||
46 | */ | ||
47 | @Deprecated | ||
48 | @Query(value = "SELECT sum(upa.points) AS pointsProduce FROM uc_points_available upa WHERE (TO_DAYS(create_time)+1) = TO_DAYS(NOW())" | ||
49 | ,nativeQuery = true) | ||
50 | Long findEveryDayPointsProduce(PointsAvailableQueryCriteria criteria); | ||
51 | |||
52 | /** | ||
53 | * 可用总积分 | ||
54 | * @param criteria | ||
55 | * @return | ||
56 | */ | ||
57 | @Deprecated | ||
58 | @Query(value = "SELECT sum(upa.points) AS pointsAvailable FROM uc_points_available upa WHERE (TO_DAYS(create_time)+1) = TO_DAYS(NOW())" | ||
59 | ,nativeQuery = true) | ||
60 | Long findEveryDayPointsAvailable(PointsAvailableQueryCriteria criteria); | ||
61 | |||
62 | /** | ||
63 | * 过期总积分 | ||
64 | * @param criteria | ||
65 | * @return | ||
66 | */ | ||
67 | @Deprecated | ||
68 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where (TO_DAYS(create_time)+1) = TO_DAYS(NOW()) " + | ||
69 | " and TO_DAYS(expire_time) < TO_DAYS(NOW())" | ||
70 | ,nativeQuery = true) | ||
71 | Long findEveryDayPointsExpire(PointsAvailableQueryCriteria criteria); | ||
72 | |||
73 | /** | ||
74 | * 获取可用积分 | ||
75 | * @param memberId | ||
76 | * @return | ||
77 | */ | ||
78 | @Query(value = "SELECT sum(upa.points) AS pointsExpire from uc_points_available upa where upa.member_id = ?1 and upa.expire_time >= now()" | ||
79 | ,nativeQuery = true) | ||
80 | long findAvailablePointsByMemberId(long memberId); | ||
81 | |||
82 | List<PointsAvailable> findByMemberIdOrderByExpireTime(Long memberId); | ||
83 | |||
84 | @Transactional | ||
85 | @Modifying | ||
86 | @Query(value = "delete from uc_points_available where id in ?1" ,nativeQuery = true) | ||
87 | void deleteBatchByIds(List<Long> id); | ||
88 | |||
89 | List<PointsAvailable> findByExpireTimeBefore(Timestamp now); | ||
90 | } |
1 | package com.topdraw.business.basicdata.points.available.rest; | ||
2 | |||
3 | import com.topdraw.common.ResultInfo; | ||
4 | import com.topdraw.annotation.Log; | ||
5 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; | ||
6 | import com.topdraw.business.basicdata.points.available.service.PointsAvailableService; | ||
7 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.data.domain.Pageable; | ||
10 | import org.springframework.http.HttpStatus; | ||
11 | import org.springframework.http.ResponseEntity; | ||
12 | import org.springframework.validation.annotation.Validated; | ||
13 | import org.springframework.web.bind.annotation.*; | ||
14 | import io.swagger.annotations.*; | ||
15 | import java.io.IOException; | ||
16 | import javax.servlet.http.HttpServletResponse; | ||
17 | |||
18 | /** | ||
19 | * @author XiangHan | ||
20 | * @date 2021-10-23 | ||
21 | */ | ||
22 | //@Api(tags = "PointsAvailable管理") | ||
23 | //@RestController | ||
24 | //@RequestMapping("/api/PointsAvailable") | ||
25 | public class PointsAvailableController { | ||
26 | |||
27 | /*@Autowired | ||
28 | private PointsAvailableService PointsAvailableService; | ||
29 | |||
30 | @GetMapping | ||
31 | @ApiOperation("查询PointsAvailable") | ||
32 | public ResultInfo getPointsAvailables(PointsAvailableQueryCriteria criteria, Pageable pageable) { | ||
33 | return ResultInfo.successPage(PointsAvailableService.queryAll(criteria,pageable)); | ||
34 | } | ||
35 | |||
36 | @GetMapping(value = "/all") | ||
37 | @ApiOperation("查询所有PointsAvailable") | ||
38 | public ResultInfo getPointsAvailables(PointsAvailableQueryCriteria criteria) { | ||
39 | return ResultInfo.success(PointsAvailableService.queryAll(criteria)); | ||
40 | } | ||
41 | |||
42 | @Log | ||
43 | @PostMapping | ||
44 | @ApiOperation("新增PointsAvailable") | ||
45 | public ResultInfo create(@Validated @RequestBody PointsAvailable resources) { | ||
46 | PointsAvailableService.create(resources); | ||
47 | return ResultInfo.success(); | ||
48 | } | ||
49 | |||
50 | @Log | ||
51 | @PutMapping | ||
52 | @ApiOperation("修改PointsAvailable") | ||
53 | public ResultInfo update(@Validated @RequestBody PointsAvailable resources) { | ||
54 | PointsAvailableService.update(resources); | ||
55 | return ResultInfo.success(); | ||
56 | } | ||
57 | |||
58 | |||
59 | @Log | ||
60 | @DeleteMapping(value = "/{id}") | ||
61 | @ApiOperation("删除PointsAvailable") | ||
62 | public ResultInfo delete(@PathVariable Long id) { | ||
63 | PointsAvailableService.delete(id); | ||
64 | return ResultInfo.success(); | ||
65 | } | ||
66 | |||
67 | @GetMapping(value = "/getByCode/{code}") | ||
68 | @ApiOperation(value = "根据标识查询") | ||
69 | public ResultInfo getByCode(@PathVariable String code) { | ||
70 | return ResultInfo.success(PointsAvailableService.getByCode(code)); | ||
71 | }*/ | ||
72 | } |
1 | package com.topdraw.business.basicdata.points.available.service; | ||
2 | |||
3 | import com.topdraw.business.basicdata.points.available.domain.PointsAvailable; | ||
4 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableDTO; | ||
5 | import com.topdraw.business.basicdata.points.available.service.dto.PointsAvailableQueryCriteria; | ||
6 | import com.topdraw.business.process.domian.TempPoints; | ||
7 | import org.springframework.data.domain.Pageable; | ||
8 | |||
9 | import java.sql.Timestamp; | ||
10 | import java.util.Date; | ||
11 | import java.util.Map; | ||
12 | import java.util.List; | ||
13 | import java.io.IOException; | ||
14 | import javax.servlet.http.HttpServletResponse; | ||
15 | |||
16 | /** | ||
17 | * @author XiangHan | ||
18 | * @date 2021-10-23 | ||
19 | */ | ||
20 | public interface PointsAvailableService { | ||
21 | |||
22 | /** | ||
23 | * 查询数据分页 | ||
24 | * @param criteria 条件参数 | ||
25 | * @param pageable 分页参数 | ||
26 | * @return Map<String,Object> | ||
27 | */ | ||
28 | Map<String,Object> queryAll(PointsAvailableQueryCriteria criteria, Pageable pageable); | ||
29 | |||
30 | /** | ||
31 | * 查询所有数据不分页 | ||
32 | * @param criteria 条件参数 | ||
33 | * @return List<PointsAvailableDTO> | ||
34 | */ | ||
35 | List<PointsAvailableDTO> queryAll(PointsAvailableQueryCriteria criteria); | ||
36 | |||
37 | /** | ||
38 | * 根据ID查询 | ||
39 | * @param id ID | ||
40 | * @return PointsAvailableDTO | ||
41 | */ | ||
42 | PointsAvailableDTO findById(Long id); | ||
43 | |||
44 | /** | ||
45 | * | ||
46 | * @param resources | ||
47 | */ | ||
48 | void create(PointsAvailable resources); | ||
49 | |||
50 | /** | ||
51 | * | ||
52 | * @param resources | ||
53 | */ | ||
54 | void update(PointsAvailable resources); | ||
55 | |||
56 | /** | ||
57 | * | ||
58 | * @param id | ||
59 | */ | ||
60 | void delete(Long id); | ||
61 | |||
62 | /** | ||
63 | * | ||
64 | * @param id | ||
65 | */ | ||
66 | void deleteBatchByIds(List<Long> id); | ||
67 | |||
68 | /** | ||
69 | * Code校验 | ||
70 | * @param code | ||
71 | * @return PointsAvailableDTO | ||
72 | */ | ||
73 | PointsAvailableDTO getByCode(String code); | ||
74 | |||
75 | /** | ||
76 | * 已过期的积分 | ||
77 | * @param memberId | ||
78 | * @param timestamp | ||
79 | * @return | ||
80 | */ | ||
81 | List<PointsAvailableDTO> findByMemberIdAndExpireTimeBefore(Long memberId, Date timestamp); | ||
82 | |||
83 | /** | ||
84 | * 即将过期的积分 | ||
85 | * @param memberId 会员id | ||
86 | * @param factor 阈值 | ||
87 | * @return | ||
88 | */ | ||
89 | Long findSoonExpireTime(Long memberId,Integer factor); | ||
90 | |||
91 | /** | ||
92 | * 查询数据分页 | ||
93 | * @param criteria 条件参数 | ||
94 | * @param pageable 分页参数 | ||
95 | * @return Map<String,Object> | ||
96 | */ | ||
97 | Map<String,Object> findByMemberIdAndExpireTimeBefore(PointsAvailableQueryCriteria criteria, Pageable pageable); | ||
98 | |||
99 | /** | ||
100 | * | ||
101 | * @param memberId | ||
102 | * @return | ||
103 | */ | ||
104 | List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId); | ||
105 | |||
106 | /** | ||
107 | * 可用总积分 | ||
108 | * @param criteria 条件参数 | ||
109 | * @return Map<String,Object> | ||
110 | */ | ||
111 | Long findEveryDayPointsAvailable(PointsAvailableQueryCriteria criteria); | ||
112 | |||
113 | /** | ||
114 | * 总积分 | ||
115 | * @param criteria | ||
116 | * @return | ||
117 | */ | ||
118 | Long findEveryDayPointsProduce(PointsAvailableQueryCriteria criteria); | ||
119 | |||
120 | /** | ||
121 | * 积分消耗 | ||
122 | * @param criteria | ||
123 | * @return | ||
124 | */ | ||
125 | Long findEveryDayPointsConsume(PointsAvailableQueryCriteria criteria); | ||
126 | |||
127 | /** | ||
128 | * 积分过期 | ||
129 | * @param criteria | ||
130 | * @return | ||
131 | */ | ||
132 | Long findEveryDayPointsExpire(PointsAvailableQueryCriteria criteria); | ||
133 | |||
134 | |||
135 | long findAvailablePointsByMemberId(long memberId); | ||
136 | |||
137 | |||
138 | List<PointsAvailableDTO> findByExpireTimeBefore(Timestamp now); | ||
139 | } |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/points/domain/Points.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/points/rest/PointsController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/points/service/PointsService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/points/service/dto/PointsDTO.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/rights/constant/RightsType.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/rights/domain/Rights.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/rights/rest/RightsController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/rights/service/RightsService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/rights/service/dto/RightsDTO.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/task/repository/TaskRepository.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/task/rest/TaskController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/task/service/TaskService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/task/service/dto/TaskDTO.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/basicdata/task/service/mapper/TaskMapper.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/rest/CouponOperationController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/rest/ExpOperationController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/rest/PointsOperationController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/rest/RightsOperationController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/rest/TaskOperationController.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/rest/TaskOperationQueryCriteria.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/CouponOperationService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/ExpOperationService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/MemberOperationService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/PointsOperationService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/RightsOperationService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/TaskDealService.java
0 → 100644
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/TaskOperationService.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/TaskDealHandler.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/test/java/com/topdraw/test/business/basicdata/member/MemberServiceTest.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/test/java/com/topdraw/test/business/basicdata/rights/RightsServiceTest.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
member-service-impl/src/test/java/com/topdraw/test/business/basicdata/task/TaskServiceTest.java
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
pom.xml
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment