新增后台通知中心和产品审核发布功能
This commit is contained in:
@@ -11,6 +11,14 @@ from utils import load_data, save_data, parse_date_to_timestamp
|
||||
items_bp = Blueprint('api_items', __name__)
|
||||
|
||||
|
||||
def is_review_required():
|
||||
try:
|
||||
import app as app_module
|
||||
return getattr(app_module, 'REQUIRE_REVIEW', False)
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
@items_bp.route('/api/items/<category_id>')
|
||||
def api_items(category_id):
|
||||
items_file = DATA_DIR / f'items_{category_id}.json'
|
||||
@@ -49,6 +57,23 @@ def api_item_detail(category_id, item_id):
|
||||
@items_bp.route('/api/items/<category_id>', methods=['POST'])
|
||||
def api_create_item(category_id):
|
||||
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(category_id, data, source='web')
|
||||
product_name = data.get('name', '未知')
|
||||
create_notification(
|
||||
title='新产品待审核',
|
||||
message=f'有新的产品"{product_name}"待审核',
|
||||
level='warning',
|
||||
category='review',
|
||||
data={'review_id': review['id'], 'category': category_id}
|
||||
)
|
||||
return jsonify({'success': True, 'message': '已提交审核,请等待管理员确认', 'review_id': review['id']})
|
||||
|
||||
items_file = DATA_DIR / f'items_{category_id}.json'
|
||||
items = load_data(items_file)
|
||||
data['id'] = uuid.uuid4().hex[:12]
|
||||
|
||||
Reference in New Issue
Block a user