存在しないPC番号の場合はINSERTでレコードを作るように

This commit is contained in:
suti7yk5032 2024-10-05 09:35:49 +09:00
parent d643e6d1ba
commit ee4061d10b

View file

@ -307,6 +307,17 @@ class Auth():
cursor.execute("SELECT pc_uuid FROM pc_list WHERE pc_number = %s", (pc_number,)) cursor.execute("SELECT pc_uuid FROM pc_list WHERE pc_number = %s", (pc_number,))
pc_record = cursor.fetchall() pc_record = cursor.fetchall()
pc_record_uuid = pc_record[0][0] pc_record_uuid = pc_record[0][0]
cursor.execute("SELECT pc_number FROM pc_list WHERE pc_number = %s", (pc_number,))
pc_record = cursor.fetchall()
pc_record_number = pc_record[0][0]
if pc_record_number == None:
pc_token = self.token_generate(36)
master_password = self.master_password_generate(16)
master_password_hash = self.hash_genarate(master_password)
cursor.execute("INSERT INTO pc_list (pc_number, pc_uuid, pc_token, master_password) VALUES (%s, %s, %s, %s)", (pc_number, pc_uuid, pc_token, master_password))
self.db.commit()
return {"result": 0, "about": "ok", "output_dict": {"pc_token": pc_token, "master_password": master_password, "master_password_hash": master_password_hash}}
else:
if pc_record_uuid == None: if pc_record_uuid == None:
pc_token = self.token_generate(36) pc_token = self.token_generate(36)
master_password = self.master_password_generate(16) master_password = self.master_password_generate(16)
@ -318,7 +329,7 @@ class Auth():
return {"result": 1, "about": "exist"} return {"result": 1, "about": "exist"}
except Exception as error: except Exception as error:
print("停止処理中にエラーが発生しました。\nエラー内容") print("PCの登録処理中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__)) print(str(error.__class__.__name__))
print(str(error.args)) print(str(error.args))
print(str(error)) print(str(error))