From 14ea7f215414036563c36d1b0ccf3b87aa5d94ad Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 23 Dec 2025 15:57:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=96=E6=B6=88=E5=92=8C?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/family/FamilyRestController.java | 18 ++++++ .../command/family/CancelFamilyApplyExe.java | 35 ++++++++++++ .../app/command/family/ReapplyFamilyExe.java | 57 +++++++++++++++++++ .../app/service/family/FamilyServiceImpl.java | 24 +++++++- .../dto/cmd/family/CancelFamilyApplyCmd.java | 20 +++++++ .../app/dto/cmd/family/ReapplyFamilyCmd.java | 20 +++++++ .../app/service/family/FamilyService.java | 10 ++++ 7 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/CancelFamilyApplyExe.java create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ReapplyFamilyExe.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/CancelFamilyApplyCmd.java create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/ReapplyFamilyCmd.java diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java index 574ce1c4..f7c1b179 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/family/FamilyRestController.java @@ -16,6 +16,8 @@ import com.red.circle.other.app.dto.clientobject.family.FamilyRewardCO; import com.red.circle.other.app.dto.clientobject.family.FamilyUserInfoCO; import com.red.circle.other.app.dto.clientobject.room.RoomVoiceProfileCO; import com.red.circle.other.app.dto.cmd.family.ApplyJoinFamilyCmd; +import com.red.circle.other.app.dto.cmd.family.CancelFamilyApplyCmd; +import com.red.circle.other.app.dto.cmd.family.ReapplyFamilyCmd; import com.red.circle.other.app.dto.cmd.family.FamilyAdminQueryCmd; import com.red.circle.other.app.dto.cmd.family.FamilyBaseInfoQueryCmd; import com.red.circle.other.app.dto.cmd.family.FamilyCreateCmd; @@ -129,6 +131,22 @@ public class FamilyRestController extends BaseController { return familyService.myApplyList(cmd); } + /** + * 取消家族申请. + */ + @PostMapping("/cancel-apply") + public void cancelApply(@RequestBody @Validated CancelFamilyApplyCmd cmd) { + familyService.cancelFamilyApply(cmd); + } + + /** + * 重新申请家族. + */ + @PostMapping("/reapply") + public void reapply(@RequestBody @Validated ReapplyFamilyCmd cmd) { + familyService.reapplyFamily(cmd); + } + /** * 家族成员信息 */ diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/CancelFamilyApplyExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/CancelFamilyApplyExe.java new file mode 100644 index 00000000..c061e63a --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/CancelFamilyApplyExe.java @@ -0,0 +1,35 @@ +package com.red.circle.other.app.command.family; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.other.app.dto.cmd.family.CancelFamilyApplyCmd; +import com.red.circle.other.infra.database.rds.entity.family.FamilyMessage; +import com.red.circle.other.infra.database.rds.service.family.FamilyMessageService; +import com.red.circle.other.inner.enums.FamilyMessageStatusEnum; +import java.util.Objects; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +/** + * 取消家族申请. + */ +@Component +@RequiredArgsConstructor +public class CancelFamilyApplyExe { + + private final FamilyMessageService familyMessageService; + + public void execute(CancelFamilyApplyCmd cmd) { + + FamilyMessage msg = familyMessageService.getById(cmd.getMsgId()); + ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, msg); + ResponseAssert.isTrue(CommonErrorCode.DATA_ERROR, + Objects.equals(msg.getSenderUser(), cmd.getReqUserId())); + ResponseAssert.isTrue(CommonErrorCode.DATA_ERROR, + Objects.equals(msg.getStatus(), FamilyMessageStatusEnum.PENDING.getCode())); + + msg.setStatus(FamilyMessageStatusEnum.CANCELLED.getCode()); + msg.setUpdateUser(cmd.getReqUserId()); + familyMessageService.updateSelectiveById(msg); + } +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ReapplyFamilyExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ReapplyFamilyExe.java new file mode 100644 index 00000000..eda53ce8 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/family/ReapplyFamilyExe.java @@ -0,0 +1,57 @@ +package com.red.circle.other.app.command.family; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.other.app.dto.cmd.family.ReapplyFamilyCmd; +import com.red.circle.other.infra.common.family.FamilyCommon; +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; +import com.red.circle.other.inner.asserts.FamilyErrorCode; +import com.red.circle.other.inner.enums.FamilyMessageStatusEnum; +import com.red.circle.other.inner.model.dto.famliy.FamilyDetailsDTO; +import java.util.Objects; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +/** + * 重新申请家族. + */ +@Component +@RequiredArgsConstructor +public class ReapplyFamilyExe { + + private final FamilyCommon familyCommon; + private final FamilyMessageService familyMessageService; + private final FamilyMemberInfoService familyMemberInfoService; + + public void execute(ReapplyFamilyCmd cmd) { + + FamilyMessage msg = familyMessageService.getById(cmd.getMsgId()); + ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, msg); + ResponseAssert.isTrue(CommonErrorCode.DATA_ERROR, + Objects.equals(msg.getSenderUser(), cmd.getReqUserId())); + ResponseAssert.isTrue(CommonErrorCode.DATA_ERROR, + Objects.equals(msg.getStatus(), FamilyMessageStatusEnum.REJECTED.getCode())); + + ResponseAssert.isFalse(FamilyErrorCode.THERE_ARE_FAMILIES_ERROR, + familyCommon.isExistFamilyByUserId(cmd.getReqUserId())); + + ResponseAssert.isTrue(FamilyErrorCode.NOT_EXIST_FAMILY_INFO_DATA, + familyCommon.isExistFamilyById(msg.getFamilyId())); + + ResponseAssert.isFalse(FamilyErrorCode.REPEAT_APPLICATION, + familyMessageService.isExistApplyingMsg(msg.getFamilyId(), cmd.getReqUserId())); + + FamilyDetailsDTO levelConfig = familyCommon.getFamilyDetails( + cmd.getReqSysOrigin().getOrigin(), msg.getFamilyId()); + + Integer familyMemberCount = familyMemberInfoService.getFamilyMemberCount(msg.getFamilyId()); + ResponseAssert.isTrue(FamilyErrorCode.FAMILY_MEMBER_MAX, + levelConfig.getMaxMember() > familyMemberCount); + + msg.setStatus(FamilyMessageStatusEnum.PENDING.getCode()); + msg.setUpdateUser(cmd.getReqUserId()); + familyMessageService.updateSelectiveById(msg); + } +} 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 b35a29f1..e6b75848 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 @@ -26,6 +26,8 @@ import com.red.circle.other.app.command.family.FamilyUserExitExe; import com.red.circle.other.app.command.family.FamilyUserInfoExe; import com.red.circle.other.app.command.family.ReceiveFamilyAwardExe; import com.red.circle.other.app.command.family.MyFamilyApplyListExe; +import com.red.circle.other.app.command.family.CancelFamilyApplyExe; +import com.red.circle.other.app.command.family.ReapplyFamilyExe; import com.red.circle.other.app.command.family.FamilyListExe; import com.red.circle.other.app.dto.clientobject.family.FamilyBaseInfoCO; import com.red.circle.other.app.dto.clientobject.family.FamilyCreateRulesCO; @@ -39,6 +41,8 @@ import com.red.circle.other.app.dto.clientobject.family.FamilyRewardCO; import com.red.circle.other.app.dto.clientobject.family.FamilyUserInfoCO; import com.red.circle.other.app.dto.clientobject.room.RoomVoiceProfileCO; import com.red.circle.other.app.dto.cmd.family.ApplyJoinFamilyCmd; +import com.red.circle.other.app.dto.cmd.family.CancelFamilyApplyCmd; +import com.red.circle.other.app.dto.cmd.family.ReapplyFamilyCmd; import com.red.circle.other.app.dto.cmd.family.FamilyAdminQueryCmd; import com.red.circle.other.app.dto.cmd.family.FamilyBaseInfoQueryCmd; import com.red.circle.other.app.dto.cmd.family.FamilyCreateCmd; @@ -103,6 +107,8 @@ public class FamilyServiceImpl implements FamilyService { private final FamilyMemberIdGetUserIdExe familyMemberIdGetUserIdExe; private final FamilyPurchasingGroupChatExe familyPurchasingGroupChatExe; private final MyFamilyApplyListExe myFamilyApplyListExe; + private final CancelFamilyApplyExe cancelFamilyApplyExe; + private final ReapplyFamilyExe reapplyFamilyExe; private final FamilyListExe familyListExe; private final DistributedLockUtil distributedLockUtil; @@ -190,7 +196,7 @@ public class FamilyServiceImpl implements FamilyService { @Override public void applyJoin(ApplyJoinFamilyCmd cmd) { - String key = "FAMILY_APPLY_JOIN" + ":" + cmd.getReqUserId() + "_" + cmd.getReqUserId(); + String key = "FAMILY_APPLY_JOIN" + ":" + cmd.getFamilyId() + "_" + cmd.getReqUserId(); distributedLockUtil.executeWithLock(key, () -> { applyJoinFamilyExe.execute(cmd); }); @@ -242,6 +248,22 @@ public class FamilyServiceImpl implements FamilyService { return myFamilyApplyListExe.execute(cmd); } + @Override + public void cancelFamilyApply(CancelFamilyApplyCmd cmd) { + String key = "FAMILY_APPLY_CANCEL" + ":" + cmd.getReqUserId(); + distributedLockUtil.executeWithLock(key, () -> { + cancelFamilyApplyExe.execute(cmd); + }); + } + + @Override + public void reapplyFamily(ReapplyFamilyCmd cmd) { + String key = "FAMILY_APPLY_REAPPLY" + ":" + cmd.getReqUserId(); + distributedLockUtil.executeWithLock(key, () -> { + reapplyFamilyExe.execute(cmd); + }); + } + @Override public PageResult familyList(FamilyListCmd cmd) { return familyListExe.execute(cmd); diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/CancelFamilyApplyCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/CancelFamilyApplyCmd.java new file mode 100644 index 00000000..c7d2cfc0 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/CancelFamilyApplyCmd.java @@ -0,0 +1,20 @@ +package com.red.circle.other.app.dto.cmd.family; + +import com.red.circle.common.business.dto.cmd.AppExtCommand; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 取消家族申请. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CancelFamilyApplyCmd extends AppExtCommand { + + /** + * 消息ID. + */ + @NotNull(message = "消息ID不能为空") + private Long msgId; +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/ReapplyFamilyCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/ReapplyFamilyCmd.java new file mode 100644 index 00000000..18715b01 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/family/ReapplyFamilyCmd.java @@ -0,0 +1,20 @@ +package com.red.circle.other.app.dto.cmd.family; + +import com.red.circle.common.business.dto.cmd.AppExtCommand; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 重新申请家族. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class ReapplyFamilyCmd extends AppExtCommand { + + /** + * 消息ID. + */ + @NotNull(message = "消息ID不能为空") + private Long msgId; +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java index a6eb767f..47de1d65 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/family/FamilyService.java @@ -141,6 +141,16 @@ public interface FamilyService { */ List myApplyList(MyFamilyApplyListCmd cmd); + /** + * 取消家族申请. + */ + void cancelFamilyApply(CancelFamilyApplyCmd cmd); + + /** + * 重新申请家族. + */ + void reapplyFamily(ReapplyFamilyCmd cmd); + /** * 家族列表. */