Skip to content

Commit

Permalink
Delete logue functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Subilan committed Apr 22, 2020
1 parent bdf864f commit ab92795
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 9 additions & 5 deletions backend/mono-back/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,26 @@ def post(self):
self.json = json
funcs = {
"submit": self.submit,
"alter": self.alter
"alter": self.alter,
"delete": self.delete,
}
func = funcs[json["method"]]
return func()

def submit(self):
json = self.json
logue = LogueController()
result = logue.write(json["title"], json["contents"], json["type"])
return result
return logue.write(json["title"], json["contents"], json["type"])

def alter(self):
json = self.json
logue = LogueController()
result = logue.alter(json["id"], json["title"], json["contents"], json["type"])
return result
return logue.alter(json["id"], json["title"], json["contents"], json["type"])

def delete(self):
json = self.json
logue = LogueController()
return logue.delete(json["id"])

class AuthAPI(Resource):
def login(self):
Expand Down
8 changes: 8 additions & 0 deletions backend/mono-back/Logue.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ def alter(self, id, title, contents, typ):
args = (title, contents, typ, id)
sql = ("UPDATE Logue SET title=%s, contents=%s, type=%s WHERE id=%s")
cur.execute(sql, args)
return db.commit(True)

def delete(self, id):
if not id:
return False
db = DBController()
cur = db.cursor()
cur.execute("DELETE FROM Logue WHERE id=%s" % id)
return db.commit(True)

0 comments on commit ab92795

Please sign in to comment.