package com.engine.organization.entity.personnelcard;

import com.api.system.language.service.LanguageService;
import com.engine.organization.entity.extend.po.ExtendInfoPO;
import com.engine.organization.util.field.FieldDefinedValueUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @author:dxfeng
 * @createTime: 2022/10/08
 * @version: 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserCard {
    private Integer id;
    private String ecId;
    private String image;
    private String name;
    private String sex;
    private String email;
    private String phone;
    private String belongTo;
    private String accountType;
    private String status;

    public String getAccountType() {
        if ("1".equals(accountType)) {
            return "次账号";
        }
        return "主账号";
    }

    public String getStatus() {
        if (StringUtils.isNotBlank(status)) {
            return ResourceStatusEnum.getResourceStatus(status).getName();
        }
        return status;
    }

    public String getImage() {
        weaver.hrm.User user = new weaver.hrm.User();
        user.setLanguage(LanguageService.getDefaultLang());
        if (StringUtils.isNotBlank(image) && image.contains("/")) {
            return image;
        }
        return FieldDefinedValueUtil.getFieldValue(user, ExtendInfoPO.builder().controlType(6).browserType("1").build(), image);
    }
}
