package com.unicorn.hgzero.meeting.infra.gateway.entity;

import com.unicorn.hgzero.common.entity.BaseTimeEntity;
import com.unicorn.hgzero.meeting.biz.domain.AgendaSection;
import jakarta.persistence.*;
import lombok.*;

/**
 * 회의 안건 섹션 엔티티
 * agenda_sections 테이블과 매핑
 */
@Entity
@Table(name = "agenda_sections")
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AgendaSectionEntity extends BaseTimeEntity {
    
    @Id
    @Column(length = 36)
    private String id;
    
    @Column(name = "minutes_id", length = 36, nullable = false)
    private String minutesId;
    
    @Column(name = "meeting_id", length = 50, nullable = false)
    private String meetingId;
    
    @Column(name = "agenda_number", nullable = false)
    private Integer agendaNumber;
    
    @Column(name = "agenda_title", length = 200, nullable = false)
    private String agendaTitle;
    
    @Column(name = "ai_summary_short", columnDefinition = "TEXT")
    private String aiSummaryShort;
    
    @Column(name = "discussions", columnDefinition = "TEXT")
    private String discussions;
    
    @Column(name = "decisions", columnDefinition = "TEXT")
    private String decisions;
    
    @Column(name = "opinions", columnDefinition = "TEXT")
    private String opinions;
    
    @Column(name = "pending_items", columnDefinition = "TEXT")
    private String pendingItems;
    
    @Column(name = "todos", columnDefinition = "TEXT")
    private String todos;
    
    /**
     * 도메인 객체로 변환
     */
    public AgendaSection toDomain() {
        return AgendaSection.builder()
                .id(this.id)
                .minutesId(this.minutesId)
                .meetingId(this.meetingId)
                .agendaNumber(this.agendaNumber)
                .agendaTitle(this.agendaTitle)
                .aiSummaryShort(this.aiSummaryShort)
                .discussions(this.discussions)
                .decisions(this.decisions)
                .opinions(this.opinions)
                .pendingItems(this.pendingItems)
                .todos(this.todos)
                .createdAt(this.getCreatedAt())
                .updatedAt(this.getUpdatedAt())
                .build();
    }
    
    /**
     * 도메인 객체에서 엔티티 생성
     */
    public static AgendaSectionEntity fromDomain(AgendaSection domain) {
        return AgendaSectionEntity.builder()
                .id(domain.getId())
                .minutesId(domain.getMinutesId())
                .meetingId(domain.getMeetingId())
                .agendaNumber(domain.getAgendaNumber())
                .agendaTitle(domain.getAgendaTitle())
                .aiSummaryShort(domain.getAiSummaryShort())
                .discussions(domain.getDiscussions())
                .decisions(domain.getDecisions())
                .opinions(domain.getOpinions())
                .pendingItems(domain.getPendingItems())
                .todos(domain.getTodos())
                .build();
    }
}