package com.microservices.pms.enterprise.domain.vo;

import com.microservices.common.core.utils.html.EscapeUtil;
import com.microservices.pms.enterprise.domain.PmsEnterprise;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author otto
 */
@Data
@ApiModel("GitLink组织详情对象")
public class GitlinkOrganizationDetailVo {
    @ApiModelProperty(value = "组织Id")
    private Long id;
    @ApiModelProperty(value = "组织名称")
    private String nickname;
    @ApiModelProperty(value = "组织标识")
    private String name;
    @ApiModelProperty(value = "组织描述")
    private String description;
    @ApiModelProperty(value = "头像")
    private String avatar_url;
    @ApiModelProperty(value = "所在地区")
    private String location;

    public PmsEnterprise toPmsEnterprise(String gitLinkUrl) {
        PmsEnterprise pmsEnterprise = new PmsEnterprise();
        pmsEnterprise.setGitlinkOrgId(id);
        pmsEnterprise.setEnterpriseIdentifier(name);
        pmsEnterprise.setEnterpriseName(nickname);
        pmsEnterprise.setEnterpriseDescription(description);
        pmsEnterprise.setEnterpriseLocation(location);
        pmsEnterprise.setEnterpriseImage(
                EscapeUtil.removeExtraSlashOfUrl(
                        gitLinkUrl + "/" + avatar_url));
        return pmsEnterprise;
    }
}
