package com.webchat.service.message.builder;

import com.webchat.common.constants.MessageConstants;
import com.webchat.common.enums.ResourceTypeEnum;
import com.webchat.domain.vo.dto.CommentReplyMessageDTO;

import java.util.Date;

/**
 * @Author 程序员七七
 * @webSite https://www.coderutil.com
 * @Date 2022/11/13 14:07
 * @description
 */
public class CommentReplyMessageBuilder extends AbstractMessageBuilder {

    @Override
    protected String getMessageCategory() {
        return MessageConstants.CategoryEnum.COMMENT_REPLY.getCategory();
    }

    /**
     * 构建评论回复消息
     * @param type 评论或回复通过type区分
     * @param fromUserId
     * @param toUserId
     * @param resourceType 内容主体
     * @param resourceId 内容id
     * @param content 评论或回复消息
     * @return
     */
    public CommentReplyMessageDTO build(MessageConstants.TypeEnum type,
                                        String fromUserId,
                                        String toUserId,
                                        ResourceTypeEnum resourceType,
                                        String resourceId,
                                        String content) {
        CommentReplyMessageDTO message = new CommentReplyMessageDTO();
        message.setCategory(getMessageCategory());
        message.setType(type.getType());
        message.setFromUserId(fromUserId);
        message.setToUserId(toUserId);
        message.setResourceType(resourceType.getType());
        message.setResourceId(resourceId);
        message.setContent(content);
        message.setCreateDate(new Date());
        return message;
    }
}
