Skip to content

Commit

Permalink
feat: 站内信和邮件的评论及其回复,在链接上添加锚点,用于定位
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrunkang committed Jan 28, 2023
1 parent 8a08dac commit c2b82c6
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import com.upupor.service.base.ContentService;
import com.upupor.service.base.MemberIntegralService;
import com.upupor.service.base.MemberService;
import com.upupor.service.business.comment.comment.abstracts.AbstractComment;
import com.upupor.service.business.links.LinkBuilderInstance;
import com.upupor.service.business.links.abstracts.BusinessLinkType;
import com.upupor.service.business.links.abstracts.MsgType;
import com.upupor.service.business.links.abstracts.dto.ContentLinkParamDto;
import com.upupor.service.business.links.abstracts.dto.MemberProfileLinkParamDto;
import com.upupor.service.business.comment.comment.abstracts.AbstractComment;
import com.upupor.service.business.message.MessageSend;
import com.upupor.service.business.message.model.MessageModel;
import org.springframework.stereotype.Component;
Expand All @@ -70,7 +70,7 @@ public ContentComment(MemberService memberService) {
}

@Override
public void comment(String targetId, String commenterUserId) {
public void comment(String targetId, String commenterUserId, Long floorNum) {
String msgId = getMsgId();
// 文章信息
ContentEnhance contentEnhance = getTarget(targetId);
Expand All @@ -91,6 +91,7 @@ public void comment(String targetId, String commenterUserId) {
ContentLinkParamDto contentLinkParamDto = ContentLinkParamDto.builder()
.contentId(contentId)
.msgId(msgId)
.floorNum(floorNum)
.contentTitle(contentTitle)
.build();
String buildContentMsg = LinkBuilderInstance.buildLink(BusinessLinkType.CONTENT, contentLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -100,6 +101,7 @@ public void comment(String targetId, String commenterUserId) {
MemberProfileLinkParamDto memberProfileLinkParamDto = MemberProfileLinkParamDto.builder()
.memberUserId(commenterUserId)
.msgId(msgId)
.floorNum(floorNum)
.memberUserName(commenterUserName)
.build();
String buildProfileMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MEMBER_PROFILE, memberProfileLinkParamDto, MsgType.INNER_MSG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import com.upupor.framework.common.IntegralEnum;
import com.upupor.service.base.MemberIntegralService;
import com.upupor.service.base.MemberService;
import com.upupor.service.business.comment.comment.abstracts.AbstractComment;
import com.upupor.service.business.links.LinkBuilderInstance;
import com.upupor.service.business.links.abstracts.BusinessLinkType;
import com.upupor.service.business.links.abstracts.MsgType;
import com.upupor.service.business.links.abstracts.dto.MemberProfileLinkParamDto;
import com.upupor.service.business.links.abstracts.dto.MessageBoardLinkParamDto;
import com.upupor.service.business.comment.comment.abstracts.AbstractComment;
import com.upupor.service.business.message.MessageSend;
import com.upupor.service.business.message.model.MessageModel;
import org.springframework.stereotype.Component;
Expand All @@ -66,7 +66,7 @@ public MessageBoardComment(MemberService memberService) {
}

@Override
public void comment(String targetId, String commenterUserId) {
public void comment(String targetId, String commenterUserId, Long floorNum) {
String msgId = getMsgId();

// 获取被评论的用户
Expand All @@ -85,6 +85,7 @@ public void comment(String targetId, String commenterUserId) {
MessageBoardLinkParamDto messageBoardLinkParamDto = MessageBoardLinkParamDto.builder()
.targetUserId(targetUserId)
.msgId(msgId)
.floorNum(floorNum)
.title("<strong>留言板</strong>")
.build();
String buildMessageBoardMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MESSAGE_BOARD, messageBoardLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -93,6 +94,7 @@ public void comment(String targetId, String commenterUserId) {
MemberProfileLinkParamDto memberProfileLinkParamDto = MemberProfileLinkParamDto.builder()
.memberUserId(commenterUserId)
.msgId(msgId)
.floorNum(floorNum)
.memberUserName(commenterUserName)
.build();
String buildProfileMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MEMBER_PROFILE, memberProfileLinkParamDto, MsgType.INNER_MSG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import com.upupor.framework.utils.CcDateUtil;
import com.upupor.service.base.MemberService;
import com.upupor.service.base.RadioService;
import com.upupor.service.business.comment.comment.abstracts.AbstractComment;
import com.upupor.service.business.links.LinkBuilderInstance;
import com.upupor.service.business.links.abstracts.BusinessLinkType;
import com.upupor.service.business.links.abstracts.MsgType;
import com.upupor.service.business.links.abstracts.dto.MemberProfileLinkParamDto;
import com.upupor.service.business.links.abstracts.dto.RadioLinkParamDto;
import com.upupor.service.business.comment.comment.abstracts.AbstractComment;
import com.upupor.service.business.message.MessageSend;
import com.upupor.service.business.message.model.MessageModel;
import org.springframework.stereotype.Component;
Expand All @@ -63,7 +63,7 @@ public RadioComment(MemberService memberService) {
}

@Override
public void comment(String targetId, String commenterUserId) {
public void comment(String targetId, String commenterUserId, Long floorNum) {
String msgId = getMsgId();

Radio radio = radioService.getByRadioId(targetId).getRadio();
Expand All @@ -84,6 +84,7 @@ public void comment(String targetId, String commenterUserId) {
RadioLinkParamDto radioLinkParamDto = RadioLinkParamDto.builder()
.radioId(radio.getRadioId())
.msgId(msgId)
.floorNum(floorNum)
.radioIntro(radioName)
.build();
String buildRadioMsg = LinkBuilderInstance.buildLink(BusinessLinkType.RADIO, radioLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -92,6 +93,7 @@ public void comment(String targetId, String commenterUserId) {
MemberProfileLinkParamDto memberProfileLinkParamDto = MemberProfileLinkParamDto.builder()
.memberUserId(commenterUserId)
.msgId(msgId)
.floorNum(floorNum)
.memberUserName(commenterUserName)
.build();
String buildProfileMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MEMBER_PROFILE, memberProfileLinkParamDto, MsgType.INNER_MSG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public AbstractComment(MemberService memberService) {
*
* @param targetId 评论目标
* @param commenterUserId 评论者id
* @param floorNum 评论所在的楼层
*/
public abstract void comment(String targetId, String commenterUserId);
public abstract void comment(String targetId, String commenterUserId, Long floorNum);

/**
* 获取目标
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
Member beRepliedMember = getMember(beRepliedUserId);
String createReplayUserId = replayCommentEvent.getCreateReplayUserId();
String createReplayUserName = replayCommentEvent.getCreateReplayUserName();
Long floorNum = replayCommentEvent.getFloorNum();

Content content = getTarget(replayCommentEvent.getTargetId()).getContent();

ContentLinkParamDto contentLinkParamDto = ContentLinkParamDto.builder()
.contentId(content.getContentId())
.msgId(msgId)
.floorNum(floorNum)
.contentTitle(content.getTitle())
.build();
String buildContentMsg = LinkBuilderInstance.buildLink(BusinessLinkType.CONTENT, contentLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -92,6 +94,7 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
MemberProfileLinkParamDto memberProfileLinkParamDto = MemberProfileLinkParamDto.builder()
.memberUserId(createReplayUserId)
.msgId(msgId)
.floorNum(floorNum)
.memberUserName(createReplayUserName)
.build();
String buildProfileMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MEMBER_PROFILE, memberProfileLinkParamDto, MsgType.INNER_MSG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
String targetId = replayCommentEvent.getTargetId();
String creatorReplayUserId = replayCommentEvent.getCreateReplayUserId();
String creatorReplayUserName = replayCommentEvent.getCreateReplayUserName();
Long floorNum = replayCommentEvent.getFloorNum();

Member targetMember = getMember(targetId);

MemberProfileLinkParamDto memberProfileLinkParamDto = MemberProfileLinkParamDto.builder()
.memberUserId(creatorReplayUserId)
.msgId(msgId)
.floorNum(floorNum)
.memberUserName(creatorReplayUserName)
.build();
String buildProfileMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MEMBER_PROFILE, memberProfileLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -87,6 +89,7 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
MessageBoardLinkParamDto messageBoardLinkParamDto = MessageBoardLinkParamDto.builder()
.targetUserId(targetId)
.msgId(msgId)
.floorNum(floorNum)
.title("<strong>我的留言板</strong>")
.build();
String buildMessageBoardMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MESSAGE_BOARD, messageBoardLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -99,6 +102,7 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
MessageBoardLinkParamDto messageBoardLinkParamDto = MessageBoardLinkParamDto.builder()
.targetUserId(creatorReplayUserId)
.msgId(msgId)
.floorNum(floorNum)
.title("我在<strong>" + targetMember.getUserName() + "</strong>留言板上的留言内容")
.build();
String buildMessageBoardMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MESSAGE_BOARD, messageBoardLinkParamDto, MsgType.INNER_MSG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
String msgId = msgId();
String beRepliedUserId = replayCommentEvent.getBeRepliedUserId();
Member beReplayedUser = getMember(beRepliedUserId);
Long floorNum = replayCommentEvent.getFloorNum();

Radio radio = getTarget(replayCommentEvent.getTargetId()).getRadio();


RadioLinkParamDto radioLinkParamDto = RadioLinkParamDto.builder()
.radioId(radio.getRadioId())
.msgId(msgId)
.floorNum(floorNum)
.radioIntro(radio.getRadioIntro())
.build();
String buildRadioMsg = LinkBuilderInstance.buildLink(BusinessLinkType.RADIO, radioLinkParamDto, MsgType.INNER_MSG);
Expand All @@ -92,6 +94,7 @@ public void reply(ReplayCommentEvent replayCommentEvent) {
MemberProfileLinkParamDto memberProfileLinkParamDto = MemberProfileLinkParamDto.builder()
.memberUserId(creatorReplayUserId)
.msgId(msgId)
.floorNum(floorNum)
.memberUserName(creatorReplayUserName)
.build();
String buildProfileMsg = LinkBuilderInstance.buildLink(BusinessLinkType.MEMBER_PROFILE, memberProfileLinkParamDto, MsgType.INNER_MSG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@
package com.upupor.service.business.links.abstracts.dto;

import com.upupor.service.business.links.abstracts.dto.parent.LinkParamDto;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;

/**
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 02:25
* @email: [email protected]
*/
@Data
@Builder
@SuperBuilder
public class ContentLinkParamDto extends LinkParamDto {
private String contentId;
private String msgId;
private String contentTitle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@
package com.upupor.service.business.links.abstracts.dto;

import com.upupor.service.business.links.abstracts.dto.parent.LinkParamDto;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;

/**
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 02:25
* @email: [email protected]
*/
@Data
@Builder
@SuperBuilder
public class MemberProfileLinkParamDto extends LinkParamDto {
private String memberUserId;
private String msgId;
private String memberUserName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@
package com.upupor.service.business.links.abstracts.dto;

import com.upupor.service.business.links.abstracts.dto.parent.LinkParamDto;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;

/**
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 02:25
* @email: [email protected]
*/
@Data
@Builder
@SuperBuilder
public class MessageBoardLinkParamDto extends LinkParamDto {
private String targetUserId;
private String msgId;
private String title;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@
package com.upupor.service.business.links.abstracts.dto;

import com.upupor.service.business.links.abstracts.dto.parent.LinkParamDto;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;

/**
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 02:25
* @email: [email protected]
*/
@Data
@Builder
@SuperBuilder
public class RadioLinkParamDto extends LinkParamDto {
private String radioId;
private String msgId;
private String radioIntro;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@

package com.upupor.service.business.links.abstracts.dto.parent;

import lombok.Data;
import lombok.experimental.SuperBuilder;

/**
* 链接所需参数 标识
*
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 02:44
* @email: [email protected]
*/
@Data
@SuperBuilder
public class LinkParamDto {
/**
* 评论所在楼层
*/
private Long floorNum;

/**
* 消息Id
*/
private String msgId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public class ContentLink extends AbstractBuildLink<ContentLinkParamDto> {

@Override
protected String buildInnerLink() {
final String CONTENT_INNER_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/u/%s?msgId=%s'>%s</a>";
return String.format(CONTENT_INNER_MSG, linkParamDto.getContentId(), linkParamDto.getMsgId(), linkParamDto.getContentTitle());
final String CONTENT_INNER_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/u/%s?msgId=%s#comment_%s'>%s</a>";
return String.format(CONTENT_INNER_MSG, linkParamDto.getContentId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getContentTitle());
}

@Override
protected String buildEmailLink() {
final String CONTENT_EMAIL = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '" + EMAIL_NEED_WEBSITE + "/u/%s?msgId=%s'>%s</a>";
return String.format(CONTENT_EMAIL, linkParamDto.getContentId(), linkParamDto.getMsgId(), linkParamDto.getContentTitle());
final String CONTENT_EMAIL = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '" + EMAIL_NEED_WEBSITE + "/u/%s?msgId=%s#comment_%s'>%s</a>";
return String.format(CONTENT_EMAIL, linkParamDto.getContentId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getContentTitle());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
public class MemberProfileLink extends AbstractBuildLink<MemberProfileLinkParamDto> {
@Override
protected String buildInnerLink() {
final String PROFILE_INNER_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/profile/%s/content?msgId=%s'> %s </a>";
return String.format(PROFILE_INNER_MSG, linkParamDto.getMemberUserId(), linkParamDto.getMsgId(), linkParamDto.getMemberUserName());
final String PROFILE_INNER_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/profile/%s/content?msgId=%s#comment_%s'> %s </a>";
return String.format(PROFILE_INNER_MSG, linkParamDto.getMemberUserId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getMemberUserName());
}

@Override
protected String buildEmailLink() {
final String PROFILE_EMAIL = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '" + EMAIL_NEED_WEBSITE + "/profile/%s/content?msgId=%s'> %s </a>";
return String.format(PROFILE_EMAIL, linkParamDto.getMemberUserId(), linkParamDto.getMsgId(), linkParamDto.getMemberUserName());
final String PROFILE_EMAIL = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '" + EMAIL_NEED_WEBSITE + "/profile/%s/content?msgId=%s#comment_%s'> %s </a>";
return String.format(PROFILE_EMAIL, linkParamDto.getMemberUserId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getMemberUserName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
public class MessageBoardLink extends AbstractBuildLink<MessageBoardLinkParamDto> {
@Override
protected String buildInnerLink() {
final String MESSAGE_BOARD_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/profile/%s/message?msgId=%s'>%s</a>";
return String.format(MESSAGE_BOARD_MSG, linkParamDto.getTargetUserId(), linkParamDto.getMsgId(), linkParamDto.getTitle());
final String MESSAGE_BOARD_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/profile/%s/message?msgId=%s#comment_%s'>%s</a>";
return String.format(MESSAGE_BOARD_MSG, linkParamDto.getTargetUserId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getTitle());
}

@Override
protected String buildEmailLink() {
final String MESSAGE_BOARD_EMAIL = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '" + EMAIL_NEED_WEBSITE + "/profile/%s/message?msgId=%s'>%s</a>";
return String.format(MESSAGE_BOARD_EMAIL, linkParamDto.getTargetUserId(), linkParamDto.getMsgId(), linkParamDto.getTitle());
final String MESSAGE_BOARD_EMAIL = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '" + EMAIL_NEED_WEBSITE + "/profile/%s/message?msgId=%s#comment_%s'>%s</a>";
return String.format(MESSAGE_BOARD_EMAIL, linkParamDto.getTargetUserId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getTitle());
}

@Override
Expand Down
Loading

0 comments on commit c2b82c6

Please sign in to comment.