管理员为用户添加临时权限

This commit is contained in:
2025-07-05 00:24:11 +08:00
parent ddfc8e98c6
commit ebf7a5125b
5 changed files with 190 additions and 18 deletions

View File

@@ -116,3 +116,84 @@ export const adminAddTempPrivilege = async (uuid, privilege, exp_time) => {
throw error;
}
}
/**
* 获取用户信息
* 路由: /user/get
* 方法: GET
* 参数: uuid | name | qq_code (优先级: uuid > name > qq_code)
* @param {Object} params - 查询参数 { uuid, name, qq_code }
* @returns {Promise<Object>} 用户信息对象
*/
export const getUserByInfo = async (params = {}) => {
try {
const response = await axiosInstance.get('/user/get', { params });
return response.data;
} catch (error) {
throw error;
}
}
/**
* 修改用户名
* 路由: /user/changename
* 方法: PUT
* 需要登录
* @param {string} name - 新用户名
* @returns {Promise<void>} 无返回值,成功即为修改成功
*/
export const changeUserName = async (name) => {
try {
await axiosInstance.put('/user/changename', { name });
} catch (error) {
throw error;
}
}
/**
* 用户请求修改密码(发送重置请求)
* 路由: /user/resetpassword
* 方法: POST
* 需要登录
* @returns {Promise<void>} 无返回值,成功即为请求成功
*/
export const requestResetPassword = async () => {
try {
await axiosInstance.post('/user/resetpassword');
} catch (error) {
throw error;
}
}
/**
* 用户修改密码
* 路由: /user/resetpassword
* 方法: PUT
* 需要登录
* @param {string} token - 请求token
* @param {string} password - 新密码
* @returns {Promise<void>} 无返回值,成功即为修改成功
*/
export const resetPassword = async (token, password) => {
try {
await axiosInstance.put('/user/resetpassword', { token, password });
} catch (error) {
throw error;
}
}
/**
* 获取用户临时权限信息
* 路由: /user/temp_privilege
* 方法: GET
* 需要登录
* @returns {Promise<Object>} 返回一个包含临时权限信息的Promise对象
*/
export const getTempPrivilege = async () => {
try {
const response = await axiosInstance.get('/user/temp_privilege');
return response.data;
} catch (error) {
throw error;
}
}