package cn.fateverse.query.entity.bo;

import cn.fateverse.query.entity.Portal;
import cn.fateverse.query.entity.PortalMapping;
import cn.fateverse.query.enums.PortalEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author Clay
 * @date 2024/4/19 10:04
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PortalBo implements Serializable {
    private Long portalId;
    private Long queryId;
    private Long adapterId;
    private PortalEnum type;
    private String requestMethod;
    private Boolean createDataAdapter;
    private Boolean page;
    private String path;
    private String url;
    private Integer state;
    private List<PortalMapping> mappings;

    public static PortalBo toPortalBo(Portal portal, List<PortalMapping> mappings) {
        return PortalBo.builder()
                .portalId(portal.getPortalId())
                .queryId(portal.getQueryId())
                .adapterId(portal.getAdapterId())
                .type(portal.getType())
                .requestMethod(portal.getRequestMethod())
                .createDataAdapter(portal.getCreateDataAdapter())
                .page(portal.getPage())
                .path(portal.getPath())
                .url(portal.getUrl())
                .state(portal.getState())
                .mappings(mappings)
                .build();
    }


}


