瀏覽代碼

删除老update接口

AnlaAnla 1 月之前
父節點
當前提交
69df5e3a10
共有 2 個文件被更改,包括 2 次插入33 次删除
  1. 2 2
      Test/test01.py
  2. 0 31
      app/api/images.py

+ 2 - 2
Test/test01.py

@@ -33,6 +33,6 @@ def send(url):
 
 
 if __name__ == '__main__':
-    base_url = 'http://127.0.0.1:7745/api/cards/query/9'
-    # base_url = 'http://192.168.31.243:7745/api/cards/query/3'
+    # base_url = 'http://127.0.0.1:7745/api/cards/query/9'
+    base_url = 'http://192.168.31.243:7745/api/cards/query/3'
     send(base_url)

+ 0 - 31
app/api/images.py

@@ -197,37 +197,6 @@ async def update_image_modified_json(
         if cursor:
             cursor.close()
 
-
-@router.put("/_update/json/{id}", status_code=200, summary="修改图片的 modified_json")
-def _update_image_modified_json(
-        id: int,
-        new_json_data: Dict[str, Any],
-        db_conn: PooledMySQLConnection = db_dependency
-):
-    """根据 id 更新 modified_json 字段。updated_at 会自动更新。"""
-    cursor = None
-    try:
-        cursor = db_conn.cursor()
-        new_json_str = json.dumps(new_json_data, ensure_ascii=False)
-        query = f"UPDATE {settings.DB_IMAGE_TABLE_NAME} SET modified_json = %s WHERE id = %s"
-        cursor.execute(query, (new_json_str, id))
-
-        if cursor.rowcount == 0:
-            raise HTTPException(status_code=404, detail=f"ID为 {id} 的图片未找到。")
-
-        db_conn.commit()
-        logger.info(f"图片ID {id} 的 modified_json 已更新。")
-        return {"message": f"成功更新图片ID {id} 的JSON数据"}
-    except Exception as e:
-        db_conn.rollback()
-        logger.error(f"更新JSON失败 ({id}): {e}")
-        if isinstance(e, HTTPException): raise e
-        raise HTTPException(status_code=500, detail="更新JSON数据失败。")
-    finally:
-        if cursor:
-            cursor.close()
-
-
 @router.get("/image_file/{id}", summary="获取指定ID的图片文件")
 def get_image_file(id: int, db_conn: PooledMySQLConnection = db_dependency):
     """根据 id 查找记录,并返回对应的图片文件。"""