|
@@ -14,7 +14,7 @@ import os
|
|
|
from sqlalchemy import create_engine, select
|
|
|
from typing import Optional
|
|
|
from utils.StripTagsHTMLParser import *
|
|
|
-from common.db import db_event_management, db_user, db_area, db_msg_center
|
|
|
+from common.db import db_event_management, db_user, db_area, db_msg_center, db_yzy
|
|
|
from common.security import valid_access_token
|
|
|
import traceback
|
|
|
from utils import *
|
|
@@ -50,3 +50,49 @@ async def msg_count(
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+@router.post("/send_yzy_msg")
|
|
|
+async def send_yzy_msg(request: Request,
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ user_id = Depends(valid_access_token)):
|
|
|
+
|
|
|
+ msg_type = body['msg_type']
|
|
|
+ detail_url = body['detail_url']
|
|
|
+ description = body['description']
|
|
|
+
|
|
|
+ foreign_key = '0'
|
|
|
+ if 'foreign_key' in body:
|
|
|
+ foreign_key = body['foreign_key']
|
|
|
+
|
|
|
+ from_scenario = ''
|
|
|
+ if 'from_scenario' in body:
|
|
|
+ from_scenario = body['from_scenario']
|
|
|
+
|
|
|
+ user_list = []
|
|
|
+ tousers = body['tousers']
|
|
|
+ for to_user_id in tousers:
|
|
|
+ user_info = db_user.get_user_info(db, to_user_id)
|
|
|
+ yzy_account = user_info.yzy_account
|
|
|
+ yzy_userid = db_yzy.get_userid_by_account(db, yzy_account)
|
|
|
+
|
|
|
+ if yzy_userid not in user_list:
|
|
|
+ data = {
|
|
|
+ "yzy_userid": yzy_userid,
|
|
|
+ "mobile": yzy_account,
|
|
|
+ "content": description,
|
|
|
+ "recorded_by": user_id,
|
|
|
+ "detail_url": settings.YZY_WEB_ROOT + detail_url,
|
|
|
+ "foreign_key": foreign_key,
|
|
|
+ "from_scenario": from_scenario,
|
|
|
+ "title": msg_type
|
|
|
+ }
|
|
|
+ YzyApi.add_to_msg_queue(db, data)
|
|
|
+ db_msg_center.add_msg(db, msg_type, foreign_key, to_user_id)
|
|
|
+ user_list.append(yzy_userid)
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "消息暂存成功"
|
|
|
+ }
|