12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import time
- from typing import Optional
- from fastapi import APIRouter
- from fastapi import Depends
- from sqlalchemy.orm import Session
- from app.utils.utils import *
- from utils.sx_time import sxtimeit
- from utils.sx_web import web_try
- from app.common.decorators import verify_special, verify_super_and_project, verify_user, verify_all, verify_super_admin
- from configs.globals import g
- from app import crud, get_db, get_page, schemas
- router = APIRouter(
- prefix="/jpt/project",
- tags=["project-项目管理"],
- )
- @router.post("/create_project", dependencies=[Depends(verify_super_admin)])
- @web_try()
- @sxtimeit
- def create_project(item: schemas.ProjectCreate, db: Session = Depends(get_db)):
- return crud.create_project(db,item)
- @router.put("/update_project", dependencies=[Depends(verify_super_and_project)])
- @web_try()
- @sxtimeit
- def update_project(item: schemas.ProjectUpdate, db: Session = Depends(get_db)):
- return crud.update_project(db,item)
- @router.get("", dependencies=[Depends(verify_user)])
- @web_try()
- @sxtimeit
- def get_projects(db: Session = Depends(get_db)):
- return crud.get_project_list(db,g.user_id)
- @router.get("/share_projects", dependencies=[Depends(verify_special)])
- @web_try()
- @sxtimeit
- def get_share_projects(db: Session = Depends(get_db)):
- return crud.get_share_projects(db)
- @router.get("/switch", dependencies=[Depends(verify_user)])
- @web_try()
- @sxtimeit
- def switch_project(project_id: int, db: Session = Depends(get_db)):
- return crud.switch_project_by_user(db,project_id,g.user_id)
- @router.get("/info", dependencies=[Depends(verify_all)])
- @web_try()
- @sxtimeit
- def get_project_info(project_id: int, db: Session = Depends(get_db)):
- return crud.get_project_info(db,project_id)
|