package com.zhongshu.card.client.model.org;

import com.github.microservice.auth.security.type.AuthType;
import com.zhongshu.card.client.model.base.SuperModel;
import com.zhongshu.card.client.type.OrganizationState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 结构基本信息模型 （与数据模型系统）
 *
 * @author TRX
 * @date 2024/5/31
 */
@Data
public class OrganizationRelationModel extends SuperModel {

    @Schema(description = "机构名称")
    private String name;

    @Schema(description = "编码、项目ID、机构编号")
    private String code;

    @Schema(description = "机构类型")
    private AuthType authType = AuthType.Enterprise;

    private String authTypeStr;

    public String getAuthTypeStr() {
        if (authType != null) {
            return authType.getRemark();
        }
        return "";
    }

    @Schema(description = "状态")
    private OrganizationState state;

    private String stateStr;

    public String getStateStr() {
        if (state != null) {
            return state.getRemark();
        }
        return "";
    }

    @Schema(description = "logo")
    private String logo;

    @Schema(description = "统一社会信用代码")
    private String orgCode;

    @Schema(description = " 行政区划编码 21,2104,210403")
    private String adminDivisionItemCode;

    @Schema(description = "地区列表")
    private List<RegionModel> regionList;

    private String regionStr;

    public String getRegionStr() {
        if (regionList != null) {
            List<String> arr = regionList.stream().map(it -> it.getName()).collect(Collectors.toList());
            return String.join("/", arr);
        }
        return "";
    }

    @Schema(description = "地址")
    private String address;

    @Schema(description = "经度")
    private String mapLon;

    @Schema(description = "纬度")
    private String mapLat;

    @Schema(description = "联系人-用来初始管理员")
    private String contactName;

    @Schema(description = "联系人电话")
    private String contactPhone;

}
