package jnpf.model.personnels.dto.regular;

import jnpf.base.UserInfo;
import jnpf.model.enums.FtbPersonnelsAuditTaskEnum;
import jnpf.model.enums.FtbPersonnelsCofigEnum;
import jnpf.model.personnels.dto.base.PersonnelsQueryDTO;
import jnpf.util.UserProvider;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @Title:FtbPersonnelsRegularQueryDTO
 * @Author:peng.hao
 * @create: 2024/2/217:07
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FtbPersonnelsForAppQueryDTO extends PersonnelsQueryDTO {
    /**
     * 1.办理 2.我的审批 3 抄送我的 4 我的申请
     */
    String flagByApp;

    String  userId;
    /**
     * 配置类型
     */
    Integer configType;

    List<Integer> statusList;

    /**
     * 初始化如果是抄送的状态包含两个
     * @param flagByApp
     */
    public void  init(String flagByApp, FtbPersonnelsCofigEnum cofigEnum){
        UserInfo user = UserProvider.getUser();
        this.setUserId(user.getUserId());
        if ("3".equals(flagByApp)) {
            Integer configType = cofigEnum.getConfigType();
            this.setConfigType(configType);
            if ( 0 == this.getApprovalStatus()){
                List<Integer> list = new ArrayList<>();
                list.add(FtbPersonnelsAuditTaskEnum.UNDER_REVIEW.getCode());
                this.setStatusList(list);
            }
        }
    }
    public static FtbPersonnelsForAppQueryDTO covert(PersonnelsQueryDTO queryDTO) {
        if (queryDTO == null) {
            return null;
        }
        FtbPersonnelsForAppQueryDTO ftbPersonnelsForAppQueryDTO = new FtbPersonnelsForAppQueryDTO();
        ftbPersonnelsForAppQueryDTO.setKeyWord(queryDTO.getKeyWord());
        ftbPersonnelsForAppQueryDTO.setApprovalStatus(queryDTO.getApprovalStatus());
        ftbPersonnelsForAppQueryDTO.setBeginTime(queryDTO.getBeginTime());
        ftbPersonnelsForAppQueryDTO.setEndTime(queryDTO.getEndTime());
        ftbPersonnelsForAppQueryDTO.setOrgId(queryDTO.getOrgId());
        ftbPersonnelsForAppQueryDTO.setPostId(queryDTO.getPostId());
        ftbPersonnelsForAppQueryDTO.setGradeId(queryDTO.getGradeId());
        ftbPersonnelsForAppQueryDTO.setFlag(queryDTO.getFlag());
        ftbPersonnelsForAppQueryDTO.setMyApprovalFlag(queryDTO.getMyApprovalFlag());
        ftbPersonnelsForAppQueryDTO.setIds(queryDTO.getIds());
        return ftbPersonnelsForAppQueryDTO;
    }
}
