package com.bio.bio_backend.domain.admin.common_code.dto;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 공통 코드 조회용 Response DTO
 * CommonGroupCode의 name과 Member의 name을 join을 통해 함께 조회
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SqlResultSetMapping(
    name = "GetCommonCodeResponseDtoMapping",
    classes = @ConstructorResult(
        targetClass = GetCommonCodeResponseDto.class,
        columns = {
            @ColumnResult(name = "code", type = String.class),
            @ColumnResult(name = "name", type = String.class),
            @ColumnResult(name = "description", type = String.class),
            @ColumnResult(name = "group_code", type = String.class),
            @ColumnResult(name = "parent_code", type = String.class),
            @ColumnResult(name = "character_ref1", type = String.class),
            @ColumnResult(name = "character_ref2", type = String.class),
            @ColumnResult(name = "character_ref3", type = String.class),
            @ColumnResult(name = "character_ref4", type = String.class),
            @ColumnResult(name = "character_ref5", type = String.class),
            @ColumnResult(name = "sort_order", type = Integer.class),
            @ColumnResult(name = "use_flag", type = Boolean.class),
            @ColumnResult(name = "created_at", type = LocalDateTime.class),
            @ColumnResult(name = "updated_at", type = LocalDateTime.class),
            @ColumnResult(name = "group_code_name", type = String.class),
            @ColumnResult(name = "created_by_name", type = String.class),
            @ColumnResult(name = "updated_by_name", type = String.class)
        }
    )
)
public class GetCommonCodeResponseDto {
    
    // CommonCode 기본 정보
    private String code;
    private String name;
    private String description;
    private String groupCode;
    private String parentCode;
    private String characterRef1;
    private String characterRef2;
    private String characterRef3;
    private String characterRef4;
    private String characterRef5;
    private Integer sortOrder;
    private Boolean useFlag;
    
    // BaseEntity 정보
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    // Join을 통해 가져올 정보
    private String groupCodeName;        // CommonGroupCode의 name
    private String createdByName;        // 생성자 Member의 name
    private String updatedByName;        // 수정자 Member의 name
}
