|
@@ -50,23 +50,32 @@ def get_db_connection():
|
|
|
# 檢查已登錄過的客戶手機號碼
|
|
|
@app.get("/check")
|
|
|
async def checkCellphone(cellphone: str = '0975-516-501'):
|
|
|
+ # 手機號碼清單
|
|
|
+ cellphone_list = cellphone.replace("%0A", ",")
|
|
|
+ print ('cellphone_list = ' + cellphone_list)
|
|
|
+
|
|
|
# 取得資料庫連線
|
|
|
db = get_db_connection()
|
|
|
|
|
|
# 取得手機號碼資料
|
|
|
q = "SELECT * \
|
|
|
FROM agent_form \
|
|
|
- WHERE cellphone = '" + cellphone + "'"
|
|
|
+ WHERE cellphone IN ('" + cellphone_list + "')"
|
|
|
|
|
|
- q_result_count = len(list(db.query(q)))
|
|
|
+ count = len(list(db.query(q)))
|
|
|
|
|
|
- if q_result_count == 0: # 無手機號碼資料
|
|
|
- print('無 ' + cellphone + ' 資料')
|
|
|
+ if count == 0: # 無手機號碼資料
|
|
|
+ print('無手機號碼資料資料')
|
|
|
+ return {"count": 0, "msg": "無手機號碼資料"}
|
|
|
else:
|
|
|
+ # 既有手機號碼資料
|
|
|
+ cellphone_list = []
|
|
|
+
|
|
|
for r1 in db.query(q):
|
|
|
- print('手機號碼: ' + r1['cellphone'] + ' 資料已存在')
|
|
|
+ print('手機號碼: ' + r1['cellphone'] + ' 資料已存在')
|
|
|
+ cellphone_list.append(r1['cellphone'])
|
|
|
|
|
|
- return {"cellphone": r1['cellphone']}
|
|
|
+ return {"count": count, "cellphone": cellphone_list}
|
|
|
|
|
|
# checkCellphone('0975-516-501')
|
|
|
|