package com.eactive.eai.rms.onl.apim.approval;

import com.eactive.apim.portal.approval.entity.ApprovalType;
import com.eactive.apim.portal.approval.statemachine.ApprovalState;
import com.eactive.eai.data.converter.LocalDateTimeFormatters;
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUI;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

@Data
public class PortalApprovalUI {

    private String id;

    private ApprovalState approvalStatus;  //승인 진행 상태 //statemachine 에 정의됨.

    private ApprovalType approvalType; //승인 유형: APP, USER
    private String approvalTypeDescription; //승인 유형 Description: API 사용, 법인사용자

    private String targetId;  //승인하는 대상 객체의 ID

    private PortalUserUI requester;

    private List<PortalApprovalApproverUI> approvers = new ArrayList<>();

    private String approvalSubject;  //제목

    private String approvalDetail;  //승인 요청 내용

    @JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYYMMDDHHMMSSSSS_17)
    @DateTimeFormat(pattern = "yyyyMMddHHmmssSSS")
    private String createdDate;

    @JsonFormat(pattern = LocalDateTimeFormatters.FORMAT_YYYYMMDDHHMMSSSSS_17)
    @DateTimeFormat(pattern = "yyyyMMddHHmmssSSS")
    private String approvalDate;

    private String expectEndDate;

    public String getApprovalTypeDescription() {
        return approvalType != null ? approvalType.getDescription() : "";
    }
}
