diff --git a/handler/ad.py b/handler/ad.py index 0b399d4..3bc130a 100644 --- a/handler/ad.py +++ b/handler/ad.py @@ -207,12 +207,14 @@ class Ad(Resource): if data: condition = f"id='{self.args['id']}'" self.mydb.update("ad", ad, condition) - time.sleep(1) - if rebuild_ad(): - log.info(f"rebuild cache via ad change!") - return jsonify({'code': 200, 'message': 'update adid={id} success!'}) + if ad['status'] == 1: + if rebuild_ad(): + log.info(f"rebuild cache via ad change!") + return jsonify({'code': 200, 'message': 'update adid={id} success!'}) + else: + return jsonify({'code': 500, 'message': 'rebuild cache failed!'}) else: - return jsonify({'code': 500, 'message': 'rebuild cache failed!'}) + return jsonify({'code': 200, 'message': 'update adid={id} success!'}) else: return jsonify({'code': 404, 'message': f"{self.args['id']} not found in mysql!"}) except Exception: