2024-11-19 12:08:21 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# @Time : 2024/11/19 下午8:05
|
|
|
|
|
# @FileName: manage_project.py
|
|
|
|
|
# @Software: PyCharm
|
|
|
|
|
from fastapi import HTTPException, Response, Depends, APIRouter
|
|
|
|
|
from typing import Optional, Annotated
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
from jose import JWTError, jwt
|
|
|
|
|
|
|
|
|
|
from sqlmodel import select
|
|
|
|
|
|
|
|
|
|
from models import Tenant, User, Project
|
|
|
|
|
from dependencies import *
|
|
|
|
|
|
2024-11-19 13:38:36 +00:00
|
|
|
from typing import List
|
|
|
|
|
|
2024-11-19 12:08:21 +00:00
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
2024-11-19 13:38:36 +00:00
|
|
|
#列举所有项目
|
|
|
|
|
@router.get("/api/s1/project")
|
|
|
|
|
async def get_project(response:Response, session: SessionDep):
|
|
|
|
|
projects = session.query(Project).filter().all()
|
|
|
|
|
if not projects:
|
|
|
|
|
raise HTTPException(status_code=404, detail="Project not found")
|
|
|
|
|
return {"projects": projects}
|
|
|
|
|
|
|
|
|
|
#新增和修改项目
|
|
|
|
|
# @router.post("/api/s1/project")
|
|
|
|
|
# async def create_project(project_detail:dict, session: SessionDep):
|
|
|
|
|
# project = {
|
|
|
|
|
# "name": project_detail["name"],
|
|
|
|
|
#
|
|
|
|
|
# }
|
|
|
|
|
# return {"newProject": project}
|