package com.izouma.zhirongip.dto;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.zhirongip.domain.Institution;
import com.izouma.zhirongip.domain.User;
import com.izouma.zhirongip.enums.ApplyStatus;
import com.izouma.zhirongip.enums.InstitutionalNature;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.time.LocalDate;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "机构认证")
public class InstitutionDTO {
    private Long id;

    @ExcelIgnore
    private Long userId;

    @ExcelProperty(value = "企业名称")
    private String name;

    @ExcelIgnore
    @ApiModelProperty(value = "机构性质")
    private InstitutionalNature nature;

    @ExcelProperty(value = "机构性质")
    private String natureDesc;

    @ExcelProperty(value = "成立日期")
    private LocalDate establishedAt;

    @ExcelProperty(value = "官网地址")
    private String url;

    @ExcelProperty(value = "机构简介")
    private String introduction;

    @ExcelIgnore
    private String logo;

    @ExcelProperty(value = "统一社会信用代码 ")
    private String uscc;

    @ExcelIgnore
    @ApiModelProperty(value = "营业执照")
    private String businessLicense;

    @ExcelIgnore
    private ApplyStatus status;

    @ExcelProperty(value = "姓名 ")
    private String nickname;

    @ExcelIgnore
    private String avatar;

    @ExcelProperty(value = "电话 ")
    private String phone;

    @ExcelProperty(value = "邮箱 ")
    private String email;

    @ExcelProperty(value = "申请状态")
    private String statusDesc;

    public InstitutionDTO(Institution institution, User user) {
        BeanUtil.copyProperties(institution, this);
        this.natureDesc = institution.getNature().getDesc();
        this.statusDesc = institution.getStatus().getDesc();

        this.nickname = user.getNickname();
        this.avatar = user.getAvatar();
        this.phone = user.getPhone();
        this.email = user.getEmail();
    }
}
