Spaces:
Sleeping
Sleeping
rogerxavier
commited on
Commit
•
a6c3560
1
Parent(s):
be46fd0
Update server/dao.py
Browse files- server/dao.py +32 -4
server/dao.py
CHANGED
@@ -99,6 +99,34 @@ class tableStore:
|
|
99 |
except Exception as e:
|
100 |
raise customError("userSignUp 失败",e)
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
def updateColumnByPrimaryKey(self,key:str,key_value:'dynamic',
|
103 |
update_column:str,update_column_value:'dynamic')\
|
104 |
-> "bool or throw error":
|
@@ -148,10 +176,10 @@ if __name__ == '__main__':
|
|
148 |
instance_name=instance_name
|
149 |
)
|
150 |
tablestore = tableStore(ots_client=ots_client,table_name=table_name)
|
151 |
-
tablestore.updateColumnByPrimaryKey(key='email',key_value='user@example.com',
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
|
156 |
|
157 |
|
|
|
99 |
except Exception as e:
|
100 |
raise customError("userSignUp 失败",e)
|
101 |
|
102 |
+
def userDelete(self,email,password)->"user info or throw error":
|
103 |
+
self.getUserInfo(email) # 检测登录前先获取用户信息
|
104 |
+
primary_key = [
|
105 |
+
['email', email],
|
106 |
+
]
|
107 |
+
if self.checkInit():
|
108 |
+
# 都存在说明正常初始化
|
109 |
+
try:
|
110 |
+
if not (self.email==email and self.stored_password==password):
|
111 |
+
raise customError("用户或密码不正确")
|
112 |
+
|
113 |
+
# 删除用户信息
|
114 |
+
self.ots_client.delete_row(
|
115 |
+
table_name=self.table_name,
|
116 |
+
primary_key=primary_key,
|
117 |
+
condition=Condition(RowExistenceExpectation.EXPECT_EXIST) # 只有存在的行才能删除
|
118 |
+
)
|
119 |
+
|
120 |
+
return {"ec": 200, "message": "用户删除成功", "email": email}
|
121 |
+
except Exception as e:
|
122 |
+
raise customError("userDelete 失败", e)
|
123 |
+
else:
|
124 |
+
raise customError("login调用时发现用户信息没有正常初始化")
|
125 |
+
|
126 |
+
|
127 |
+
|
128 |
+
|
129 |
+
|
130 |
def updateColumnByPrimaryKey(self,key:str,key_value:'dynamic',
|
131 |
update_column:str,update_column_value:'dynamic')\
|
132 |
-> "bool or throw error":
|
|
|
176 |
instance_name=instance_name
|
177 |
)
|
178 |
tablestore = tableStore(ots_client=ots_client,table_name=table_name)
|
179 |
+
# tablestore.updateColumnByPrimaryKey(key='email',key_value='user@example.com',
|
180 |
+
# update_column='balance',update_column_value=1728877808)
|
181 |
+
resp = tablestore.userDelete('1234567891011@qq.com','12345678910')
|
182 |
+
print(resp)
|
183 |
|
184 |
|
185 |
|