增加注册功能

This commit is contained in:
2026-04-12 15:10:22 +08:00
parent 3b1bd94dce
commit 05ee0929e2
21 changed files with 409 additions and 4 deletions

View File

@@ -28,3 +28,35 @@ export async function findSubordinates(managerId: number): Promise<UserRow[]> {
);
return rows as UserRow[];
}
export interface CreateUserInput {
username: string;
password: string;
name: string;
role?: UserRole;
department: string;
position: string;
manager_id?: number | null;
status?: 'active' | 'inactive';
}
export async function createUser(userData: CreateUserInput): Promise<number> {
const {
username,
password,
name,
role = 'employee',
department,
position,
manager_id = null,
status = 'active'
} = userData;
const [result] = await pool.query<any>(
`INSERT INTO user (username, password, name, role, department, position, manager_id, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
[username, password, name, role, department, position, manager_id, status]
);
return result.insertId;
}