|
@@ -344,27 +344,45 @@ async def buy(userModel : models.BuyNft):
|
|
async def nftdrops(userModel : models.NftDrops):
|
|
async def nftdrops(userModel : models.NftDrops):
|
|
# db connect
|
|
# db connect
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/arkcard?charset=utf8mb4')
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/arkcard?charset=utf8mb4')
|
|
- table3 = db['nftdrops']
|
|
|
|
|
|
+ table1 = db['nft_drop_list']
|
|
|
|
|
|
- # input對應
|
|
|
|
- eventid = '1'
|
|
|
|
- nftid = '1001'
|
|
|
|
- nftid2 = '1002'
|
|
|
|
|
|
+ # input
|
|
userid = userModel.userid
|
|
userid = userModel.userid
|
|
email = userModel.email
|
|
email = userModel.email
|
|
- now = dt.datetime.now()
|
|
|
|
|
|
|
|
- # 如果userid不在db, 寫入到一個空值nft
|
|
|
|
- if not table3.find_one(userid=userid):
|
|
|
|
- # 新增資料
|
|
|
|
- table3.insert(dict(eventid=eventid, nftid=nftid, userid=userid, email=email, time=now))
|
|
|
|
- table3.insert(dict(eventid=eventid, nftid=nftid2, userid=userid, email=email, time=now))
|
|
|
|
- db.close()
|
|
|
|
- return "新增成功"
|
|
|
|
- # 如果userid存在,回傳通知
|
|
|
|
|
|
+ the_current_event = eventPeriod()
|
|
|
|
+
|
|
|
|
+ if the_current_event == 0:
|
|
|
|
+ return "目前沒有任何進行中的活動"
|
|
else:
|
|
else:
|
|
- db.close()
|
|
|
|
- return "已有資料"
|
|
|
|
|
|
+ # 再針對有上架的 event 填寫客戶到 nftdroplist
|
|
|
|
+ now = dt.datetime.now()
|
|
|
|
+ result1 = table1.find_one(userid=userid)
|
|
|
|
+ if not result1:
|
|
|
|
+ for key, item in the_current_event.items():
|
|
|
|
+ table1.insert(dict(eventid=item, userid=userid, email=email, time=now))
|
|
|
|
+ db.close()
|
|
|
|
+ return "完成加入"
|
|
|
|
+ else:
|
|
|
|
+ db.close()
|
|
|
|
+ return "該資料已存在"
|
|
|
|
+
|
|
|
|
+@app.post("/eventPeriod")
|
|
|
|
+def eventPeriod():
|
|
|
|
+ # db connect
|
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/arkcard?charset=utf8mb4')
|
|
|
|
+ # 設定event始終期間,與上架與否
|
|
|
|
+ table3 = db['event']
|
|
|
|
+ now = dt.datetime.now()
|
|
|
|
+ # 先去找 event 表,確認在期間之內
|
|
|
|
+ result = db.query("SELECT * FROM arkcard.event WHERE start < NOW() and NOW() < end and launched='yes';")
|
|
|
|
+ rows = {}
|
|
|
|
+ i = 0
|
|
|
|
+ for row in result:
|
|
|
|
+ rows[i] = row['eventid']
|
|
|
|
+ i += 1
|
|
|
|
+ return rows
|
|
|
|
+ db.close()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8228, reload=True,ssl_context=('/etc/letsencrypt/live/ark.cards/fullchain.pem', '/etc/letsencrypt/live/ark.cards/privkey.pem'))
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8228, reload=True,ssl_context=('/etc/letsencrypt/live/ark.cards/fullchain.pem', '/etc/letsencrypt/live/ark.cards/privkey.pem'))
|