新增后台通知中心和产品审核发布功能
This commit is contained in:
@@ -11,6 +11,15 @@ from utils import load_data, save_data, parse_date_to_timestamp, safe_sort_key
|
||||
models_bp = Blueprint('api_models', __name__)
|
||||
|
||||
|
||||
def is_review_required():
|
||||
"""检查是否需要审核"""
|
||||
try:
|
||||
import app as app_module
|
||||
return getattr(app_module, 'REQUIRE_REVIEW', False)
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
@models_bp.route('/api/models')
|
||||
def api_models():
|
||||
models = load_data(MODELS_FILE)
|
||||
@@ -47,6 +56,24 @@ def api_model_detail(model_id):
|
||||
@models_bp.route('/api/models', methods=['POST'])
|
||||
def api_create_model():
|
||||
data = request.get_json()
|
||||
|
||||
# 审核模式:提交到审核队列
|
||||
if is_review_required():
|
||||
from modules.routes.api_reviews import submit_for_review
|
||||
from modules.routes.api_notifications import create_notification
|
||||
|
||||
review = submit_for_review('ai-models', data, source='web')
|
||||
product_name = data.get('name', '未知')
|
||||
create_notification(
|
||||
title='新产品待审核',
|
||||
message=f'有新的AI模型"{product_name}"待审核',
|
||||
level='warning',
|
||||
category='review',
|
||||
data={'review_id': review['id'], 'category': 'ai-models'}
|
||||
)
|
||||
return jsonify({'success': True, 'message': '已提交审核,请等待管理员确认', 'review_id': review['id']})
|
||||
|
||||
# 直接创建模式
|
||||
models = load_data(MODELS_FILE)
|
||||
data['id'] = uuid.uuid4().hex[:12]
|
||||
data['created_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Reference in New Issue
Block a user