package com.kospo.talk.payload;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.kospo.talk.model.Work;
import com.kospo.talk.model.WorkS;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.Date;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(name = "WorkDto", description = "업무관리")
public class WorkTreeDto {
    @Schema(name = "workId", description = "업무아이디")
    private String workId;

    @Schema(name = "workUrl", description = "업무URL")
    private String workUrl;

    @Schema(name = "workNm", description = "업무이름")
    private String workNm;

    @Schema(name = "gubun", description = "레벨")
    private char gubun;


    public static WorkTreeDto to(Work work) {
        WorkS workS = work.getWorkS();
        return WorkTreeDto.builder()
                .workId(work.getWorkId())
                .workUrl(workS == null ? "" : workS.getWorkUrl())
                .workNm(work.getWorkNm())
                .gubun(work.getGubun())
                .build();
    }

}