feat: 消课添加页面添加学员搜索功能
Coze-Commit-Type: user Coze-User-ID: 3722323274763196 Coze-Conversation-ID: 5260473
This commit is contained in:
@@ -11,6 +11,23 @@ import business_rules as rules
|
||||
|
||||
def register_routes(app):
|
||||
|
||||
@app.route('/api/students/search', endpoint='api_student_search')
|
||||
@login_required
|
||||
def api_student_search():
|
||||
"""学员搜索API"""
|
||||
keyword = request.args.get('q', '')
|
||||
if len(keyword) < 1:
|
||||
return {'data': []}
|
||||
|
||||
# 直接搜索学员,不受权限限制
|
||||
students = Student.query.filter(
|
||||
Student.name.contains(keyword),
|
||||
Student.status == 1
|
||||
).limit(20).all()
|
||||
|
||||
results = [{'id': s.id, 'name': s.name} for s in students]
|
||||
return {'data': results}
|
||||
|
||||
@app.route('/consumptions', endpoint='consumption_list')
|
||||
@login_required
|
||||
@permission_required('consumption_view')
|
||||
|
||||
Reference in New Issue
Block a user