package com.izouma.wenlvju.dto;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.izouma.wenlvju.domain.User;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "用户", description = "用户")
public class ExpertDTO {
    private Long id;

    private String username;

    private String nickname;

    private String sex;

    private String phone;

    private int age;

    private Long artTypeId;

    private String work;

    private String position;

    private String artType;

    public ExpertDTO(User user, String artType) {
        BeanUtil.copyProperties(user, this);
//        Expert expert = user.getExpert();
//        if (ObjectUtil.isNotNull(expert)){
//            this.work = expert.getWork();
//            this.position = expert.getPosition();
//        }
        this.artType = artType;
        if (StrUtil.isBlank(artType) && StrUtil.isNotBlank(user.getDistrict())) {
            this.artType = user.getDistrict();
        }
    }
}
