fix(notice): 修改管理控制台公告布局,并在首页滚动显示

This commit is contained in:
sophie committed 2026-06-12 14:55:28 +08:00
1 parent ced7fbe085
commit d4f629106f
18 files changed
+737 -105

No files matched your search

+21
View File
@@ -1688,6 +1688,27 @@ def create_announcement():
db.session.commit()
return (jsonify({'message': 'Created', 'id': ann.id}), 201)
@user_bp.route('/announcements/<int:id>', methods=['PUT'])
def update_announcement(id):
"""
更新公告(仅管理员)。
核心逻辑:校验 title/content 非空后更新 Announcement 记录。
"""
user = _get_current_user()
if not user or user.role != 'admin':
raise ForbiddenError('Unauthorized')
data = request.get_json() or {}
if not data.get('title') or not data.get('content'):
raise ValidationError('Missing fields')
ann = db.session.get(Announcement, id)
if not ann:
raise NotFoundError('Not found')
ann.title = data['title']
ann.content = data['content']
db.session.commit()
return jsonify({'message': 'Updated'})
@user_bp.route('/announcements/<int:id>', methods=['DELETE'])
def delete_announcement(id):
user = _get_current_user()