12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- from fastapi import APIRouter, Request, Depends, Form, Body, File, UploadFile
- from database import get_db
- from utils.StripTagsHTMLParser import *
- from sqlalchemy.orm import Session
- from datetime import datetime, timedelta
- import jwt
- from passlib.context import CryptContext
- from models import *
- from sqlalchemy import text, exists, and_, or_, not_
- from sqlalchemy.sql import func
- from models import *
- from extensions import logger
- from utils import *
- import traceback
- router = APIRouter()
- # 2.2.1.6.证照报告信息
- @router.post('/info', description='提交证照报告信息')
- async def post_certificate_info(
- request: Request,
- db: Session = Depends(get_db),
- data: dict = Depends(remove_xss_json)
- ):
- try:
- id = get_req_param(data, 'id')
- company_industry = db.query(DangerBaseCertificateInfo).filter(DangerBaseCertificateInfo.id == id).first()
- if company_industry is None:
- new_entity = DangerBaseCertificateInfo(**data)
- db.add(new_entity)
- else:
- db.query(DangerBaseCertificateInfo).filter(DangerBaseCertificateInfo.id == id).update(data)
- db.commit()
- return {
- "code":1,
- "message":"成功",
- "data":{}
- }
- except Exception as e:
- traceback.print_exc()
- return {
- "code":0,
- "message":"更新异常,错误信息:" + str(e),
- "data":{}
- }
|