新增取消和重新申请接口

This commit is contained in:
tianfeng 2025-12-23 15:57:46 +08:00
parent 5b6c2c5f33
commit 14ea7f2154
7 changed files with 183 additions and 1 deletions

View File

@ -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);
}
/**
* 家族成员信息
*/

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<FamilyListCO> familyList(FamilyListCmd cmd) {
return familyListExe.execute(cmd);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -141,6 +141,16 @@ public interface FamilyService {
*/
List<MyFamilyApplyCO> myApplyList(MyFamilyApplyListCmd cmd);
/**
* 取消家族申请.
*/
void cancelFamilyApply(CancelFamilyApplyCmd cmd);
/**
* 重新申请家族.
*/
void reapplyFamily(ReapplyFamilyCmd cmd);
/**
* 家族列表.
*/