certificate.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from fastapi import APIRouter, Request, Depends, Form, Body, File, UploadFile
  4. from database import get_db
  5. from utils.StripTagsHTMLParser import *
  6. from sqlalchemy.orm import Session
  7. from datetime import datetime, timedelta
  8. import jwt
  9. from passlib.context import CryptContext
  10. from models import *
  11. from sqlalchemy import text, exists, and_, or_, not_
  12. from sqlalchemy.sql import func
  13. from models import *
  14. from extensions import logger
  15. from utils import *
  16. import traceback
  17. router = APIRouter()
  18. # 2.2.1.6.证照报告信息
  19. @router.post('/info', description='提交证照报告信息')
  20. async def post_certificate_info(
  21. request: Request,
  22. db: Session = Depends(get_db),
  23. data: dict = Depends(remove_xss_json)
  24. ):
  25. try:
  26. id = get_req_param(data, 'id')
  27. company_industry = db.query(DangerBaseCertificateInfo).filter(DangerBaseCertificateInfo.id == id).first()
  28. if company_industry is None:
  29. new_entity = DangerBaseCertificateInfo(**data)
  30. db.add(new_entity)
  31. else:
  32. db.query(DangerBaseCertificateInfo).filter(DangerBaseCertificateInfo.id == id).update(data)
  33. db.commit()
  34. return {
  35. "code":1,
  36. "message":"成功",
  37. "data":{}
  38. }
  39. except Exception as e:
  40. traceback.print_exc()
  41. return {
  42. "code":0,
  43. "message":"更新异常,错误信息:" + str(e),
  44. "data":{}
  45. }