package jnpf.model.helpailog.dto;

import jnpf.model.helpailog.po.FtbHelpAiChatLog;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
public class HelpAiLogDto {

    /**
     * 问题
     */
    @NotBlank(message = "问题-不能为空")
    private String question;

    /**
     * 答
     */
    @NotBlank(message = "回答-不能为空")
    private String answer;

    /**
     * 会话id
     */
    @NotBlank(message = "会话ID-不能为空")
    private String sessionId;


    public FtbHelpAiChatLog convertToEntity(String userId, String userName, String tenantId) {
        FtbHelpAiChatLog entity = new FtbHelpAiChatLog();
        if (this.question.length() > 65500) {
            this.question = this.question.substring(0, 65500);
        }
        entity.setQuestion(this.question);
        if (this.answer.length() > 65500) {
            this.answer = this.answer.substring(0, 65500);
        }
        entity.setAnswer(this.answer);
        entity.setSessionId(this.sessionId);
        entity.setCreatorTime(new Date());
        entity.setUserName(userName);


        entity.setUserId(userId);
        //获取租户id
        entity.setTenantId(tenantId);
        return entity;
    }
}
