diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/FamilyErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/FamilyErrorCode.java index 98654c88..551f8486 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/FamilyErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/FamilyErrorCode.java @@ -73,6 +73,11 @@ public enum FamilyErrorCode implements IResponseErrorCode { NOT_PERMISSION_VIEW(2512, "You do not have permission to view"), + /** + * 用户最近刚退出家族 + */ + USER_RECENT_LEAVE(2513, "Your recently left a family. Please tryagain 1 day after leaving"), + ; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ApplyJoinFamilyExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ApplyJoinFamilyExe.java index af8e90df..64391aba 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ApplyJoinFamilyExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ApplyJoinFamilyExe.java @@ -12,6 +12,7 @@ import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.infra.common.family.FamilyCommon; +import com.red.circle.other.infra.database.cache.key.FamilyKeys; import com.red.circle.other.infra.database.rds.entity.family.FamilyMessage; import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService; import com.red.circle.other.infra.database.rds.service.family.FamilyMessageService; @@ -47,6 +48,8 @@ public class ApplyJoinFamilyExe { public void execute(ApplyJoinFamilyCmd cmd) { + String string = redisService.getString(FamilyKeys.USER_LEAVE.getKey()); + ResponseAssert.isNull(FamilyErrorCode.USER_RECENT_LEAVE, string); ResponseAssert.isFalse(FamilyErrorCode.THERE_ARE_FAMILIES_ERROR, getExistFamilyByUserId(cmd)); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java index 9252413d..bbea127b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/FamilyListExe.java @@ -19,6 +19,7 @@ import java.util.Set; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; /** * 家族列表查询. @@ -34,7 +35,9 @@ public class FamilyListExe { public PageResult execute(FamilyListCmd cmd) { Page page = new Page<>(); IPage baseInfoIPage = familyBaseInfoService.page(page, - Wrappers.lambdaQuery().orderByDesc(TimestampBaseEntity::getCreateTime)); + Wrappers.lambdaQuery() + .eq(StringUtils.hasText(cmd.getFamilyAccount()), FamilyBaseInfo::getFamilyAccount, cmd.getFamilyAccount()) + .orderByDesc(TimestampBaseEntity::getCreateTime)); PageResult pageResult = new PageResult<>(); pageResult.setCurrent(page.getCurrent()); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java index 7d7983c9..b35a29f1 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/family/FamilyServiceImpl.java @@ -108,7 +108,8 @@ public class FamilyServiceImpl implements FamilyService { @Override public Long create(FamilyCreateCmd cmd) { - return familyCreateExe.execute(cmd); + String key = "FAMILY_CREATE_KEY" + ":" + cmd.getReqUserId(); + return distributedLockUtil.executeWithLock(key, () -> familyCreateExe.execute(cmd)); } @Override diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyListCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyListCmd.java index 77ea9a96..3d9ccb52 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyListCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/FamilyListCmd.java @@ -11,4 +11,6 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class FamilyListCmd extends PageQueryCmd { + private String familyAccount; + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java index 98babca9..38392e60 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/family/FamilyCommon.java @@ -3,6 +3,7 @@ package com.red.circle.other.infra.common.family; import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.red.circle.component.redis.service.RedisService; import com.red.circle.external.inner.endpoint.message.ImGroupMemberClient; import com.red.circle.external.inner.model.cmd.message.GroupMemberAddCmd; import com.red.circle.external.inner.model.cmd.message.GroupMemberRemoveCmd; @@ -10,6 +11,7 @@ import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.infra.convertor.material.BadgeInfraConvertor; +import com.red.circle.other.infra.database.cache.key.FamilyKeys; import com.red.circle.other.infra.database.cache.service.other.FamilyLevelCacheService; import com.red.circle.other.infra.database.rds.entity.badge.BadgeBackpack; import com.red.circle.other.infra.database.rds.entity.badge.BadgePictureConfig; @@ -49,6 +51,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -83,6 +86,7 @@ public class FamilyCommon { private final FamilyLevelConfigService familyLevelConfigService; private final BadgePictureConfigService badgePictureConfigService; private final FamilyMemberWeekExpService familyMemberWeekExpService; + private final RedisService redisService; /** @@ -538,13 +542,13 @@ public class FamilyCommon { familyMemberWeekExpService .deleteBySysOriginMemberId(member.getId(), member.getSysOrigin()); - deleteFamilyAwardByUserId(member.getMemberUserId()); - userProfileGateway.removeUseProps(member.getMemberUserId(), - PropsCommodityType.AVATAR_FRAME.name()); + redisService.setString(FamilyKeys.USER_LEAVE.getKey(), member.getMemberUserId(), 1, TimeUnit.DAYS); +// deleteFamilyAwardByUserId(member.getMemberUserId()); +// userProfileGateway.removeUseProps(member.getMemberUserId(),PropsCommodityType.AVATAR_FRAME.name()); - userProfileGateway.removeCacheAll(member.getMemberUserId()); +// userProfileGateway.removeCacheAll(member.getMemberUserId()); - removeGroup(member.getFamilyId(), member.getMemberUserId()); +// removeGroup(member.getFamilyId(), member.getMemberUserId()); } /** diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/FamilyKeys.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/FamilyKeys.java index 5499aba2..cdcb9a00 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/FamilyKeys.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/FamilyKeys.java @@ -26,7 +26,14 @@ public enum FamilyKeys implements RedisKeys { /** * 周奖励开始结束时间 周一 / 周日. */ - FAMILY_WEEK_REWARD_TIME; + FAMILY_WEEK_REWARD_TIME, + + /** + * 用户离开家族 + */ + USER_LEAVE, + + ; @Override public String businessPrefix() {