def delete(self, id): """ 删除host :param id: :return: """ try: hosts = model.Hosts result = hosts.get(hosts.id == id).delete_instance() return result except Exception: model.database.rollback() raise error.Database( error.data_delete_error, error.get_error_message(error.data_delete_error))
def update(self, id, **kwargs): """ 修改host信息 :param id: :param kwargs: :return: """ kwargs["update_time"] = common.get_time_now() try: hosts = model.Hosts hosts_update = hosts.update(**kwargs).where( (hosts.id == id)).execute() return hosts_update except Exception as e: model.database.rollback() raise error.Database( error.data_save_error, error.get_error_message(error.data_save_error))
def update_result(self, case_id, case_result): """ 更新case的成功返回的result :param case_id: :param case_result: :return: """ try: cases = model.Cases cases_update = cases.update({ "result": case_result }).where((cases.id == case_id)).execute() return cases_update except Exception: model.database.rollback() raise error.Database( error.data_delete_error, error.get_error_message(error.data_delete_error))
def update_password(self, **kwargs): """ 修改用户密码 :param id: :param kwargs: :return: """ kwargs["update_time"] = common.get_time_now() kwargs["password"] = encode_password(kwargs["password"]) email = kwargs["email"] del kwargs["email"] try: users = model.Users result = users.update(**kwargs).where( (users.email == email)).execute() return result except Exception: model.database.rollback() raise error.Database( error.data_save_error, error.get_error_message(error.data_save_error))