Skip to content

Commit fe1bc10

Browse files
committed
refactor: clean up code formatting and remove unnecessary lines in portal module
1 parent 9cdc09d commit fe1bc10

5 files changed

Lines changed: 219 additions & 266 deletions

File tree

‎apps/portal/api/portal.py‎

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# coding=utf-8
22
"""
3-
@project: MaxKB
4-
@Author:MaxKB
5-
@file: portal.py
6-
@date:2026/8/3
7-
@desc: 门户API文档
3+
@project: MaxKB
4+
@Author:MaxKB
5+
@file: portal.py
6+
@date:2026/8/3
7+
@desc: 门户API文档
88
"""
9+
910
from drf_spectacular.types import OpenApiTypes
1011
from drf_spectacular.utils import OpenApiParameter
1112

@@ -15,7 +16,6 @@
1516

1617

1718
class PortalAPI(APIMixin):
18-
1919
class Get(APIMixin):
2020
@staticmethod
2121
def get_response():
@@ -25,20 +25,20 @@ class Save(APIMixin):
2525
@staticmethod
2626
def get_request():
2727
return {
28-
'multipart/form-data': {
29-
'type': 'object',
30-
'properties': {
31-
'name': {'type': 'string', 'description': '门户名称'},
32-
'description': {'type': 'string', 'description': '门户描述'},
33-
'logo': {'type': 'string', 'format': 'binary', 'description': '门户Logo'},
34-
'tab_logo': {'type': 'string', 'format': 'binary', 'description': '浏览器Tab Logo'},
35-
'enable_public_access': {'type': 'boolean', 'description': '是否开启公开访问'},
36-
'enable_api': {'type': 'boolean', 'description': '是否开启API服务'},
37-
'enable_auth': {'type': 'boolean', 'description': '是否开启身份认证'},
38-
'auth_config': {'type': 'object', 'description': '身份认证配置'},
39-
'enable_cors': {'type': 'boolean', 'description': '是否开启跨域设置'},
40-
'cors_config': {'type': 'object', 'description': '跨域配置'},
41-
}
28+
"multipart/form-data": {
29+
"type": "object",
30+
"properties": {
31+
"name": {"type": "string", "description": "门户名称"},
32+
"description": {"type": "string", "description": "门户描述"},
33+
"logo": {"type": "string", "format": "binary", "description": "门户Logo"},
34+
"tab_logo": {"type": "string", "format": "binary", "description": "浏览器Tab Logo"},
35+
"enable_public_access": {"type": "boolean", "description": "是否开启公开访问"},
36+
"enable_api": {"type": "boolean", "description": "是否开启API服务"},
37+
"enable_auth": {"type": "boolean", "description": "是否开启身份认证"},
38+
"auth_config": {"type": "object", "description": "身份认证配置"},
39+
"enable_cors": {"type": "boolean", "description": "是否开启跨域设置"},
40+
"cors_config": {"type": "object", "description": "跨域配置"},
41+
},
4242
}
4343
}
4444

@@ -51,24 +51,24 @@ class Application(APIMixin):
5151
def get_parameters():
5252
return [
5353
OpenApiParameter(
54-
name='current_page',
55-
description='当前页码',
54+
name="current_page",
55+
description="当前页码",
5656
type=OpenApiTypes.INT,
57-
location='path',
57+
location="path",
5858
required=True,
5959
),
6060
OpenApiParameter(
61-
name='page_size',
62-
description='每页数量',
61+
name="page_size",
62+
description="每页数量",
6363
type=OpenApiTypes.INT,
64-
location='path',
64+
location="path",
6565
required=True,
6666
),
6767
OpenApiParameter(
68-
name='name',
69-
description='应用名称搜索',
68+
name="name",
69+
description="应用名称搜索",
7070
type=OpenApiTypes.STR,
71-
location='query',
71+
location="query",
7272
required=False,
7373
),
7474
]
@@ -101,24 +101,24 @@ class Conversation(APIMixin):
101101
def get_parameters():
102102
return [
103103
OpenApiParameter(
104-
name='current_page',
105-
description='当前页码',
104+
name="current_page",
105+
description="当前页码",
106106
type=OpenApiTypes.INT,
107-
location='path',
107+
location="path",
108108
required=True,
109109
),
110110
OpenApiParameter(
111-
name='page_size',
112-
description='每页数量',
111+
name="page_size",
112+
description="每页数量",
113113
type=OpenApiTypes.INT,
114-
location='path',
114+
location="path",
115115
required=True,
116116
),
117117
OpenApiParameter(
118-
name='name',
119-
description='应用名称搜索',
118+
name="name",
119+
description="应用名称搜索",
120120
type=OpenApiTypes.STR,
121-
location='query',
121+
location="query",
122122
required=False,
123123
),
124124
]

‎apps/portal/models/portal.py‎

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# coding=utf-8
22

33
import uuid_utils.compat as uuid
4-
from common.encoder.encoder import SystemEncoder
54
from common.mixins.app_model_mixin import AppModelMixin
65
from django.db import models
76

@@ -11,74 +10,29 @@ class Portal(AppModelMixin):
1110
门户配置
1211
"""
1312

14-
id = models.UUIDField(
15-
primary_key=True,
16-
max_length=128,
17-
default=uuid.uuid7,
18-
editable=False,
19-
verbose_name="主键id"
20-
)
13+
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
2114

2215
# 基础信息
23-
name = models.CharField(
24-
max_length=64,
25-
verbose_name="门户名称",
26-
default="智能体门户"
27-
)
16+
name = models.CharField(max_length=64, verbose_name="门户名称", default="智能体门户")
2817

29-
description = models.TextField(
30-
null=True,
31-
blank=True,
32-
max_length=256,
33-
verbose_name="门户描述"
34-
)
18+
description = models.TextField(null=True, blank=True, max_length=256, verbose_name="门户描述")
3519

36-
logo = models.CharField(
37-
max_length=512,
38-
null=True,
39-
blank=True,
40-
verbose_name="门户Logo地址"
41-
)
20+
logo = models.CharField(max_length=512, null=True, blank=True, verbose_name="门户Logo地址")
4221

43-
tab_logo = models.CharField(
44-
max_length=512,
45-
null=True,
46-
blank=True,
47-
verbose_name="浏览器Tab Logo地址"
48-
)
22+
tab_logo = models.CharField(max_length=512, null=True, blank=True, verbose_name="浏览器Tab Logo地址")
4923

50-
enable_public_access = models.BooleanField(
51-
default=True,
52-
verbose_name="是否开启公开访问"
53-
)
24+
enable_public_access = models.BooleanField(default=True, verbose_name="是否开启公开访问")
5425
# API服务配置
55-
enable_api = models.BooleanField(
56-
default=True,
57-
verbose_name="是否开启API服务"
58-
)
26+
enable_api = models.BooleanField(default=True, verbose_name="是否开启API服务")
5927

6028
# 身份认证配置
61-
enable_auth = models.BooleanField(
62-
default=False,
63-
verbose_name="是否开启身份认证"
64-
)
29+
enable_auth = models.BooleanField(default=False, verbose_name="是否开启身份认证")
6530

66-
auth_config = models.JSONField(
67-
default=dict,
68-
blank=True,
69-
verbose_name="身份认证配置"
70-
)
31+
auth_config = models.JSONField(default=dict, blank=True, verbose_name="身份认证配置")
7132

72-
enable_cors = models.BooleanField(
73-
default=False,
74-
verbose_name="是否开启跨域设置"
75-
)
33+
enable_cors = models.BooleanField(default=False, verbose_name="是否开启跨域设置")
7634

77-
cors_config = models.JSONField(
78-
default=dict,
79-
blank=True,
80-
verbose_name="跨域配置"
81-
)
35+
cors_config = models.JSONField(default=dict, blank=True, verbose_name="跨域配置")
8236

8337
class Meta:
84-
db_table = "portal"
38+
db_table = "portal"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# coding=utf-8
2-
from .portal import *

0 commit comments

Comments
 (0)