|
@@ -25,18 +25,24 @@ def index():
|
|
|
video_id = request.form['video_id']
|
|
|
|
|
|
if video_id:
|
|
|
- query = """
|
|
|
+ condition = "b.miniprogram_video_id = %s"
|
|
|
+ if staff_id:
|
|
|
+ condition += " AND a.carrier_id = %s"
|
|
|
+ query = f"""
|
|
|
SELECT a.carrier_id, a.remark, b.miniprogram_video_id, b.send_time,
|
|
|
DATEDIFF(NOW(), b.send_time) as days
|
|
|
FROM we_com_staff a JOIN we_com_message_attachment b
|
|
|
ON a.id = b.staff_id
|
|
|
- WHERE a.carrier_id = %s AND b.miniprogram_video_id = %s ORDER BY send_time DESC
|
|
|
+ WHERE {condition} ORDER BY send_time DESC
|
|
|
"""
|
|
|
cursor = mysql.get_db().cursor()
|
|
|
- cursor.execute(query, (staff_id, video_id))
|
|
|
+ if staff_id:
|
|
|
+ cursor.execute(query, (video_id, staff_id))
|
|
|
+ else:
|
|
|
+ cursor.execute(query, (video_id))
|
|
|
result = cursor.fetchall()
|
|
|
cursor.close()
|
|
|
- else:
|
|
|
+ elif staff_id:
|
|
|
query = """
|
|
|
SELECT a.carrier_id, a.remark, b.miniprogram_video_id, b.send_time,
|
|
|
DATEDIFF(NOW(), b.send_time) as days
|
|
@@ -48,9 +54,11 @@ def index():
|
|
|
cursor.execute(query, (staff_id,))
|
|
|
result = cursor.fetchall()
|
|
|
cursor.close()
|
|
|
+ else:
|
|
|
+ return render_template('index.html', results=[], form=request.form)
|
|
|
|
|
|
return render_template('index.html', results=result, form=request.form)
|
|
|
- return render_template('index.html')
|
|
|
+ return render_template('index.html', results=[], form={'staff_id': '', 'video_id': ''})
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
app.run(debug=True)
|