package com.fs.course.param;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fs.common.core.domain.BaseEntity;
import lombok.Data;

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

@Data
public class FsCourseAnswerLogsParam  extends BaseEntity  {

    private Long logId;
    private String phone;
    private String phoneMk;
    private String courseId;
    private String videoId;
    private String companyUserName;
    /**
     * 销售id
     */
    private Long companyUserId;
    private Long companyId;
    private Long isRight;
    private Long watchLogId;

    private Long qwUserId;
    private Long userId;
    private String nickName;
    private String project;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date eTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date sTime;

    private Integer pageNum;
    private Integer pageSize;

    /**
     * 用户（昵称_id组合）
     */
    private String userName;
    /**
     * 用户id
     */
    private Set<Long> userIds;

    @TableField(exist = false)
    private List<String> companyUserIds=new ArrayList<>();


    public List<String> getCompanyUserIds() {
        if (companyUserIds == null || companyUserIds.isEmpty()) {
            return companyUserIds;
        }

        // 直接在原始列表上修改
        for (int i = 0; i < companyUserIds.size(); i++) {
            String id = companyUserIds.get(i);
            if (id != null) {
                if (id.startsWith("dept_")) {
                    companyUserIds.set(i, id.substring(5));
                } else if (id.startsWith("company_")) {
                    companyUserIds.set(i, id.substring(8));
                } else if (id.startsWith("user_")) {
                    companyUserIds.set(i, id.substring(5));
                }
            }
        }
        return companyUserIds;
    }

}
