1.接口优化,删除不必要的接口
Showing
22 changed files
with
177 additions
and
326 deletions
| ... | @@ -20,13 +20,6 @@ | ... | @@ -20,13 +20,6 @@ |
| 20 | 20 | ||
| 21 | <dependencies> | 21 | <dependencies> |
| 22 | 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--> | 23 | <!--api--> |
| 31 | <dependency> | 24 | <dependency> |
| 32 | <groupId>com.topdraw</groupId> | 25 | <groupId>com.topdraw</groupId> | ... | ... |
| ... | @@ -2,13 +2,12 @@ package com.topdraw.business.module.exp.detail.service.impl; | ... | @@ -2,13 +2,12 @@ package com.topdraw.business.module.exp.detail.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; | 3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; |
| 4 | import com.topdraw.business.module.exp.detail.domain.ExpDetailBuilder; | 4 | import com.topdraw.business.module.exp.detail.domain.ExpDetailBuilder; |
| 5 | import com.topdraw.utils.RedisUtils; | ||
| 5 | import com.topdraw.utils.ValidationUtil; | 6 | import com.topdraw.utils.ValidationUtil; |
| 6 | import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository; | 7 | import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository; |
| 7 | import com.topdraw.business.module.exp.detail.service.ExpDetailService; | 8 | import com.topdraw.business.module.exp.detail.service.ExpDetailService; |
| 8 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO; | 9 | import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO; |
| 9 | import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper; | 10 | import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper; |
| 10 | import org.redisson.api.RLock; | ||
| 11 | import org.redisson.api.RedissonClient; | ||
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
| ... | @@ -32,7 +31,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { | ... | @@ -32,7 +31,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { |
| 32 | private ExpDetailMapper expDetailMapper; | 31 | private ExpDetailMapper expDetailMapper; |
| 33 | 32 | ||
| 34 | @Autowired | 33 | @Autowired |
| 35 | private RedissonClient redissonClient; | 34 | private RedisUtils redisUtils; |
| 36 | 35 | ||
| 37 | @Override | 36 | @Override |
| 38 | public ExpDetailDTO findById(Long id) { | 37 | public ExpDetailDTO findById(Long id) { |
| ... | @@ -51,7 +50,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { | ... | @@ -51,7 +50,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { |
| 51 | @Override | 50 | @Override |
| 52 | @Transactional(rollbackFor = Exception.class) | 51 | @Transactional(rollbackFor = Exception.class) |
| 53 | public void update(ExpDetail resources) { | 52 | public void update(ExpDetail resources) { |
| 54 | RLock rLock = this.redissonClient.getLock(resources.getId().toString()); | 53 | this.redisUtils.doLock("expDetail::memberId::" + resources.getMemberId()); |
| 55 | try { | 54 | try { |
| 56 | ExpDetail ExpDetail = this.expDetailRepository.findById(resources.getId()).orElseGet(ExpDetail::new); | 55 | ExpDetail ExpDetail = this.expDetailRepository.findById(resources.getId()).orElseGet(ExpDetail::new); |
| 57 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); | 56 | ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId()); |
| ... | @@ -61,7 +60,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { | ... | @@ -61,7 +60,7 @@ public class ExpDetailServiceImpl implements ExpDetailService { |
| 61 | e.printStackTrace(); | 60 | e.printStackTrace(); |
| 62 | throw e; | 61 | throw e; |
| 63 | } finally { | 62 | } finally { |
| 64 | rLock.unlock(); | 63 | this.redisUtils.doUnLock("expDetail::memberId::" + resources.getMemberId()); |
| 65 | } | 64 | } |
| 66 | } | 65 | } |
| 67 | 66 | ... | ... |
| ... | @@ -4,15 +4,13 @@ import com.topdraw.business.module.member.address.domain.MemberAddress; | ... | @@ -4,15 +4,13 @@ import com.topdraw.business.module.member.address.domain.MemberAddress; |
| 4 | import com.topdraw.business.module.member.address.domain.MemberAddressBuilder; | 4 | import com.topdraw.business.module.member.address.domain.MemberAddressBuilder; |
| 5 | import com.topdraw.business.module.member.service.MemberService; | 5 | import com.topdraw.business.module.member.service.MemberService; |
| 6 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 6 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 7 | import com.topdraw.util.RedissonUtil; | 7 | import com.topdraw.utils.RedisUtils; |
| 8 | import com.topdraw.utils.ValidationUtil; | 8 | import com.topdraw.utils.ValidationUtil; |
| 9 | import com.topdraw.business.module.member.address.repository.MemberAddressRepository; | 9 | import com.topdraw.business.module.member.address.repository.MemberAddressRepository; |
| 10 | import com.topdraw.business.module.member.address.service.MemberAddressService; | 10 | import com.topdraw.business.module.member.address.service.MemberAddressService; |
| 11 | import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; | 11 | import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; |
| 12 | import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper; | 12 | import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper; |
| 13 | import lombok.extern.slf4j.Slf4j; | 13 | import lombok.extern.slf4j.Slf4j; |
| 14 | import org.redisson.api.RLock; | ||
| 15 | import org.redisson.api.RedissonClient; | ||
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 18 | import org.springframework.transaction.annotation.Propagation; | 16 | import org.springframework.transaction.annotation.Propagation; |
| ... | @@ -37,7 +35,7 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -37,7 +35,7 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
| 37 | private MemberAddressRepository memberAddressRepository; | 35 | private MemberAddressRepository memberAddressRepository; |
| 38 | 36 | ||
| 39 | @Autowired | 37 | @Autowired |
| 40 | private RedissonClient redissonClient; | 38 | private RedisUtils redisUtils; |
| 41 | 39 | ||
| 42 | @Override | 40 | @Override |
| 43 | public MemberAddressDTO findById(Long id) { | 41 | public MemberAddressDTO findById(Long id) { |
| ... | @@ -62,10 +60,10 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -62,10 +60,10 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
| 62 | public void update(MemberAddress resources) { | 60 | public void update(MemberAddress resources) { |
| 63 | log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); | 61 | log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources); |
| 64 | Assert.notNull(resources.getId(),"id can't be null"); | 62 | Assert.notNull(resources.getId(),"id can't be null"); |
| 65 | RLock rLock = this.redissonClient.getLock("MemberAddress::update::code" + resources.getId()); | 63 | // RLock rLock = this.redissonClient.getLock("MemberAddress::update::code" + resources.getId()); |
| 66 | try { | 64 | try { |
| 67 | RedissonUtil.lock(rLock); | 65 | // RedissonUtil.lock(rLock); |
| 68 | 66 | this.redisUtils.doLock("MemberAddress::update::code" + resources.getId()); | |
| 69 | MemberDTO memberDTO = this.checkMember(resources); | 67 | MemberDTO memberDTO = this.checkMember(resources); |
| 70 | resources.setMemberCode(memberDTO.getCode()); | 68 | resources.setMemberCode(memberDTO.getCode()); |
| 71 | 69 | ||
| ... | @@ -78,7 +76,8 @@ public class MemberAddressServiceImpl implements MemberAddressService { | ... | @@ -78,7 +76,8 @@ public class MemberAddressServiceImpl implements MemberAddressService { |
| 78 | e.printStackTrace(); | 76 | e.printStackTrace(); |
| 79 | throw e; | 77 | throw e; |
| 80 | } finally { | 78 | } finally { |
| 81 | RedissonUtil.unlock(rLock); | 79 | // RedissonUtil.unlock(rLock); |
| 80 | this.redisUtils.doUnLock("MemberAddress::update::code" + resources.getId()); | ||
| 82 | } | 81 | } |
| 83 | } | 82 | } |
| 84 | 83 | ... | ... |
| ... | @@ -37,7 +37,7 @@ public class Member implements Serializable { | ... | @@ -37,7 +37,7 @@ public class Member implements Serializable { |
| 37 | @Id | 37 | @Id |
| 38 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 38 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 39 | @Column(name = "id") | 39 | @Column(name = "id") |
| 40 | @NotNull(message = "code can't be null!!",groups = {UpdateGroup.class}) | 40 | @NotNull(message = "id can't be null!!",groups = {UpdateGroup.class}) |
| 41 | private Long id; | 41 | private Long id; |
| 42 | 42 | ||
| 43 | /** 标识 */ | 43 | /** 标识 */ | ... | ... |
| ... | @@ -6,7 +6,7 @@ import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder; | ... | @@ -6,7 +6,7 @@ import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder; |
| 6 | import com.topdraw.business.module.member.service.MemberService; | 6 | import com.topdraw.business.module.member.service.MemberService; |
| 7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 7 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 8 | import com.topdraw.util.Base64Util; | 8 | import com.topdraw.util.Base64Util; |
| 9 | import com.topdraw.util.RedissonUtil; | 9 | import com.topdraw.utils.RedisUtils; |
| 10 | import com.topdraw.utils.StringUtils; | 10 | import com.topdraw.utils.StringUtils; |
| 11 | import com.topdraw.utils.ValidationUtil; | 11 | import com.topdraw.utils.ValidationUtil; |
| 12 | import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; | 12 | import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; |
| ... | @@ -14,8 +14,6 @@ import com.topdraw.business.module.member.profile.service.MemberProfileService; | ... | @@ -14,8 +14,6 @@ import com.topdraw.business.module.member.profile.service.MemberProfileService; |
| 14 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 14 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 15 | import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; | 15 | import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; |
| 16 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 17 | import org.redisson.api.RLock; | ||
| 18 | import org.redisson.api.RedissonClient; | ||
| 19 | import org.springframework.beans.BeanUtils; | 17 | import org.springframework.beans.BeanUtils; |
| 20 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| ... | @@ -37,12 +35,12 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -37,12 +35,12 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 37 | @Autowired | 35 | @Autowired |
| 38 | private MemberService memberService; | 36 | private MemberService memberService; |
| 39 | @Autowired | 37 | @Autowired |
| 40 | private RedissonClient redissonClient; | ||
| 41 | @Autowired | ||
| 42 | private MemberProfileMapper memberProfileMapper; | 38 | private MemberProfileMapper memberProfileMapper; |
| 43 | @Autowired | 39 | @Autowired |
| 44 | private MemberProfileRepository memberProfileRepository; | 40 | private MemberProfileRepository memberProfileRepository; |
| 45 | 41 | ||
| 42 | @Autowired | ||
| 43 | private RedisUtils redisUtils; | ||
| 46 | 44 | ||
| 47 | @Override | 45 | @Override |
| 48 | public MemberProfileDTO findById(Long id) { | 46 | public MemberProfileDTO findById(Long id) { |
| ... | @@ -112,10 +110,8 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -112,10 +110,8 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 112 | public void update(MemberProfile resources) { | 110 | public void update(MemberProfile resources) { |
| 113 | 111 | ||
| 114 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | 112 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); |
| 115 | RLock rLock = this.redissonClient.getLock("memberProfile::update::id" + resources.getId()); | 113 | this.redisUtils.doLock("memberProfile::update::id" + resources.getId()); |
| 116 | try { | 114 | try { |
| 117 | RedissonUtil.lock(rLock); | ||
| 118 | |||
| 119 | // 检查会员是否存在 | 115 | // 检查会员是否存在 |
| 120 | this.checkMember(resources); | 116 | this.checkMember(resources); |
| 121 | // 真实姓名(加密) | 117 | // 真实姓名(加密) |
| ... | @@ -133,7 +129,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -133,7 +129,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 133 | e.printStackTrace(); | 129 | e.printStackTrace(); |
| 134 | throw e; | 130 | throw e; |
| 135 | } finally { | 131 | } finally { |
| 136 | RedissonUtil.unlock(rLock); | 132 | this.redisUtils.doUnLock("memberProfile::update::id" + resources.getId()); |
| 137 | } | 133 | } |
| 138 | 134 | ||
| 139 | } | 135 | } | ... | ... |
| ... | @@ -8,15 +8,13 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; | ... | @@ -8,15 +8,13 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 8 | import com.topdraw.exception.BadRequestException; | 8 | import com.topdraw.exception.BadRequestException; |
| 9 | import com.topdraw.exception.GlobeExceptionMsg; | 9 | import com.topdraw.exception.GlobeExceptionMsg; |
| 10 | import com.topdraw.util.Base64Util; | 10 | import com.topdraw.util.Base64Util; |
| 11 | import com.topdraw.util.RedissonUtil; | 11 | import com.topdraw.utils.RedisUtils; |
| 12 | import com.topdraw.utils.ValidationUtil; | 12 | import com.topdraw.utils.ValidationUtil; |
| 13 | import com.topdraw.business.module.member.relatedinfo.repository.MemberRelatedInfoRepository; | 13 | import com.topdraw.business.module.member.relatedinfo.repository.MemberRelatedInfoRepository; |
| 14 | import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService; | 14 | import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService; |
| 15 | import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; | 15 | import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; |
| 16 | import com.topdraw.business.module.member.relatedinfo.service.mapper.MemberRelatedInfoMapper; | 16 | import com.topdraw.business.module.member.relatedinfo.service.mapper.MemberRelatedInfoMapper; |
| 17 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
| 18 | import org.redisson.api.RLock; | ||
| 19 | import org.redisson.api.RedissonClient; | ||
| 20 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 22 | import org.springframework.transaction.annotation.Propagation; | 20 | import org.springframework.transaction.annotation.Propagation; |
| ... | @@ -44,7 +42,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -44,7 +42,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
| 44 | private MemberRelatedInfoRepository memberRelatedInfoRepository; | 42 | private MemberRelatedInfoRepository memberRelatedInfoRepository; |
| 45 | 43 | ||
| 46 | @Autowired | 44 | @Autowired |
| 47 | private RedissonClient redissonClient; | 45 | private RedisUtils redisUtils; |
| 48 | 46 | ||
| 49 | 47 | ||
| 50 | private static final String DEFAULT_IDCARD = "000000000000000000"; | 48 | private static final String DEFAULT_IDCARD = "000000000000000000"; |
| ... | @@ -108,9 +106,8 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -108,9 +106,8 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
| 108 | @Transactional(rollbackFor = Exception.class) | 106 | @Transactional(rollbackFor = Exception.class) |
| 109 | public void update(MemberRelatedInfo resources) { | 107 | public void update(MemberRelatedInfo resources) { |
| 110 | log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]",resources); | 108 | log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]",resources); |
| 111 | RLock rLock = this.redissonClient.getLock("memberRelatedInfo::update::id" + resources.getId()); | 109 | this.redisUtils.doLock("memberRelatedInfo::update::id" + resources.getId()); |
| 112 | try { | 110 | try { |
| 113 | RedissonUtil.lock(rLock); | ||
| 114 | 111 | ||
| 115 | this.checkMemberAndEncodeRealname(resources); | 112 | this.checkMemberAndEncodeRealname(resources); |
| 116 | 113 | ||
| ... | @@ -126,7 +123,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { | ... | @@ -126,7 +123,7 @@ public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { |
| 126 | e.printStackTrace(); | 123 | e.printStackTrace(); |
| 127 | throw e; | 124 | throw e; |
| 128 | } finally { | 125 | } finally { |
| 129 | RedissonUtil.unlock(rLock); | 126 | this.redisUtils.doUnLock("memberRelatedInfo::update::id" + resources.getId()); |
| 130 | } | 127 | } |
| 131 | } | 128 | } |
| 132 | 129 | ... | ... |
| 1 | package com.topdraw.business.module.member.rest; | 1 | package com.topdraw.business.module.member.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.aop.log.Log; | 4 | import com.topdraw.aop.log.Log; |
| 4 | import com.topdraw.business.module.common.validated.CreateGroup; | 5 | import com.topdraw.business.module.common.validated.CreateGroup; |
| 5 | import com.topdraw.business.module.common.validated.UpdateGroup; | 6 | import com.topdraw.business.module.common.validated.UpdateGroup; |
| 6 | import com.topdraw.business.module.member.domain.Member; | 7 | import com.topdraw.business.module.member.domain.Member; |
| 7 | import com.topdraw.business.module.member.service.MemberService; | 8 | import com.topdraw.business.module.member.service.MemberService; |
| 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
| 8 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 10 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 9 | import com.topdraw.business.process.service.MemberOperationService; | 11 | import com.topdraw.business.process.service.MemberOperationService; |
| 10 | import com.topdraw.business.process.service.UserOperationService; | 12 | import com.topdraw.business.process.service.UserOperationService; |
| ... | @@ -32,6 +34,7 @@ public class MemberController { | ... | @@ -32,6 +34,7 @@ public class MemberController { |
| 32 | @Autowired | 34 | @Autowired |
| 33 | private UserOperationService userTvOperationService; | 35 | private UserOperationService userTvOperationService; |
| 34 | 36 | ||
| 37 | |||
| 35 | @Log("为大屏账户创建会员") | 38 | @Log("为大屏账户创建会员") |
| 36 | @RequestMapping(value = "/createMemberByUserTv") | 39 | @RequestMapping(value = "/createMemberByUserTv") |
| 37 | @ApiOperation("为大屏账户创建会员") | 40 | @ApiOperation("为大屏账户创建会员") | ... | ... |
| ... | @@ -11,6 +11,8 @@ import java.util.List; | ... | @@ -11,6 +11,8 @@ import java.util.List; |
| 11 | */ | 11 | */ |
| 12 | public interface MemberService { | 12 | public interface MemberService { |
| 13 | 13 | ||
| 14 | |||
| 15 | |||
| 14 | /** | 16 | /** |
| 15 | * 根据ID查询 | 17 | * 根据ID查询 |
| 16 | * @param id ID | 18 | * @param id ID |
| ... | @@ -30,26 +32,26 @@ public interface MemberService { | ... | @@ -30,26 +32,26 @@ public interface MemberService { |
| 30 | * @param resources | 32 | * @param resources |
| 31 | * @return Long id | 33 | * @return Long id |
| 32 | */ | 34 | */ |
| 33 | Long create(Member resources); | 35 | MemberDTO create(Member resources); |
| 34 | 36 | ||
| 35 | /** | 37 | /** |
| 36 | * 创建并返回会员 | 38 | * 创建并返回会员 |
| 37 | * @param resources 会员 | 39 | * @param resources 会员 |
| 38 | * @return Member | 40 | * @return Member |
| 39 | */ | 41 | */ |
| 40 | Member createAndReturnMember(Member resources); | 42 | MemberDTO createAndReturnMember(Member resources); |
| 41 | 43 | ||
| 42 | /** | 44 | /** |
| 43 | * 修改会员 | 45 | * 修改会员 |
| 44 | * @param resources | 46 | * @param resources |
| 45 | */ | 47 | */ |
| 46 | void update(Member resources); | 48 | MemberDTO update(Member resources); |
| 47 | 49 | ||
| 48 | /** | 50 | /** |
| 49 | * 修改会员积分 | 51 | * 修改会员积分 |
| 50 | * @param member 会员 | 52 | * @param member 会员 |
| 51 | */ | 53 | */ |
| 52 | void doUpdateMemberPoints(Member member); | 54 | MemberDTO doUpdateMemberPoints(Member member); |
| 53 | 55 | ||
| 54 | /** | 56 | /** |
| 55 | * 查询绑定了大屏会员列表 | 57 | * 查询绑定了大屏会员列表 | ... | ... |
| ... | @@ -9,14 +9,15 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; | ... | @@ -9,14 +9,15 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 9 | import com.topdraw.business.module.member.service.mapper.MemberMapper; | 9 | import com.topdraw.business.module.member.service.mapper.MemberMapper; |
| 10 | import com.topdraw.exception.BadRequestException; | 10 | import com.topdraw.exception.BadRequestException; |
| 11 | import com.topdraw.exception.GlobeExceptionMsg; | 11 | import com.topdraw.exception.GlobeExceptionMsg; |
| 12 | import com.topdraw.util.RedissonUtil; | 12 | import com.topdraw.utils.RedisUtils; |
| 13 | import com.topdraw.utils.ValidationUtil; | 13 | import com.topdraw.utils.ValidationUtil; |
| 14 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.apache.commons.lang3.StringUtils; | 15 | import org.apache.commons.lang3.StringUtils; |
| 16 | import org.redisson.api.RLock; | ||
| 17 | import org.redisson.api.RedissonClient; | ||
| 18 | import org.springframework.beans.BeanUtils; | 16 | import org.springframework.beans.BeanUtils; |
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | import org.springframework.cache.annotation.CacheEvict; | ||
| 19 | import org.springframework.cache.annotation.CachePut; | ||
| 20 | import org.springframework.cache.annotation.Cacheable; | ||
| 20 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 21 | import org.springframework.transaction.annotation.Propagation; | 22 | import org.springframework.transaction.annotation.Propagation; |
| 22 | import org.springframework.transaction.annotation.Transactional; | 23 | import org.springframework.transaction.annotation.Transactional; |
| ... | @@ -40,15 +41,15 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -40,15 +41,15 @@ public class MemberServiceImpl implements MemberService { |
| 40 | private MemberProfileService memberProfileService; | 41 | private MemberProfileService memberProfileService; |
| 41 | 42 | ||
| 42 | @Autowired | 43 | @Autowired |
| 43 | private RedissonClient redissonClient; | 44 | private RedisUtils redisUtils; |
| 45 | |||
| 44 | 46 | ||
| 45 | @Override | 47 | @Override |
| 46 | public MemberDTO findById(Long id) { | 48 | public MemberDTO findById(Long id) { |
| 47 | |||
| 48 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); | 49 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); |
| 49 | ValidationUtil.isNull(member.getId(),"Member","id",id); | 50 | ValidationUtil.isNull(member.getId(),"Member","id",id); |
| 50 | 51 | ||
| 51 | return memberMapper.toDto(member); | 52 | return this.memberMapper.toDto(member); |
| 52 | 53 | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| ... | @@ -58,7 +59,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -58,7 +59,7 @@ public class MemberServiceImpl implements MemberService { |
| 58 | Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new); | 59 | Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new); |
| 59 | ValidationUtil.isNull(member.getId(),"Member","id",code); | 60 | ValidationUtil.isNull(member.getId(),"Member","id",code); |
| 60 | 61 | ||
| 61 | return memberMapper.toDto(member); | 62 | return this.memberMapper.toDto(member); |
| 62 | 63 | ||
| 63 | } | 64 | } |
| 64 | 65 | ||
| ... | @@ -67,7 +68,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -67,7 +68,7 @@ public class MemberServiceImpl implements MemberService { |
| 67 | Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new); | 68 | Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new); |
| 68 | ValidationUtil.isNull(member.getId(),"Member","param",code); | 69 | ValidationUtil.isNull(member.getId(),"Member","param",code); |
| 69 | 70 | ||
| 70 | return memberMapper.toDto(member); | 71 | return this.memberMapper.toDto(member); |
| 71 | 72 | ||
| 72 | } | 73 | } |
| 73 | 74 | ||
| ... | @@ -76,7 +77,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -76,7 +77,7 @@ public class MemberServiceImpl implements MemberService { |
| 76 | 77 | ||
| 77 | List<Member> memberList = this.memberRepository.findByUserIptvId(id); | 78 | List<Member> memberList = this.memberRepository.findByUserIptvId(id); |
| 78 | 79 | ||
| 79 | return memberMapper.toDto(memberList); | 80 | return this.memberMapper.toDto(memberList); |
| 80 | 81 | ||
| 81 | } | 82 | } |
| 82 | 83 | ||
| ... | @@ -101,7 +102,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -101,7 +102,7 @@ public class MemberServiceImpl implements MemberService { |
| 101 | 102 | ||
| 102 | @Override | 103 | @Override |
| 103 | @Transactional(rollbackFor = Exception.class) | 104 | @Transactional(rollbackFor = Exception.class) |
| 104 | public Long create(Member resources) { | 105 | public MemberDTO create(Member resources) { |
| 105 | 106 | ||
| 106 | Member member = MemberBuilder.build(resources); | 107 | Member member = MemberBuilder.build(resources); |
| 107 | Long memberId = this.save(member); | 108 | Long memberId = this.save(member); |
| ... | @@ -110,28 +111,27 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -110,28 +111,27 @@ public class MemberServiceImpl implements MemberService { |
| 110 | // 保存会员属性 | 111 | // 保存会员属性 |
| 111 | this.memberProfileService.createDefault(member); | 112 | this.memberProfileService.createDefault(member); |
| 112 | 113 | ||
| 113 | return member.getId(); | 114 | return this.memberMapper.toDto(member); |
| 114 | 115 | ||
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | @Override | 118 | @Override |
| 118 | @Transactional(rollbackFor = Exception.class) | 119 | @Transactional(rollbackFor = Exception.class) |
| 119 | public Member createAndReturnMember(Member resources) { | 120 | public MemberDTO createAndReturnMember(Member resources) { |
| 120 | 121 | ||
| 121 | this.create(MemberBuilder.build(resources)); | 122 | MemberDTO memberDTO = this.create(MemberBuilder.build(resources)); |
| 122 | 123 | ||
| 123 | return resources; | 124 | return memberDTO; |
| 124 | 125 | ||
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | @Override | 128 | @Override |
| 128 | @Transactional(rollbackFor = Exception.class) | 129 | @Transactional(rollbackFor = Exception.class) |
| 129 | public void update(Member resources) { | 130 | public MemberDTO update(Member resources) { |
| 130 | 131 | ||
| 131 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); | 132 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); |
| 132 | RLock rLock = this.redissonClient.getLock("member::update::code" + resources.getCode()); | 133 | this.redisUtils.doLock("member::update::code" + resources.getCode()); |
| 133 | try { | 134 | try { |
| 134 | RedissonUtil.lock(rLock); | ||
| 135 | MemberDTO memberDTO = this.checkMember(resources); | 135 | MemberDTO memberDTO = this.checkMember(resources); |
| 136 | 136 | ||
| 137 | Member member = new Member(); | 137 | Member member = new Member(); |
| ... | @@ -140,11 +140,13 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -140,11 +140,13 @@ public class MemberServiceImpl implements MemberService { |
| 140 | 140 | ||
| 141 | this.save(member); | 141 | this.save(member); |
| 142 | 142 | ||
| 143 | return this.memberMapper.toDto(member); | ||
| 144 | |||
| 143 | } catch (Exception e) { | 145 | } catch (Exception e) { |
| 144 | e.printStackTrace(); | 146 | e.printStackTrace(); |
| 145 | throw e; | 147 | throw e; |
| 146 | } finally { | 148 | } finally { |
| 147 | RedissonUtil.unlock(rLock); | 149 | this.redisUtils.doUnLock("member::update::code" + resources.getCode()); |
| 148 | } | 150 | } |
| 149 | 151 | ||
| 150 | } | 152 | } |
| ... | @@ -157,19 +159,23 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -157,19 +159,23 @@ public class MemberServiceImpl implements MemberService { |
| 157 | 159 | ||
| 158 | @Override | 160 | @Override |
| 159 | @Transactional(rollbackFor = Exception.class) | 161 | @Transactional(rollbackFor = Exception.class) |
| 160 | public void doUpdateMemberPoints(Member resources) { | 162 | public MemberDTO doUpdateMemberPoints(Member resources) { |
| 161 | RLock rLock = this.redissonClient.getLock("member::update::code" + resources.getId().toString()); | ||
| 162 | try { | 163 | try { |
| 163 | RedissonUtil.lock(rLock); | 164 | this.redisUtils.doLock("member::update::code" + resources.getCode()); |
| 165 | |||
| 164 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); | 166 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); |
| 165 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | 167 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); |
| 166 | member.copy(resources); | 168 | member.copy(resources); |
| 169 | |||
| 167 | this.save(member); | 170 | this.save(member); |
| 171 | |||
| 172 | return this.memberMapper.toDto(member); | ||
| 173 | |||
| 168 | } catch (Exception e) { | 174 | } catch (Exception e) { |
| 169 | e.printStackTrace(); | 175 | e.printStackTrace(); |
| 170 | throw e; | 176 | throw e; |
| 171 | } finally { | 177 | } finally { |
| 172 | RedissonUtil.unlock(rLock); | 178 | this.redisUtils.doUnLock("member::update::code" + resources.getCode()); |
| 173 | } | 179 | } |
| 174 | } | 180 | } |
| 175 | 181 | ... | ... |
| 1 | package com.topdraw.business.module.points.available.service.impl; | 1 | package com.topdraw.business.module.points.available.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 4 | import com.topdraw.business.module.points.available.domain.PointsAvailable; | 3 | import com.topdraw.business.module.points.available.domain.PointsAvailable; |
| 5 | import com.topdraw.util.RedissonUtil; | 4 | import com.topdraw.utils.RedisUtils; |
| 6 | import com.topdraw.utils.ValidationUtil; | 5 | import com.topdraw.utils.ValidationUtil; |
| 7 | import com.topdraw.business.module.points.available.repository.PointsAvailableRepository; | 6 | import com.topdraw.business.module.points.available.repository.PointsAvailableRepository; |
| 8 | import com.topdraw.business.module.points.available.service.PointsAvailableService; | 7 | import com.topdraw.business.module.points.available.service.PointsAvailableService; |
| 9 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO; | 8 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO; |
| 10 | import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria; | ||
| 11 | import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper; | 9 | import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper; |
| 12 | import org.redisson.api.RLock; | ||
| 13 | import org.redisson.api.RedissonClient; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 16 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
| 17 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
| 18 | import org.springframework.dao.EmptyResultDataAccessException; | 14 | 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; | 15 | import org.springframework.util.Assert; |
| 22 | import com.topdraw.utils.PageUtil; | ||
| 23 | import com.topdraw.utils.QueryHelp; | ||
| 24 | import com.topdraw.utils.StringUtils; | 16 | import com.topdraw.utils.StringUtils; |
| 25 | 17 | ||
| 26 | import java.time.LocalDateTime; | 18 | import java.time.LocalDateTime; |
| ... | @@ -41,7 +33,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -41,7 +33,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 41 | private PointsAvailableMapper PointsAvailableMapper; | 33 | private PointsAvailableMapper PointsAvailableMapper; |
| 42 | 34 | ||
| 43 | @Autowired | 35 | @Autowired |
| 44 | private RedissonClient redissonClient; | 36 | private RedisUtils redisUtils; |
| 45 | 37 | ||
| 46 | @Override | 38 | @Override |
| 47 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { | 39 | public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) { |
| ... | @@ -58,24 +50,22 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -58,24 +50,22 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 58 | @Override | 50 | @Override |
| 59 | @Transactional(rollbackFor = Exception.class) | 51 | @Transactional(rollbackFor = Exception.class) |
| 60 | public void create(PointsAvailable resources) { | 52 | public void create(PointsAvailable resources) { |
| 61 | RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | 53 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
| 62 | try { | 54 | try { |
| 63 | RedissonUtil.lock(rLock); | ||
| 64 | PointsAvailableRepository.save(resources); | 55 | PointsAvailableRepository.save(resources); |
| 65 | } catch (Exception e) { | 56 | } catch (Exception e) { |
| 66 | e.printStackTrace(); | 57 | e.printStackTrace(); |
| 67 | throw e; | 58 | throw e; |
| 68 | } finally { | 59 | } finally { |
| 69 | RedissonUtil.unlock(rLock); | 60 | this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
| 70 | } | 61 | } |
| 71 | } | 62 | } |
| 72 | 63 | ||
| 73 | @Override | 64 | @Override |
| 74 | @Transactional(rollbackFor = Exception.class) | 65 | @Transactional(rollbackFor = Exception.class) |
| 75 | public void update(PointsAvailable resources) { | 66 | public void update(PointsAvailable resources) { |
| 76 | RLock rLock = this.redissonClient.getLock("PointsAvailable::update::id"+resources.getMemberId().toString()); | 67 | this.redisUtils.doLock("PointsAvailable::update::id"+resources.getMemberId().toString()); |
| 77 | try { | 68 | try { |
| 78 | RedissonUtil.lock(rLock); | ||
| 79 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); | 69 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new); |
| 80 | ValidationUtil.isNull( PointsAvailable.getId(),"PointsAvailable","id",resources.getId()); | 70 | ValidationUtil.isNull( PointsAvailable.getId(),"PointsAvailable","id",resources.getId()); |
| 81 | PointsAvailable.copy(resources); | 71 | PointsAvailable.copy(resources); |
| ... | @@ -84,7 +74,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -84,7 +74,7 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 84 | e.printStackTrace(); | 74 | e.printStackTrace(); |
| 85 | throw e; | 75 | throw e; |
| 86 | } finally { | 76 | } finally { |
| 87 | RedissonUtil.unlock(rLock); | 77 | this.redisUtils.doUnLock("PointsAvailable::update::id"+resources.getMemberId().toString()); |
| 88 | } | 78 | } |
| 89 | } | 79 | } |
| 90 | 80 | ||
| ... | @@ -92,9 +82,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -92,9 +82,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 92 | @Transactional(rollbackFor = Exception.class) | 82 | @Transactional(rollbackFor = Exception.class) |
| 93 | public void delete(Long id) { | 83 | public void delete(Long id) { |
| 94 | Assert.notNull(id, "The given id must not be null!"); | 84 | Assert.notNull(id, "The given id must not be null!"); |
| 95 | RLock rLock = this.redissonClient.getLock("PointsAvailable::delete::id"+id); | 85 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); |
| 96 | try { | 86 | try { |
| 97 | RedissonUtil.lock(rLock); | ||
| 98 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 87 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( |
| 99 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 88 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); |
| 100 | PointsAvailableRepository.delete(PointsAvailable); | 89 | PointsAvailableRepository.delete(PointsAvailable); |
| ... | @@ -102,22 +91,21 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -102,22 +91,21 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 102 | e.printStackTrace(); | 91 | e.printStackTrace(); |
| 103 | throw e; | 92 | throw e; |
| 104 | } finally { | 93 | } finally { |
| 105 | RedissonUtil.unlock(rLock); | 94 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); |
| 106 | } | 95 | } |
| 107 | } | 96 | } |
| 108 | 97 | ||
| 109 | @Override | 98 | @Override |
| 110 | @Transactional(rollbackFor = Exception.class) | 99 | @Transactional(rollbackFor = Exception.class) |
| 111 | public void deleteBatchByIds(List<Long> id) { | 100 | public void deleteBatchByIds(List<Long> id) { |
| 112 | RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+id.get(0)); | 101 | this.redisUtils.doLock("PointsAvailable::create::id"+id); |
| 113 | try { | 102 | try { |
| 114 | RedissonUtil.lock(rLock); | ||
| 115 | PointsAvailableRepository.deleteBatchByIds(id); | 103 | PointsAvailableRepository.deleteBatchByIds(id); |
| 116 | } catch (Exception e) { | 104 | } catch (Exception e) { |
| 117 | e.printStackTrace(); | 105 | e.printStackTrace(); |
| 118 | throw e; | 106 | throw e; |
| 119 | } finally { | 107 | } finally { |
| 120 | RedissonUtil.unlock(rLock); | 108 | this.redisUtils.doUnLock("PointsAvailable::create::id"+id); |
| 121 | } | 109 | } |
| 122 | } | 110 | } |
| 123 | 111 | ||
| ... | @@ -154,9 +142,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -154,9 +142,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 154 | @Override | 142 | @Override |
| 155 | public void delete4Custom(Long id) { | 143 | public void delete4Custom(Long id) { |
| 156 | Assert.notNull(id, "The given id must not be null!"); | 144 | Assert.notNull(id, "The given id must not be null!"); |
| 157 | RLock rLock = this.redissonClient.getLock("PointsAvailable::delete::id"+id); | 145 | this.redisUtils.doLock("PointsAvailable::delete::id"+id); |
| 158 | try { | 146 | try { |
| 159 | RedissonUtil.lock(rLock); | ||
| 160 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( | 147 | PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseThrow( |
| 161 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); | 148 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PointsAvailable.class, id), 1)); |
| 162 | PointsAvailableRepository.delete(PointsAvailable); | 149 | PointsAvailableRepository.delete(PointsAvailable); |
| ... | @@ -164,21 +151,20 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -164,21 +151,20 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
| 164 | e.printStackTrace(); | 151 | e.printStackTrace(); |
| 165 | throw e; | 152 | throw e; |
| 166 | } finally { | 153 | } finally { |
| 167 | RedissonUtil.unlock(rLock); | 154 | this.redisUtils.doUnLock("PointsAvailable::delete::id"+id); |
| 168 | } | 155 | } |
| 169 | } | 156 | } |
| 170 | 157 | ||
| 171 | @Override | 158 | @Override |
| 172 | public void create4Custom(PointsAvailable resources) { | 159 | public void create4Custom(PointsAvailable resources) { |
| 173 | RLock rLock = this.redissonClient.getLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | 160 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
| 174 | try { | 161 | try { |
| 175 | RedissonUtil.lock(rLock); | ||
| 176 | PointsAvailableRepository.save(resources); | 162 | PointsAvailableRepository.save(resources); |
| 177 | } catch (Exception e) { | 163 | } catch (Exception e) { |
| 178 | e.printStackTrace(); | 164 | e.printStackTrace(); |
| 179 | throw e; | 165 | throw e; |
| 180 | } finally { | 166 | } finally { |
| 181 | RedissonUtil.unlock(rLock); | 167 | this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString()); |
| 182 | } | 168 | } |
| 183 | } | 169 | } |
| 184 | 170 | ... | ... |
| 1 | package com.topdraw.business.module.points.service.impl; | 1 | package com.topdraw.business.module.points.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 4 | import com.topdraw.business.module.points.domain.Points; | 3 | import com.topdraw.business.module.points.domain.Points; |
| 5 | import com.topdraw.util.RedissonUtil; | 4 | import com.topdraw.utils.RedisUtils; |
| 6 | import com.topdraw.utils.ValidationUtil; | 5 | import com.topdraw.utils.ValidationUtil; |
| 7 | import com.topdraw.business.module.points.repository.PointsRepository; | 6 | import com.topdraw.business.module.points.repository.PointsRepository; |
| 8 | import com.topdraw.business.module.points.service.PointsService; | 7 | import com.topdraw.business.module.points.service.PointsService; |
| 9 | import com.topdraw.business.module.points.service.dto.PointsDTO; | 8 | import com.topdraw.business.module.points.service.dto.PointsDTO; |
| 10 | import com.topdraw.business.module.points.service.dto.PointsQueryCriteria; | 9 | import com.topdraw.business.module.points.service.dto.PointsQueryCriteria; |
| 11 | import com.topdraw.business.module.points.service.mapper.PointsMapper; | 10 | import com.topdraw.business.module.points.service.mapper.PointsMapper; |
| 12 | import org.redisson.api.RLock; | ||
| 13 | import org.redisson.api.RedissonClient; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 16 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
| ... | @@ -42,7 +39,7 @@ public class PointsServiceImpl implements PointsService { | ... | @@ -42,7 +39,7 @@ public class PointsServiceImpl implements PointsService { |
| 42 | private PointsMapper PointsMapper; | 39 | private PointsMapper PointsMapper; |
| 43 | 40 | ||
| 44 | @Autowired | 41 | @Autowired |
| 45 | private RedissonClient redissonClient; | 42 | private RedisUtils redisUtils; |
| 46 | 43 | ||
| 47 | @Override | 44 | @Override |
| 48 | public Map<String, Object> queryAll(PointsQueryCriteria criteria, Pageable pageable) { | 45 | public Map<String, Object> queryAll(PointsQueryCriteria criteria, Pageable pageable) { |
| ... | @@ -73,9 +70,8 @@ public class PointsServiceImpl implements PointsService { | ... | @@ -73,9 +70,8 @@ public class PointsServiceImpl implements PointsService { |
| 73 | @Override | 70 | @Override |
| 74 | @Transactional(rollbackFor = Exception.class) | 71 | @Transactional(rollbackFor = Exception.class) |
| 75 | public void update(Points resources) { | 72 | public void update(Points resources) { |
| 76 | RLock rLock = this.redissonClient.getLock(resources.getId().toString()); | 73 | this.redisUtils.doLock("Points::update::userId"+resources.getUserId().toString()); |
| 77 | try { | 74 | try { |
| 78 | RedissonUtil.lock(rLock); | ||
| 79 | Points Points = PointsRepository.findById(resources.getId()).orElseGet(Points::new); | 75 | Points Points = PointsRepository.findById(resources.getId()).orElseGet(Points::new); |
| 80 | ValidationUtil.isNull(Points.getId(), "Points", "id", resources.getId()); | 76 | ValidationUtil.isNull(Points.getId(), "Points", "id", resources.getId()); |
| 81 | Points.copy(resources); | 77 | Points.copy(resources); |
| ... | @@ -84,7 +80,7 @@ public class PointsServiceImpl implements PointsService { | ... | @@ -84,7 +80,7 @@ public class PointsServiceImpl implements PointsService { |
| 84 | e.printStackTrace(); | 80 | e.printStackTrace(); |
| 85 | throw e; | 81 | throw e; |
| 86 | } finally { | 82 | } finally { |
| 87 | RedissonUtil.unlock(rLock); | 83 | this.redisUtils.doUnLock("Points::update::userId"+resources.getUserId().toString()); |
| 88 | } | 84 | } |
| 89 | } | 85 | } |
| 90 | 86 | ... | ... |
| 1 | package com.topdraw.business.module.rights.service; | 1 | package com.topdraw.business.module.rights.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.rights.domain.Rights; | ||
| 4 | import com.topdraw.business.module.rights.service.dto.RightsDTO; | 3 | import com.topdraw.business.module.rights.service.dto.RightsDTO; |
| 5 | import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria; | ||
| 6 | import org.springframework.data.domain.Pageable; | ||
| 7 | import java.util.Map; | ||
| 8 | import java.util.List; | ||
| 9 | 4 | ||
| 10 | /** | 5 | /** |
| 11 | * @author XiangHan | 6 | * @author XiangHan |
| ... | @@ -14,21 +9,6 @@ import java.util.List; | ... | @@ -14,21 +9,6 @@ import java.util.List; |
| 14 | public interface RightsService { | 9 | public interface RightsService { |
| 15 | 10 | ||
| 16 | /** | 11 | /** |
| 17 | * 查询数据分页 | ||
| 18 | * @param criteria 条件参数 | ||
| 19 | * @param pageable 分页参数 | ||
| 20 | * @return Map<String,Object> | ||
| 21 | */ | ||
| 22 | Map<String,Object> queryAll(RightsQueryCriteria criteria, Pageable pageable); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * 查询所有数据不分页 | ||
| 26 | * @param criteria 条件参数 | ||
| 27 | * @return List<RightsDTO> | ||
| 28 | */ | ||
| 29 | List<RightsDTO> queryAll(RightsQueryCriteria criteria); | ||
| 30 | |||
| 31 | /** | ||
| 32 | * 根据ID查询 | 12 | * 根据ID查询 |
| 33 | * @param id ID | 13 | * @param id ID |
| 34 | * @return RightsDTO | 14 | * @return RightsDTO |
| ... | @@ -36,19 +16,6 @@ public interface RightsService { | ... | @@ -36,19 +16,6 @@ public interface RightsService { |
| 36 | RightsDTO findById(Long id); | 16 | RightsDTO findById(Long id); |
| 37 | 17 | ||
| 38 | /** | 18 | /** |
| 39 | * 批量查询 | ||
| 40 | * @param ids | ||
| 41 | * @return | ||
| 42 | */ | ||
| 43 | List<RightsDTO> findBatchByIds(Long... ids); | ||
| 44 | |||
| 45 | void create(Rights resources); | ||
| 46 | |||
| 47 | void update(Rights resources); | ||
| 48 | |||
| 49 | void delete(Long id); | ||
| 50 | |||
| 51 | /** | ||
| 52 | * Code校验 | 19 | * Code校验 |
| 53 | * @param code | 20 | * @param code |
| 54 | * @return RightsDTO | 21 | * @return RightsDTO | ... | ... |
| 1 | package com.topdraw.business.module.rights.service.impl; | 1 | package com.topdraw.business.module.rights.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 4 | import com.topdraw.business.module.rights.domain.Rights; | 3 | import com.topdraw.business.module.rights.domain.Rights; |
| 5 | import com.topdraw.utils.ValidationUtil; | 4 | import com.topdraw.utils.*; |
| 6 | import com.topdraw.business.module.rights.repository.RightsRepository; | 5 | import com.topdraw.business.module.rights.repository.RightsRepository; |
| 7 | import com.topdraw.business.module.rights.service.RightsService; | 6 | import com.topdraw.business.module.rights.service.RightsService; |
| 8 | import com.topdraw.business.module.rights.service.dto.RightsDTO; | 7 | import com.topdraw.business.module.rights.service.dto.RightsDTO; |
| 9 | import com.topdraw.business.module.rights.service.dto.RightsQueryCriteria; | ||
| 10 | import com.topdraw.business.module.rights.service.mapper.RightsMapper; | 8 | import com.topdraw.business.module.rights.service.mapper.RightsMapper; |
| 11 | import org.redisson.api.RLock; | ||
| 12 | import org.redisson.api.RedissonClient; | ||
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 15 | import org.springframework.transaction.annotation.Propagation; | 11 | import org.springframework.transaction.annotation.Propagation; |
| 16 | import org.springframework.transaction.annotation.Transactional; | 12 | 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 | import org.springframework.util.CollectionUtils; | ||
| 25 | |||
| 26 | import java.util.List; | ||
| 27 | import java.util.Map; | ||
| 28 | 13 | ||
| 29 | /** | 14 | /** |
| 30 | * @author XiangHan | 15 | * @author XiangHan |
| ... | @@ -41,18 +26,7 @@ public class RightsServiceImpl implements RightsService { | ... | @@ -41,18 +26,7 @@ public class RightsServiceImpl implements RightsService { |
| 41 | private RightsMapper RightsMapper; | 26 | private RightsMapper RightsMapper; |
| 42 | 27 | ||
| 43 | @Autowired | 28 | @Autowired |
| 44 | private RedissonClient redissonClient; | 29 | private RedisUtils redisUtils; |
| 45 | |||
| 46 | @Override | ||
| 47 | public Map<String, Object> queryAll(RightsQueryCriteria criteria, Pageable pageable) { | ||
| 48 | Page<Rights> page = RightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); | ||
| 49 | return PageUtil.toPage(page.map(RightsMapper::toDto)); | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | public List<RightsDTO> queryAll(RightsQueryCriteria criteria) { | ||
| 54 | return RightsMapper.toDto(RightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); | ||
| 55 | } | ||
| 56 | 30 | ||
| 57 | @Override | 31 | @Override |
| 58 | public RightsDTO findById(Long id) { | 32 | public RightsDTO findById(Long id) { |
| ... | @@ -62,45 +36,6 @@ public class RightsServiceImpl implements RightsService { | ... | @@ -62,45 +36,6 @@ public class RightsServiceImpl implements RightsService { |
| 62 | } | 36 | } |
| 63 | 37 | ||
| 64 | @Override | 38 | @Override |
| 65 | public List<RightsDTO> findBatchByIds(Long... ids) { | ||
| 66 | List<Rights> rightsList = this.RightsRepository.findBatchByIds(ids); | ||
| 67 | return !CollectionUtils.isEmpty(rightsList) ? RightsMapper.toDto(rightsList) : null; | ||
| 68 | } | ||
| 69 | |||
| 70 | @Override | ||
| 71 | @Transactional(rollbackFor = Exception.class) | ||
| 72 | public void create(Rights resources) { | ||
| 73 | RightsRepository.save(resources); | ||
| 74 | } | ||
| 75 | |||
| 76 | @Override | ||
| 77 | @Transactional(rollbackFor = Exception.class) | ||
| 78 | public void update(Rights resources) { | ||
| 79 | RLock rLock = this.redissonClient.getLock(resources.getId().toString()); | ||
| 80 | try { | ||
| 81 | Rights Rights = RightsRepository.findById(resources.getId()).orElseGet(Rights::new); | ||
| 82 | ValidationUtil.isNull( Rights.getId(),"Rights","id",resources.getId()); | ||
| 83 | Rights.copy(resources); | ||
| 84 | RightsRepository.save(Rights); | ||
| 85 | } catch (Exception e) { | ||
| 86 | e.printStackTrace(); | ||
| 87 | throw e; | ||
| 88 | } finally { | ||
| 89 | rLock.unlock(); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | @Override | ||
| 94 | @Transactional(rollbackFor = Exception.class) | ||
| 95 | public void delete(Long id) { | ||
| 96 | Assert.notNull(id, "The given id must not be null!"); | ||
| 97 | Rights Rights = RightsRepository.findById(id).orElseThrow( | ||
| 98 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Rights.class, id), 1)); | ||
| 99 | RightsRepository.delete(Rights); | ||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | @Override | ||
| 104 | public RightsDTO getByCode(String code) { | 39 | public RightsDTO getByCode(String code) { |
| 105 | return StringUtils.isNotEmpty(code) ? RightsMapper.toDto(RightsRepository.findFirstByCode(code).orElseGet(Rights::new)) | 40 | return StringUtils.isNotEmpty(code) ? RightsMapper.toDto(RightsRepository.findFirstByCode(code).orElseGet(Rights::new)) |
| 106 | : new RightsDTO(); | 41 | : new RightsDTO(); | ... | ... |
| ... | @@ -2,11 +2,16 @@ package com.topdraw.business.process.rest; | ... | @@ -2,11 +2,16 @@ package com.topdraw.business.process.rest; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.ObjectUtil; | 3 | import cn.hutool.core.util.ObjectUtil; |
| 4 | import com.topdraw.annotation.AnonymousAccess; | 4 | import com.topdraw.annotation.AnonymousAccess; |
| 5 | import com.topdraw.aop.log.Log; | ||
| 6 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
| 7 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
| 8 | import com.topdraw.business.module.member.domain.Member; | ||
| 5 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 9 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 6 | import com.topdraw.business.module.member.service.MemberService; | 10 | import com.topdraw.business.module.member.service.MemberService; |
| 7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 11 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 8 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | 12 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; |
| 9 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; | 13 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; |
| 14 | import com.topdraw.business.module.user.iptv.domain.UserTv; | ||
| 10 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | 15 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; |
| 11 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 16 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
| 12 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | 17 | import com.topdraw.business.process.domian.weixin.BuyVipBean; |
| ... | @@ -16,7 +21,9 @@ import com.topdraw.common.ResultInfo; | ... | @@ -16,7 +21,9 @@ import com.topdraw.common.ResultInfo; |
| 16 | import com.topdraw.exception.BadRequestException; | 21 | import com.topdraw.exception.BadRequestException; |
| 17 | import io.swagger.annotations.Api; | 22 | import io.swagger.annotations.Api; |
| 18 | import io.swagger.annotations.ApiOperation; | 23 | import io.swagger.annotations.ApiOperation; |
| 24 | import lombok.extern.slf4j.Slf4j; | ||
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | import org.springframework.validation.annotation.Validated; | ||
| 20 | import org.springframework.web.bind.annotation.*; | 27 | import org.springframework.web.bind.annotation.*; |
| 21 | 28 | ||
| 22 | import java.time.LocalDateTime; | 29 | import java.time.LocalDateTime; |
| ... | @@ -25,6 +32,8 @@ import java.util.Objects; | ... | @@ -25,6 +32,8 @@ import java.util.Objects; |
| 25 | @Api("会员处理") | 32 | @Api("会员处理") |
| 26 | @RestController | 33 | @RestController |
| 27 | @RequestMapping(value = "/ucEngine/api/memberOperation") | 34 | @RequestMapping(value = "/ucEngine/api/memberOperation") |
| 35 | @CrossOrigin | ||
| 36 | @Slf4j | ||
| 28 | public class MemberOperationController { | 37 | public class MemberOperationController { |
| 29 | 38 | ||
| 30 | @Autowired | 39 | @Autowired |
| ... | @@ -36,6 +45,31 @@ public class MemberOperationController { | ... | @@ -36,6 +45,31 @@ public class MemberOperationController { |
| 36 | @Autowired | 45 | @Autowired |
| 37 | private MemberService memberService; | 46 | private MemberService memberService; |
| 38 | 47 | ||
| 48 | @Log("查询会员") | ||
| 49 | @GetMapping(value = "/findById/{id}") | ||
| 50 | @ApiOperation("查询会员") | ||
| 51 | @AnonymousAccess | ||
| 52 | public ResultInfo findById(@PathVariable(value = "id") Long id) { | ||
| 53 | log.info("memberOperation ==>> findById ==>> param ==>> [{}]",id); | ||
| 54 | MemberDTO memberDTO = this.memberOperationService.findById(id); | ||
| 55 | log.info("memberOperation ==>> findById ==>> result ==>> [{}]",memberDTO); | ||
| 56 | return ResultInfo.success(memberDTO); | ||
| 57 | } | ||
| 58 | |||
| 59 | @Log("手动修改vip") | ||
| 60 | @RequestMapping(value = "/doUpdateVipByCode") | ||
| 61 | @ApiOperation("手动修改vip") | ||
| 62 | @AnonymousAccess | ||
| 63 | public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { | ||
| 64 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); | ||
| 65 | |||
| 66 | MemberDTO memberDTO = this.memberService.findByCode(resources.getCode()); | ||
| 67 | resources.setId(memberDTO.getId()); | ||
| 68 | this.memberOperationService.update(resources); | ||
| 69 | log.info("member ==>> doUpdateVipByCode ==>> result ==>> [{}]",resources); | ||
| 70 | return ResultInfo.success(); | ||
| 71 | } | ||
| 72 | |||
| 39 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") | 73 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") |
| 40 | @ApiOperation("获取会员基本信息并且检查vip状态") | 74 | @ApiOperation("获取会员基本信息并且检查vip状态") |
| 41 | @AnonymousAccess | 75 | @AnonymousAccess | ... | ... |
| ... | @@ -11,13 +11,13 @@ public interface MemberOperationService { | ... | @@ -11,13 +11,13 @@ public interface MemberOperationService { |
| 11 | * | 11 | * |
| 12 | * @param member | 12 | * @param member |
| 13 | */ | 13 | */ |
| 14 | void doUpdateMemberInfo(Member member); | 14 | MemberDTO doUpdateMemberInfo(Member member); |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | * | 17 | * |
| 18 | * @param member | 18 | * @param member |
| 19 | */ | 19 | */ |
| 20 | void doInsertMember(Member member); | 20 | MemberDTO doInsertMember(Member member); |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * | 23 | * |
| ... | @@ -30,19 +30,19 @@ public interface MemberOperationService { | ... | @@ -30,19 +30,19 @@ public interface MemberOperationService { |
| 30 | * | 30 | * |
| 31 | * @param member | 31 | * @param member |
| 32 | */ | 32 | */ |
| 33 | void doUpdateMemberExp(Member member); | 33 | MemberDTO doUpdateMemberExp(Member member); |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * | 36 | * |
| 37 | * @param member | 37 | * @param member |
| 38 | */ | 38 | */ |
| 39 | void doUpdateMemberPoints(Member member); | 39 | MemberDTO doUpdateMemberPoints(Member member); |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * | 42 | * |
| 43 | * @param member | 43 | * @param member |
| 44 | */ | 44 | */ |
| 45 | void doUpdateMemberCoupon(Member member); | 45 | MemberDTO doUpdateMemberCoupon(Member member); |
| 46 | 46 | ||
| 47 | /** | 47 | /** |
| 48 | * | 48 | * |
| ... | @@ -63,5 +63,6 @@ public interface MemberOperationService { | ... | @@ -63,5 +63,6 @@ public interface MemberOperationService { |
| 63 | * 修改会员 | 63 | * 修改会员 |
| 64 | * @param resources | 64 | * @param resources |
| 65 | */ | 65 | */ |
| 66 | void update(Member resources); | 66 | MemberDTO update(Member resources); |
| 67 | |||
| 67 | } | 68 | } | ... | ... |
| ... | @@ -11,10 +11,7 @@ import com.topdraw.business.process.service.CouponOperationService; | ... | @@ -11,10 +11,7 @@ import com.topdraw.business.process.service.CouponOperationService; |
| 11 | import com.topdraw.business.process.service.MemberOperationService; | 11 | import com.topdraw.business.process.service.MemberOperationService; |
| 12 | import com.topdraw.business.process.domian.TempCoupon; | 12 | import com.topdraw.business.process.domian.TempCoupon; |
| 13 | import com.topdraw.business.process.service.RightsOperationService; | 13 | import com.topdraw.business.process.service.RightsOperationService; |
| 14 | import com.topdraw.util.RedissonUtil; | 14 | import com.topdraw.utils.RedisUtils; |
| 15 | import com.topdraw.util.TimestampUtil; | ||
| 16 | import org.redisson.api.RLock; | ||
| 17 | import org.redisson.api.RedissonClient; | ||
| 18 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 19 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
| 20 | import org.springframework.beans.BeanUtils; | 17 | import org.springframework.beans.BeanUtils; |
| ... | @@ -22,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; | ... | @@ -22,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 22 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 19 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 23 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 24 | 21 | ||
| 25 | import java.sql.Timestamp; | ||
| 26 | import java.time.LocalDateTime; | 22 | import java.time.LocalDateTime; |
| 27 | import java.util.List; | 23 | import java.util.List; |
| 28 | import java.util.Objects; | 24 | import java.util.Objects; |
| ... | @@ -43,11 +39,13 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -43,11 +39,13 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 43 | RightsOperationService rightsOperationService; | 39 | RightsOperationService rightsOperationService; |
| 44 | @Autowired | 40 | @Autowired |
| 45 | MemberService memberService; | 41 | MemberService memberService; |
| 46 | @Autowired | 42 | |
| 47 | RedissonClient redissonClient; | ||
| 48 | @Autowired | 43 | @Autowired |
| 49 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 44 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| 50 | 45 | ||
| 46 | @Autowired | ||
| 47 | private RedisUtils redisUtils; | ||
| 48 | |||
| 51 | // 过期阀值(默认一个月) | 49 | // 过期阀值(默认一个月) |
| 52 | private static final Integer EXPIRE_FACTOR_DAY = 30; | 50 | private static final Integer EXPIRE_FACTOR_DAY = 30; |
| 53 | 51 | ||
| ... | @@ -94,9 +92,8 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -94,9 +92,8 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 94 | // Long userId = tempCoupon.getUserId(); | 92 | // Long userId = tempCoupon.getUserId(); |
| 95 | Long memberId = tempCoupon.getMemberId(); | 93 | Long memberId = tempCoupon.getMemberId(); |
| 96 | Integer rightsAmount = tempCoupon.getRightsAmount(); | 94 | Integer rightsAmount = tempCoupon.getRightsAmount(); |
| 97 | RLock rLock = this.redissonClient.getLock("refreshMemberCoupon:" + memberId.toString()); | ||
| 98 | try { | 95 | try { |
| 99 | RedissonUtil.lock(rLock); | 96 | this.redisUtils.doLock("refreshMemberCoupon:" + memberId.toString()); |
| 100 | // 1.历史总优惠券数量 | 97 | // 1.历史总优惠券数量 |
| 101 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); | 98 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); |
| 102 | // 1.当前总优惠券数量 | 99 | // 1.当前总优惠券数量 |
| ... | @@ -113,7 +110,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -113,7 +110,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 113 | e.printStackTrace(); | 110 | e.printStackTrace(); |
| 114 | throw e; | 111 | throw e; |
| 115 | } finally { | 112 | } finally { |
| 116 | RedissonUtil.unlock(rLock); | 113 | this.redisUtils.doUnLock("refreshMemberCoupon:" + memberId.toString()); |
| 117 | } | 114 | } |
| 118 | } | 115 | } |
| 119 | 116 | ... | ... |
| ... | @@ -12,11 +12,8 @@ import com.topdraw.business.process.service.ExpOperationService; | ... | @@ -12,11 +12,8 @@ import com.topdraw.business.process.service.ExpOperationService; |
| 12 | import com.topdraw.business.process.service.MemberOperationService; | 12 | import com.topdraw.business.process.service.MemberOperationService; |
| 13 | import com.topdraw.business.process.domian.TempExp; | 13 | import com.topdraw.business.process.domian.TempExp; |
| 14 | import com.topdraw.util.IdWorker; | 14 | import com.topdraw.util.IdWorker; |
| 15 | import com.topdraw.util.RedissonUtil; | 15 | import com.topdraw.utils.RedisUtils; |
| 16 | import com.topdraw.util.TimestampUtil; | ||
| 17 | import com.topdraw.utils.StringUtils; | 16 | import com.topdraw.utils.StringUtils; |
| 18 | import org.redisson.api.RLock; | ||
| 19 | import org.redisson.api.RedissonClient; | ||
| 20 | import org.slf4j.Logger; | 17 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; | 18 | import org.slf4j.LoggerFactory; |
| 22 | import org.springframework.beans.BeanUtils; | 19 | import org.springframework.beans.BeanUtils; |
| ... | @@ -45,11 +42,13 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -45,11 +42,13 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 45 | MemberLevelService memberLevelService; | 42 | MemberLevelService memberLevelService; |
| 46 | @Autowired | 43 | @Autowired |
| 47 | MemberService memberService; | 44 | MemberService memberService; |
| 48 | @Autowired | 45 | |
| 49 | RedissonClient redissonClient; | ||
| 50 | @Autowired | 46 | @Autowired |
| 51 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 47 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| 52 | 48 | ||
| 49 | @Autowired | ||
| 50 | private RedisUtils redisUtils; | ||
| 51 | |||
| 53 | @Override | 52 | @Override |
| 54 | @AsyncMqSend | 53 | @AsyncMqSend |
| 55 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { | 54 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { |
| ... | @@ -80,9 +79,8 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -80,9 +79,8 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 80 | * @param tempExp | 79 | * @param tempExp |
| 81 | */ | 80 | */ |
| 82 | private void refresh(TempExp tempExp) { | 81 | private void refresh(TempExp tempExp) { |
| 83 | RLock lock = this.redissonClient.getLock("uc-refresh-exp:" + tempExp.getMemberId()); | ||
| 84 | try { | 82 | try { |
| 85 | RedissonUtil.lock(lock); | 83 | this.redisUtils.doLock("uc-refresh-exp:" + tempExp.getMemberId()); |
| 86 | // 原始积分 | 84 | // 原始积分 |
| 87 | long originExp = this.getExpByMemberId(tempExp); | 85 | long originExp = this.getExpByMemberId(tempExp); |
| 88 | // 总积分 | 86 | // 总积分 |
| ... | @@ -98,7 +96,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -98,7 +96,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 98 | e.printStackTrace(); | 96 | e.printStackTrace(); |
| 99 | throw e; | 97 | throw e; |
| 100 | } finally { | 98 | } finally { |
| 101 | RedissonUtil.unlock(lock); | 99 | this.redisUtils.doUnLock("uc-refresh-exp:" + tempExp.getMemberId()); |
| 102 | } | 100 | } |
| 103 | } | 101 | } |
| 104 | 102 | ... | ... |
| ... | @@ -16,6 +16,10 @@ import com.topdraw.business.process.service.MemberOperationService; | ... | @@ -16,6 +16,10 @@ import com.topdraw.business.process.service.MemberOperationService; |
| 16 | import com.topdraw.exception.EntityNotFoundException; | 16 | import com.topdraw.exception.EntityNotFoundException; |
| 17 | import org.springframework.beans.BeanUtils; | 17 | import org.springframework.beans.BeanUtils; |
| 18 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 19 | import org.springframework.cache.annotation.CacheConfig; | ||
| 20 | import org.springframework.cache.annotation.CacheEvict; | ||
| 21 | import org.springframework.cache.annotation.CachePut; | ||
| 22 | import org.springframework.cache.annotation.Cacheable; | ||
| 19 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 23 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 20 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
| 21 | import org.springframework.util.Assert; | 25 | import org.springframework.util.Assert; |
| ... | @@ -25,6 +29,7 @@ import java.time.ZoneOffset; | ... | @@ -25,6 +29,7 @@ import java.time.ZoneOffset; |
| 25 | import java.util.Objects; | 29 | import java.util.Objects; |
| 26 | 30 | ||
| 27 | @Service | 31 | @Service |
| 32 | @CacheConfig(cacheNames = "member") | ||
| 28 | public class MemberOperationServiceImpl implements MemberOperationService { | 33 | public class MemberOperationServiceImpl implements MemberOperationService { |
| 29 | 34 | ||
| 30 | @Autowired | 35 | @Autowired |
| ... | @@ -38,14 +43,15 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -38,14 +43,15 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
| 38 | @Autowired | 43 | @Autowired |
| 39 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; | 44 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| 40 | 45 | ||
| 46 | @CachePut(key = "#resources.memberId") | ||
| 41 | @Override | 47 | @Override |
| 42 | public MemberDTO buyVip(BuyVipBean criteria) { | 48 | public MemberDTO buyVip(BuyVipBean resources) { |
| 43 | // 小程序账户id | 49 | // 小程序账户id |
| 44 | Long id = criteria.getId(); | 50 | Long id = resources.getId(); |
| 45 | 51 | ||
| 46 | // 过期时间 | 52 | // 过期时间 |
| 47 | LocalDateTime vipExpireTime1 = criteria.getVipExpireTime(); | 53 | LocalDateTime vipExpireTime1 = resources.getVipExpireTime(); |
| 48 | Integer vip1 = criteria.getVip(); | 54 | Integer vip1 = resources.getVip(); |
| 49 | 55 | ||
| 50 | // 查询微信账户 | 56 | // 查询微信账户 |
| 51 | UserWeixinDTO userWeixin = this.findWeiXinById(id); | 57 | UserWeixinDTO userWeixin = this.findWeiXinById(id); |
| ... | @@ -90,11 +96,14 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -90,11 +96,14 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
| 90 | return memberDTO; | 96 | return memberDTO; |
| 91 | } | 97 | } |
| 92 | 98 | ||
| 99 | @CachePut(key = "#resources.id") | ||
| 93 | @Override | 100 | @Override |
| 94 | public void update(Member resources) { | 101 | public MemberDTO update(Member resources) { |
| 95 | this.memberService.update(resources); | 102 | MemberDTO member = this.memberService.update(resources); |
| 103 | return member; | ||
| 96 | } | 104 | } |
| 97 | 105 | ||
| 106 | |||
| 98 | private UserWeixinDTO findWeiXinById(Long id) { | 107 | private UserWeixinDTO findWeiXinById(Long id) { |
| 99 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id); | 108 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id); |
| 100 | if (Objects.isNull(userWeixinDTO)) { | 109 | if (Objects.isNull(userWeixinDTO)) { |
| ... | @@ -105,35 +114,40 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -105,35 +114,40 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
| 105 | } | 114 | } |
| 106 | 115 | ||
| 107 | @Override | 116 | @Override |
| 108 | public void doUpdateMemberInfo(Member member) { | 117 | public MemberDTO doUpdateMemberInfo(Member resources) { |
| 109 | Long id = member.getId(); | 118 | Long id = resources.getId(); |
| 110 | Assert.notNull(id,"ERROR MSG: MemberOperationServiceImpl -> doUpdateMemberInfo -> id not be null!!"); | 119 | Assert.notNull(id,"ERROR MSG: MemberOperationServiceImpl -> doUpdateMemberInfo -> id not be null!!"); |
| 111 | this.memberService.update(member); | 120 | return this.update(resources); |
| 112 | } | 121 | } |
| 113 | 122 | ||
| 123 | @CachePut(key = "#resources.id") | ||
| 114 | @Override | 124 | @Override |
| 115 | public void doInsertMember(Member member) { | 125 | public MemberDTO doInsertMember(Member resources) { |
| 116 | this.memberService.create(member); | 126 | return this.memberService.create(resources); |
| 117 | } | 127 | } |
| 118 | 128 | ||
| 129 | @Cacheable(key = "#memberId") | ||
| 119 | @Override | 130 | @Override |
| 120 | public MemberDTO findById(Long memberId) { | 131 | public MemberDTO findById(Long memberId) { |
| 121 | return Objects.nonNull(memberId) ? this.memberService.findById(memberId) : null; | 132 | MemberDTO memberDTO = this.memberService.findById(memberId); |
| 133 | return Objects.nonNull(memberId) ? memberDTO : null; | ||
| 122 | } | 134 | } |
| 123 | 135 | ||
| 124 | @Override | 136 | @Override |
| 125 | public void doUpdateMemberExp(Member member) { | 137 | public MemberDTO doUpdateMemberExp(Member member) { |
| 126 | this.doUpdateMemberInfo(member); | 138 | return this.update(member); |
| 127 | } | 139 | } |
| 128 | 140 | ||
| 141 | |||
| 142 | @CachePut(key = "#resources.id") | ||
| 129 | @Override | 143 | @Override |
| 130 | public void doUpdateMemberPoints(Member member) { | 144 | public MemberDTO doUpdateMemberPoints(Member resources) { |
| 131 | this.memberService.doUpdateMemberPoints(member); | 145 | return this.memberService.doUpdateMemberPoints(resources); |
| 132 | } | 146 | } |
| 133 | 147 | ||
| 134 | @Override | 148 | @Override |
| 135 | public void doUpdateMemberCoupon(Member member) { | 149 | public MemberDTO doUpdateMemberCoupon(Member member) { |
| 136 | this.doUpdateMemberInfo(member); | 150 | return this.update(member); |
| 137 | } | 151 | } |
| 138 | 152 | ||
| 139 | @Override | 153 | @Override | ... | ... |
| ... | @@ -17,12 +17,10 @@ import com.topdraw.business.process.service.MemberOperationService; | ... | @@ -17,12 +17,10 @@ import com.topdraw.business.process.service.MemberOperationService; |
| 17 | import com.topdraw.business.process.service.PointsOperationService; | 17 | import com.topdraw.business.process.service.PointsOperationService; |
| 18 | import com.topdraw.business.process.domian.TempPoints; | 18 | import com.topdraw.business.process.domian.TempPoints; |
| 19 | import com.topdraw.util.IdWorker; | 19 | import com.topdraw.util.IdWorker; |
| 20 | import com.topdraw.util.RedissonUtil; | ||
| 21 | import com.topdraw.util.TimestampUtil; | 20 | import com.topdraw.util.TimestampUtil; |
| 21 | import com.topdraw.utils.RedisUtils; | ||
| 22 | import com.topdraw.utils.StringUtils; | 22 | import com.topdraw.utils.StringUtils; |
| 23 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
| 24 | import org.redisson.api.RLock; | ||
| 25 | import org.redisson.api.RedissonClient; | ||
| 26 | import org.slf4j.Logger; | 24 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; | 25 | import org.slf4j.LoggerFactory; |
| 28 | import org.springframework.beans.BeanUtils; | 26 | import org.springframework.beans.BeanUtils; |
| ... | @@ -60,16 +58,18 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -60,16 +58,18 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 60 | @Autowired | 58 | @Autowired |
| 61 | MemberService memberService; | 59 | MemberService memberService; |
| 62 | 60 | ||
| 61 | @Autowired | ||
| 62 | private RedisUtils redisUtils; | ||
| 63 | @Autowired | ||
| 64 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
| 65 | |||
| 63 | // 过期阈值 30天 | 66 | // 过期阈值 30天 |
| 64 | private static final Integer EXPIRE_FACTOR = 30; | 67 | private static final Integer EXPIRE_FACTOR = 30; |
| 65 | 68 | ||
| 66 | private static final String DELETE_AVAILABLE_POINTS = "delete"; | 69 | private static final String DELETE_AVAILABLE_POINTS = "delete"; |
| 67 | private static final String INSERT_AVAILABLE_POINTS = "insert"; | 70 | private static final String INSERT_AVAILABLE_POINTS = "insert"; |
| 68 | 71 | ||
| 69 | @Autowired | 72 | |
| 70 | RedissonClient redissonClient; | ||
| 71 | @Autowired | ||
| 72 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
| 73 | 73 | ||
| 74 | @Override | 74 | @Override |
| 75 | @Transactional(rollbackFor = Exception.class) | 75 | @Transactional(rollbackFor = Exception.class) |
| ... | @@ -104,9 +104,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -104,9 +104,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 104 | 104 | ||
| 105 | Long memberId = tempPoints.getMemberId(); | 105 | Long memberId = tempPoints.getMemberId(); |
| 106 | 106 | ||
| 107 | RLock rLock = this.redissonClient.getLock("member::id::" + memberId.toString()); | ||
| 108 | try { | 107 | try { |
| 109 | RedissonUtil.lock(rLock); | 108 | this.redisUtils.doLock("member::id::" + memberId.toString()); |
| 110 | //1.删除过期的积分 | 109 | //1.删除过期的积分 |
| 111 | this.cleanInvalidAvailablePointsByMemberId(memberId); | 110 | this.cleanInvalidAvailablePointsByMemberId(memberId); |
| 112 | // 1.判断可用积分是否够用 | 111 | // 1.判断可用积分是否够用 |
| ... | @@ -139,7 +138,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -139,7 +138,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 139 | e.printStackTrace(); | 138 | e.printStackTrace(); |
| 140 | throw e; | 139 | throw e; |
| 141 | } finally { | 140 | } finally { |
| 142 | RedissonUtil.unlock(rLock); | 141 | this.redisUtils.doUnLock("member::id::" + memberId.toString()); |
| 143 | } | 142 | } |
| 144 | 143 | ||
| 145 | return customPointsResult; | 144 | return customPointsResult; |
| ... | @@ -414,11 +413,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -414,11 +413,8 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 414 | private void refresh(TempPoints tempPoints) { | 413 | private void refresh(TempPoints tempPoints) { |
| 415 | Long memberId = tempPoints.getMemberId(); | 414 | Long memberId = tempPoints.getMemberId(); |
| 416 | log.info("----------->> 会员id ===>>>>" + memberId); | 415 | log.info("----------->> 会员id ===>>>>" + memberId); |
| 417 | RLock rLock = this.redissonClient.getLock("member::id::" + memberId.toString()); | ||
| 418 | log.info("----------->> rLock --->> start" ); | ||
| 419 | try { | 416 | try { |
| 420 | RedissonUtil.lock(rLock); | 417 | this.redisUtils.doLock("member::id::" + memberId.toString()); |
| 421 | |||
| 422 | // 1.可用总积分 | 418 | // 1.可用总积分 |
| 423 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); | 419 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); |
| 424 | log.info("----------->> 可用总积分 --->>>> " + currentPoints); | 420 | log.info("----------->> 可用总积分 --->>>> " + currentPoints); |
| ... | @@ -447,7 +443,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -447,7 +443,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 447 | e.printStackTrace(); | 443 | e.printStackTrace(); |
| 448 | throw e; | 444 | throw e; |
| 449 | } finally { | 445 | } finally { |
| 450 | RedissonUtil.unlock(rLock); | 446 | this.redisUtils.doUnLock("member::id::" + memberId.toString()); |
| 451 | } | 447 | } |
| 452 | } | 448 | } |
| 453 | 449 | ... | ... |
| ... | @@ -1063,7 +1063,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1063,7 +1063,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1063 | * @return | 1063 | * @return |
| 1064 | */ | 1064 | */ |
| 1065 | private Long createMember(Member member){ | 1065 | private Long createMember(Member member){ |
| 1066 | return this.memberService.create(member); | 1066 | return this.memberService.create(member).getId(); |
| 1067 | } | 1067 | } |
| 1068 | 1068 | ||
| 1069 | /** | 1069 | /** | ... | ... |
| 1 | package com.topdraw.config; | ||
| 2 | |||
| 3 | import com.topdraw.utils.StringUtils; | ||
| 4 | import org.redisson.Redisson; | ||
| 5 | import org.redisson.api.RedissonClient; | ||
| 6 | import org.redisson.config.Config; | ||
| 7 | import org.springframework.beans.factory.annotation.Value; | ||
| 8 | import org.springframework.context.annotation.Bean; | ||
| 9 | import org.springframework.context.annotation.Configuration; | ||
| 10 | |||
| 11 | @Configuration | ||
| 12 | public class RedissonConfig { | ||
| 13 | |||
| 14 | // @Value("122.112.214.149") | ||
| 15 | @Value("${spring.redis.host}") | ||
| 16 | private String redisHost; | ||
| 17 | |||
| 18 | @Value("${spring.redis.port}") | ||
| 19 | private String port; | ||
| 20 | |||
| 21 | @Value("${spring.redis.password}") | ||
| 22 | private String password; | ||
| 23 | |||
| 24 | @Bean | ||
| 25 | public Redisson redisson(){ | ||
| 26 | Config config = new Config(); | ||
| 27 | if (StringUtils.isNotEmpty(password)) { | ||
| 28 | config.useSingleServer().setAddress("redis://"+redisHost+":"+port).setPassword(password); | ||
| 29 | } else { | ||
| 30 | config.useSingleServer().setAddress("redis://"+redisHost+":"+port); | ||
| 31 | } | ||
| 32 | /* config.useClusterServers().addNodeAddress( | ||
| 33 | "redis://172.29.3.245:6375","redis://172.29.3.245:6376", "redis://172.29.3.245:6377", | ||
| 34 | "redis://172.29.3.245:6378","redis://172.29.3.245:6i379", "redis://172.29.3.245:6380") | ||
| 35 | .setPassword("a123456").setScanInterval(5000);*/ | ||
| 36 | Redisson redissonClient = (Redisson)Redisson.create(config); | ||
| 37 | return redissonClient; | ||
| 38 | } | ||
| 39 | |||
| 40 | } |
| 1 | package com.topdraw.util; | ||
| 2 | |||
| 3 | |||
| 4 | import org.redisson.api.RLock; | ||
| 5 | |||
| 6 | public class RedissonUtil { | ||
| 7 | |||
| 8 | public static void lock(RLock rLock){ | ||
| 9 | rLock.lock(); | ||
| 10 | } | ||
| 11 | |||
| 12 | |||
| 13 | public static void unlock(RLock rLock){ | ||
| 14 | if (rLock.isLocked() && rLock.isHeldByCurrentThread()) | ||
| 15 | rLock.unlock(); | ||
| 16 | } | ||
| 17 | |||
| 18 | /** | ||
| 19 | * 保存数据 | ||
| 20 | * @param key 键 | ||
| 21 | * @param value 值 | ||
| 22 | * @param validTime 过期时间 | ||
| 23 | */ | ||
| 24 | public static void doSave(String key , String value , Integer validTime){ | ||
| 25 | |||
| 26 | } | ||
| 27 | |||
| 28 | } |
-
Please register or sign in to post a comment