1.优化
Showing
5 changed files
with
96 additions
and
13 deletions
... | @@ -9,6 +9,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder; | ... | @@ -9,6 +9,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder; |
9 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | 9 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
10 | import org.springframework.cache.annotation.EnableCaching; | 10 | import org.springframework.cache.annotation.EnableCaching; |
11 | import org.springframework.context.annotation.Bean; | 11 | import org.springframework.context.annotation.Bean; |
12 | import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||
12 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | 13 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; |
13 | import org.springframework.retry.annotation.EnableRetry; | 14 | import org.springframework.retry.annotation.EnableRetry; |
14 | import org.springframework.scheduling.annotation.EnableAsync; | 15 | import org.springframework.scheduling.annotation.EnableAsync; |
... | @@ -24,6 +25,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; | ... | @@ -24,6 +25,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; |
24 | @EnableRetry | 25 | @EnableRetry |
25 | @EnableCaching | 26 | @EnableCaching |
26 | @SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) | 27 | @SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) |
28 | @EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true) | ||
27 | public class MemberServiceApplication extends SpringBootServletInitializer { | 29 | public class MemberServiceApplication extends SpringBootServletInitializer { |
28 | 30 | ||
29 | public static void main(String[] args) { | 31 | public static void main(String[] args) { | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.aspect; | ... | @@ -2,6 +2,8 @@ package com.topdraw.aspect; |
2 | 2 | ||
3 | 3 | ||
4 | import com.alibaba.fastjson.JSON; | 4 | import com.alibaba.fastjson.JSON; |
5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
6 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
5 | import com.topdraw.mq.domain.TableOperationMsg; | 7 | import com.topdraw.mq.domain.TableOperationMsg; |
6 | import com.topdraw.mq.producer.MessageProducer; | 8 | import com.topdraw.mq.producer.MessageProducer; |
7 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/process/service/dto/MemberAndUserTvDTO.java
0 → 100644
1 | package com.topdraw.business.process.service.dto; | ||
2 | |||
3 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
4 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
5 | import lombok.AllArgsConstructor; | ||
6 | import lombok.Data; | ||
7 | import lombok.NoArgsConstructor; | ||
8 | |||
9 | import java.io.Serializable; | ||
10 | |||
11 | /** | ||
12 | * @author : | ||
13 | * @description: | ||
14 | * @function : | ||
15 | * @date :Created in 2022/3/23 9:48 | ||
16 | * @version: : | ||
17 | * @modified By: | ||
18 | * @since : modified in 2022/3/23 9:48 | ||
19 | */ | ||
20 | |||
21 | @Data | ||
22 | @AllArgsConstructor | ||
23 | @NoArgsConstructor | ||
24 | public class MemberAndUserTvDTO implements Serializable { | ||
25 | |||
26 | private MemberDTO memberDTO; | ||
27 | private UserTvDTO userTvDTO; | ||
28 | } |
1 | package com.topdraw.business.process.service.dto; | ||
2 | |||
3 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
4 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
5 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
6 | import lombok.AllArgsConstructor; | ||
7 | import lombok.Data; | ||
8 | import lombok.NoArgsConstructor; | ||
9 | |||
10 | import java.io.Serializable; | ||
11 | |||
12 | /** | ||
13 | * @author : | ||
14 | * @description: | ||
15 | * @function : | ||
16 | * @date :Created in 2022/3/23 9:48 | ||
17 | * @version: : | ||
18 | * @modified By: | ||
19 | * @since : modified in 2022/3/23 9:48 | ||
20 | */ | ||
21 | |||
22 | @Data | ||
23 | @AllArgsConstructor | ||
24 | @NoArgsConstructor | ||
25 | public class MemberAndWeixinUserDTO implements Serializable { | ||
26 | |||
27 | private MemberDTO memberDTO; | ||
28 | private UserWeixinDTO userWeixinDTO; | ||
29 | |||
30 | } |
... | @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; | ... | @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; |
4 | import cn.hutool.core.util.ObjectUtil; | 4 | import cn.hutool.core.util.ObjectUtil; |
5 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
6 | import com.alibaba.fastjson.JSON; | 6 | import com.alibaba.fastjson.JSON; |
7 | import com.alibaba.fastjson.JSONArray; | ||
7 | import com.alibaba.fastjson.JSONObject; | 8 | import com.alibaba.fastjson.JSONObject; |
8 | import com.topdraw.aspect.AsyncMqSend; | 9 | import com.topdraw.aspect.AsyncMqSend; |
9 | import com.topdraw.business.module.member.domain.Member; | 10 | import com.topdraw.business.module.member.domain.Member; |
... | @@ -28,18 +29,22 @@ import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ... | @@ -28,18 +29,22 @@ import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
28 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria; | 29 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria; |
29 | import com.topdraw.business.process.domian.weixin.*; | 30 | import com.topdraw.business.process.domian.weixin.*; |
30 | import com.topdraw.business.process.service.UserOperationService; | 31 | import com.topdraw.business.process.service.UserOperationService; |
32 | import com.topdraw.business.process.service.dto.MemberAndUserTvDTO; | ||
33 | import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO; | ||
31 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; | 34 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; |
32 | import com.topdraw.config.LocalConstants; | 35 | import com.topdraw.config.LocalConstants; |
33 | import com.topdraw.config.RedisKeyUtil; | 36 | import com.topdraw.config.RedisKeyUtil; |
34 | import com.topdraw.exception.BadRequestException; | 37 | import com.topdraw.exception.BadRequestException; |
35 | import com.topdraw.exception.EntityNotFoundException; | 38 | import com.topdraw.exception.EntityNotFoundException; |
36 | import com.topdraw.exception.GlobeExceptionMsg; | 39 | import com.topdraw.exception.GlobeExceptionMsg; |
40 | import com.topdraw.mq.producer.MessageProducer; | ||
37 | import com.topdraw.util.TimestampUtil; | 41 | import com.topdraw.util.TimestampUtil; |
38 | import com.topdraw.utils.QueryHelp; | 42 | import com.topdraw.utils.QueryHelp; |
39 | import com.topdraw.utils.RedisUtils; | 43 | import com.topdraw.utils.RedisUtils; |
40 | import lombok.extern.slf4j.Slf4j; | 44 | import lombok.extern.slf4j.Slf4j; |
41 | import org.apache.commons.collections4.CollectionUtils; | 45 | import org.apache.commons.collections4.CollectionUtils; |
42 | import org.apache.commons.lang3.StringUtils; | 46 | import org.apache.commons.lang3.StringUtils; |
47 | import org.springframework.aop.framework.AopContext; | ||
43 | import org.springframework.beans.BeanUtils; | 48 | import org.springframework.beans.BeanUtils; |
44 | import org.springframework.beans.factory.annotation.Autowired; | 49 | import org.springframework.beans.factory.annotation.Autowired; |
45 | import org.springframework.beans.factory.annotation.Value; | 50 | import org.springframework.beans.factory.annotation.Value; |
... | @@ -50,6 +55,7 @@ import org.springframework.transaction.annotation.Propagation; | ... | @@ -50,6 +55,7 @@ import org.springframework.transaction.annotation.Propagation; |
50 | import org.springframework.transaction.annotation.Transactional; | 55 | import org.springframework.transaction.annotation.Transactional; |
51 | import org.springframework.util.Assert; | 56 | import org.springframework.util.Assert; |
52 | 57 | ||
58 | import javax.annotation.Resource; | ||
53 | import java.nio.charset.StandardCharsets; | 59 | import java.nio.charset.StandardCharsets; |
54 | import java.time.LocalDateTime; | 60 | import java.time.LocalDateTime; |
55 | import java.util.*; | 61 | import java.util.*; |
... | @@ -96,15 +102,29 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -96,15 +102,29 @@ public class UserOperationServiceImpl implements UserOperationService { |
96 | 102 | ||
97 | 103 | ||
98 | @AsyncMqSend | 104 | @AsyncMqSend |
99 | public void asyncWeixinMemberAndUserWeixin4Iptv(MemberDTO memberDTO, UserWeixinDTO weixinDTO) {} | 105 | public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) { |
106 | messageProducer.sendMessage(JSON.toJSONString(memberAndWeixinUserDTO)); | ||
107 | } | ||
100 | @AsyncMqSend | 108 | @AsyncMqSend |
101 | public void asyncMemberAndUserTv4Iptv(MemberDTO memberDTO, UserTvDTO userTvDTO) {} | 109 | public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTv) { |
110 | //messageProducer.sendMessage(JSON.toJSONString(memberAndUserTv)); | ||
111 | } | ||
102 | @AsyncMqSend | 112 | @AsyncMqSend |
103 | public void asyncWeixin(UserWeixinDTO weixinDTO) {} | 113 | public void asyncWeixin(UserWeixinDTO weixinDTO) { |
114 | messageProducer.sendMessage(JSON.toJSONString(weixinDTO)); | ||
115 | } | ||
104 | @AsyncMqSend | 116 | @AsyncMqSend |
105 | public void asyncUserTv(UserTvDTO userTvDTO) {} | 117 | public void asyncUserTv(UserTvDTO userTvDTO) { |
118 | messageProducer.sendMessage(JSON.toJSONString(userTvDTO)); | ||
119 | } | ||
106 | @AsyncMqSend | 120 | @AsyncMqSend |
107 | public void asyncMember(MemberDTO memberDTO) {} | 121 | public void asyncMember(MemberDTO memberDTO) { |
122 | messageProducer.sendMessage(JSON.toJSONString(memberDTO)); | ||
123 | } | ||
124 | |||
125 | |||
126 | @Autowired | ||
127 | private MessageProducer messageProducer; | ||
108 | 128 | ||
109 | /** | 129 | /** |
110 | * 创建大屏账户同时创建会员 | 130 | * 创建大屏账户同时创建会员 |
... | @@ -134,18 +154,19 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -134,18 +154,19 @@ public class UserOperationServiceImpl implements UserOperationService { |
134 | // 创建大屏账户 | 154 | // 创建大屏账户 |
135 | UserTvDTO tvUserDTO = this.createTvUser(userTv, memberDTO.getId(), memberDTO.getCode()); | 155 | UserTvDTO tvUserDTO = this.createTvUser(userTv, memberDTO.getId(), memberDTO.getCode()); |
136 | 156 | ||
137 | this.asyncMemberAndUserTv4Iptv(memberDTO,tvUserDTO); | 157 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(memberDTO, tvUserDTO)); |
138 | 158 | ||
139 | return tvUserDTO; | 159 | return tvUserDTO; |
140 | 160 | ||
141 | } | 161 | } |
142 | 162 | ||
143 | throw new EntityNotFoundException(MemberDTO.class,"code",GlobeExceptionMsg.MEMBER_ID_IS_NULL); | 163 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_ID_IS_NULL); |
144 | 164 | ||
145 | } | 165 | } |
146 | 166 | ||
147 | throw new BadRequestException(GlobeExceptionMsg.ENTITY_ALREADY_EXISTS); | 167 | throw new BadRequestException(GlobeExceptionMsg.ENTITY_ALREADY_EXISTS); |
148 | 168 | ||
169 | |||
149 | } | 170 | } |
150 | 171 | ||
151 | /** | 172 | /** |
... | @@ -182,7 +203,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -182,7 +203,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
182 | UserWeixinDTO weixinDTO = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); | 203 | UserWeixinDTO weixinDTO = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); |
183 | 204 | ||
184 | // 同步至iptv | 205 | // 同步至iptv |
185 | this.asyncWeixinMemberAndUserWeixin4Iptv(memberDTO,weixinDTO); | 206 | this.asyncWeixin(weixinDTO); |
186 | 207 | ||
187 | return weixinDTO; | 208 | return weixinDTO; |
188 | } | 209 | } |
... | @@ -202,7 +223,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -202,7 +223,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
202 | UserWeixinDTO _userWeixinDTO1 = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); | 223 | UserWeixinDTO _userWeixinDTO1 = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); |
203 | 224 | ||
204 | // 同步至iptv | 225 | // 同步至iptv |
205 | this.asyncWeixinMemberAndUserWeixin4Iptv(memberDTO,_userWeixinDTO1); | 226 | this.asyncMemberAndUserWeixin4Iptv(new MemberAndWeixinUserDTO(memberDTO, _userWeixinDTO1)); |
206 | 227 | ||
207 | return _userWeixinDTO1; | 228 | return _userWeixinDTO1; |
208 | } | 229 | } |
... | @@ -339,7 +360,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -339,7 +360,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
339 | MemberDTO _memberDTO = this.doUpdateMemberVip(memberDTO, 0); | 360 | MemberDTO _memberDTO = this.doUpdateMemberVip(memberDTO, 0); |
340 | 361 | ||
341 | // 同步至iptv | 362 | // 同步至iptv |
342 | this.asyncWeixinMemberAndUserWeixin4Iptv(_memberDTO,userWeixinDTO); | 363 | this.asyncMemberAndUserWeixin4Iptv(new MemberAndWeixinUserDTO(memberDTO, userWeixinDTO)); |
343 | 364 | ||
344 | return true; | 365 | return true; |
345 | } | 366 | } |
... | @@ -435,7 +456,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -435,7 +456,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
435 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId()); | 456 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId()); |
436 | 457 | ||
437 | // 同步至iptv | 458 | // 同步至iptv |
438 | this.asyncMemberAndUserTv4Iptv(_memberDTO, _userTvDTO); | 459 | this.asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); |
439 | } | 460 | } |
440 | 461 | ||
441 | @Override | 462 | @Override |
... | @@ -682,7 +703,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -682,7 +703,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
682 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); | 703 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); |
683 | 704 | ||
684 | // 同步至iptv | 705 | // 同步至iptv |
685 | this.asyncMemberAndUserTv4Iptv(_memberDTO, _userTvDTO); | 706 | this.asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); |
686 | 707 | ||
687 | return true; | 708 | return true; |
688 | } | 709 | } |
... | @@ -763,7 +784,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -763,7 +784,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
763 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); | 784 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); |
764 | 785 | ||
765 | // 同步至iptv | 786 | // 同步至iptv |
766 | this.asyncMemberAndUserTv4Iptv(_memberDTO,_userTvDTO); | 787 | this.asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); |
767 | 788 | ||
768 | return null; | 789 | return null; |
769 | } | 790 | } | ... | ... |
-
Please register or sign in to post a comment