File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,29 @@ async def option_pager(
4242 stmt = stmt ,
4343 pagination = pagination ,
4444 )
45+
46+ @router .get ("/uws/option" , response_model = UserWsOption )
47+ async def option_user (
48+ session : SessionDep ,
49+ current_user : CurrentUser ,
50+ keyword : str = Query (description = "搜索关键字" )
51+ ):
52+ if (not current_user .isAdmin ) and current_user .weight == 0 :
53+ raise RuntimeError ("no permission to execute this api" )
54+ oid = current_user .oid
55+
56+ stmt = select (UserModel .id , UserModel .account , UserModel .name ).where (
57+ ~ exists ().where (UserWsModel .uid == UserModel .id , UserWsModel .oid == oid )
58+ )
59+
60+ if keyword :
61+ stmt = stmt .where (
62+ or_ (
63+ UserModel .account == int (keyword ),
64+ UserModel .name == keyword ,
65+ )
66+ )
67+ return session .exec (stmt ).first ()
4568
4669@router .get ("/uws/pager/{pageNum}/{pageSize}" , response_model = PaginatedResponse [WorkspaceUser ])
4770async def pager (
You can’t perform that action at this time.
0 commit comments