package com.zhongshu.card.client.model.org.orgUser;

import com.github.microservice.auth.security.type.AuthType;
import com.zhongshu.card.client.model.base.SuperSearch;
import com.zhongshu.card.client.type.OrganizationUserType;
import com.zhongshu.card.client.type.Sex;
import com.zhongshu.card.client.type.UserState;
import com.zhongshu.card.client.type.user.OrgAddType;
import com.zhongshu.card.client.type.user.OrgUserState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;

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

/**
 * @author TRX
 * @date 2024/5/31
 */
@Data
public class OrganizationUserSearch extends SuperSearch {

    @Schema(description = "用户添加方式：管理员后台添加、注册")
    private OrgAddType addType = OrgAddType.Manager;

    @Schema(description = "用户审核状态")
    private OrgUserState orgUserState;

    @Schema(description = "关键字")
    private String keyWord;

    @Schema(description = "用户ID")
    private String userId;

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

    @Schema(description = "登录名")
    private String loginName;

    @Schema(description = "工号")
    private String code;

    @Schema(description = "用户手机号")
    private String phone;

    @Schema(description = "姓名")
    private String name;

    @Schema(description = "性别")
    private Sex sex;

    @Schema(description = "用户状态")
    private UserState state;

    @Schema(description = "是否是企业管理员")
    private Boolean isAdmin;

    @Schema(description = "企业类型")
    private AuthType authType;

    @Schema(description = "用户在机构的类型")
    private OrganizationUserType userType;

    @Schema(description = "职位ID")
    private String positionId;

    @Schema(description = "部门ID集合")
    private List<String> departmentIds;

    @Schema(description = "人员类型-角色ID集合")
    private List<String> roleIds;

    @Schema(description = "是否是搜索项目的用户")
    private Boolean isSearchProject = Boolean.FALSE;

    @Schema(description = "机构类型")
    private AuthType notAuthType;

    @Schema(description = "是否是机构类型")
    private Boolean isOrg;

    @Schema(description = "")
    private String openid;

    @Schema(description = "审核用户")
    private String reViewUserId;

    @Schema(description = "审核用户名称")
    private String reViewUserName;

    @Schema(description = "审核开始")
    private Long startReViewTime;

    @Schema(description = "审核结束")
    private Long endReViewTime;

    public boolean hasSearchFilter() {
        if (StringUtils.isNotEmpty(getOid()) || ObjectUtils.isNotEmpty(departmentIds)
                || ObjectUtils.isNotEmpty(roleIds) || StringUtils.isNotEmpty(positionId)
                || state != null || StringUtils.isNotEmpty(keyWord)) {
            return true;
        }
        return false;
    }
}
