/**
 * @ProjectName: 智慧评标-主观分助手
 * @Package: com.zhpb.gdyd_zhpb_zgf.entity.mysql
 * @ClassName: QaSession
 * @Description: QA会话实体
 * @Author: 张志锋
 * @Date: 2025-11-03
 * @Version: 1.0
 * @Copyright: © 2025 智慧评标-主观分助手
 */
package com.zhpb.gdyd_zhpb_zgf.entity.mysql;

import jakarta.persistence.*;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * QA会话实体
 */
@Data
@Entity
@Table(name = "t_qa_session")
public class QaSession {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "session_id", nullable = false, length = 100)
    private String sessionId;

    @Column(name = "project_id", nullable = false, length = 50)
    private String projectId;

    @Column(name = "user_id", nullable = false, length = 50)
    private String userId;

    @Column(name = "first_query", columnDefinition = "TEXT")
    private String firstQuery;

    @Column(name = "start_time", nullable = false)
    private LocalDateTime startTime;

    @Column(name = "last_message_time")
    private LocalDateTime lastMessageTime;

    @Column(name = "message_count", columnDefinition = "int default 0")
    private Integer messageCount = 0;

    @Column(name = "status", length = 20, columnDefinition = "varchar(20) default 'active'")
    private String status = "active";

    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    @PrePersist
    protected void onCreate() {
        createTime = LocalDateTime.now();
        updateTime = LocalDateTime.now();
    }

    @PreUpdate
    protected void onUpdate() {
        updateTime = LocalDateTime.now();
    }
}
