def put(self, request, *args, **kwargs): """ 修改插件配置信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: plugin_id description: 插件ID required: true type: string paramType: path - name: build_version description: 版本 required: true type: string paramType: path - name: body description: 配置组内容 required: true type: string paramType: body """ config = request.data injection = config.get("injection") service_meta_type = config.get("service_meta_type") config_name = config.get("config_name") config_group_pk = config.get("ID") config_groups = plugin_config_service.get_config_group( self.plugin_version.plugin_id, self.plugin_version.build_version).exclude(pk=config_group_pk) is_pass, msg = plugin_config_service.check_group_config( service_meta_type, injection, config_groups) if not is_pass: return Response(general_message(400, "param error", msg), status=400) config_group = plugin_config_service.get_config_group_by_pk( config_group_pk) old_meta_type = config_group.service_meta_type plugin_config_service.update_config_group_by_pk( config_group_pk, config_name, service_meta_type, injection) # 删除原有配置项 plugin_config_service.delet_config_items( self.plugin_version.plugin_id, self.plugin_version.build_version, old_meta_type) options = config.get("options") plugin_config_service.create_config_items( self.plugin_version.plugin_id, self.plugin_version.build_version, service_meta_type, *options) result = general_message(200, "success", "修改成功") return Response(result, status=result["code"])
def post(self, request, *args, **kwargs): """ 添加插件配置信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: plugin_id description: 插件ID required: true type: string paramType: path - name: build_version description: 版本 required: true type: string paramType: path - name: body description: 配置组内容 required: true type: string paramType: body """ try: config = request.data injection = config.get("injection") service_meta_type = config.get("service_meta_type") config_groups = plugin_config_service.get_config_group( self.plugin_version.plugin_id, self.plugin_version.build_version) is_pass, msg = plugin_config_service.check_group_config( service_meta_type, injection, config_groups) if not is_pass: return Response(general_message(400, "param error", msg), status=400) create_data = [config] plugin_config_service.create_config_groups( self.plugin_version.plugin_id, self.plugin_version.build_version, create_data) result = general_message(200, "success", "添加成功") except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])