package com.railway.business.catenary.util;

import com.railway.business.catenary.domain.BusJcab;
import com.railway.business.catenary.domain.BusJceb;
import com.railway.business.catenary.domain.vo.JcebQueryParamVo;
import com.railway.business.catenary.domain.vo.JcebQueryVo;
import com.railway.business.catenary.enums.JcebStatusEnum;
import com.railway.common.core.domain.entity.SysUser;
import com.railway.common.enums.PostTypeEnum;
import com.railway.common.utils.SecurityUtils;
import com.railway.common.utils.bean.BeanUtils;

/**
 * @author ZhaoMn
 */
public class JcebQueryUtil {

  private static JcebQueryParamVo getJcebQuery(){
    SysUser user = SecurityUtils.getLoginUser().getUser();
    String post = user.getPost();
    PostTypeEnum postType = PostTypeEnum.ofValue(post);
    JcebQueryParamVo jcebQuery = new JcebQueryParamVo();
    if(postType == PostTypeEnum.LEADER){
      jcebQuery.setSubmitState(JcebStatusEnum.REPORTED.getCode());
      jcebQuery.setDeptId(user.getDeptId());
      jcebQuery.setCreateBy(null);
    }else {
      jcebQuery.setCreateBy(user.getUserName());
    }
    return jcebQuery;
  }

  public static void setBusJceb(BusJceb jceb){
    JcebQueryParamVo jcebQuery = getJcebQuery();
    jceb.setSubmitState(jcebQuery.getSubmitState());
    jceb.setDeptId(jcebQuery.getDeptId());
    jceb.setCreateBy(jcebQuery.getCreateBy());
  }

  public static void setBusJcab(BusJcab jcab){
    JcebQueryParamVo jcebQuery = getJcebQuery();
    jcab.setSubmitState(jcebQuery.getSubmitState());
    jcab.setDeptId(jcebQuery.getDeptId());
    jcab.setCreateBy(jcebQuery.getCreateBy());
  }

  public static void setBusJcebQuery(JcebQueryVo query){
    JcebQueryParamVo jcebQuery = getJcebQuery();
    query.setSubmitState(jcebQuery.getSubmitState());
    query.setDeptId(jcebQuery.getDeptId());
    query.setCreateBy(jcebQuery.getCreateBy());
  }

}
