package cn.com.qmth.stmms.biz.user.service.query;

import java.util.HashSet;
import java.util.Set;

import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

import cn.com.qmth.stmms.biz.common.BaseQuery;
import cn.com.qmth.stmms.biz.user.model.User;
import cn.com.qmth.stmms.common.enums.Role;
import cn.com.qmth.stmms.common.enums.UserSource;

public class UserSearchQuery extends BaseQuery<User> {

    private int schoolId;

    private String loginName;

    private String name;

    private String relatedAccount;

    private Role role;

    private UserSource source;

    private Boolean enable;

    private Set<Role> includeRoles;

    public void orderByIdAsc() {
        setSort(new Sort(Direction.ASC, "id"));
    }

    public int getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(int schoolId) {
        this.schoolId = schoolId;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Set<Role> getIncludeRoles() {
        return includeRoles;
    }

    public void addIncludeRole(Role role) {
        if (includeRoles == null) {
            includeRoles = new HashSet<Role>();
        }
        if (role != null) {
            includeRoles.add(role);
        }
    }

    public String getRelatedAccount() {
        return relatedAccount;
    }

    public void setRelatedAccount(String relatedAccount) {
        this.relatedAccount = relatedAccount;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public UserSource getSource() {
        return source;
    }

    public void setSource(UserSource source) {
        this.source = source;
    }
}
