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.Personal;
import com.izouma.zhirongip.domain.User;
import com.izouma.zhirongip.enums.ApplyStatus;
import com.izouma.zhirongip.enums.DocumentType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "个人认证", description = "个人认证")
public class PersonalDTO {

    private Long id;

    @ExcelIgnore
    private Long userId;

    @ExcelIgnore
    private DocumentType type;

    @ExcelProperty(value = "证件类型")
    private String typeDesc;

    @ExcelProperty(value = "证件编号")
    private String documentNumber;

    @ExcelIgnore
    @ApiModelProperty(value = "证件照片(正面)")
    private String photoFront;

    @ExcelIgnore
    @ApiModelProperty(value = "证件照片(反面)")
    private String photoBackside;

    @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 PersonalDTO(Personal personal, User user) {
        BeanUtil.copyProperties(personal, this);
        this.statusDesc = personal.getStatus().getDesc();
        this.typeDesc = personal.getType().getDesc();

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