package com.zd.laboratory.onemachine.domain;

import cn.hutool.core.collection.CollUtil;
import com.zd.laboratory.domain.LabApproval;
import com.zd.laboratory.domain.LabSecurityApply;
import com.zd.laboratory.domain.vo.LabApprovalVO;
import com.zd.laboratory.domain.vo.LabSecurityApplyVO;
import com.zd.system.api.domain.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;
import java.util.List;
import java.util.Optional;

/**
 * 签到用户信息
 *
 * @Author: zhoupan
 * @Date: 2021/09/15/12:01
 * @Description:
 */
@ApiModel("签到用户信息")
public class SingInUser {


    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("用户账户")
    private String userName;

    @ApiModelProperty("用户姓名")
    private String nickName;

    @ApiModelProperty("用户类型")
    private String type;

    @ApiModelProperty("部门id")
    private Long deptId;

    @ApiModelProperty("失效时间")
    private Date expirationDate;

    /**
     * 用户头像
     */
    private String avatar;


    public SingInUser(){}
    public SingInUser(SysUser user, List<LabSecurityApplyVO> labApprovals) {
        this.userId = user.getUserId();
        this.userName = user.getUserName();
        this.nickName = user.getNickName();
        this.type = user.getUserType();
        this.deptId = user.getDeptId();
        this.avatar=user.getAvatar();
        this.expirationDate=Optional.ofNullable(labApprovals)
                .filter(a->a.size()>0)
                .map(a->a.get(0))
                .filter(a->a.getAuditStatus().equals(2))
                .map(a->a.getValidEndTime())
                .orElseGet(()->null);

    }
    /*public SingInUser(SysUser user, List<LabApprovalVO> labApprovals) {
        this.userId = user.getUserId();
        this.userName = user.getUserName();
        this.nickName = user.getNickName();
        this.type = user.getUserType();
        this.deptId = user.getDeptId();
        this.avatar=user.getAvatar();
        this.expirationDate=Optional.ofNullable(labApprovals)
                .filter(a->a.size()>0)
                .map(a->a.get(0))
                .filter(a->a.getRecordContent().equals(1))
                .map(a->a.getExpirationDate())
                .orElseGet(()->null);

    }*/
    public String getAvatar() {
        return avatar;
    }
    public Long getDeptId() {
        return deptId;
    }

    public Long getUserId() {
        return userId;
    }

    public String getUserName() {
        return userName;
    }

    public String getNickName() {
        return nickName;
    }

    public String getType() {
        return type;
    }

    public Date getExpirationDate() {
        return expirationDate;
    }


    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
}
