package com.railway.common.enums;

import com.railway.common.core.domain.entity.SysUser;
import com.railway.common.utils.SecurityUtils;

/**
 * 岗位
 *
 * @author zhaomn
 */
public enum PostTypeEnum {

  /** 岗位 */
  LEADER("leader", "领导"),
  STAFF("staff", "职工"),
  INSPECTOR("inspector", "送检员"),
  TESTER("tester", "实验员"),
  ;

  private final String code;
  private final String info;

  PostTypeEnum(String code, String info) {
    this.code = code;
    this.info = info;
  }

  public String getCode() {
    return code;
  }

  public String getInfo() {
    return info;
  }

  public static PostTypeEnum ofValue(String code) {
    for (PostTypeEnum investor : PostTypeEnum.values()) {
      if (investor.getCode().equals(code)) {
        return investor;
      }
    }
    return STAFF;
  }

  public static PostTypeEnum getPostTypeEnum() {
    SysUser user = SecurityUtils.getLoginUser().getUser();
    String post = user.getPost();
    return ofValue(post);
  }

}
