1.优化
Showing
19 changed files
with
199 additions
and
286 deletions
... | @@ -20,6 +20,11 @@ | ... | @@ -20,6 +20,11 @@ |
20 | 20 | ||
21 | <dependencies> | 21 | <dependencies> |
22 | 22 | ||
23 | <dependency> | ||
24 | <groupId>org.springframework.boot</groupId> | ||
25 | <artifactId>spring-boot-starter-cache</artifactId> | ||
26 | </dependency> | ||
27 | |||
23 | <!--api--> | 28 | <!--api--> |
24 | <dependency> | 29 | <dependency> |
25 | <groupId>com.topdraw</groupId> | 30 | <groupId>com.topdraw</groupId> | ... | ... |
... | @@ -56,7 +56,6 @@ public class MemberController { | ... | @@ -56,7 +56,6 @@ public class MemberController { |
56 | public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { | 56 | public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { |
57 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); | 57 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); |
58 | this.memberOperationService.update(resources); | 58 | this.memberOperationService.update(resources); |
59 | log.info("member ==>> doUpdateVipByCode ==>> result ==>> [{}]",resources); | ||
60 | return ResultInfo.success(); | 59 | return ResultInfo.success(); |
61 | } | 60 | } |
62 | 61 | ||
... | @@ -68,7 +67,6 @@ public class MemberController { | ... | @@ -68,7 +67,6 @@ public class MemberController { |
68 | log.info("member ==>> update ==>> param ==>> [{}]",resources); | 67 | log.info("member ==>> update ==>> param ==>> [{}]",resources); |
69 | 68 | ||
70 | MemberDTO memberDTO = this.memberOperationService.update(resources); | 69 | MemberDTO memberDTO = this.memberOperationService.update(resources); |
71 | log.info("member ==>> update ==>> result ==>> [{}]",resources); | ||
72 | return ResultInfo.success(memberDTO); | 70 | return ResultInfo.success(memberDTO); |
73 | } | 71 | } |
74 | 72 | ... | ... |
... | @@ -59,7 +59,7 @@ public class Rights implements Serializable { | ... | @@ -59,7 +59,7 @@ public class Rights implements Serializable { |
59 | 59 | ||
60 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ | 60 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ |
61 | @Column(name = "expire_time") | 61 | @Column(name = "expire_time") |
62 | private Timestamp expireTime; | 62 | private Long expireTime; |
63 | 63 | ||
64 | /** 创建时间 */ | 64 | /** 创建时间 */ |
65 | @CreatedDate | 65 | @CreatedDate | ... | ... |
... | @@ -37,7 +37,7 @@ public class RightsDTO implements Serializable { | ... | @@ -37,7 +37,7 @@ public class RightsDTO implements Serializable { |
37 | private Timestamp validTime; | 37 | private Timestamp validTime; |
38 | 38 | ||
39 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ | 39 | /** 失效时间,空为不失效,否则为获得权益后直到失效的毫秒数 */ |
40 | private Timestamp expireTime; | 40 | private Long expireTime; |
41 | 41 | ||
42 | /** 创建时间 */ | 42 | /** 创建时间 */ |
43 | private Timestamp createTime; | 43 | private Timestamp createTime; | ... | ... |
... | @@ -15,7 +15,7 @@ public class WeiXinUserBean { | ... | @@ -15,7 +15,7 @@ public class WeiXinUserBean { |
15 | 15 | ||
16 | private Long id; | 16 | private Long id; |
17 | 17 | ||
18 | @NotNull(message = "unionid can't be null" , groups = {BindGroup.class}) | 18 | // @NotNull(message = "unionid can't be null" , groups = {BindGroup.class}) |
19 | private String unionid; | 19 | private String unionid; |
20 | 20 | ||
21 | /** */ | 21 | /** */ | ... | ... |
... | @@ -172,10 +172,10 @@ public class UserOperationController { | ... | @@ -172,10 +172,10 @@ public class UserOperationController { |
172 | 172 | ||
173 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class); | 173 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class); |
174 | 174 | ||
175 | String appId = subscribeBean.getAppId(); | 175 | String appId = subscribeBean.getAppid(); |
176 | Assert.notNull(appId, GlobeExceptionMsg.APP_ID_IS_NULL); | 176 | Assert.notNull(appId, GlobeExceptionMsg.APP_ID_IS_NULL); |
177 | // openId | 177 | // openId |
178 | String openId = subscribeBean.getOpenId(); | 178 | String openId = subscribeBean.getOpenid(); |
179 | Assert.notNull(openId, GlobeExceptionMsg.OPEN_ID_IS_NULL); | 179 | Assert.notNull(openId, GlobeExceptionMsg.OPEN_ID_IS_NULL); |
180 | 180 | ||
181 | subscribeBean.setAppid(appId); | 181 | subscribeBean.setAppid(appId); |
... | @@ -200,10 +200,10 @@ public class UserOperationController { | ... | @@ -200,10 +200,10 @@ public class UserOperationController { |
200 | @PostMapping("/minaUnbind") | 200 | @PostMapping("/minaUnbind") |
201 | @ApiOperation("小屏解绑") | 201 | @ApiOperation("小屏解绑") |
202 | @AnonymousAccess | 202 | @AnonymousAccess |
203 | public ResultInfo minaUnbind(@Validated(value = {BindGroup.class}) @RequestBody TvUnBindBean tvUnBindBean) { | 203 | public ResultInfo minaUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { |
204 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",tvUnBindBean); | 204 | log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); |
205 | 205 | ||
206 | this.userOperationService.minaUnbind(tvUnBindBean); | 206 | this.userOperationService.minaUnbind(weixinUnBindBean); |
207 | return ResultInfo.success(); | 207 | return ResultInfo.success(); |
208 | } | 208 | } |
209 | 209 | ... | ... |
... | @@ -8,6 +8,7 @@ import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ... | @@ -8,6 +8,7 @@ import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
8 | import com.topdraw.business.process.domian.weixin.BindBean; | 8 | import com.topdraw.business.process.domian.weixin.BindBean; |
9 | import com.topdraw.business.process.domian.weixin.SubscribeBean; | 9 | import com.topdraw.business.process.domian.weixin.SubscribeBean; |
10 | import com.topdraw.business.process.domian.weixin.TvUnBindBean; | 10 | import com.topdraw.business.process.domian.weixin.TvUnBindBean; |
11 | import com.topdraw.business.process.domian.weixin.WeixinUnBindBean; | ||
11 | 12 | ||
12 | 13 | ||
13 | public interface UserOperationService { | 14 | public interface UserOperationService { |
... | @@ -142,7 +143,7 @@ public interface UserOperationService { | ... | @@ -142,7 +143,7 @@ public interface UserOperationService { |
142 | 143 | ||
143 | /** | 144 | /** |
144 | * 小屏解绑 | 145 | * 小屏解绑 |
145 | * @param tvUnBindBean | 146 | * @param weixinUnBindBean |
146 | */ | 147 | */ |
147 | void minaUnbind(TvUnBindBean tvUnBindBean); | 148 | void minaUnbind(WeixinUnBindBean weixinUnBindBean); |
148 | } | 149 | } | ... | ... |
... | @@ -230,7 +230,11 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -230,7 +230,11 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
230 | RightsDTO rightsDTO = this.getRights(rightId); | 230 | RightsDTO rightsDTO = this.getRights(rightId); |
231 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 231 | // 权益的实体类型 1:积分;2成长值;3优惠券 |
232 | String type = rightsDTO.getEntityType(); | 232 | String type = rightsDTO.getEntityType(); |
233 | Timestamp expireTime = rightsDTO.getExpireTime(); | 233 | Long expireTime1 = rightsDTO.getExpireTime(); |
234 | Timestamp expireTime = null; | ||
235 | if (Objects.nonNull(expireTime1)){ | ||
236 | expireTime = TimestampUtil.long2Timestamp(expireTime1); | ||
237 | } | ||
234 | 238 | ||
235 | switch (type) { | 239 | switch (type) { |
236 | // 优惠券 | 240 | // 优惠券 | ... | ... |
... | @@ -345,9 +345,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -345,9 +345,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
345 | tempRights.setMemberId(memberId); | 345 | tempRights.setMemberId(memberId); |
346 | tempRights.setMemberCode(memberCode); | 346 | tempRights.setMemberCode(memberCode); |
347 | tempRights.setRightsAmount(rightsAmount); | 347 | tempRights.setRightsAmount(rightsAmount); |
348 | Timestamp expireTime = rightsDTO.getExpireTime(); | 348 | Long expireTime1 = rightsDTO.getExpireTime(); |
349 | if (Objects.nonNull(expireTime)) | 349 | if (Objects.nonNull(expireTime1)) { |
350 | tempRights.setExpireTime(expireTime); | 350 | Timestamp expireTime = TimestampUtil.long2Timestamp(expireTime1); |
351 | if (Objects.nonNull(expireTime)) | ||
352 | tempRights.setExpireTime(expireTime); | ||
353 | } | ||
351 | return tempRights; | 354 | return tempRights; |
352 | } | 355 | } |
353 | 356 | ... | ... |
... | @@ -412,8 +412,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -412,8 +412,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
412 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); | 412 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); |
413 | 413 | ||
414 | if (Objects.nonNull(userTvDTO)) { | 414 | if (Objects.nonNull(userTvDTO)) { |
415 | 415 | if (StringUtils.isNotBlank(userTvDTO.getPriorityMemberCode()) && userTvDTO.getPriorityMemberCode().equalsIgnoreCase(memberCode)) | |
416 | if (userTvDTO.getPriorityMemberCode().equalsIgnoreCase(memberCode)) | ||
417 | throw new BadRequestException("会员已是主账户"); | 416 | throw new BadRequestException("会员已是主账户"); |
418 | 417 | ||
419 | } else { | 418 | } else { |
... | @@ -548,7 +547,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -548,7 +547,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
548 | public boolean addCollection(String content) { | 547 | public boolean addCollection(String content) { |
549 | try { | 548 | try { |
550 | //处理接口调用 中文不显示问题 | 549 | //处理接口调用 中文不显示问题 |
551 | content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); | 550 | //content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); |
552 | 551 | ||
553 | log.info("receive UserCollection add message, content {}", content); | 552 | log.info("receive UserCollection add message, content {}", content); |
554 | 553 | ||
... | @@ -904,7 +903,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -904,7 +903,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
904 | * @param memberCode | 903 | * @param memberCode |
905 | * @param auto manual:手动 auto:自动 | 904 | * @param auto manual:手动 auto:自动 |
906 | */ | 905 | */ |
907 | private UserTvDTO bondPriorityMember(UserTvDTO userTvDTO, String memberCode,String auto) { | 906 | private UserTvDTO bondPriorityMember(UserTvDTO userTvDTO, String memberCode, String auto) { |
908 | 907 | ||
909 | if (auto.equalsIgnoreCase("auto")) { | 908 | if (auto.equalsIgnoreCase("auto")) { |
910 | // 主账户 | 909 | // 主账户 |
... | @@ -944,31 +943,39 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -944,31 +943,39 @@ public class UserOperationServiceImpl implements UserOperationService { |
944 | if (Objects.nonNull(userTvDTO)) { | 943 | if (Objects.nonNull(userTvDTO)) { |
945 | 944 | ||
946 | if (autoModel == true) { | 945 | if (autoModel == true) { |
947 | 946 | // 有其他绑定的小程序会员 | |
948 | List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); | 947 | List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); |
949 | if (CollectionUtils.isNotEmpty(memberDTOList)) { | 948 | if (CollectionUtils.isNotEmpty(memberDTOList)) { |
950 | 949 | ||
951 | // 过滤预解绑的会员 | 950 | // 按绑定时间倒排 |
952 | /*List<MemberDTO> memberDTOS = memberDTOList.stream().filter(memberDTO -> | 951 | memberDTOList.sort(new Comparator<MemberDTO>() { |
953 | !memberDTO.getCode().equalsIgnoreCase(memberCode)).collect(Collectors.toList());*/ | 952 | @Override |
953 | public int compare(MemberDTO memberDTO, MemberDTO t1) { | ||
954 | return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime()); | ||
955 | } | ||
956 | }); | ||
954 | 957 | ||
955 | // if (CollectionUtils.isNotEmpty(memberDTOS)) { | 958 | // 绑定新的主账号 |
959 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual"); | ||
956 | 960 | ||
957 | // 按绑定时间倒排 | 961 | return _userTvDTO; |
958 | memberDTOList.sort(new Comparator<MemberDTO>() { | ||
959 | @Override | ||
960 | public int compare(MemberDTO memberDTO, MemberDTO t1) { | ||
961 | return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime()); | ||
962 | } | ||
963 | }); | ||
964 | 962 | ||
965 | // 绑定新的主账号 | 963 | } else { |
966 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual"); | ||
967 | 964 | ||
968 | return _userTvDTO; | 965 | // 绑定新的主账号 |
969 | } | 966 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); |
967 | |||
968 | return _userTvDTO; | ||
969 | |||
970 | } | ||
971 | |||
972 | } else { | ||
973 | |||
974 | // 绑定新的主账号 | ||
975 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); | ||
976 | |||
977 | return _userTvDTO; | ||
970 | 978 | ||
971 | // } | ||
972 | } | 979 | } |
973 | 980 | ||
974 | } | 981 | } |
... | @@ -1169,11 +1176,18 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1169,11 +1176,18 @@ public class UserOperationServiceImpl implements UserOperationService { |
1169 | } | 1176 | } |
1170 | 1177 | ||
1171 | @Override | 1178 | @Override |
1172 | public void minaUnbind(TvUnBindBean tvUnBindBean) { | 1179 | public void minaUnbind(WeixinUnBindBean weixinUnBindBean) { |
1173 | 1180 | ||
1174 | Long memberId = tvUnBindBean.getMemberId(); | 1181 | Long memberId = weixinUnBindBean.getMemberId(); |
1175 | MemberDTO memberDTO = this.memberService.findById(memberId); | 1182 | MemberDTO memberDTO = this.memberService.findById(memberId); |
1183 | |||
1184 | Assert.notNull(memberDTO.getUserIptvId(), GlobeExceptionMsg.IPTV_IS_NULL); | ||
1185 | |||
1176 | UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId()); | 1186 | UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId()); |
1187 | |||
1188 | TvUnBindBean tvUnBindBean = new TvUnBindBean(); | ||
1189 | tvUnBindBean.setMemberId(memberId); | ||
1190 | tvUnBindBean.setAutoModel(weixinUnBindBean.getAutoModel()); | ||
1177 | String platformAccount = userTvDTO.getPlatformAccount(); | 1191 | String platformAccount = userTvDTO.getPlatformAccount(); |
1178 | tvUnBindBean.setPlatformAccount(platformAccount); | 1192 | tvUnBindBean.setPlatformAccount(platformAccount); |
1179 | this.tvUnbind(tvUnBindBean); | 1193 | this.tvUnbind(tvUnBindBean); | ... | ... |
... | @@ -21,6 +21,7 @@ import com.topdraw.util.TimestampUtil; | ... | @@ -21,6 +21,7 @@ import com.topdraw.util.TimestampUtil; |
21 | import org.springframework.beans.BeanUtils; | 21 | import org.springframework.beans.BeanUtils; |
22 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
23 | import org.springframework.cache.annotation.CacheConfig; | 23 | import org.springframework.cache.annotation.CacheConfig; |
24 | import org.springframework.cache.annotation.CacheEvict; | ||
24 | import org.springframework.cache.annotation.CachePut; | 25 | import org.springframework.cache.annotation.CachePut; |
25 | import org.springframework.cache.annotation.Cacheable; | 26 | import org.springframework.cache.annotation.Cacheable; |
26 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 27 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
... | @@ -33,7 +34,7 @@ import java.time.ZoneOffset; | ... | @@ -33,7 +34,7 @@ import java.time.ZoneOffset; |
33 | import java.util.Objects; | 34 | import java.util.Objects; |
34 | 35 | ||
35 | @Service | 36 | @Service |
36 | @CacheConfig(cacheNames = "member") | 37 | //@CacheConfig(cacheNames = "member") |
37 | public class MemberOperationServiceImpl implements MemberOperationService { | 38 | public class MemberOperationServiceImpl implements MemberOperationService { |
38 | 39 | ||
39 | @Autowired | 40 | @Autowired |
... | @@ -109,7 +110,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -109,7 +110,7 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
109 | } | 110 | } |
110 | 111 | ||
111 | @AsyncMqSend | 112 | @AsyncMqSend |
112 | // @CachePut(key = "#resources.id") | 113 | // @CachePut(value = "ucs::member", key = "#resources.id") |
113 | @Override | 114 | @Override |
114 | public MemberDTO update(Member resources) { | 115 | public MemberDTO update(Member resources) { |
115 | MemberDTO memberDTO = this.memberService.update(resources); | 116 | MemberDTO memberDTO = this.memberService.update(resources); | ... | ... |
1 | package com.topdraw.mq.config; | 1 | package com.topdraw.mq.config; |
2 | 2 | ||
3 | |||
4 | import com.topdraw.config.LocalConstants; | ||
5 | import org.apache.commons.lang3.StringUtils; | 3 | import org.apache.commons.lang3.StringUtils; |
6 | import org.springframework.amqp.core.*; | 4 | import org.springframework.amqp.core.*; |
7 | import org.springframework.beans.factory.annotation.Value; | 5 | import org.springframework.beans.factory.annotation.Value; |
... | @@ -11,41 +9,29 @@ import org.springframework.context.annotation.Configuration; | ... | @@ -11,41 +9,29 @@ import org.springframework.context.annotation.Configuration; |
11 | @Configuration | 9 | @Configuration |
12 | public class RabbitMqConfig { | 10 | public class RabbitMqConfig { |
13 | 11 | ||
14 | @Value("${engine.platform}") | 12 | public static final String UCE_EXCHANGE = "uce.exchange"; |
15 | private String platform; | 13 | public static final String UCE_QUEUE = "uce.queue"; |
16 | |||
17 | @Value("${engine.type}") | ||
18 | private String type; | ||
19 | 14 | ||
20 | @Value("${engine.mq.exchange}") | 15 | @Value("${service.mq.exchange}") |
21 | private String exchange; | 16 | private String exchange; |
22 | 17 | ||
23 | @Value("${engine.mq.routingkey}") | 18 | @Value("${service.mq.queue}") |
24 | private String routingKey; | 19 | private String queue; |
25 | 20 | ||
26 | public String getExchange(){ | 21 | public String getExchange(){ |
27 | if (StringUtils.isEmpty(this.exchange)) { | 22 | if (StringUtils.isEmpty(this.exchange)) { |
28 | this.routingKey = "uc.direct"; | 23 | this.exchange = UCE_EXCHANGE; |
29 | } | 24 | } |
30 | 25 | ||
31 | return this.exchange; | 26 | return this.exchange; |
32 | } | 27 | } |
33 | 28 | ||
34 | public String getRoutingKey() { | 29 | public String getQueue() { |
35 | if (StringUtils.isEmpty(this.routingKey)) { | 30 | if (StringUtils.isEmpty(this.queue)) { |
36 | 31 | this.queue = UCE_QUEUE; | |
37 | if (platform.equalsIgnoreCase(LocalConstants.PLATFORM_TYPE_SERVICE)) { | ||
38 | |||
39 | if (StringUtils.isEmpty(this.type)) { | ||
40 | this.type = LocalConstants.ENV_VIS; | ||
41 | } | ||
42 | |||
43 | } | ||
44 | |||
45 | this.routingKey = "uc."+platform+"."+type+".direct"; | ||
46 | } | 32 | } |
47 | 33 | ||
48 | return routingKey; | 34 | return this.queue; |
49 | } | 35 | } |
50 | 36 | ||
51 | @Bean | 37 | @Bean |
... | @@ -54,13 +40,13 @@ public class RabbitMqConfig { | ... | @@ -54,13 +40,13 @@ public class RabbitMqConfig { |
54 | } | 40 | } |
55 | 41 | ||
56 | @Bean | 42 | @Bean |
57 | Queue queue(){ return new Queue(getRoutingKey()); } | 43 | Queue queue(){ return new Queue(getQueue()); } |
58 | 44 | ||
59 | @Bean | 45 | @Bean |
60 | Binding binding(DirectExchange directExchange , Queue queue) { | 46 | Binding binding(DirectExchange directExchange , Queue queue) { |
61 | BindingBuilder.DirectExchangeRoutingKeyConfigurer directExchangeRoutingKeyConfigurer = | 47 | BindingBuilder.DirectExchangeRoutingKeyConfigurer directExchangeRoutingKeyConfigurer = |
62 | BindingBuilder.bind(queue).to(directExchange); | 48 | BindingBuilder.bind(queue).to(directExchange); |
63 | return directExchangeRoutingKeyConfigurer.with(getRoutingKey()); | 49 | return directExchangeRoutingKeyConfigurer.with(this.getQueue()); |
64 | } | 50 | } |
65 | 51 | ||
66 | } | 52 | } | ... | ... |
1 | package com.topdraw.mq.producer; | 1 | package com.topdraw.mq.producer; |
2 | 2 | ||
3 | import com.topdraw.config.LocalConstants; | ||
4 | import com.topdraw.mq.config.RabbitMqConfig; | ||
5 | import lombok.extern.slf4j.Slf4j; | 3 | import lombok.extern.slf4j.Slf4j; |
6 | import org.springframework.amqp.core.AmqpTemplate; | 4 | import org.springframework.amqp.core.AmqpTemplate; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
... | @@ -18,41 +16,45 @@ public class MessageProducer { | ... | @@ -18,41 +16,45 @@ public class MessageProducer { |
18 | @Autowired | 16 | @Autowired |
19 | private AmqpTemplate amqpTemplate; | 17 | private AmqpTemplate amqpTemplate; |
20 | 18 | ||
21 | @Value("#{rabbitMqConfig.getRoutingKey()}") | 19 | @Value("#{rabbitMqConfig.getExchange()}") |
22 | private String routingKey; | 20 | private String exchange; |
23 | 21 | ||
22 | @Value("#{rabbitMqConfig.getQueue()}") | ||
23 | private String queue; | ||
24 | 24 | ||
25 | public void sendMessage(String msg,String exchangeName){ | 25 | public void sendMessage(String msg){ |
26 | |||
27 | this.sendMessage(msg, null, null); | ||
28 | |||
29 | } | ||
30 | |||
31 | public void sendMessage(String msg, String queue){ | ||
26 | 32 | ||
27 | // 管理侧 | 33 | // 管理侧 |
28 | if (StringUtils.isEmpty(exchangeName)) { | 34 | if (StringUtils.isEmpty(queue)) { |
29 | exchangeName = this.routingKey; | 35 | queue = this.queue; |
30 | } | 36 | } |
31 | 37 | ||
32 | this.sendDirectMessage(msg,exchangeName); | 38 | this.sendMessage(msg, null, queue); |
33 | 39 | ||
34 | } | 40 | } |
35 | 41 | ||
36 | /** | 42 | public void sendMessage(String msg, String exchange, String queue){ |
37 | * 直连 | 43 | |
38 | * @param msg | 44 | if (StringUtils.isEmpty(exchange)) { |
39 | * @param queueName | 45 | exchange = this.exchange; |
40 | * @author XiangHan | 46 | } |
41 | * @date 2021/9/7 11:10 上午 | 47 | |
42 | */ | 48 | if (StringUtils.isEmpty(queue)) { |
43 | private void sendDirectMessage(String msg,String queueName) { | 49 | queue = this.queue; |
44 | 50 | } | |
45 | amqpTemplate.convertAndSend(queueName, msg); | 51 | |
46 | log.info("send sendMessage msg || routingkey: {} || msg:{} ", queueName, msg); | 52 | this.sendDirectMessage(msg, exchange, queue); |
53 | |||
47 | } | 54 | } |
48 | 55 | ||
49 | /** | 56 | private void sendDirectMessage(String msg, String exchange, String queue) { |
50 | * 发送 | 57 | amqpTemplate.convertAndSend(exchange, queue, msg); |
51 | * @param msg | 58 | log.info("send sendMessage msg || exchange: {} || queue: {} || msg:{} ", exchange, queue, msg); |
52 | * @author XiangHan | ||
53 | * @date 2021/9/7 11:10 上午 | ||
54 | */ | ||
55 | public void sendMessage(String msg) { | ||
56 | this.sendMessage(msg,null); | ||
57 | } | 59 | } |
58 | } | 60 | } | ... | ... |
... | @@ -105,14 +105,10 @@ file: | ... | @@ -105,14 +105,10 @@ file: |
105 | maxSize: 100 | 105 | maxSize: 100 |
106 | avatarMaxSize: 5 | 106 | avatarMaxSize: 5 |
107 | 107 | ||
108 | engine: | 108 | service: |
109 | platform: management | ||
110 | type: | ||
111 | mq: | 109 | mq: |
112 | exchange: uc.direct.management # 管理侧 | 110 | exchange: uce.exchange # 管理侧 |
113 | routingkey: uc.engine.service.direct # 管理侧 | 111 | queue: uce.queue # 管理侧 |
114 | # exchange: uc.direct # 服务侧 | ||
115 | # routingkey: uc.engine.management.direct # 服务侧 | ||
116 | 112 | ||
117 | weixin: | 113 | weixin: |
118 | list: | 114 | list: | ... | ... |
1 | #配置数据源 | ||
2 | spring: | ||
3 | datasource: | ||
4 | # 测试/演示库 | ||
5 | url: jdbc:log4jdbc:mysql://172.0.31.10:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
6 | username: root | ||
7 | password: Tjlh@2021 | ||
8 | driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy | ||
9 | #Druid | ||
10 | type: com.alibaba.druid.pool.DruidDataSource | ||
11 | druid: | ||
12 | # 初始化配置 | ||
13 | initial-size: 3 | ||
14 | # 最小连接数 | ||
15 | min-idle: 3 | ||
16 | # 最大连接数 | ||
17 | max-active: 15 | ||
18 | # 获取连接超时时间 | ||
19 | max-wait: 5000 | ||
20 | # 连接有效性检测时间 | ||
21 | time-between-eviction-runs-millis: 90000 | ||
22 | # 最大空闲时间 | ||
23 | min-evictable-idle-time-millis: 1800000 | ||
24 | test-while-idle: true | ||
25 | test-on-borrow: false | ||
26 | test-on-return: false | ||
27 | |||
28 | validation-query: select 1 | ||
29 | # 配置监控统计拦截的filters | ||
30 | filters: stat | ||
31 | stat-view-servlet: | ||
32 | url-pattern: /druid/* | ||
33 | reset-enable: false | ||
34 | |||
35 | web-stat-filter: | ||
36 | url-pattern: /* | ||
37 | exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" | ||
38 | |||
39 | #配置 Jpa | ||
40 | jpa: | ||
41 | hibernate: | ||
42 | # 生产环境设置成 none,避免程序运行时自动更新数据库结构 | ||
43 | ddl-auto: none | ||
44 | servlet: | ||
45 | multipart: | ||
46 | file-size-threshold: 2KB | ||
47 | max-file-size: 100MB | ||
48 | max-request-size: 200MB | ||
49 | redis: | ||
50 | #数据库索引 | ||
51 | database: 0 | ||
52 | host: 127.0.0.1 | ||
53 | port: 6379 | ||
54 | #连接超时时间 | ||
55 | timeout: 5000 | ||
56 | rabbitmq: | ||
57 | host: 172.0.31.96 # rabbitmq的连接地址 | ||
58 | #host: 139.196.192.242 # rabbitmq的连接地址 | ||
59 | port: 5672 # rabbitmq的连接端口号 | ||
60 | #virtual-host: /member_center # rabbitmq的虚拟host | ||
61 | #username: member_center # rabbitmq的用户名 | ||
62 | #password: Tjlh@2021 # rabbitmq的密码 | ||
63 | virtual-host: member_center # rabbitmq的虚拟host | ||
64 | username: admin # rabbitmq的用户名 | ||
65 | password: Tjlh@2021 # rabbitmq的密码 | ||
66 | publisher-confirms: true #如果对异步消息需要回调必须设置为true | ||
67 | |||
68 | #jwt。依赖的common中有需要jwt的部分属性。 | ||
69 | jwt: | ||
70 | header: Authorization | ||
71 | secret: mySecret | ||
72 | # token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒 | ||
73 | expiration: 7200000 | ||
74 | # 在线用户key | ||
75 | online: online-token | ||
76 | # 验证码 | ||
77 | codeKey: code-key | ||
78 | # token 续期检查时间范围(60分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期 | ||
79 | detect: 3600000 | ||
80 | # 续期时间,2小时,单位毫秒 | ||
81 | renew: 7200000 | ||
82 | |||
83 | #是否允许生成代码,生产环境设置为false | ||
84 | generator: | ||
85 | enabled: true | ||
86 | |||
87 | #是否开启 swagger-ui | ||
88 | swagger: | ||
89 | enabled: true | ||
90 |
1 | #配置数据源 | ||
2 | spring: | ||
3 | datasource: | ||
4 | # 测试/演示库 | ||
5 | url: jdbc:log4jdbc:mysql://139.196.192.242:3306/tj_user_0819?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
6 | username: root | ||
7 | password: Tjlh@2017 | ||
8 | |||
9 | # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
10 | # url: jdbc:mysql://122.112.214.149:3306/tj_user?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | ||
11 | # username: root | ||
12 | # password: root | ||
13 | driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy | ||
14 | #Druid | ||
15 | type: com.alibaba.druid.pool.DruidDataSource | ||
16 | druid: | ||
17 | # 初始化配置 | ||
18 | initial-size: 3 | ||
19 | # 最小连接数 | ||
20 | min-idle: 3 | ||
21 | # 最大连接数 | ||
22 | max-active: 15 | ||
23 | # 获取连接超时时间 | ||
24 | max-wait: 5000 | ||
25 | # 连接有效性检测时间 | ||
26 | time-between-eviction-runs-millis: 90000 | ||
27 | # 最大空闲时间 | ||
28 | min-evictable-idle-time-millis: 1800000 | ||
29 | test-while-idle: true | ||
30 | test-on-borrow: false | ||
31 | test-on-return: false | ||
32 | |||
33 | validation-query: select 1 | ||
34 | # 配置监控统计拦截的filters | ||
35 | filters: stat | ||
36 | stat-view-servlet: | ||
37 | url-pattern: /druid/* | ||
38 | reset-enable: false | ||
39 | |||
40 | web-stat-filter: | ||
41 | url-pattern: /* | ||
42 | exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" | ||
43 | |||
44 | #配置 Jpa | ||
45 | jpa: | ||
46 | hibernate: | ||
47 | # 生产环境设置成 none,避免程序运行时自动更新数据库结构 | ||
48 | ddl-auto: none | ||
49 | servlet: | ||
50 | multipart: | ||
51 | file-size-threshold: 2KB | ||
52 | max-file-size: 100MB | ||
53 | max-request-size: 200MB | ||
54 | redis: | ||
55 | #数据库索引 | ||
56 | database: 16 | ||
57 | host: 122.112.214.149 | ||
58 | # host: 139.196.4.234 | ||
59 | port: 6379 | ||
60 | password: redis123 | ||
61 | # password: | ||
62 | #连接超时时间 | ||
63 | timeout: 5000 | ||
64 | rabbitmq: | ||
65 | host: 139.196.145.150 # rabbitmq的连接地址 | ||
66 | port: 5672 # rabbitmq的连接端口号 | ||
67 | virtual-host: member_center # rabbitmq的虚拟host | ||
68 | username: admin # rabbitmq的用户名 | ||
69 | password: Topdraw1qaz # rabbitmq的密码 | ||
70 | publisher-confirms: true #如果对异步消息需要回调必须设置为true | ||
71 | |||
72 | #jwt。依赖的common中有需要jwt的部分属性。 | ||
73 | jwt: | ||
74 | header: Authorization | ||
75 | secret: mySecret | ||
76 | # token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒 | ||
77 | expiration: 7200000 | ||
78 | # 在线用户key | ||
79 | online: online-token | ||
80 | # 验证码 | ||
81 | codeKey: code-key | ||
82 | # token 续期检查时间范围(60分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期 | ||
83 | detect: 3600000 | ||
84 | # 续期时间,2小时,单位毫秒 | ||
85 | renew: 7200000 | ||
86 | |||
87 | #是否允许生成代码,生产环境设置为false | ||
88 | generator: | ||
89 | enabled: true | ||
90 | |||
91 | #是否开启 swagger-ui | ||
92 | swagger: | ||
93 | enabled: true | ||
94 |
... | @@ -7,6 +7,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTv; | ... | @@ -7,6 +7,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTv; |
7 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 7 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
8 | import com.topdraw.business.process.domian.weixin.BindBean; | 8 | import com.topdraw.business.process.domian.weixin.BindBean; |
9 | import com.topdraw.business.process.domian.weixin.TvUnBindBean; | 9 | import com.topdraw.business.process.domian.weixin.TvUnBindBean; |
10 | import com.topdraw.business.process.domian.weixin.WeixinUnBindBean; | ||
10 | import com.topdraw.business.process.rest.TaskOperationController; | 11 | import com.topdraw.business.process.rest.TaskOperationController; |
11 | import com.topdraw.business.process.rest.UserOperationController; | 12 | import com.topdraw.business.process.rest.UserOperationController; |
12 | import com.topdraw.business.process.service.dto.TaskOperationQueryCriteria; | 13 | import com.topdraw.business.process.service.dto.TaskOperationQueryCriteria; |
... | @@ -26,9 +27,71 @@ public class UserOperationControllerTest extends BaseTest { | ... | @@ -26,9 +27,71 @@ public class UserOperationControllerTest extends BaseTest { |
26 | private UserOperationController userOperationController; | 27 | private UserOperationController userOperationController; |
27 | 28 | ||
28 | @Test | 29 | @Test |
30 | public void deleteCollection() { | ||
31 | try { | ||
32 | String a = "{\n" + | ||
33 | "\t\"platformAccount\": \"topdraw\",\n" + | ||
34 | "\t\"data\": \"[{\\\"appId\\\":\\\"57\\\",\\\"userId\\\":\\\"5\\\",\\\"type\\\":\\\"1\\\",\\\"name\\\":\\\"PersonalCollectionRecords\\\",\\\"count\\\":\\\"1\\\",\\\"images\\\":\\\"\\\",\\\"userCollectionId\\\":\\\"\\\",\\\"detailFolderCode\\\":\\\"\\\",\\\"detailType\\\":\\\"\\\"},\\\"detailId\\\":\\\"\\\",\\\"detailEpisodeId\\\":\\\"\\\",\\\"detailEpisodeCode\\\":\\\"\\\",\\\"detailName\\\":\\\"\\\",\\\"detailMark\\\":\\\"\\\",\\\"detailImg\\\":\\\"\\\",\\\"detailImg\\\":\\\"\\\",\\\"detailIndex\\\":\\\"\\\",\\\"detailTotalIndex\\\":\\\"\\\",\\\"detailPlayTime\\\":\\\"\\\",\\\"detailTotalTime\\\":\\\"\\\",\\\"detailSequence\\\":\\\"\\\",\\\"detailScore\\\":\\\"\\\",\\\"detailLike\\\":\\\"\\\",\\\"detailExtData\\\":\\\"\\\"}]\"\n" + | ||
35 | "}"; | ||
36 | ResultInfo weixinUserAndMember = this.userOperationController.deleteCollection(a); | ||
37 | System.out.println(weixinUserAndMember); | ||
38 | } catch (Exception e) { | ||
39 | e.printStackTrace(); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | @Test | ||
44 | public void deleteAllCollection() { | ||
45 | try { | ||
46 | String a = "{\n" + | ||
47 | "\t\"platformAccount\": \"topdraw\",\n" + | ||
48 | "\t\"collectionType\": \"1\"\n" + | ||
49 | "}"; | ||
50 | ResultInfo weixinUserAndMember = this.userOperationController.deleteAllCollection(a); | ||
51 | System.out.println(weixinUserAndMember); | ||
52 | } catch (Exception e) { | ||
53 | e.printStackTrace(); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | @Test | ||
58 | public void addCollection() { | ||
59 | try { | ||
60 | String a = "{\n" + | ||
61 | "\t\"data\": [\n" + | ||
62 | "\t{\n" + | ||
63 | "\t\"app_id\": 57,\n" + | ||
64 | "\t\"user_id\": 1,\n" + | ||
65 | "\t\"type\": 1,\n" + | ||
66 | "\t\"name\": \"PersonalCollectionRecords\",\n" + | ||
67 | "\t\"count\": 22,\n" + | ||
68 | "\t\"images\": \"{\\\"map\\\":{\\\"poster\\\":[0]},\\\"list\\\":[{\\\"id\\\":47422,\\\"type\\\":2,\\\"width\\\":222,\\\"height\\\":294,\\\"fileUrl\\\":\\\"upload/image/media/2020-07-30/9a8a02db-9444-4bff-ba54-ea784ae4f88c.jpg\\\",\\\"size\\\":104643}]}\",\n" + | ||
69 | "\t\"id\": 756756,\n" + | ||
70 | "\t\"user_collection_id\": 1,\n" + | ||
71 | "\t\"detail_folder_code\": \"Default\",\n" + | ||
72 | "\t\"detail_type\": \"MEDIA\",\n" + | ||
73 | "\t\"detail_id\": 46532,\n" + | ||
74 | "\t\"detail_code\": \"media_558bc45a-5480-46ec-be9a-c749ffdbdf49\",\n" + | ||
75 | "\t\"detail_name\": \"熊出没之探险日记2\",\n" + | ||
76 | "\t\"detail_total_index\": 40,\n" + | ||
77 | "\t\"detail_sequence\": 1,\n" + | ||
78 | "\t\"create_time\": 1644503167000,\n" + | ||
79 | "\t\"update_time\": 1644503167000\n" + | ||
80 | "\t}\n" + | ||
81 | "\t],\n" + | ||
82 | "\t\"platformAccount\": \"topdraw\"\n" + | ||
83 | "}"; | ||
84 | ResultInfo weixinUserAndMember = this.userOperationController.addCollection(a); | ||
85 | System.out.println(weixinUserAndMember); | ||
86 | } catch (Exception e) { | ||
87 | e.printStackTrace(); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | @Test | ||
29 | public void minaUnbind() { | 92 | public void minaUnbind() { |
30 | try { | 93 | try { |
31 | TvUnBindBean bindBean = new TvUnBindBean(); | 94 | WeixinUnBindBean bindBean = new WeixinUnBindBean(); |
32 | // 小屏会员 | 95 | // 小屏会员 |
33 | bindBean.setMemberId(4L); | 96 | bindBean.setMemberId(4L); |
34 | bindBean.setAutoModel(true); | 97 | bindBean.setAutoModel(true); | ... | ... |
-
Please register or sign in to post a comment