package com.fs.qw.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fs.common.utils.DateUtils;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.StringJoiner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Data
public class QwWatchLogStatisticsListParam {
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date eTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date sTime;

    private String startDate;
    private String endDate;

    public String getStartDate() {
        return DateUtils.getStartOfDayString(sTime);
    }

    public String getEndDate() {
        return DateUtils.getEndOfDayString(eTime);
    }

    private String nickName;
    private String corpId;
    private Long companyId;
    private Long companyUserId;
    private Long id;
    private String ids;
    private List<String> idsList;
    private Long project;
    private Long courseId;
    private Long videoId;
    private Long deptId;
    private List<Long> deptIds; //多选

    private Long pageNum;
    private Long pageSize;
    private List<Long> filterDeptIds;

    /**
     * 添加方式
     */
    private List<Integer> addWays;

    /**
     * 今正要求把公司筛选条件优化到细分至部门，销售（前端判断，只有今正传）
     */
    private List<String> userIds;
    public List<String> getUserIds() {
        if (userIds == null || userIds.isEmpty()) {
            return userIds;
        }
        ArrayList<String> longs = new ArrayList<>();
        userIds.forEach(userId -> {
            if (userId.contains("user_")){
                StringJoiner joiner = new StringJoiner("");
                Matcher matcher = Pattern.compile("\\d+").matcher(userId);
                while (matcher.find()) {
                    joiner.add(matcher.group());
                }
                longs.add(joiner.toString());
            }

        });
        return longs;
    }
}
