def blue_print_component(self, request, *args, **kwargs): """ 组件库添加/删除蓝图 """ msg_prefix = u"组件库添加/删除蓝图 " try: blue_print_instance = self.get_object() blue_print_category = blue_print_instance.category.name if blue_print_instance.is_component: blue_component_set = BlueComponentDefinition.objects.filter(component_entity=blue_print_instance.id) for blue_component in blue_component_set: blue_component.delete() else: blue_component_serializer = serializers.BlueComponentDefinitionSerializer(data=dict( component_category=blue_print_category, component_type=0, component_entity=blue_print_instance.id )) blue_component_serializer.is_valid() self.perform_create(blue_component_serializer) blue_print_instance.is_component = not blue_print_instance.is_component blue_print_instance.save() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def fuzzy_search_test(self, request): """ :param request: :return: """ msg_prefix = u"一级应用模糊搜索" req_dict = post_data_to_dict(request.data) search_keyword = smart_get(req_dict, 'search_keyword', str) try: first_app_set = self.get_queryset().filter( app_name__icontains=search_keyword) if not first_app_set: first_app_set1 = self.get_queryset().filter( app_short_name__icontains=search_keyword) if not first_app_set1: return Response({"status": 1, "msg": "暂无数据", "data": []}) else: serializer = self.get_serializer(first_app_set1, many=True) else: serializer = self.get_serializer(first_app_set, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}})
def option_edit(request): """ 修改动态表单选项 * 权限 - 超级管理员(SU) * 参数 ** app - 模块名称 ** name - 表单名称 ** value - 选项值 ** display - 选项显示名称 ** 其他 - 其他附加属性 """ msg_prefix = u"修改表单选项 <%s>:<%s> " req_dict = post_data_to_dict(request.data) app = req_dict.pop('app') name = req_dict.pop('name') value = req_dict.pop('value') display = req_dict.pop('display', '') try: updated = DataDict.options.update_option(app, name, value, display, **req_dict) data = DataDict.options.get_options_serialized(app, name) except Exception, e: msg = (msg_prefix % (name, value)) + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def group_delete(request): """ 删除用户组 * 权限 - 超级管理员(SU) * 参数 ** id - 组id """ msg_prefix = u"删除用户组 " req_dict = post_data_to_dict(request.data) id = smart_get(req_dict, 'id', int) try: # 获取用户组 group_set = ExGroup.objects.filter(id=id) if not group_set.exists(): raise Exception(u"没有符合条件的用户组") data = list(group_set.values('id', 'name', 'member_type')) group_set.delete() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(msg) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def update_note_data(self, request, *args, **kwargs): """ 更新子映射 :param request: :param args: :param kwargs: :return: """ msg_prefix = u"更新子映射" req_data = request.data serverMap_id = req_data.get('serverMap_id') node_id = req_data.get('node_id') page_id = req_data.get('page_id') try: page_obj = Pages.objects.filter(id=page_id).first() node_obj = TaskDefinition.objects.filter(id=node_id).first() instance = ServerMapWf.objects.filter(id=serverMap_id).first() instance.node_id = node_id instance.node_name = node_obj.taskName.taskName instance.page_id = page_obj.id instance.page_name = page_obj.name instance.save() data = model_to_dict(instance) # serializer = self.get_serializer(data=instance) except Exception, e: msg = msg_prefix + u"失败,错误信息:" + unicode(e) logger.error(format_exc()) return Response({'status': -1, 'msg': msg, "data": []})
def task_blue_note_update(data, last_data, **kwargs): """ :param data: :param args: :param kwargs: :return: """ msg_prefix = "节点更新任务" try: note_instance_data = data['data'] print "节点更新任务" * 10 print note_instance_data print "节点更新任务" * 10 last_data1 = last_data['data']['data'] d = BlueInstanceAPI(data) d1 = d.blue_note_update(ori_data=data, last_data=last_data1) # data 为 上个任务的data req_status = d1['status'] if not d1: msg = msg_prefix + u"失败" return {"status": -1, "msg": msg, "data": []} except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) blue_engine_logger.error(format_exc()) return {"status": -1, "msg": msg, "data": []}
def user_detail(request): """ 获取用户详情 * 参数 ** id - 用户id """ msg_prefix = u"获取用户详情 " req_user = request.user try: if request.method == 'GET': user = req_user else: req_dict = post_data_to_dict(request.data) id = smart_get(req_dict, 'id', int) user = ExUser.objects.get(pk=int(id)) serializer = serializers.ExUserDetailSerializer(user) except Exception, e: if isinstance(e, APIException): raise e msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(msg) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def create(self, request, *args, **kwargs): """ 创建服务目录分类 """ msg_prefix = "创建服务目录分类 " # req_dict = post_data_to_dict(request.data) queryset = ServerMenuCategory.objects.all() instance_len = len(queryset) i = 1 i += instance_len # print i try: serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) server_menu_instance = serializer.save() server_menu_instance.coding = "c%03d" % (i) server_menu_instance.save() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def related_node(self, request, *args, **kwargs): """ 节点间关系(上下游) * 参数 ** up_id, 上游节点id, int ** down_id, 下游节点id, int ** is_related, 是否添加关系, bool """ msg_prefix = u"更新节点间关系 " req_dict = post_data_to_dict(request.data) up_id = smart_get(req_dict, 'up_id', int) down_id = smart_get(req_dict, 'down_id', int) is_related = smart_get(req_dict, 'is_related', bool, False) try: up_instance = BlueNodeDefinition.objects.get(id=up_id) if is_related: up_instance.downstream_node.add(down_id) else: up_instance.downstream_node.remove(down_id) node_map_set = BlueNodeMapParam.objects.filter(target_node=down_id, source_node=up_id) for node_map in node_map_set: node_map.delete() up_instance.save() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def create(self, request, *args, **kwargs): """ 创建服务列表 """ msg_prefix = "服务列表 " req_category = request.data.get('category') if not req_category: msg = msg_prefix + u"失败, 分类必填" return Response({"status": -1, "msg": msg, "data": {}}) queryset = Servers.objects.filter(category=req_category).all() instance_len = len(queryset) i = 1 i += instance_len try: serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) server_instance = serializer.save() server_instance.coding = "s%03d" % (i) server_instance.save() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def group_list(request): """ 用户组列表 * 权限 - 超级管理员(SU) * 参数 ** search - 用户组名称 ** type - 用户类型 """ msg_prefix = u"获取用户组列表 " try: groups = ExGroup.objects.all() if request.method == 'POST': req_dict = post_data_to_dict(request.data) keyword = smart_get(req_dict, 'search', unicode, '') member_type = smart_get(req_dict, 'type', str, '').lower() if keyword: groups = groups.filter( Q(name__icontains=keyword) | Q(comment__icontains=keyword)) if member_type: groups = groups.filter(member_type=member_type) serializer = serializers.ExGroupSerializer(groups, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(msg) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def create(self, request, *args, **kwargs): """ 创建蓝图和服务的映射 :param request: :param args: :param kwargs: :return: """ msg_prefix = u"创建蓝图和服务映射" req_data = request.data blue_print_id = req_data.get("blue_print_id") button_id = req_data.get("button_id") blue_print_obj = BluePrintDefinition.objects.filter( id=blue_print_id).first() button_obj = Button.objects.filter(id=button_id).first() try: serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) instance = serializer.save() instance.blue_print_name = blue_print_obj.name instance.button_name = button_obj.name instance.synthesize_code = button_obj.composite_code instance.save() except Exception, e: logger.error(format_exc()) msg = msg_prefix + u"失败,错误信息:" + unicode(e) logger.error(format_exc()) return Response({'status': -1, 'msg': msg, "data": []})
def ajax_user_list(request): """ ajax请求 - 动态搜索 - 用户列表 * 参数 ** search - 搜索 ** limit - 返回记录条数 """ req_dict = post_data_to_dict(request.data) PYWorker = PinYin() search = smart_get(req_dict, 'search', unicode) limit = smart_get(req_dict, 'limit', int) try: result = [] q_set = ExUser.objects.all() if search: search = search.lower() for q in q_set: if search in q.username.lower() \ or search in q.name.lower() \ or search in PYWorker.hanzi2pinyin_split(q.name) \ or search in PYWorker.hanzi2firstletter(q.name): result.append(q) else: result = q_set serializer = ExUserSerializer(result[:limit], many=True) except Exception, e: msg = u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_secondary_app(self, request): msg_prefix = u"动态获取二级应用" req_dict = post_data_to_dict(request.data) primary_app_id = smart_get(req_dict, 'id', int) app_name = smart_get(req_dict, 'app_name', str) app_short_name = smart_get(req_dict, 'app_short_name', str) try: primary_ins = self.get_queryset().filter(id=primary_app_id).first() if not primary_ins: msg = msg_prefix + u"失败" return Response({"status": -1, "msg": msg, "data": []}) secondary_set = primary_ins.secondary.all() # print secondary_set if not secondary_set: msg = msg_prefix + u"失败" return Response({"status": -1, "msg": msg, "data": []}) list1 = [] for i in secondary_set: data1 = model_to_dict(i) if data1: list1.append(data1) # if list1: # return except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}})
def node_params(self, request, *args, **kwargs): """ 获取节点参数及参数映射信息 * 参数 ** source_id, 来源节点id, int ** target_id, 目标节点id, int """ msg_prefix = u"获取节点参数及参数映射信息 " req_dict = post_data_to_dict(request.data) source_id = smart_get(req_dict, 'source_id', int) target_id = smart_get(req_dict, 'target_id', int) try: source_node_instance = self.get_queryset().get(id=source_id) target_node_instance = self.get_queryset().get(id=target_id) target_params = target_node_instance.component_data.get('params') source_params = source_node_instance.component_data.get('params') # 两个节点间映射集合 exist_map_self_set = BlueNodeMapParam.objects.filter(target_node=target_id, source_node=source_id) # 目标节点所有映射集合 exist_map_all_set = BlueNodeMapParam.objects.filter(target_node=target_id) exist_params = serializers.BlueNodeMapParamSerializer(instance=exist_map_self_set, many=True).data # 参数过滤 for target_param in copy.deepcopy(target_params): # 删除输出项 have_io_stream = "io_stream" in [k for k, _ in target_param.items()] if have_io_stream: if target_param['io_stream'] == "输出": target_params.remove(target_param) continue # 删除其它节点已映射项 for exist_map in exist_map_all_set: if exist_map.target_param_name == target_param['param_name'] and exist_map.source_node != source_id: target_params.remove(target_param) continue for source_param in copy.deepcopy(source_params): # 删除输入项 have_io_stream = "io_stream" in [k for k, _ in source_param.items()] if have_io_stream: if source_param['io_stream'] == "输入": source_params.remove(source_param) continue params = dict( source_params=source_params, target_params=target_params, exist_params=exist_params ) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def user_mana_key(request): """ 管理用户RSA密钥 * 参数 ** generate - 生成新密钥 ** download - 下载私钥 ** passphrase - 私钥密码 ** puttykey - putty格式 """ msg_prefix = u"管理用户RSA密钥 " req_dict = post_data_to_dict(request.data) user = request.user generate = smart_get(req_dict, 'generate', bool, False) download = smart_get(req_dict, 'download', bool, False) passphrase = smart_get(req_dict, 'passphrase', str, '') puttykey = smart_get(req_dict, 'puttykey', bool, False) try: # admin系统内置账户不可更换密钥 if user.username == 'admin': generate = False if generate: user_gen_rsakey(user, key_expiration=timezone.now() + timezone.timedelta(days=ExUser.KEY_LIFE)) if download: key = get_rsakey_from_string(user.ssh_key_str, passphrase=ExUser.KEY_PASSPHRASE) if puttykey: key_filename = "putty_pkey.ppk" key_string = toString_PUTTY_private(key, passphrase=passphrase) else: key_filename = "{username}.id_rsa".format( username=user.username) key_string = get_key_string(key, passphrase=passphrase) response = StreamingHttpResponse( content_type='application/octet-stream') response[ 'Content-Disposition'] = "attachment; filename={filename}".format( filename=key_filename) response.streaming_content = key_string return response except Exception, e: if isinstance(e, APIException): raise e msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def list(self, request, *args, **kwargs): msg_prefix = "获取蓝图列表 " try: query_set = self.get_queryset().filter(keep_status=1) serializer = self.get_serializer(instance=query_set, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def component_type(self, request, *args, **kwargs): """ 获取组件实体类型 """ msg_prefix = u"获取组件实体类型 " try: component_type = COMPONENT_TYPE except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def order_list(self, request, *args, **kwargs): """ 给列表排序 :param request: :param args: :param kwargs: :return: """ msg_prefix = u"筛选" # req_dict = post_data_to_dict(request.data) status_num = request.data.get("status") order_reverse = request.data.get("order_reverse") # order_queryset = self.get_queryset().filter(status=status_num) # # status_num = smart_get(req_dict, "status", str) # # order_reverse = smart_get(req_dict, "order_reverse", str) # # ori_queryset = self.get_queryset() # ori_queryset_ord = self.get_queryset().order_by("-" + "id") # # order_queryset_reverse = self.get_queryset().filter(status=status_num).order_by("-" + "startTime") # if not (status_num and order_reverse): # serializer = self.get_serializer(instance=ori_queryset, many=True) # elif status_num == '' and order_reverse == '-': # serializer = self.get_serializer(instance=ori_queryset_ord, many=True) # # if order_reverse == "-": # serializer = self.get_serializer(instance=order_queryset_reverse, many=True) # else: # serializer = self.get_serializer(instance=order_queryset, many=True) # # serializer = self.get_serializer(instance=order_queryset, many=True) try: if not order_reverse and status_num: # 進行中 默認 order_queryset = self.get_queryset().filter(status=status_num) serializer = self.get_serializer(instance=order_queryset, many=True) # ori_queryset = self.get_queryset() # serializer = self.get_serializer(instance=ori_queryset, many=True) elif not status_num and order_reverse: # 默認 倒敘 ori_queryset_ord = self.get_queryset().order_by("-" + "id") serializer = self.get_serializer(instance=ori_queryset_ord, many=True) elif status_num and order_reverse: order_queryset_reverse = self.get_queryset().filter(status=status_num).order_by("-" + "startTime") serializer = self.get_serializer(instance=order_queryset_reverse, many=True) else: ori_queryset = self.get_queryset() serializer = self.get_serializer(instance=ori_queryset, many=True) except Exception, e: msg = msg_prefix + u"失败,错误信息:" + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_blue_nodes(self, request, *args, **kwargs): """ 获取蓝图节点 """ msg_prefix = u"获取蓝图节点 " try: blue_print_instance = self.get_object() nodes = blue_print_instance.blue_nodes.all() nodes_serializer = serializers.BlueNodeDefinitionSerializer(instance=nodes, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def update_url(self, request): """ - 生成接口配置文件中接口数据 """ msg_prefix = u"接口url查询 " try: urls = interface_config.blue_url for url in urls: requests.options(url) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def option_apps(request): """ 获取动态参数APP列表 返回: app列表 """ msg_prefix = u"获取动态参数APP列表 " try: apps = DataDict.options.get_app() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def user_add(request): """ 添加用户 * 参数 ** username - 用户名称 ** email - 邮箱地址 ** password - 密码 ** aam_id - 统一认证号 ** name - 显示名称 ** group_id - 用户组id(','号分隔列表) ** role - 角色(CU/GM/SN), SU只通过后台创建 """ msg_prefix = u"添加用户 %s " req_dict = post_data_to_dict(request.data) username = smart_get(req_dict, 'username', str) email = smart_get(req_dict, 'email', str) password = smart_get(req_dict, 'password', str) aam_id = smart_get(req_dict, 'aam_id', str, '') group_id = smart_get(req_dict, 'group_id', list, default_list=None) name = smart_get(req_dict, 'name', unicode, '') role = smart_get(req_dict, 'role', str, 'CU') try: if ExUser.objects.filter(username=username): raise Exception(u'用户名已存在') user = ExUser.objects.create_user(username, email, password, name, role, aam_id=aam_id) user_gen_rsakey(user, key_expiration=timezone.now() + timezone.timedelta(days=ExUser.KEY_LIFE)) user_id = user.id if group_id: for var in group_id: group = ExGroup.objects.get(pk=int(var)) group_add_user(group, user_id) serializer = serializers.ExUserSerializer(user) except Exception, e: msg = (msg_prefix % username) + u"失败, 错误信息: " + unicode(e) logger.error(msg) return Response({ "status": -1, "msg": msg, "data": {} }, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def option_names(request): """ 根据应用名获取表单名 """ msg_prefix = u"获取表单名列表 " req_dict = post_data_to_dict(request.data) app = req_dict.pop('app') try: names = DataDict.options.get_name(app=app) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def acc_module_params(self, request, *args, **kwargs): """ 蓝图接入模块参数组参数 """ msg_prefix = u"蓝图接入模块参数组参数 " try: acc_module_params_instance = self.get_object() params = acc_module_params_instance.params.all() pre_group_params_serializer = serializers.BlueAccessModuleParamsGroupParamSerializer(instance=params, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get_blue(self, request): """ 根据类别过滤蓝图 * 参数 ** category_name, 分类名, str """ msg_prefix = u"蓝图过滤 " try: blue_category_id = request.data.get('blue_category_id') queryset = self.get_queryset().filter(category_id=blue_category_id, keep_status=1) serializer = self.get_serializer(instance=queryset, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def interface_params(self, request, *args, **kwargs): """ 获取接口参数 """ msg_prefix = u"获取接口参数 " req_dict = post_data_to_dict(request.data) io_stream = smart_get(req_dict, 'io_stream', str) try: interface_instance = self.get_object() params = interface_instance.params.filter(io_stream=io_stream) interface_params_serializer = serializers.BlueInterfaceParamSerializer(instance=params, many=True) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def category_of_type(self, request, *args, **kwargs): """ 获取组件实体分类 """ msg_prefix = u"获取组件实体分类 " req_dict = post_data_to_dict(request.data) component_type = smart_get(req_dict, 'component_type', int) try: component_category = set() queryset = self.get_queryset().filter(component_type=component_type) for cc in queryset: component_category.add(cc.component_category) except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def link_data(self, request, *args, **kwargs): """ 画板连线数据 * 参数 ** link_data, 连线数据, list """ msg_prefix = u"更新画板连线数据 " req_dict = post_data_to_dict(request.data) link_data = smart_get(req_dict, 'link_data', list) try: blue_print = self.get_object() blue_print.link_data = link_data blue_print.save() except Exception, e: msg = msg_prefix + u"失败, 错误信息: " + unicode(e) logger.error(format_exc()) return Response({"status": -1, "msg": msg, "data": {}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def find_map_relation(self, request, *args, **kwargs): """ 返回对应关系 :param request: :param args: :param kwargs: :return: """ msg_prefix = u"查找对应关系" req_dict = post_data_to_dict(request.data) category_code = smart_get(req_dict, 'category_code', str) page_code = smart_get(req_dict, 'page_code', str) service_code = smart_get(req_dict, 'service_code', str) button_code = smart_get(req_dict, 'button_code', str) try: synthesize_code = category_code + service_code + page_code + button_code wf_map_ins = self.get_queryset().filter( synthesize_code=synthesize_code).first() bp_map_ins = ServerMapBp.objects.filter( synthesize_code=synthesize_code).first() data = {} if not wf_map_ins and not bp_map_ins: msg = msg_prefix + u"失败," logger.error(format_exc()) return Response({'status': -1, 'msg': msg, "data": []}) elif wf_map_ins and not bp_map_ins: wf_map_dict = model_to_dict(wf_map_ins) data['wf_map_relation'] = wf_map_dict elif bp_map_ins and not wf_map_ins: bp_map_dict = model_to_dict(bp_map_ins) data['bp_map_relation'] = bp_map_dict else: bp_map_dict = model_to_dict(bp_map_ins) data['bp_map_relation'] = bp_map_dict wf_map_dict = model_to_dict(wf_map_ins) data['wf_map_relation'] = wf_map_dict except Exception, e: msg = msg_prefix + u"失败,错误信息:" + unicode(e) logger.error(format_exc()) return Response({'status': -1, 'msg': msg, "data": []})