| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import api from '@/utils/http'
- // ==================== 用户管理 API(遗留,地磅独立用户;门户登录请用 authApi) ====================
- export interface User {
- id: string
- username: string
- role: string
- createdAt?: string
- }
- export interface UserCreate {
- username: string
- password: string
- role: string
- remark?: string
- }
- export interface UserUpdate {
- username?: string
- password?: string
- role?: string
- remark?: string
- }
- /** @deprecated 旧地磅用户 CRUD,门户体系下不再使用 */
- export const userApi = {
- list: async (): Promise<User[]> => {
- return api.get<User[]>({
- url: '/users'
- })
- },
- get: async (id: string): Promise<User> => {
- return api.get<User>({
- url: `/users/${id}`
- })
- },
- create: async (payload: UserCreate): Promise<User> => {
- return api.post<User>({
- url: '/users',
- data: payload
- })
- },
- update: async (id: string, payload: UserUpdate): Promise<User> => {
- return api.put<User>({
- url: `/users/${id}`,
- data: payload
- })
- },
- delete: async (id: string): Promise<void> => {
- return api.del({
- url: `/users/${id}`
- })
- }
- }
- /**
- * @deprecated 请使用 `@/api/authApi` 的 `fetchLogin`(门户 RSA + JWT)
- */
- export const UserService = {
- login: async (_username: string, _password: string): Promise<never> => {
- throw new Error('请使用 fetchLogin(@/api/authApi)登录门户账号')
- },
- getUserInfo: async (): Promise<never> => {
- throw new Error('请使用门户 /web/auth/current-user 获取用户信息')
- }
- }
|