Skip to content

Commit

Permalink
mode: 链接构建方法重命名
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrunkang committed Jan 29, 2023
1 parent 2fa6037 commit 65c5218
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Objects;

/**
* 抽象构造消息内容逻辑
* 抽象构造链接内容逻辑
*
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 01:39
Expand All @@ -47,7 +47,7 @@
public abstract class AbstractBuildLink<T extends LinkParamDto> {

/**
* 消息参数Dto
* 链接参数Dto
*/
protected T linkParamDto;

Expand All @@ -57,23 +57,23 @@ public abstract class AbstractBuildLink<T extends LinkParamDto> {
protected static final String EMAIL_NEED_WEBSITE = SpringContextUtils.getBean(UpuporConfig.class).getWebsite();

/**
* 标识业务消息类型
* 标识业务链接类型
*
* @return
*/
public abstract BusinessLinkType businessLinkType();

/**
* 构造消息内容
* 构造链接内容
*
* @return
*/
public String buildLink(LinkParamDto linkParamDto, MsgType msgType) {
init(linkParamDto);
if (MsgType.INNER_MSG.equals(msgType)) {
return isCommentOperation() ? buildInnerLink() : buildNotCommentInnerLink();
return isCommentOperation() ? buildInnerAnchorLink() : buildInnerLink();
} else if (MsgType.EMAIL.equals(msgType)) {
return isCommentOperation() ? buildEmailLink() : buildNotCommentEmailLink();
return isCommentOperation() ? buildEmailAnchorLink() : buildEmailLink();
}
throw new BusinessException(ErrorCode.UNSUPPORT_UNKNOWN_LINK_CONTENT_BUILD);
}
Expand All @@ -93,36 +93,35 @@ private void init(LinkParamDto linkParamDto) {


/**
* 构造站内信消息
* 构造站内信锚点链接-评论锚点
*
* @return
*/
protected abstract String buildInnerLink();
protected abstract String buildInnerAnchorLink();

/**
* 构造非评论站内信消息
* 构造邮件锚点链接-评论锚点
*
* @return
*/
protected String buildNotCommentInnerLink() {
return buildInnerLink();
}

protected abstract String buildEmailAnchorLink();

/**
* 构造邮件消息
* 构造站内信链接
*
* @return
*/
protected abstract String buildEmailLink();
protected String buildInnerLink() {
return buildInnerAnchorLink();
}

/**
* 构造非评论邮件消息
* 构造邮件链接
*
* @return
*/
protected String buildNotCommentEmailLink() {
return buildEmailLink();
protected String buildEmailLink() {
return buildEmailAnchorLink();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@
public class ContentLink extends AbstractBuildLink<ContentLinkParamDto> {

@Override
protected String buildInnerLink() {
protected String buildInnerAnchorLink() {
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() {
protected String buildEmailAnchorLink() {
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
protected String buildNotCommentInnerLink() {
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());
}

@Override
protected String buildNotCommentEmailLink() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@

/**
* 用户主页
*
* @author Yang Runkang (cruise)
* @createTime 2023-01-27 02:35
* @email: [email protected]
*/
public class MemberProfileLink extends AbstractBuildLink<MemberProfileLinkParamDto> {
@Override
protected String buildInnerLink() {
protected String buildInnerAnchorLink() {
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());
}

@Override
protected String buildEmailLink() {
protected String buildEmailAnchorLink() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
*/
public class MessageBoardLink extends AbstractBuildLink<MessageBoardLinkParamDto> {
@Override
protected String buildInnerLink() {
protected String buildInnerAnchorLink() {
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() {
protected String buildEmailAnchorLink() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
*/
public class RadioLink extends AbstractBuildLink<RadioLinkParamDto> {
@Override
protected String buildInnerLink() {
protected String buildInnerAnchorLink() {
final String RADIO_MSG = "<a style='cursor: pointer;position: relative;text-decoration: none;font-weight: bold;color: #000000;' href = '/r/%s?msgId=%s#comment_%s'>%s</a>";
return String.format(RADIO_MSG, linkParamDto.getRadioId(), linkParamDto.getMsgId(), linkParamDto.getFloorNum(), linkParamDto.getRadioIntro());
}

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

0 comments on commit 65c5218

Please sign in to comment.