package com.oqpo.api.web.dto.response.oper.mailform;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.oper.MailFormEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class MailFormResponse {

    @ApiModelProperty(value = "메일양식번호")
    private String mailFormNo;

    @ApiModelProperty(value = "메일양식명")
    private String mailFormNm;

    @ApiModelProperty(value = "메일양식제목")
    private String mailSubject;

    @ApiModelProperty(value = "상태코드")
    private String mailStatusCd;

    @ApiModelProperty(value = "상태명")
    private String mailStatusNm;

    @ApiModelProperty(value = "파일번호")
    private String fileNo;

    @ApiModelProperty(value = "메일양식내역")
    private String mailDesc;

    public static MailFormResponse toDTO(MailFormEntity entity) {
        if (entity == null) return null;
        return MailFormResponse.builder()
                .mailFormNo(entity.getMailFormNo())
                .mailFormNm(entity.getMailFormNm())
                .mailSubject(entity.getMailSubject())
                .mailStatusCd(entity.getMailStatusCd())
                .mailStatusNm(entity.getMailStatusNm())
                .fileNo(entity.getFileNo()  == null ? "" : entity.getFileNo())
                .mailDesc(entity.getMailDesc() == null ? "" : entity.getMailDesc() )
                .build();
    }
}
