Completed Change to ReactJS
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
|
||||
class MessageCode():
|
||||
CREATE_USER_SUCCESS: str = 'CREATE_USER_SUCCESS'
|
||||
CREATED_USER: str = 'CREATED_USER'
|
||||
WRONG_INPUT: str = 'LOGIN_WRONG'
|
||||
ACCOUNT_LOCK: str = 'USER_LOCK'
|
||||
CREATE_USER_SUCCESS: str = 'message_create_user_success'
|
||||
CREATED_USER: str = 'message_created_user'
|
||||
WRONG_INPUT: str = 'message_login_wrong'
|
||||
ACCOUNT_LOCK: str = 'message_user_lock'
|
||||
REFRESH_TOKEN_EXPIRED: str = 'REFRESH_TOKEN_EXPIRED'
|
||||
CREATE_HOUSE_FAIL: str = 'CREATE_HOUSE_FAIL'
|
||||
CREATE_HOUSE_SUCCESS: str = 'CREATE_HOUSE_SUCCESS'
|
||||
CREATE_HOUSE_FAIL: str = 'message_create_house_fail'
|
||||
CREATE_HOUSE_SUCCESS: str = 'message_create_house_success'
|
||||
HOUSE_NOT_FOUND: str = 'HOUSE_NOT_FOUND'
|
||||
|
@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
from backend.db.models.houses import Houses, Areas
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@ -75,4 +76,15 @@ class RepositoryHouses:
|
||||
return db_house
|
||||
|
||||
def delete(self, db: Session, house_id: str):
|
||||
pass
|
||||
db_house = self.get_by_id(house_id)
|
||||
if not db_house:
|
||||
return None
|
||||
try:
|
||||
self.houses.query.where(Houses.id == house_id).update({"deleted_at": datetime.utcnow()})
|
||||
db.commit()
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
|
||||
db.refresh(db_house)
|
||||
return db_house
|
||||
|
@ -43,3 +43,8 @@ def get_house_by_id(house_id: str, current_user: current_user_token) -> ReturnVa
|
||||
def update_house(house: HouseUpdate, current_user: current_user_token, db: db_dependency) -> ReturnValue[Any]:
|
||||
db_house = house_service.update(db=db, house=house)
|
||||
return ReturnValue(status=200, data=db_house)
|
||||
|
||||
@public_router.delete("/delete/{house_id}", response_model=ReturnValue[Any])
|
||||
def delete_house(house_id: str, current_user: current_user_token, db: db_dependency) -> ReturnValue[Any]:
|
||||
db_house = house_service.delete(db=db, house_id=house_id)
|
||||
return ReturnValue(status=200, data="Deleted")
|
||||
|
@ -21,3 +21,6 @@ class HouseService(BaseService):
|
||||
|
||||
def update(self, db: Session, house: HouseUpdate):
|
||||
return self.repos.update(db=db, house=house)
|
||||
|
||||
def delete(self, db: Session, house_id: str):
|
||||
return self.repos.delete(db=db, house_id=house_id)
|
||||
|
Reference in New Issue
Block a user