client_query.py
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# coding=utf-8
#author: qianyingz
#createtime: 2021/8/13
#email: qianyingz@chinadci.com
from .models import *
from app.util.component.ApiTemplate import ApiTemplate
from werkzeug.security import gen_salt
class Api(ApiTemplate):
api_name = "获取client列表"
def para_check(self):
pass
def process(self):
# 返回结果
res = {}
res["result"] = False
res["data"] = []
try:
# 默认值
name = self.para.get("name")
if name:
clients = OAuth2Client.query.filter_by(client_name=name).all()
else:
clients = OAuth2Client.query.all()
for client in clients:
res["data"].append(
{'client_id': client.client_id,
'client_secret': client.client_secret,
'client_id_issued_at': client.client_id_issued_at,
'client_secret_expires_at': client.client_secret_expires_at,
'client_metadata': client.client_metadata,
'id': client.id,
'user_id': client.user_id
})
res["msg"] = "获取clients集合成功"
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["认证接口"],
"parameters": [
{"name": "name",
"in": "formData",
"type": "string",
"description": "客户端名称"}
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}