diff --git a/routers/classticmanage.py b/routers/classticmanage.py index ca2b46f..9171cb7 100644 --- a/routers/classticmanage.py +++ b/routers/classticmanage.py @@ -32,3 +32,26 @@ async def classtic_search(header:str=Query(description="语录标题")): params.append(f"%{header}%") classtic_query=fetch_all(select_query,params=params,fetchall=True) return response_success(data=classtic_query,message="classtic search success") + +# 语录修改 +@router.put("/update/{id}") +async def classtic_put(classtic:Classtic,id: str = Path(description="语录id")): + update_query = ( + "UPDATE classtics SET header=%s,text=%s,descr=%s WHERE id=%s;" + ) + update_data = (classtic.header, classtic.text, + classtic.descr,id) + execute_query(update_query, update_data) + return response_success("classtic update sucess") + +# 语录修改 +@router.delete("/delete/{id}") +async def classtic_del(id: str = Path(description="语录id")): + update_query = ( + "DELETE FROM classtics WHERE id=%s;" + ) + update_data = (id) + execute_query(update_query, update_data) + return response_success() + +# 根据id查询 \ No newline at end of file