package com.backendsys.modules.ai.chat.entity;

import com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeAdapter;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.gson.annotations.JsonAdapter;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("ai_chat")
public class Chat {

    public static interface Abort{}
    public static interface Detail{}
    public static interface Create{}
    public static interface Update{}
    public static interface Delete{}
    public static interface DeleteOne{}

    @TableId(type = IdType.AUTO)
    @NotNull(message = "id 不能为空", groups = { DeleteOne.class })
    private Long id;

    @Size(max = 36, message = "对话历史记录ID长度不超过 {max} 字符", groups = { Abort.class, Detail.class, Delete.class })
    @NotEmpty(message = "history_code 不能为空", groups = { Abort.class, Detail.class, Delete.class })
    private String history_code;

    @NotEmpty(message = "model 不能为空", groups = { Create.class })
    // @RangeStringArray(message="模型取值有误，范围应是(HUNYUAN, DEEPSEEK_API, DEEPSEEK_R1)", value = {"HUNYUAN", "DEEPSEEK_API", "DEEPSEEK_R1"}, groups = { Create.class, Update.class })
    private String model;
    private String model_version;
    @NotEmpty(message = "tag 不能为空", groups = { Create.class })
    @TableField(exist = false)
    private String tag;

    private Long user_id;
//    private String user_nickname;
//    private String user_avatar;
    private String robot_code;

    private String role;    // 对话角色 ("user", "assistant")

    @Size(max = 5000, message = "对话内容长度不超过 {max} 字符", groups = { Create.class })
    @NotEmpty(message = "对话内容不能为空", groups = { Create.class })
    private String content;
    private String content_type;    // 对话内容类型 (LOADING-加载中, SEARCH-搜索, REPLY-回复, REPLY-回复, REPLY_ABORT-回复中止, THINK-思考, THINK_ABORT-思考中止)
    private Long duration;

    @TableField(exist = false)
    private Boolean internet = false;       // 是否联网搜索
    private Integer del_flag;

    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime create_time;

    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime update_time;

}
