import api, { PageResponse, unwrap } from './request'; export interface UserResp { userId: number; loginId: string; userName: string; email?: string; phone?: string; agentId?: number; agentName?: string; orgName?: string; status: string; failCount?: number; lastLoginAt?: string; createdAt?: string; roleCodes?: string[]; } export interface UserSaveReq { loginId: string; userName: string; email?: string; phone?: string; agentId?: number; status?: string; password?: string; roleIds?: number[]; } export const userApi = { list: (p: { searchKeyword?: string; status?: string; pageNum?: number; pageSize?: number }) => unwrap>(api.get('/api/system/users', { params: p })), detail: (id: number) => unwrap(api.get(`/api/system/users/${id}`)), create: (req: UserSaveReq) => unwrap(api.post('/api/system/users', req)), update: (id: number, req: UserSaveReq) => unwrap(api.put(`/api/system/users/${id}`, req)), resetPassword: (id: number) => unwrap(api.put(`/api/system/users/${id}/reset-password`)), unlock: (id: number) => unwrap(api.put(`/api/system/users/${id}/unlock`)), }; export interface RoleVO { roleId: number; roleCode: string; roleName: string; roleDesc?: string; roleLevel: number; isSystem: string; isActive: string; } export const roleApi = { list: () => unwrap(api.get('/api/system/roles')), detail: (id: number) => unwrap(api.get(`/api/system/roles/${id}`)), permissions: (id: number) => unwrap>(api.get(`/api/system/roles/${id}/permissions`)), create: (vo: Partial) => unwrap(api.post('/api/system/roles', vo)), update: (id: number, vo: Partial) => unwrap(api.put(`/api/system/roles/${id}`, vo)), savePermissions: (id: number, perms: Array<{ menuId: number; permCode: string; isGranted: string }>) => unwrap(api.put(`/api/system/roles/${id}/permissions`, perms)), }; export interface CommonCodeGroup { groupCode: string; groupName: string; description?: string; isSystem: string; isActive: string; sortOrder: number; } export interface CommonCode { codeId: number; groupCode: string; code: string; codeName: string; codeDesc?: string; sortOrder: number; isActive: string; } export const commonCodeApi = { groups: (keyword?: string) => unwrap(api.get('/api/common/codes/groups', { params: { keyword } })), codes: (groupCode: string) => unwrap(api.get(`/api/common/codes/groups/${groupCode}/codes`)), createGroup: (vo: Partial) => unwrap(api.post('/api/common/codes/groups', vo)), updateGroup: (groupCode: string, vo: Partial) => unwrap(api.put(`/api/common/codes/groups/${groupCode}`, vo)), createCode: (groupCode: string, vo: Partial) => unwrap(api.post(`/api/common/codes/groups/${groupCode}/codes`, vo)), updateCode: (codeId: number, vo: Partial) => unwrap(api.put(`/api/common/codes/codes/${codeId}`, vo)), deleteCode: (codeId: number) => unwrap(api.delete(`/api/common/codes/codes/${codeId}`)), };