|
@@ -53,6 +53,48 @@ async def msg_count(
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
+@router.post("/new_system_notice")
|
|
|
+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 = '系统消息'
|
|
|
+ title = body['title']
|
|
|
+ description = body['description']
|
|
|
+
|
|
|
+ foreign_key = '0'
|
|
|
+ from_scenario = ''
|
|
|
+
|
|
|
+ # 对所有用户
|
|
|
+ tousers = db.query(SysUser).filter(SysUser.del_flag == '0').all()
|
|
|
+
|
|
|
+ user_list = []
|
|
|
+ for user_info in tousers:
|
|
|
+ to_user_id = user_info.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,
|
|
|
+ "foreign_key": foreign_key,
|
|
|
+ "from_scenario": from_scenario,
|
|
|
+ "title": title
|
|
|
+ }
|
|
|
+ YzyApi.add_to_msg_queue(db, data)
|
|
|
+ user_list.append(yzy_userid)
|
|
|
+
|
|
|
+ db_msg_center.add_message(db, msg_type, to_user_id, title, description, foreign_key, from_scenario)
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "消息暂存成功"
|
|
|
+ }
|
|
|
|
|
|
@router.post("/send_yzy_msg")
|
|
|
async def send_yzy_msg(request: Request,
|
|
@@ -92,7 +134,6 @@ async def send_yzy_msg(request: Request,
|
|
|
"title": title
|
|
|
}
|
|
|
YzyApi.add_to_msg_queue(db, data)
|
|
|
- db_msg_center.add_msg(db, msg_type, foreign_key, to_user_id)
|
|
|
db_msg_center.add_message(db, msg_type, to_user_id, title, description, foreign_key, from_scenario)
|
|
|
user_list.append(yzy_userid)
|
|
|
|