From 0d6b5919af742003e172c417641857bfc862c78a Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 17 Oct 2025 12:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=85=B3=E6=B3=A8=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/message/OfficialNoticeTypeEnum.java | 9 ++++++- .../inner/asserts/user/UserErrorCode.java | 3 +++ .../UserSupportRelationRestController.java | 5 ++++ ...erSupportRelationFollowOrCancelCmdExe.java | 25 +++++++++++++++++++ .../UserSupportRelationServiceImpl.java | 5 ++++ .../relation/UserSupportRelationService.java | 2 ++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java b/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java index 1b120ad3..0aed1c5b 100644 --- a/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java +++ b/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java @@ -190,7 +190,14 @@ public enum OfficialNoticeTypeEnum { /** * 用户告白 */ - USER_CONFESSION; + USER_CONFESSION, + + /** + * 用户关注 + */ + USER_FOLLOW + + ; public String getTitle(Locale locale) { diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java index 8866cc05..5f25fae5 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java @@ -221,6 +221,9 @@ public enum UserErrorCode implements IResponseErrorCode { // 密码不正确 ,PASSWORD_NOT_MATCH(4074, "password is incorrect") + // 用户已关注 + ,USER_FOLLOWED(4075, "This user has followed"), + ; diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/relation/UserSupportRelationRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/relation/UserSupportRelationRestController.java index 79980168..ab4b7bd3 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/relation/UserSupportRelationRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/relation/UserSupportRelationRestController.java @@ -85,6 +85,11 @@ public class UserSupportRelationRestController extends BaseController { return userRelationInterviewService.followOrCancel(cmd); } + @PostMapping("/follow-new") + public Boolean follow(@RequestBody @Validated AppUserIdCmd cmd) { + return userRelationInterviewService.follow(cmd); + } + /** * 我的关注列表. * diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java index 2ff77c14..b91a595a 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java @@ -2,10 +2,15 @@ package com.red.circle.other.app.command.user; import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd; import com.red.circle.external.inner.endpoint.message.ImGroupClient; +import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; import com.red.circle.external.inner.model.cmd.message.GroupUnbanCmd; +import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; +import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.mq.rocket.business.producer.TaskMqMessage; +import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +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.UserRelationsCalculatorGateway; import com.red.circle.other.domain.model.user.ability.UserRelationsCalculator; @@ -19,6 +24,7 @@ import com.red.circle.other.infra.database.rds.service.user.user.RelationshipFri import com.red.circle.other.infra.database.rds.service.user.user.ShieldBlackService; import com.red.circle.other.infra.database.rds.service.user.user.UserSubscriptionService; import com.red.circle.other.inner.asserts.user.UserRelationErrorCode; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.text.StringUtils; import com.red.circle.other.inner.asserts.user.UserErrorCode; @@ -45,6 +51,8 @@ public class UserSupportRelationFollowOrCancelCmdExe { private final ImGroupClient imGroupClient; private final ShieldBlackService shieldBlackService; private final RoomUserBlacklistService roomUserBlacklistService; + private final UserProfileAppConvertor userProfileAppConvertor; + private final OfficialNoticeClient officialNoticeClient; private final RoomProfileManagerService roomProfileManagerService; private final RelationshipFriendService relationshipFriendService; @@ -57,6 +65,15 @@ public class UserSupportRelationFollowOrCancelCmdExe { : subscription(cmd); } + public Boolean follow(AppUserIdCmd cmd) { + // 不可操作自己 + ResponseAssert.notEquals(UserErrorCode.NOT_OPERATION_ME, cmd.requiredReqUserId(),cmd.getUserId()); + boolean checkedSubscription = userSubscriptionService.checkSubscription(cmd.requiredReqUserId(), cmd.getUserId()); + ResponseAssert.isFalse(UserErrorCode.USER_FOLLOWED, checkedSubscription); + + return subscription(cmd); + } + private Boolean subscription(AppUserIdCmd cmd) { // 无法操作,错误归属 @@ -111,6 +128,14 @@ public class UserSupportRelationFollowOrCancelCmdExe { roomUserBlacklistService.removeBlack(roomProfile.getId(), cmd.requiredReqUserId()); } } + } else { + UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO(userProfileGateway.getByUserId(cmd.requiredReqUserId())); + officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() + .toAccount(cmd.getUserId()) + .noticeType(OfficialNoticeTypeEnum.USER_FOLLOW) + .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) + .build() + ); } return Boolean.TRUE; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationServiceImpl.java index 45657eeb..218ab9b2 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationServiceImpl.java @@ -53,6 +53,11 @@ public class UserSupportRelationServiceImpl implements UserSupportRelationServic return userSupportRelationFollowOrCancelCmdExe.execute(cmd); } + @Override + public Boolean follow(AppUserIdCmd cmd) { + return userSupportRelationFollowOrCancelCmdExe.follow(cmd); + } + @Override public List listUserFollow(AppFlowCmd cmd) { return userRelationFollowQryExe.execute(cmd); diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationService.java index a1a04ce8..9f53a957 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/user/relation/UserSupportRelationService.java @@ -22,6 +22,8 @@ public interface UserSupportRelationService { Boolean followOrCancel(AppUserIdCmd cmd); + Boolean follow(AppUserIdCmd cmd); + List listUserFollow(AppFlowCmd cmd); Boolean checkFollow(AppUserIdCmd cmd);