File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 :copyright: © 2020 by the Lin team.
33 :license: MIT, see LICENSE for more details.
44"""
5+ import os
6+ from uuid import uuid4
7+
8+ from lin import SpecTree
9+
10+ if os .getenv ("FLASK_ENV" , "production" ) == "production" :
11+ # spectree 暂未提供关闭文档功能,production部署变更随机路径
12+ lindoc = SpecTree (
13+ backend_name = "flask" ,
14+ title = "Lin-CMS API" ,
15+ mode = "strict" ,
16+ path = "/" .join (str (uuid4 ()).split ("-" )),
17+ )
18+ else :
19+ lindoc = SpecTree (
20+ backend_name = "flask" ,
21+ title = "Lin-CMS API" ,
22+ mode = "strict" ,
23+ )
Original file line number Diff line number Diff line change 11import math
22
33from flask import g
4- from lin import DocResponse , lindoc , permission_meta
4+ from lin import DocResponse , permission_meta
55from lin .db import db
66from lin .jwt import group_required
77from lin .logger import Log
88from lin .redprint import Redprint
99from sqlalchemy import text
1010
11+ from app .api import lindoc
1112from app .validator .schema import (
1213 AuthorizationSchema ,
1314 LogListSchema ,
@@ -65,13 +66,11 @@ def get_users_for_log():
6566 """
6667 获取所有记录行为日志的用户名
6768 """
68- usernames_dict = db .query (
69- """
70- SELECT l.username
71- FROM lin_log l
72- WHERE l.delete_time IS NULL
73- GROUP BY l.username
74- HAVING COUNT(l.username) > 0
75- """
76- ).as_dict ()
77- return NameListSchema (items = [ud .get ("username" ) for ud in usernames_dict ])
69+ usernames = (
70+ db .session .query (Log .username )
71+ .filter_by (soft = False )
72+ .group_by (text ("username" ))
73+ .having (text ("count(username) > 0" ))
74+ .all ()
75+ )
76+ return NameListSchema (items = [u .username for u in usernames ])
Original file line number Diff line number Diff line change 66"""
77
88from flask import g , request
9- from lin import DocResponse , lindoc , permission_meta
9+ from lin import DocResponse , permission_meta
1010from lin .exception import Success
1111from lin .jwt import group_required , login_required
1212from lin .redprint import Redprint
1313
14+ from app .api import lindoc
1415from app .exception .api import BookNotFound
1516from app .model .v1 .book import Book
1617from app .validator .schema import (
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def register_blueprints(app):
1616
1717
1818def register_lindoc (app ):
19- from lin import lindoc
19+ from app . api import lindoc
2020
2121 lindoc .register (app )
2222
Original file line number Diff line number Diff line change 1- # Lin-CMS==0.3.0a5
1+ Lin-CMS == 0.3.0a5
22Flask-Cors == 3.0.9
33python-dotenv == 0.15.0
44oss2 == 2.13.1
You can’t perform that action at this time.
0 commit comments