refactor(backend): 重构后端代码 wave 3
This commit is contained in:
1 parent
affe139bf9
commit
8415653365
97 files changed
+4673
-6164
No files matched your search
@@ -1,4 +1,5 @@
|
||||
/** 请假(leave)子模块 barrel:纯函数 + handler 工厂 */
|
||||
export * from './leave.api';
|
||||
export * from './leaveDateTime';
|
||||
export * from './leaveDisplay';
|
||||
export * from './leaveIntent';
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* features/chat/leave/leave.api.ts
|
||||
* 用途:封装聊天请假流程的余额查询与 OA 工作流提交请求。
|
||||
* 依赖:shared/utils/auth、shared/api/client。
|
||||
* 逻辑:聊天请假表单调用本模块;后端暂保留 /api/user/leave-* 路径以兼容既有接口。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { LeaveRequestFormData } from '../types/leave.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
export interface LeaveBalanceResult {
|
||||
has_balance: boolean;
|
||||
leave_type_label: string;
|
||||
year: number;
|
||||
total_hours: number | null;
|
||||
used_hours: number | null;
|
||||
remaining_hours: number | null;
|
||||
}
|
||||
|
||||
/** 查询当前用户指定假别的可用余额。 */
|
||||
export const getLeaveBalance = (leaveType: string) =>
|
||||
requestJson<LeaveBalanceResult>(`/api/user/leave-balance?leave_type=${encodeURIComponent(leaveType)}`, auth());
|
||||
|
||||
export interface LeaveWorkflowSubmitResult {
|
||||
request_id?: string;
|
||||
submitted_at?: string;
|
||||
request_name?: string;
|
||||
}
|
||||
|
||||
/** 将聊天内确认后的请假表单提交至 OA 工作流。 */
|
||||
export const submitLeaveWorkflow = (form: LeaveRequestFormData) =>
|
||||
requestJson<LeaveWorkflowSubmitResult>('/api/user/leave-workflow/submit', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 请假:表单初始数据、校验、余额断言、确认与 OA 提交。
|
||||
*/
|
||||
import { getLeaveBalance, submitLeaveWorkflow } from '@/features/auth/api/user.api';
|
||||
import { getLeaveBalance, submitLeaveWorkflow } from './leave.api';
|
||||
import { NEED_BALANCE_CHECK_TYPES } from '../constants/leave';
|
||||
import { formatLeaveBalanceNumber, getLeaveTypeLabel } from './leaveDisplay';
|
||||
import {
|
||||
|
||||
Reference in new issue
Block a user