package cn.fateverse.workflow.entity.bpmn;

import cn.fateverse.admin.entity.User;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.workflow.enums.OperationStateEnums;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用户的简单信息
 * @author Clay
 * @date 2022/12/27
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserInfo {
  /**
   * id
   */
  private String id;
  /**
   * 名称
   */
  private String name;
  /**
   * 用户审批状态
   */
  private OperationStateEnums state;
  /**
   * 头像
   */
  private String avatar;
  /**
   * 性别
   */
  private String sex;
  /**
   * 是否选中
   */
  private Boolean selected;


  public static UserInfo toUserInfo(User user){
    return toUserInfo(user, OperationStateEnums.RUNNING);
  }
  public static UserInfo toUserInfo(User user, OperationStateEnums state){
    return UserInfo.builder()
            .id(user.getUserId().toString())
            .avatar(user.getAvatar())
            .name(user.getNickName())
            .state(state)
            .sex(user.getSex())
            .build();
  }

  public static UserInfo toUserInfo(UserVo user, OperationStateEnums state){
    return UserInfo.builder()
            .id(user.getUserId().toString())
            .avatar(user.getAvatar())
            .name(user.getNickName())
            .state(state)
            .sex(user.getSex())
            .build();
  }
  public static UserInfo toUserInfo(UserVo user){
    return toUserInfo(user, OperationStateEnums.RUNNING);
  }
}
