完成项目管理模块的接口测试

This commit is contained in:
2025-04-18 17:22:57 +08:00
parent 434e1af3e8
commit 7a9e571a96
16 changed files with 91 additions and 74 deletions

View File

@ -5,11 +5,11 @@
# @File : views.py
# @IDE : PyCharm
# @desc : 路由,项目信息管理,包括项目主体,项目图片,项目标签和图片的标注信息
from utils.response import SuccessResponse, ErrorResponse
from . import params, schemas, crud, models
from core.dependencies import IdList
from typing import List
from core.dependencies import IdList
from . import params, schemas, crud, models
from utils.response import SuccessResponse, ErrorResponse
from fastapi import APIRouter, Depends, UploadFile, Form
from apps.vadmin.auth.utils.current import FullAdminAuth
from apps.vadmin.auth.utils.validation.auth import Auth
@ -60,12 +60,12 @@ async def del_project(
return SuccessResponse(msg="删除成功")
@app.get("/label/{pro_id}", summary="查询标签列表")
@app.get("/label/{project_id}", summary="查询标签列表")
async def label_list(
pro_id: int,
project_id: int,
auth: Auth = Depends(FullAdminAuth())
):
result = await crud.ProjectLabelDal(auth.db).get_datas(v_where=[models.ProjectLabel.project_id == pro_id],
result = await crud.ProjectLabelDal(auth.db).get_datas(v_where=[models.ProjectLabel.project_id == project_id],
v_schema=schemas.ProjectLabel)
return SuccessResponse(data=result)
@ -101,8 +101,7 @@ async def delete_label(
):
# 删除标签信息,然后删除图片标签关联表
await crud.ProjectLabelDal(auth.db).delete_datas(label_ids.ids)
for label_id in label_ids.ids:
await crud.ProjectImgLabelDal(auth.db).delete_datas(label_id=label_id)
await crud.ProjectImgLabelDal(auth.db).del_img_label(label_ids.ids)
return SuccessResponse(msg="删除成功")
@ -111,7 +110,7 @@ async def project_pager(
param: params.ProjectImageParams = Depends(),
auth: Auth = Depends(FullAdminAuth())
):
if param.limit:
if param.limit > 0:
# 分页查询,关联一个标签数量
datas, count = await crud.ProjectImageDal(auth.db).img_page(param)
return SuccessResponse(data=datas, count=count)
@ -124,7 +123,7 @@ async def project_pager(
@app.post("/img", summary="上传图片")
async def up_img(
project_id: int = Form(...),
files: List[UploadFile] = Form(...),
files: list[UploadFile] = Form(...),
img_type: str = Form(...),
auth: Auth = Depends(FullAdminAuth())
):
@ -155,8 +154,10 @@ async def add_img_label(
return SuccessResponse(msg="保存成功")
@app.get("/img_label/{image_id}", summary="获取图片的标注信息")
async def get_img_label(
image_id: int,
auth: Auth = Depends(FullAdminAuth())
):
leafer = await crud.ProjectImgLeaferDal(auth.db).get_leafer(image_id)
return SuccessResponse(data=leafer)