增加注册功能
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user