feat(oa): 评论@人员优先展示同部门用户
OA 评论选人列表改为请求 users/options 时按当前登录用户部门优先排序,Web 与移动 OA 共用后端稳定排序,便于先选到同部门同事。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7751cc0f4a
commit
f9aa16ef31
6 files changed
+71
-7
No files matched your search
@@ -29,6 +29,7 @@ from app.crud import user as user_svc
|
||||
from app.crud.collection_protocol import _lookup_attachment_by_url
|
||||
from app.models.models import BizAttachment, SysDept, SysRole, SysUser, SysMenu, SysPost
|
||||
from app.services.permission_administration import validate_tenant_references
|
||||
from app.services.user_select_options import prioritize_caller_dept_options
|
||||
from app.services.web_auth_roles import (
|
||||
_map_role_name_to_web,
|
||||
list_user_ids_with_effective_role_name,
|
||||
@@ -77,12 +78,15 @@ async def list_roles_for_select(
|
||||
@router.get("/users/options")
|
||||
async def list_users_for_select(
|
||||
roleName: Optional[str] = Query(None, alias="roleName"),
|
||||
prioritizeCallerDept: bool = Query(False, alias="prioritizeCallerDept"),
|
||||
_user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""返回用户下拉选项(label=昵称,value=用户ID),供流程设计器审批人选择使用。
|
||||
"""返回用户下拉选项(label=昵称,value=用户ID,deptId=部门ID)。
|
||||
|
||||
供流程设计器审批人选择、OA 评论 @ 人员等使用。
|
||||
可选 roleName:按有效角色(直接绑定 ∪ 职位继承)精确过滤。
|
||||
可选 prioritizeCallerDept:当前登录用户同部门人员排在前面(组内仍按创建时间倒序)。
|
||||
"""
|
||||
tenant_no = _user.get("tenant_no", "")
|
||||
q = db.query(SysUser).filter(SysUser.del_flag == 0, SysUser.status == "1")
|
||||
@@ -97,7 +101,16 @@ async def list_users_for_select(
|
||||
return success_response([])
|
||||
q = q.filter(SysUser.id.in_(matched_ids))
|
||||
rows = q.order_by(SysUser.create_time.desc()).distinct().all()
|
||||
out = [{"label": (r.nick_name or r.user_no or ""), "value": r.id} for r in rows]
|
||||
out = [
|
||||
{
|
||||
"label": (r.nick_name or r.user_no or ""),
|
||||
"value": r.id,
|
||||
"deptId": (r.dept_id or ""),
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
if prioritizeCallerDept:
|
||||
out = prioritize_caller_dept_options(out, _user.get("region_id") or "")
|
||||
return success_response(out)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user