import httpClient from '@/services/http'
import { CommonFetchOptions } from '@/services/http/types'
import { useUserStore } from '@/stores'

const userStore = useUserStore()

/**
 * 管理员查询
 */
export function querySystemmanager(options: CommonFetchOptions<{ request: Model.SystemmanagerReq; response: Model.SystemmanagerRsp[]; }>) {
    if (options.data) {
        options.data.releType = userStore.userInfo.releType.toString()
    }
    return httpClient.commonRequest('/systemmanager/query', 'get', options)
}

/**
 * 获取当前管理员详情信息
 */
export function querySystemmanagerDetail(options: CommonFetchOptions<{ request: Model.SystemmanagerDetailReq; response: Model.SystemmanagerRsp; }>) {
    return httpClient.commonRequest('/systemmanager/queryDetail', 'get', options)
}

/**
 * 处理管理员信息
 */
export function dealUserMsg(options: CommonFetchOptions<{ request: Partial<Model.DealUserMsgReq>; }>) {
    return httpClient.commonRequest('/systemmanager/dealUserMsg', 'post', options)
}

/**
 * 处理管理员状态
 */
export function dealUserStatus(options: CommonFetchOptions<{ request: Model.DealUserStatusReq; }>) {
    return httpClient.commonRequest('/systemmanager/dealUserStatus', 'post', options)
}

/**
 * 获取角色菜单列表信息
 */
export function queryRole(options: CommonFetchOptions<{ request: Model.RoleReq; response: Model.RoleRsp[]; }>) {
    return httpClient.commonRequest('/role/query', 'get', options)
}

/**
 * 获取添加管理员获取角色菜单列表
 */
export function queryRoleByAdd(options: CommonFetchOptions<{ response: Model.RoleRsp[]; }>) {
    return httpClient.commonRequest('/role/queryByAdd', 'get', options)
}

/**
 * 获取当前角色详情信息
 */
export function queryDetail(options: CommonFetchOptions<{ request: Model.RoleDetailReq; response: Model.RoleRsp; }>) {
    return httpClient.commonRequest('/role/queryDetail', 'get', options)
}

/**
 * 会员机构管理-->机构管理-->系统角色管理-->获取当前角色关联关系
 */
export function queryRoleUser(options: CommonFetchOptions<{ request: Model.RoleUserReq; response: Model.RoleUserRsp[]; }>) {
    return httpClient.commonRequest('/organDetail/queryRoleUser', 'get', options)
}

/**
 * 处理角色菜单信息
 */
export function dealRoleMenus(options: CommonFetchOptions<{ request: Partial<Model.RoleRsp>; }>) {
    return httpClient.commonRequest('/role/dealRoleMenus', 'post', options)
}

/**
 * 删除角色菜单信息
 */
export function deleteRoleMenus(options: CommonFetchOptions<{ request: Partial<Model.RoleRsp>; }>) {
    return httpClient.commonRequest('/role/deleteRoleMenus', 'post', options)
}