chore: initial commit
This commit is contained in:
35
src/api/system/user.ts
Normal file
35
src/api/system/user.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { http } from '@/lib'
|
||||
import type { SysRole, SysUser, SysUserFormOutput, SysUserInfo } from '@/schemas'
|
||||
import { type PageParams } from '@/schemas'
|
||||
|
||||
export const getSysUsers = (params: PageParams) => {
|
||||
return http.get<SysUser[], ApiPageResponse<SysUser>>('/user', { params })
|
||||
}
|
||||
|
||||
export const getSysUserRoles = (id: number) => {
|
||||
return http.get<SysRole[]>(`/user/${id}/roles`)
|
||||
}
|
||||
|
||||
export const getSysUserInfo = () => {
|
||||
return http.get<SysUserInfo>('/user/info')
|
||||
}
|
||||
|
||||
export const updateSysUser = (id: number, data: SysUserFormOutput) => {
|
||||
return http.patch('/user/' + id, data)
|
||||
}
|
||||
|
||||
export const createSysUser = (data: SysUserFormOutput) => {
|
||||
return http.post('/user', data)
|
||||
}
|
||||
|
||||
export const deleteSysUser = (id: number) => {
|
||||
return http.delete(`/user/${id}`)
|
||||
}
|
||||
|
||||
export const assignSysUserRoles = (id: number, role_ids: number[]) => {
|
||||
return http.put(`user/${id}/roles`, { role_ids })
|
||||
}
|
||||
|
||||
export const changeSysUserPassword = (id: number, password: string) => {
|
||||
return http.patch(`/user/${id}/password`, { password })
|
||||
}
|
||||
Reference in New Issue
Block a user