package com.qmth.paper.library.common.service;

import com.qmth.paper.library.common.bean.auth.AuthBean;
import com.qmth.paper.library.common.bean.dto.AuthOrgInfoDto;
import com.qmth.paper.library.common.bean.result.LoginResult;
import com.qmth.paper.library.common.bean.result.MenuResult;
import com.qmth.paper.library.common.entity.SysRolePrivilege;
import com.qmth.paper.library.common.entity.SysUser;
import com.qmth.paper.library.common.entity.SysUserRole;
import com.qmth.paper.library.common.enums.AppSourceEnum;
import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;

import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Set;

/**
 * @Description: 公共服务service
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/3/26
 */
public interface LibraryCommonService {

    /**
     * 获取用户菜单
     *
     * @param userId
     * @return
     */
    public MenuResult getUserMenu(Long userId);

    /**
     * 新增用户权限
     *
     * @param sysUser
     * @param roleIds
     */
    public void addUserRolePrivilege(SysUser sysUser, Long[] roleIds);

    /**
     * 获取用户角色
     *
     * @param userId
     * @return
     */
    public List<SysUserRole> getUserRolePrivilege(Long userId);

    /**
     * 获取角色权限
     *
     * @param roleId
     * @return
     */
    public List<SysRolePrivilege> getRolePrivilege(Long roleId);

    /**
     * 获取用户权限
     *
     * @param userId
     * @return
     */
    public AuthBean getUserAuth(Long userId);

    /**
     * 获取鉴权url
     *
     * @param privilegePropertyEnum
     * @param schoolId
     * @return
     */
    public Set<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId);

    /**
     * 删除用户信息
     *
     * @param userId
     * @param all
     */
    public void removeUserInfo(Long userId, boolean all) throws NoSuchAlgorithmException;

    /**
     * 批量删除用户信息
     *
     * @param userIds
     * @param all
     */
    public void removeUserInfoBatch(List<Long> userIds, boolean all);

    /**
     * 文件预览
     *
     * @param path
     * @return
     */
    public String filePreview(String path);

    String preViewPath(String path, String uploadType, String type, Boolean isExpire);

    /**
     * 根据orgId查询所有子机构ID集合
     *
     * @return
     */
    public Set<Long> listSubOrgIds(Long orgId);

    /**
     * 登录公用
     *
     * @param password
     * @param sysUser
     * @param appSource
     * @return
     */
    public LoginResult login(String password, SysUser sysUser, AppSourceEnum appSource) throws NoSuchAlgorithmException;

    public AuthOrgInfoDto authInfoCache(String code);

    void flushCache(String type);
}
