feat: 用户选择增加手机号搜索功能
Coze-Commit-Type: user Coze-User-ID: 3722323274763196 Coze-Conversation-ID: 9894087
This commit is contained in:
12
app.py
12
app.py
@@ -325,19 +325,19 @@ def get_entities():
|
||||
return jsonify({'success': True, 'data': stations, 'total': total, 'page': page, 'page_size': page_size})
|
||||
|
||||
else:
|
||||
# 获取用户列表(支持分页和搜索)
|
||||
# 获取用户列表(支持分页和搜索,搜索支持用户名和手机号)
|
||||
if search:
|
||||
users = execute_query(
|
||||
'SELECT id AS user_id, user_name FROM t_user WHERE user_name LIKE %s ORDER BY user_name LIMIT %s OFFSET %s',
|
||||
(f'%{search}%', page_size, offset)
|
||||
'SELECT id AS user_id, user_name, phone FROM t_user WHERE user_name LIKE %s OR phone LIKE %s ORDER BY user_name LIMIT %s OFFSET %s',
|
||||
(f'%{search}%', f'%{search}%', page_size, offset)
|
||||
)
|
||||
total_result = execute_query(
|
||||
'SELECT COUNT(*) as total FROM t_user WHERE user_name LIKE %s',
|
||||
(f'%{search}%',)
|
||||
'SELECT COUNT(*) as total FROM t_user WHERE user_name LIKE %s OR phone LIKE %s',
|
||||
(f'%{search}%', f'%{search}%')
|
||||
)
|
||||
else:
|
||||
users = execute_query(
|
||||
'SELECT id AS user_id, user_name FROM t_user ORDER BY user_name LIMIT %s OFFSET %s',
|
||||
'SELECT id AS user_id, user_name, phone FROM t_user ORDER BY user_name LIMIT %s OFFSET %s',
|
||||
(page_size, offset)
|
||||
)
|
||||
total_result = execute_query(
|
||||
|
||||
@@ -1329,6 +1329,9 @@
|
||||
value = e.user_id;
|
||||
name = e.user_name;
|
||||
typeLabel = e.order_type === 3 ? '(企业用户)' : '(普通用户)';
|
||||
if (e.phone) {
|
||||
name = `${e.user_name} (${e.phone})`;
|
||||
}
|
||||
} else if (splitType === 'station_id') {
|
||||
value = e.station_id;
|
||||
name = e.station_name;
|
||||
@@ -1542,6 +1545,9 @@
|
||||
value = e.user_id;
|
||||
name = e.user_name;
|
||||
typeLabel = e.order_type === 3 ? '(企业用户)' : '(普通用户)';
|
||||
if (e.phone) {
|
||||
name = `${e.user_name} (${e.phone})`;
|
||||
}
|
||||
} else if (splitType === 'station_id') {
|
||||
value = e.station_id;
|
||||
name = e.station_name;
|
||||
@@ -1566,6 +1572,9 @@
|
||||
value = e.user_id;
|
||||
name = e.user_name;
|
||||
typeLabel = e.order_type === 3 ? '(企业用户)' : '(普通用户)';
|
||||
if (e.phone) {
|
||||
name = `${e.user_name} (${e.phone})`;
|
||||
}
|
||||
} else if (splitType === 'station_id') {
|
||||
value = e.station_id;
|
||||
name = e.station_name;
|
||||
|
||||
Reference in New Issue
Block a user