|
@@ -61,6 +61,7 @@ async def send_yzy_msg(request: Request,
|
|
|
user_id = Depends(valid_access_token)):
|
|
|
|
|
|
msg_type = body['msg_type']
|
|
|
+ title = body['title']
|
|
|
detail_url = body['detail_url']
|
|
|
description = body['description']
|
|
|
|
|
@@ -88,10 +89,11 @@ async def send_yzy_msg(request: Request,
|
|
|
"detail_url": settings.YZY_WEB_ROOT + detail_url,
|
|
|
"foreign_key": foreign_key,
|
|
|
"from_scenario": from_scenario,
|
|
|
- "title": msg_type
|
|
|
+ "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)
|
|
|
|
|
|
return {
|
|
@@ -266,7 +268,7 @@ async def get_center_list(
|
|
|
elif row.msg_type == '系统消息':
|
|
|
try:
|
|
|
detail = {
|
|
|
- "detail_url": "/infoDetails?id="+str(row.id)
|
|
|
+ "detail_url": ""
|
|
|
}
|
|
|
|
|
|
except:
|
|
@@ -303,4 +305,68 @@ async def get_center_list(
|
|
|
except Exception as e:
|
|
|
# 处理异常
|
|
|
traceback.print_exc()
|
|
|
- raise HTTPException(status_code=500, detail=str(e))
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
+
|
|
|
+@router.get('/unread_system_notice')
|
|
|
+async def unread_system_notice(
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ page: int = Query(1, gt=0, description='页码'),
|
|
|
+ page_size: int = Query(10, gt=0, description='pageSize'),
|
|
|
+ user_id = Depends(valid_access_token)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ # 应用查询条件
|
|
|
+ where = and_(MsgCenter.del_flag == '0', MsgCenter.msg_type == '系统消息', MsgCenter.recv_status == 0, MsgCenter.recv_userid == user_id)
|
|
|
+ # 计算总条目数
|
|
|
+ q = db.query(func.count(MsgCenter.id))
|
|
|
+ q = q.filter(where)
|
|
|
+ total = q.scalar()
|
|
|
+
|
|
|
+ # 执行分页查询
|
|
|
+ q = db.query(MsgCenter)
|
|
|
+ q = q.filter(where)
|
|
|
+
|
|
|
+ # 执行分页查询
|
|
|
+ q = db.query(MsgCenter)
|
|
|
+ q = q.filter(where)
|
|
|
+
|
|
|
+ q = q.order_by(MsgCenter.recv_time.asc())
|
|
|
+
|
|
|
+ rows = q.offset((page - 1) * page_size).limit(page_size).all()
|
|
|
+
|
|
|
+ data = []
|
|
|
+ for row in rows:
|
|
|
+ data.append({
|
|
|
+ "id": row.id,
|
|
|
+ "msg_type": row.msg_type,
|
|
|
+ "title": row.title,
|
|
|
+ "content": row.content,
|
|
|
+ "recv_time": get_datetime_str(row.recv_time)
|
|
|
+ })
|
|
|
+
|
|
|
+ # 返回结果
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "查询成功",
|
|
|
+ "data": data,
|
|
|
+ "total": total
|
|
|
+ }
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ # 处理异常
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
+
|
|
|
+@router.post('/readall_system_notice')
|
|
|
+async def readall_system_notice(
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ user_id = Depends(valid_access_token)
|
|
|
+):
|
|
|
+ where = and_(MsgCenter.del_flag == '0', MsgCenter.msg_type == '系统消息', MsgCenter.recv_status == 0, MsgCenter.recv_userid == user_id)
|
|
|
+ db.query(MsgCenter).filter(where).update({"recv_status": 1, "update_time": datetime.now()})
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "保存成功"
|
|
|
+ }
|