initial commit
This commit is contained in:
0
apps/project/schemas/__init__.py
Normal file
0
apps/project/schemas/__init__.py
Normal file
BIN
apps/project/schemas/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/case.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/case.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/case.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/case.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/design.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/design.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/design.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/design.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/dut.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/dut.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/dut.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/dut.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/problem.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/problem.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/problem.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/problem.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/project.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/project.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/project.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/project.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/round.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/round.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/round.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/round.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/testDemand.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/testDemand.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/testDemand.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/testDemand.cpython-38.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/treeOperation.cpython-313.pyc
Normal file
BIN
apps/project/schemas/__pycache__/treeOperation.cpython-313.pyc
Normal file
Binary file not shown.
BIN
apps/project/schemas/__pycache__/treeOperation.cpython-38.pyc
Normal file
BIN
apps/project/schemas/__pycache__/treeOperation.cpython-38.pyc
Normal file
Binary file not shown.
121
apps/project/schemas/case.py
Normal file
121
apps/project/schemas/case.py
Normal file
@@ -0,0 +1,121 @@
|
||||
from pydantic import AliasChoices
|
||||
from apps.project.models import Case, CaseStep
|
||||
from ninja import Field, Schema, ModelSchema
|
||||
from typing import List, Union, Optional
|
||||
from datetime import date
|
||||
# 关联问题单
|
||||
from apps.project.schemas.problem import ProblemModelOutSchema
|
||||
|
||||
# 删除schema
|
||||
class DeleteSchema(Schema):
|
||||
ids: List[int]
|
||||
|
||||
# 测试步骤输出schema
|
||||
class CaseStepSchema(ModelSchema):
|
||||
class Config:
|
||||
model = CaseStep
|
||||
model_fields = ["operation", 'expect', 'result', 'passed', 'case', 'id']
|
||||
|
||||
# 测试用例的步骤输出schema,输出isPassed和isExe转换后的
|
||||
class CaseStepWithTransitionSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = CaseStep
|
||||
fields = ["operation", 'expect', 'result', 'passed', 'case', 'id']
|
||||
|
||||
# 输出case:不关联问题单和步骤
|
||||
class CaseModelOutSchemaWithoutProblem(ModelSchema):
|
||||
testStep: List[CaseStepWithTransitionSchema]
|
||||
testType: str # 用例额外字段,用于测试类型FT的标识给前端
|
||||
|
||||
class Config:
|
||||
model = Case
|
||||
model_exclude = ['project', 'round', 'dut', 'design', 'test', 'remark', 'sort']
|
||||
|
||||
# 输出case:关联问题单
|
||||
class CaseModelOutSchema(ModelSchema):
|
||||
testStep: List[CaseStepSchema]
|
||||
testType: str # 用例额外字段,用于测试类型FT的标识给前端
|
||||
# 新增:关联的问题单
|
||||
problem: Optional[ProblemModelOutSchema] = None
|
||||
|
||||
class Config:
|
||||
model = Case
|
||||
model_exclude = ['project', 'round', 'dut', 'design', 'test', 'remark', 'sort']
|
||||
|
||||
# 查询测试项
|
||||
class CaseFilterSchema(Schema):
|
||||
id: int = Field(None, alias='id')
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
round_id: str = Field(None, alias='round')
|
||||
dut_id: str = Field(None, alias='dut')
|
||||
design_id: str = Field(None, alias='designDemand')
|
||||
test_id: str = Field(None, alias='testDemand')
|
||||
# 其他字段
|
||||
ident: str = Field(None, alias='ident')
|
||||
name: str = Field(None, alias='name')
|
||||
designPerson: str = Field(None, alias='designPerson')
|
||||
testPerson: str = Field(None, alias='testPerson')
|
||||
monitorPerson: str = Field(None, alias='monitorPerson')
|
||||
summarize: str = Field(None, alias='summarize')
|
||||
|
||||
# 处理树状结构的schema
|
||||
class CaseTreeReturnSchema(Schema):
|
||||
title: str = Field(..., alias='title')
|
||||
key: str = Field(..., alias='key')
|
||||
level: str = Field(..., alias='level')
|
||||
# 3月13日新增字段,让case作为树状尾部节点
|
||||
isLeaf: bool = Field(True, alias='isLeaf')
|
||||
# 2024年6月6日新增:用于树图显示
|
||||
isRelatedProblem: bool = Field(False, alias='isRelatedProblem')
|
||||
isNotPassed: bool = Field(False, alias='isNotPassed')
|
||||
|
||||
class CaseTreeInputSchema(Schema):
|
||||
# 注意这里有alias
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
key: str = Field(None, alias='key')
|
||||
level: str = Field(None, alias='level')
|
||||
|
||||
# 增加测试用例
|
||||
class CaseCreateOutSchema(ModelSchema):
|
||||
level: Union[str, int]
|
||||
|
||||
class Config:
|
||||
model = Case
|
||||
model_exclude = ['remark', 'sort', 'project', 'round', 'dut', 'design']
|
||||
|
||||
# 新增接口schema
|
||||
class CaseInputSchema(Schema):
|
||||
operation: str = Field(None, alias="operation")
|
||||
expect: str = Field(None, alias="expect")
|
||||
result: str = Field(None, alias="result")
|
||||
passed: str = Field('3', alias="passed")
|
||||
|
||||
class CaseCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., validation_alias=AliasChoices('project_id', 'projectId'),
|
||||
serialization_alias='projectId')
|
||||
round_key: str = Field(None, alias="round")
|
||||
dut_key: str = Field(None, alias="dut")
|
||||
design_key: str = Field(None, alias="designDemand")
|
||||
test_key: str = Field(None, alias="testDemand")
|
||||
# 其他字段
|
||||
ident: str = Field('', alias='ident')
|
||||
name: str = Field('', alias='name')
|
||||
designPerson: str = Field('', alias='designPerson')
|
||||
testPerson: str = Field('', alias='testPerson')
|
||||
monitorPerson: str = Field('', alias='monitorPerson')
|
||||
summarize: str = Field('', alias='summarize')
|
||||
initialization: str = Field('', alias='initialization')
|
||||
premise: str = Field('', alias='premise')
|
||||
testStep: List[CaseInputSchema]
|
||||
# 新增执行时间字段
|
||||
exe_time: date = Field(None, alias='exe_time')
|
||||
# 新增时序图字段
|
||||
timing_diagram: str = Field("", alias="timing_diagram")
|
||||
|
||||
# 由demand创建case的输入Schema
|
||||
class DemandNodeSchema(Schema):
|
||||
project_id: int
|
||||
level: int = Field(3, gt=0)
|
||||
isLeaf: bool = False
|
||||
key: str = Field(None, alias='nodekey')
|
||||
title: str = Field(None)
|
||||
74
apps/project/schemas/design.py
Normal file
74
apps/project/schemas/design.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from apps.project.models import Design
|
||||
from ninja import Field, Schema, ModelSchema
|
||||
from typing import List, Union
|
||||
from pydantic import AliasChoices
|
||||
|
||||
# 删除schema
|
||||
class DeleteSchema(Schema):
|
||||
ids: List[int]
|
||||
|
||||
# 查询设计需求
|
||||
class DesignFilterSchema(Schema):
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
round_id: str = Field(None, alias='round')
|
||||
dut_id: str = Field(None, alias='dut')
|
||||
ident: str = Field(None, alias='ident')
|
||||
demandType: str = Field(None, alias='demandType')
|
||||
name: str = Field(None, alias='name')
|
||||
# 新增字段 - chapter
|
||||
chapter: str = Field(None, alias='chapter')
|
||||
|
||||
class DesignModelOutSchema(ModelSchema):
|
||||
class Config:
|
||||
model = Design
|
||||
model_exclude = ['project', 'round', 'dut', 'remark', 'sort']
|
||||
|
||||
# 处理树状结构的schema
|
||||
class DesignTreeReturnSchema(Schema):
|
||||
title: str = Field(..., alias='title')
|
||||
key: str = Field(..., alias='key')
|
||||
level: str = Field(..., alias='level')
|
||||
|
||||
class DesignTreeInputSchema(Schema):
|
||||
# 注意这里有alias
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
key: str = Field(None, alias='key')
|
||||
level: str = Field(None, alias='level')
|
||||
|
||||
# 增加设计需求/更新设计需求
|
||||
class DesignCreateOutSchema(ModelSchema):
|
||||
level: Union[str, int]
|
||||
|
||||
class Meta:
|
||||
model = Design
|
||||
exclude = ['remark', 'sort', 'project', 'round', 'dut']
|
||||
|
||||
# 新增接口schema
|
||||
class DesignCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., validation_alias=AliasChoices('project_id', 'projectId'),
|
||||
serialization_alias='projectId')
|
||||
round_key: str = Field(..., alias="round")
|
||||
dut_key: str = Field(..., alias="dut")
|
||||
ident: str = Field("", alias="ident")
|
||||
name: str = Field(None, alias="name")
|
||||
demandType: str = Field(None, alias="demandType")
|
||||
description: str = Field("", alias="description")
|
||||
chapter: str = Field(None, alias='chapter')
|
||||
# 接口独有的4个字段
|
||||
source: str = Field('', alias='source')
|
||||
to: str = Field('', alias='to')
|
||||
type: str = Field('', alias='type')
|
||||
protocal: str = Field('', alias='protocal')
|
||||
|
||||
class SingleDesignSchema(Schema):
|
||||
ident: str = Field(None, alias="ident")
|
||||
name: str = Field(None, alias="title")
|
||||
demandType: str = Field(None, alias="demandType")
|
||||
description: str = Field(None, alias="content")
|
||||
chapter: str = Field(None, alias='chapter')
|
||||
|
||||
# 批量新增design的Schema
|
||||
class MultiDesignCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., alias="projectId")
|
||||
dut_key: str = Field(..., alias="key")
|
||||
data: List[SingleDesignSchema]
|
||||
78
apps/project/schemas/dut.py
Normal file
78
apps/project/schemas/dut.py
Normal file
@@ -0,0 +1,78 @@
|
||||
from apps.project.models import Dut
|
||||
from ninja import Field, Schema, ModelSchema
|
||||
from typing import List, Union, Optional
|
||||
from datetime import date
|
||||
from pydantic import AliasChoices
|
||||
|
||||
class DutModelOutSchema(ModelSchema):
|
||||
class Config:
|
||||
model = Dut
|
||||
model_exclude = ['project', 'round', 'remark', 'sort']
|
||||
|
||||
class DutFilterSchema(Schema):
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
round_id: int = Field(None, alias='round')
|
||||
ident: str = Field(None, alias='ident')
|
||||
type: str = Field(None, alias='type')
|
||||
name: str = Field(None, alias='name')
|
||||
# 新增版本、单位
|
||||
version: str = Field(None, alias="version")
|
||||
release_union: str = Field(None, alias="release_union")
|
||||
|
||||
# 树状目录schema
|
||||
class DutTreeInputSchema(Schema):
|
||||
# 注意这里有alias
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
key: str = Field(None, alias='key')
|
||||
level: str = Field(None, alias='level')
|
||||
|
||||
class DutTreeReturnSchema(Schema):
|
||||
title: str = Field(..., alias='title')
|
||||
key: str = Field(..., alias='key')
|
||||
level: str = Field(..., alias='level')
|
||||
|
||||
# 新增接口schema
|
||||
class DutCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., validation_alias=AliasChoices('project_id', 'projectId'),
|
||||
serialization_alias='projectId')
|
||||
round_key: str = Field(..., alias="round")
|
||||
ident: str = Field(None, alias="ident")
|
||||
name: str = Field(None, alias="name")
|
||||
type: str = Field(None, alias="type")
|
||||
total_lines: Union[str, int] = Field(None, alias="total_lines")
|
||||
effective_lines: Union[str, int] = Field(None, alias="effective_lines")
|
||||
comment_lines: Union[str, int] = Field(None, alias="comment_lines")
|
||||
# 新增版本、单位、发布日期
|
||||
version: str = Field(None, alias="version")
|
||||
release_union: str = Field(None, alias="release_union")
|
||||
release_date: str = Field(None, alias="release_date")
|
||||
# 新增用户标识
|
||||
ref: str = Field(None, alias='ref')
|
||||
|
||||
# 不能去掉,这个决定前端动态刷新树状目录
|
||||
class DutCreateOutSchema(ModelSchema):
|
||||
level: Union[str, int]
|
||||
total_lines: Optional[Union[str, int]] = None
|
||||
effective_lines: Optional[Union[str, int]] = None
|
||||
comment_lines: Optional[Union[str, int]] = None
|
||||
|
||||
class Config:
|
||||
model = Dut
|
||||
model_exclude = ['remark', 'sort', 'project', 'round']
|
||||
|
||||
# 删除schema
|
||||
class DeleteSchema(Schema):
|
||||
ids: List[int]
|
||||
|
||||
# 第一轮如果没有源代码被测的新增so的schema
|
||||
class DutCreateR1SoDutSchema(Schema):
|
||||
project_id: int
|
||||
version: str
|
||||
ref: str = Field(..., alias='userRef')
|
||||
release_union: str = Field(..., alias='unit')
|
||||
release_date: date = Field(None, alias='date')
|
||||
total_lines: Union[str, int] = None
|
||||
effective_lines: Union[str, int] = None
|
||||
comment_lines: Union[str, int] = None
|
||||
# 5月17日新增轮次的key
|
||||
round_key: str
|
||||
122
apps/project/schemas/problem.py
Normal file
122
apps/project/schemas/problem.py
Normal file
@@ -0,0 +1,122 @@
|
||||
from apps.project.models import Problem
|
||||
from ninja import Field, Schema, ModelSchema
|
||||
from typing import List, Optional
|
||||
|
||||
# 删除schema
|
||||
class DeleteSchema(Schema):
|
||||
ids: List[int]
|
||||
|
||||
# 问题单-输出schema
|
||||
class ProblemModelOutSchema(ModelSchema):
|
||||
related: Optional[bool] = Field(False) # 给前端反应是否为关联的问题单
|
||||
hang: bool = Field(False) # 给前端反应是否是悬挂状态(即没有关联case)
|
||||
|
||||
class Config:
|
||||
model = Problem
|
||||
model_exclude = ['case', 'remark', 'sort']
|
||||
|
||||
# 查询问题单
|
||||
class ProblemFilterSchema(Schema):
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
round_id: str = Field(None, alias='round')
|
||||
dut_id: str = Field(None, alias='dut')
|
||||
design_id: str = Field(None, alias='designDemand')
|
||||
test_id: str = Field(None, alias='testDemand')
|
||||
case_id: str = Field(None, alias='case')
|
||||
key: str = Field(None, alias='key')
|
||||
# 其他字段
|
||||
ident: str = Field(None, alias='ident')
|
||||
name: str = Field(None, alias='name')
|
||||
status: str = Field(None, alias='status')
|
||||
type: str = Field(None, alias='type')
|
||||
grade: str = Field(None, alias='grade')
|
||||
operation: str = Field(None, alias='operation')
|
||||
postPerson: str = Field(None, alias='postPerson')
|
||||
|
||||
class ProblemFilterWithHangSchema(ProblemFilterSchema):
|
||||
# 搜索增加hang字段
|
||||
hang: str = Field('3', alias='hang')
|
||||
|
||||
# 处理树状结构的schema
|
||||
class ProblemTreeReturnSchema(Schema):
|
||||
title: str = Field(..., alias='title')
|
||||
key: str = Field(..., alias='key')
|
||||
level: str = Field(..., alias='level')
|
||||
isLeaf: bool = Field(..., alias='isLeaf')
|
||||
|
||||
class ProblemTreeInputSchema(Schema):
|
||||
# 注意这里有alias
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
key: str = Field(None, alias='key')
|
||||
level: str = Field(None, alias='level')
|
||||
isLeaf: bool = Field(None, alias='isLeaf')
|
||||
|
||||
# 增加问题单
|
||||
class ProblemCreateOutSchema(ModelSchema):
|
||||
class Config:
|
||||
model = Problem
|
||||
model_exclude = ['remark', 'sort', 'case']
|
||||
|
||||
# 更新,新增schema
|
||||
class ProblemCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., alias="projectId")
|
||||
round_key: str = Field(None, alias="round")
|
||||
dut_key: str = Field(None, alias="dut")
|
||||
design_key: str = Field(None, alias="designDemand")
|
||||
test_key: str = Field(None, alias="testDemand")
|
||||
case_key: str = Field(None, alias="case")
|
||||
# 其他字段
|
||||
ident: str = Field(None, alias='ident')
|
||||
name: str = Field(None, alias='name')
|
||||
grade: str = Field(None, alias='grade')
|
||||
operation: str = Field("", alias='operation') # !重要:由于保存到数据库为null,则查询空字符串无法查询出来
|
||||
result: str = Field("", alias='result') # 问题影响
|
||||
status: str = Field(None, alias='status')
|
||||
type: str = Field(None, alias='type')
|
||||
postPerson: str = Field(None, alias='postPerson')
|
||||
postDate: str = Field(None, alias='postDate')
|
||||
designerPerson: str = Field("", alias='designerPerson')
|
||||
designDate: str = Field(None, alias='designDate')
|
||||
verifyPerson: str = Field("", alias='verifyPerson')
|
||||
verifyDate: str = Field(None, alias='verifyDate')
|
||||
closeMethod: List[str]
|
||||
# 2024年3月27日新增-处理方式字段
|
||||
solve: Optional[str] = ""
|
||||
# 2024年5月13日新增
|
||||
analysis: str = Field("", alias='analysis')
|
||||
effect_scope: str = Field("", alias='effect_scope')
|
||||
verify_result: str = Field("", alias='verify_result')
|
||||
|
||||
# 不带round_key、dut_key、design_key、test_key、case_key的更新Schema
|
||||
class ProblemUpdateInputSchema(Schema):
|
||||
project_id: int = Field(..., alias="projectId")
|
||||
# 其他字段
|
||||
ident: str = Field(None, alias='ident')
|
||||
name: str = Field(None, alias='name')
|
||||
grade: str = Field(None, alias='grade')
|
||||
operation: str = Field(None, alias='operation')
|
||||
result: str = Field(None, alias='result')
|
||||
status: str = Field(None, alias='status')
|
||||
type: str = Field(None, alias='type')
|
||||
postPerson: str = Field(None, alias='postPerson')
|
||||
postDate: str = Field(None, alias='postDate')
|
||||
designerPerson: str = Field(None, alias='designerPerson')
|
||||
designDate: str = Field(None, alias='designDate')
|
||||
verifyPerson: str = Field(None, alias='verifyPerson')
|
||||
verifyDate: str = Field(None, alias='verifyDate')
|
||||
closeMethod: List[str]
|
||||
# 5月13日新增字段
|
||||
analysis: str = Field(None, alias='analysis')
|
||||
effect_scope: str = Field(None, alias='effect_scope')
|
||||
verify_result: str = Field(None, alias='verify_result')
|
||||
# 更新字段
|
||||
solve: Optional[str] = None
|
||||
|
||||
class ProblemSingleInputSchema(Schema):
|
||||
project_id: int = Field(..., alias="projectId")
|
||||
round_id: str = Field(..., alias="round")
|
||||
dut_id: str = Field(..., alias="dut")
|
||||
design_id: str = Field(..., alias="designDemand")
|
||||
test_id: str = Field(..., alias="testDemand")
|
||||
case_id: str = Field(..., alias="case")
|
||||
problem_id: str = Field(..., alias="problem")
|
||||
41
apps/project/schemas/project.py
Normal file
41
apps/project/schemas/project.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from ninja.errors import HttpError
|
||||
from apps.project.models import Project
|
||||
from ninja import Schema, ModelSchema
|
||||
from pydantic import field_validator
|
||||
from typing import List, Optional
|
||||
|
||||
window_file_str = ['\\', '/', ':', '*', '?', '"', '<', '>', "|"]
|
||||
|
||||
class ProjectRetrieveSchema(ModelSchema):
|
||||
class Config:
|
||||
model = Project
|
||||
model_exclude = ['update_datetime', 'create_datetime', 'remark']
|
||||
|
||||
class ProjectFilterSchema(Schema):
|
||||
ident: Optional[str] = None
|
||||
name: Optional[str] = None
|
||||
duty_person: Optional[str] = None
|
||||
security_level: Optional[str] = None
|
||||
report_type: Optional[str] = None
|
||||
step: Optional[str] = None
|
||||
# 新增软件类型:新研/改造
|
||||
soft_type: Optional[str] = None
|
||||
# 新增密级
|
||||
secret: Optional[str] = None
|
||||
|
||||
class ProjectCreateInput(ModelSchema):
|
||||
ident: str
|
||||
|
||||
class Config:
|
||||
model = Project
|
||||
model_exclude = ['remark', 'update_datetime', 'create_datetime', 'sort', 'id']
|
||||
|
||||
@field_validator('ident')
|
||||
@staticmethod
|
||||
def check_ident_window(val):
|
||||
if any(window_str in val for window_str in window_file_str):
|
||||
raise HttpError(400, message='标识包含window文件名不允许的特殊字符')
|
||||
return val
|
||||
|
||||
class DeleteSchema(Schema):
|
||||
ids: List[int]
|
||||
57
apps/project/schemas/round.py
Normal file
57
apps/project/schemas/round.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from typing import Optional
|
||||
from ninja import Schema, ModelSchema
|
||||
from pydantic import Field
|
||||
from apps.project.models import Round
|
||||
|
||||
# 输出树状信息的schema
|
||||
class TreeReturnRound(Schema):
|
||||
title: str = Field(..., alias='title')
|
||||
key: str = Field(..., alias='key')
|
||||
level: str = Field(..., alias='level')
|
||||
|
||||
class RoundInfoOutSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Round
|
||||
exclude = ('remark',)
|
||||
|
||||
class EditSchemaIn(Schema):
|
||||
beginTime: str
|
||||
best_condition_tem: Optional[str] = None
|
||||
best_condition_voltage: Optional[str] = None
|
||||
create_datetime: str
|
||||
endTime: str
|
||||
grade: str = '3'
|
||||
id: int
|
||||
ident: str
|
||||
key: str
|
||||
level: str
|
||||
low_condition_tem: Optional[str] = None
|
||||
low_condition_voltage: Optional[str] = None
|
||||
name: str
|
||||
project: int
|
||||
title: str
|
||||
update_datetime: str
|
||||
typical_condition_tem: Optional[str] = None
|
||||
typical_condition_voltage: Optional[str] = None
|
||||
# 新增
|
||||
location: str
|
||||
|
||||
class DeleteSchema(Schema):
|
||||
title: str
|
||||
key: str
|
||||
level: str
|
||||
|
||||
class CreateRoundOutSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Round
|
||||
exclude = ['remark']
|
||||
|
||||
class CreateRoundInputSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Round
|
||||
fields = ['beginTime', 'best_condition_tem', 'best_condition_voltage', 'endTime', 'grade', 'ident',
|
||||
'low_condition_tem', 'low_condition_voltage', 'name',
|
||||
'typical_condition_tem', 'typical_condition_voltage', 'key', 'location']
|
||||
fields_optional = ['best_condition_tem', 'best_condition_voltage',
|
||||
'low_condition_tem', 'low_condition_voltage', 'typical_condition_tem',
|
||||
'typical_condition_voltage' 'grade']
|
||||
104
apps/project/schemas/testDemand.py
Normal file
104
apps/project/schemas/testDemand.py
Normal file
@@ -0,0 +1,104 @@
|
||||
from apps.project.models import TestDemand, TestDemandContent, TestDemandContentStep
|
||||
from ninja import Field, Schema, ModelSchema
|
||||
from typing import List, Union, Optional
|
||||
from pydantic import AliasChoices
|
||||
|
||||
# 删除schema
|
||||
class DeleteSchema(Schema):
|
||||
ids: List[int]
|
||||
|
||||
# 测试项-输出schema -> 包含两层嵌套
|
||||
class TestContentStepSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = TestDemandContentStep
|
||||
fields = ['operation', 'expect']
|
||||
|
||||
class TestContentSchema(ModelSchema):
|
||||
subStep: List[TestContentStepSchema] = [] # 可能为空
|
||||
|
||||
class Meta:
|
||||
model = TestDemandContent
|
||||
fields = ["subName"]
|
||||
|
||||
class TestDemandModelOutSchema(ModelSchema):
|
||||
testContent: List[TestContentSchema]
|
||||
|
||||
class Meta:
|
||||
model = TestDemand
|
||||
exclude = ['project', 'round', 'dut', 'design', 'remark', 'sort']
|
||||
|
||||
# 查询测试项
|
||||
class TestDemandFilterSchema(Schema):
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
round_id: str = Field(None, alias='round')
|
||||
dut_id: str = Field(None, alias='dut')
|
||||
design_id: str = Field(None, alias='designDemand')
|
||||
# 其他字段
|
||||
ident: str = Field(None, alias='ident')
|
||||
testType: str = Field(None, alias='testType')
|
||||
name: str = Field(None, alias='name')
|
||||
priority: str = Field(None, alias="priority")
|
||||
|
||||
# 处理树状结构的schema
|
||||
class TestDemandTreeReturnSchema(Schema):
|
||||
title: str = Field(..., alias='title')
|
||||
key: str = Field(..., alias='key')
|
||||
level: str = Field(..., alias='level')
|
||||
|
||||
class TestDemandTreeInputSchema(Schema):
|
||||
# 注意这里有alias
|
||||
project_id: int = Field(None, alias='projectId')
|
||||
key: str = Field(None, alias='key')
|
||||
level: str = Field(None, alias='level')
|
||||
|
||||
# 增加测试项
|
||||
class TestDemandCreateOutSchema(ModelSchema):
|
||||
level: Union[str, int]
|
||||
|
||||
class Config:
|
||||
model = TestDemand
|
||||
model_exclude = ['remark', 'sort', 'project', 'round', 'dut', 'design']
|
||||
|
||||
# 新增测试子项,单个子项的Schema
|
||||
class TestContentInputSchema(Schema):
|
||||
subName: str = None
|
||||
subStep: Optional[List[TestContentStepSchema]] = []
|
||||
|
||||
# 新增/更新测试项Schema
|
||||
class TestDemandCreateInputSchema(Schema):
|
||||
project_id: int = Field(..., validation_alias=AliasChoices("projectId", "project_id"),
|
||||
serialization_alias="projectId")
|
||||
round_key: str = Field(..., alias="round")
|
||||
dut_key: str = Field(..., alias="dut")
|
||||
design_key: str = Field(..., alias="designDemand")
|
||||
# 其他字段
|
||||
ident: str = Field(None, alias="ident")
|
||||
name: str = Field(None, alias="name")
|
||||
adequacy: str = Field(None, alias="adequacy")
|
||||
priority: str = Field(None, alias="priority")
|
||||
testContent: List[TestContentInputSchema] = []
|
||||
testMethod: List[str] = []
|
||||
testType: str = Field(None, alias="testType")
|
||||
testDesciption: str = Field("", alias='testDesciption')
|
||||
|
||||
# 处理前端请求-设计需求关联测试需求(测试项)
|
||||
class TestDemandRelatedSchema(Schema):
|
||||
data: List[int] = None
|
||||
project_id: int = Field(None, alias="project_id")
|
||||
round_key: str = Field(None, alias="roundNumber")
|
||||
dut_key: str = Field(None, alias="dutNumber")
|
||||
design_key: str = Field(None, alias="designDemandNumber")
|
||||
|
||||
# 处理前端请求-设计需求已关联测试需求(测试项)
|
||||
class TestDemandExistRelatedSchema(Schema):
|
||||
project_id: int = Field(None, alias="project_id")
|
||||
round_key: str = Field(None, alias="roundNumber")
|
||||
dut_key: str = Field(None, alias="dutNumber")
|
||||
design_key: str = Field(None, alias="designDemandNumber")
|
||||
|
||||
# 根据design的id,testDemand数据,项目id,depth复制测试项到指定design
|
||||
class DemandCopyToDesignSchema(Schema):
|
||||
project_id: int
|
||||
design_id: int
|
||||
demand_key: str
|
||||
depth: bool = False
|
||||
6
apps/project/schemas/treeOperation.py
Normal file
6
apps/project/schemas/treeOperation.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from ninja import Schema, Field
|
||||
from typing import List
|
||||
|
||||
class CopySchema(Schema):
|
||||
pid: int = Field(alias='project_id')
|
||||
data: List[str] = Field(alias='checkedNodes')
|
||||
Reference in New Issue
Block a user