示例#1
0
    def process(self):
        setting_id = self.parameters.get('setting_id')
        logging.info("GetSettingView. setting_id:{}".format(setting_id))
        setting = SettingService.get_setting(setting_id)
        if not setting.timestamp or (int(time.time()) - setting.timestamp >
                                     60):
            SettingService.update_status_by_name(setting)
            setting = SettingService.get_setting(setting_id)

        if (setting):
            setting_info = {
                'setting_id':
                setting.id,
                "setting_name":
                setting.name,
                "setting_value":
                setting.value,
                "setting_additional":
                setting.additional,
                "setting_status":
                json.loads(setting.status if setting.status else '{}'),
                "setting_timestamp":
                setting.timestamp
            }

            return {
                "code": 200,
                "message": "get setting success",
                "results": setting_info
            }
        return {"code": 4021, "message": returncode['4021']}, 400
示例#2
0
 def process(self):
     setting_id = self.parameters.get('setting_id')
     setting_data = SettingService.get_setting(setting_id)
     if setting_data:
         SettingService.delete_setting(setting_id)
         db.session.commit()
         return {"code": 200, "message": "delete success"}
     else:
         return {"code": 4021, "message": returncode['4021']}, 401
示例#3
0
    def process(self):
        setting_body = self.parameters.get('body')
        setting_id = self.parameters.get('setting_id')
        current_settingdata = SettingService.get_setting(setting_id)
        if current_settingdata:
            if setting_body.get('id'):
                return {"code": 4012, "message": returncode['4012']}, 400
            logging.info(
                "ModifySettingViewByID. SettingService.modify_setting_by_id:{}{}"
                .format(setting_id, setting_body))
            SettingService.modify_setting_by_id(setting_id,
                                                update_data=setting_body)
            db.session.commit()
            return {"code": 200, "message": "modify setting success"}

        else:
            return {"code": 4021, "message": returncode['4021']}, 400