Files
labelmain-demo/components/label/api/user/index.ts
2026-04-11 17:37:09 +08:00

99 lines
2.5 KiB
TypeScript

import httpFetch from "@/api/fetch"
import { BASE_LABEL_API } from "../const"
import { Organization, User } from "./typing"
// 获取用户列表
export const getUserList = (data: User.ListRequest) => {
return httpFetch<User.ListResponse>({
url: BASE_LABEL_API + "/api/v1/label_server/user/list",
method: "POST",
body: JSON.stringify({ ...data, tenant: "cowarobot" }),
})
}
// 新增用户
export const userAdd = (data: User.CreateProps) => {
return httpFetch({
url: BASE_LABEL_API + "/api/v1/label_server/user/add",
method: "POST",
body: JSON.stringify(data),
})
}
// 批量导入用户
export const userImport = (data: { user_infos: any[] }) => {
return httpFetch<string[]>({
url: BASE_LABEL_API + "/api/v1/label_server/user/batch_add",
method: "POST",
body: JSON.stringify(data),
})
}
// 编辑用户
export const userEditById = (data: User.EditProps, id: number) => {
return httpFetch({
url: BASE_LABEL_API + `/api/v1/label_server/user/edit/${id}`,
method: "PUT",
body: JSON.stringify(data),
})
}
// 编辑用户组织
export const userUpdateGroup = (data: User.UpdateGroupProps) => {
return httpFetch({
url: BASE_LABEL_API + `/api/v1/label_server/user/update/group`,
method: "POST",
body: JSON.stringify(data),
})
}
// 获取用户组织树
export const getUserGroupTree = () => {
return httpFetch<Organization.Response[]>({
url: BASE_LABEL_API + "/api/v1/label_server/user/group/tree",
method: "GET",
})
}
// 新增用户组
export const userGroupAdd = (data: Organization.CreateProps) => {
return httpFetch({
url: BASE_LABEL_API + "/api/v1/label_server/user/group/add",
method: "POST",
body: JSON.stringify(data),
})
}
// 修改用户密码
export const modifyUserPassword = (data: {
old_password: string
new_password: string
}) => {
return httpFetch({
url: BASE_LABEL_API + "/api/v1/label_server/user/modify_password",
method: "PUT",
body: JSON.stringify(data),
})
}
/* ****************************** Options ****************************** */
interface Option {
label: string
value: string
}
// 获取所有用户组
export const getUserGroupAll = () => {
return httpFetch<Array<Option>>({
url: BASE_LABEL_API + `/api/v1/label_server/user/group/all`,
method: "GET",
})
}
// 获取所有用户
export const getUserAll = () => {
return httpFetch<Array<Option>>({
url: BASE_LABEL_API + "/api/v1/label_server/user/all",
method: "GET",
})
}