def put(self, id): """ 更新case :return: """ self.arguments['id'] = id try: validate.cases_update(self.arguments) del self.arguments['id'] cases = self.service.update(id, **self.arguments) if cases is False or cases is 0: raise peewee.DoesNotExist( exceptions.data_not_existed, exceptions.get_error_message(exceptions.data_not_existed)) self.echoJson(0, {"info": "success"}) except error.RequestData as e: self.echo_error(e.code, e.message) except peewee.DoesNotExist: self.echoJson( exceptions.data_not_existed, exceptions.get_error_message(exceptions.data_not_existed)) except exceptions.Database as e: self.echoJson(e.code, e.message) except Exception as e: self.echoJson(exceptions.exception, str(e)) self.close_connect_and_finish()
def delete(self, id): """ 删除用户 :return: """ self.arguments['id'] = id try: validate.users_delete(self.arguments) users = self.service.delete(self.arguments['id']) if users is False or users is 0: raise peewee.DoesNotExist( exceptions.data_not_existed, exceptions.get_error_message(exceptions.data_not_existed)) self.echoJson(0, {"info": "success"}) except error.RequestData as e: self.echo_error(e.code, e.message) except peewee.DoesNotExist: self.echoJson( exceptions.data_not_existed, exceptions.get_error_message(exceptions.data_not_existed)) except exceptions.Database as e: self.echoJson(e.code, e.message) except Exception as e: self.echoJson(exceptions.exception, str(e)) except error.Database as e: self.echoJson(e.code, e.message) self.close_connect_and_finish()
def put(self, email): """ 修改用户密码 :param email: :return: """ try: validate.users_update(self.arguments) password = self.service.update_password(**self.arguments) if password is False or password is 0: raise peewee.DoesNotExist( exceptions.data_not_existed, exceptions.get_error_message(exceptions.data_not_existed)) self.echoJson(0, {"info": "success"}) except error.RequestData as e: self.echo_error(e.code, e.message) except peewee.DoesNotExist: self.echoJson( exceptions.data_not_existed, exceptions.get_error_message(exceptions.data_not_existed)) except exceptions.Database as e: self.echoJson(e.code, e.message) except Exception as e: self.echoJson(exceptions.exception, str(e)) self.close_connect_and_finish()
def post(self, param): """ 创建host :param param: :return: """ try: validate.cases_create(self.arguments) cases = self.service.create_new(**self.arguments) if cases is False or cases is 0: raise exceptions.Database( exceptions.data_save_error, exceptions.get_error_message(exceptions.data_save_error)) self.echoJson(0, cases) except error.RequestData as e: self.echo_error(e.code, e.message) except exceptions.RequestData as e: self.echoJson(e.code, e.message) except peewee.IntegrityError as e: self.echoJson(exceptions.data_integrity_error, str(e)) except exceptions.Database as e: self.echoJson(e.code, e.message) except Exception as e: self.echoJson(exceptions.exception, str(e)) self.close_connect_and_finish()