chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,120 @@
|
||||
import { get, post, put, del } from '@/utils/request'
|
||||
|
||||
// 组织中心(租户级共享组织架构)API 封装,对应后端 /api/v1/org/*(routes_org.go)。
|
||||
// 部门/员工档案归租户所有;业务模块(企业培训/图纸标注/物料检核...)通过
|
||||
// module_key 在 org_module_members 上绑定各自角色,组织数据只维护一份。
|
||||
// 响应解包沿用 api/training 导出的 unwrap(调用方 import { unwrap } from '@/api/training')。
|
||||
|
||||
// 注意必须带 /api/v1 前缀(与其他 api 模块一致);axios baseURL 为 '/',
|
||||
// 缺前缀时请求会落入前端 SPA 回退路由,返回 index.html 而非接口数据。
|
||||
const base = '/api/v1/org'
|
||||
|
||||
export type OrgModuleKey = string
|
||||
|
||||
/** 企业培训模块的 module_key(组织中心首个接入模块)。 */
|
||||
export const ORG_MODULE_TRAINING: OrgModuleKey = 'training'
|
||||
|
||||
export interface OrgDept {
|
||||
id: string
|
||||
tenant_id: number
|
||||
parent_id: string
|
||||
name: string
|
||||
code: string
|
||||
sort: number
|
||||
}
|
||||
|
||||
/** 模块绑定行(org_module_members):某模块在某员工上的角色/扩展属性。 */
|
||||
export interface OrgModuleMember {
|
||||
id: string
|
||||
tenant_id: number
|
||||
module_key: OrgModuleKey
|
||||
employee_id: string
|
||||
roles: string[]
|
||||
extra: Record<string, any>
|
||||
}
|
||||
|
||||
export interface OrgEmployee {
|
||||
id: string
|
||||
tenant_id: number
|
||||
user_id: string
|
||||
employee_no: string
|
||||
dept_id: string
|
||||
post: string
|
||||
lecturer_rate: number
|
||||
status: string
|
||||
/** 联查展示字段:用户姓名/部门名称/指定 module_key 的绑定角色 */
|
||||
user_name?: string
|
||||
dept_name?: string
|
||||
roles?: string[]
|
||||
}
|
||||
|
||||
export interface OrgListQuery {
|
||||
module_key?: string
|
||||
dept_id?: string
|
||||
keyword?: string
|
||||
page?: number
|
||||
page_size?: number
|
||||
}
|
||||
|
||||
export interface OrgPagedData<T> {
|
||||
items: T[]
|
||||
total: number
|
||||
}
|
||||
|
||||
// ---- 部门 ----
|
||||
|
||||
export const listDepts = () => get<{ success: boolean; data: OrgDept[] }>(`${base}/depts`)
|
||||
|
||||
/** 新增/修改部门:id 为空走新增,否则更新。 */
|
||||
export const saveDept = (payload: Partial<OrgDept>) =>
|
||||
post<{ success: boolean; data: OrgDept }>(`${base}/depts`, payload)
|
||||
|
||||
export const deleteDept = (id: string) => del<{ success: boolean }>(`${base}/depts/${enc(id)}`)
|
||||
|
||||
// ---- 员工档案 ----
|
||||
|
||||
export const listEmployees = (query?: OrgListQuery) =>
|
||||
get<{ success: boolean; data: OrgPagedData<OrgEmployee> }>(`${base}/employees`, { params: query })
|
||||
|
||||
export interface OrgPlatformUser {
|
||||
id: string
|
||||
username: string
|
||||
email: string
|
||||
/** 姓名(OIDC displayName claim),可能为空 */
|
||||
display_name?: string
|
||||
in_roster: boolean
|
||||
}
|
||||
|
||||
export const listPlatformUsers = () =>
|
||||
get<{ success: boolean; data: OrgPlatformUser[] }>(`${base}/platform-users`)
|
||||
|
||||
export interface OrgImportEmployee {
|
||||
user_id: string
|
||||
employee_no?: string
|
||||
dept_id: string
|
||||
post?: string
|
||||
status?: string
|
||||
}
|
||||
|
||||
/** 批量导入员工档案(部门必填,须为已维护部门)。 */
|
||||
export const importEmployees = (employees: OrgImportEmployee[]) =>
|
||||
post<{ success: boolean; data: { imported: number } }>(`${base}/employees/import`, { employees })
|
||||
|
||||
// ---- 模块角色绑定 ----
|
||||
|
||||
export const listModuleMembers = (moduleKey: OrgModuleKey) =>
|
||||
get<{ success: boolean; data: OrgModuleMember[] }>(
|
||||
`${base}/modules/${enc(moduleKey)}/members`,
|
||||
)
|
||||
|
||||
export const putModuleMember = (moduleKey: OrgModuleKey, employeeId: string, roles: string[]) =>
|
||||
put<{ success: boolean; data: OrgModuleMember }>(
|
||||
`${base}/modules/${enc(moduleKey)}/members/${enc(employeeId)}`,
|
||||
{ roles },
|
||||
)
|
||||
|
||||
// ---- 内部小工具 ----
|
||||
|
||||
function enc(value: string) {
|
||||
return encodeURIComponent(value)
|
||||
}
|
||||
Reference in new issue
Block a user