feat(admin): 部门管理改造为组织树形结构
This commit is contained in:
1 parent
c5b7cc662b
commit
48fe19ed71
21 files changed
+1086
-234
No files matched your search
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
backend/app/api/admin/departments.py
|
||||
|
||||
用途:管理后台部门 CRUD API(薄路由层)。
|
||||
用途:管理后台部门 CRUD API(薄路由层,树形结构)。
|
||||
依赖:admin.blueprint、services/admin/department_service。
|
||||
逻辑:/departments* 路由。
|
||||
逻辑:/departments 平铺列表(兼容旧消费方)、/departments/tree 树、成员名单(支持含下级)。
|
||||
"""
|
||||
from flask import jsonify, request
|
||||
|
||||
@@ -15,10 +15,17 @@ from app.services.admin import department_service
|
||||
@admin_bp.route('/departments', methods=['GET'])
|
||||
@require_admin
|
||||
def list_departments():
|
||||
"""返回全部部门列表。"""
|
||||
"""返回全部部门平铺列表(旧消费方兼容:部门下拉等)。"""
|
||||
return jsonify(department_service.list_departments())
|
||||
|
||||
|
||||
@admin_bp.route('/departments/tree', methods=['GET'])
|
||||
@require_admin
|
||||
def department_tree():
|
||||
"""返回完整部门树(children 嵌套,成员数含下级递归汇总)。"""
|
||||
return jsonify(department_service.list_department_tree())
|
||||
|
||||
|
||||
@admin_bp.route('/departments', methods=['POST'])
|
||||
@require_admin
|
||||
def create_department():
|
||||
@@ -31,8 +38,9 @@ def create_department():
|
||||
@admin_bp.route('/departments/<int:id>/members', methods=['GET'])
|
||||
@require_admin
|
||||
def list_department_members(id: int):
|
||||
"""返回部门员工数量与名单。"""
|
||||
return jsonify(department_service.list_department_members(id))
|
||||
"""返回部门员工数量与名单;include_descendants=1 时含全部下级部门成员。"""
|
||||
include_descendants = request.args.get('include_descendants', '') in ('1', 'true')
|
||||
return jsonify(department_service.list_department_members(id, include_descendants))
|
||||
|
||||
|
||||
@admin_bp.route('/departments/<int:id>', methods=['PUT'])
|
||||
|
||||
Reference in new issue
Block a user