package com.willalp.yiqing.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.willalp.common.annotation.Excel;
import com.willalp.common.exception.base.BaseException;
import com.willalp.common.utils.StringUtils;
import lombok.Data;
import org.springframework.stereotype.Component;

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

/**
 * @author xian
 */
@Data
@Component
public class UserQueResultVo {

    /**
     * 用户编号
     */
    @Excel(name = "人员编号")
    private String userNo;

    /**
     * 用户名
     */
    @Excel(name = "姓名")
    private String userName;

    /**
     * 机构编号
     */
    @Excel(name = "机构编号")
    private String orgNo;

    /**
     * 机构名称
     */
    @Excel(name = "所属机构")
    private String orgName;

    /**
     * 推送cId
     */
    @Excel(name = "推送cId")
    private String pushCid;

    /**
     * 说明
     */
    @Excel(name = "说明")
    private String remark;

    /**
     * 打卡类型
     */
    private Integer clockInType;

    /**
     * 请假开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date vacateStartTime;

    /**
     * 请假结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date vacateEndTime;

    /**
     * 问题答案动态对象
     */
    private Object queResultTexts;

    private List<String> queResults = new ArrayList<>();

    private List<String> ques = new ArrayList<>();

    /**
     * 登记时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "登记时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 问题表头
     */
    private List<DynamicTable> list = new ArrayList<>();

    public void verify(UserQueResultVo userQueResultVo) {
        String userName = userQueResultVo.getUserName();
        String userNo = userQueResultVo.getUserNo();
        String orgNo = userQueResultVo.getOrgNo();
        String orgName = userQueResultVo.getOrgName();
        if (StringUtils.isBlank(userName)) {
            throw new BaseException("提交失败，姓名为空");
        }
        if (StringUtils.isBlank(userNo)) {
            throw new BaseException("提交失败，用户名为空");
        }
        if (StringUtils.isBlank(orgNo)) {
            throw new BaseException("提交失败，机构编号为空");
        }
        if (StringUtils.isBlank(orgName)) {
            throw new BaseException("提交失败，机构名称为空");
        }
    }
}
