20250911-初步功能已完成
This commit is contained in:
@@ -19,6 +19,7 @@ from Utils.ThreadManager import ThreadManager
|
||||
from script.ScriptManager import ScriptManager
|
||||
from Entity.Variables import anchorList, prologueList, addModelToAnchorList, removeModelFromAnchorList
|
||||
import Entity.Variables as ev
|
||||
from Utils.JsonUtils import JsonUtils
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
@@ -367,5 +368,48 @@ def deleteAnchorWithIds():
|
||||
return ResultData(data={"deleted": deleted}).toJson()
|
||||
|
||||
|
||||
# 查询主播聊天发送的最后一条信息
|
||||
@app.route("/select_last_message", methods=['GET'])
|
||||
def select_last_message():
|
||||
data = JsonUtils.query_all_json_items()
|
||||
|
||||
return ResultData(data=data).toJson()
|
||||
|
||||
|
||||
@app.route("/update_last_message", methods=['POST'])
|
||||
def update_last_message():
|
||||
data = request.get_json() # 解析 JSON
|
||||
sender = data.get("sender")
|
||||
udid = data.get("device")
|
||||
text = data.get("text")
|
||||
|
||||
updated_count = JsonUtils.update_json_items(
|
||||
match={"sender": sender, "text": text}, # 匹配条件
|
||||
patch={"status": 1}, # 修改内容
|
||||
filename="log/last_message.json", # 要修改的文件
|
||||
multi=False # 只改第一条匹配的
|
||||
)
|
||||
if updated_count > 0:
|
||||
return ResultData(data=updated_count, msg="修改成功").toJson()
|
||||
return ResultData(data=updated_count, msg="修改失败").toJson()
|
||||
|
||||
|
||||
@app.route("/delete_last_message", methods=['POST'])
|
||||
def delete_last_message():
|
||||
data = request.get_json() # 解析 JSON
|
||||
sender = data.get("sender")
|
||||
udid = data.get("device")
|
||||
text = data.get("text")
|
||||
|
||||
updated_count = JsonUtils.delete_json_items(
|
||||
match={"sender": sender, "text": text}, # 匹配条件
|
||||
filename="log/last_message.json", # 要修改的文件
|
||||
multi=False # 只改第一条匹配的
|
||||
)
|
||||
if updated_count > 0:
|
||||
return ResultData(data=updated_count, msg="修改成功").toJson()
|
||||
return ResultData(data=updated_count, msg="修改失败").toJson()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
|
||||
|
||||
Reference in New Issue
Block a user