def get(self, request, team_name, share_id, *args, **kwargs): """ 查询分享的所有应用信息和插件信息 --- parameter: - name: team_name description: 团队名 required: true type: string paramType: path - name: share_id description: 分享订单ID required: true type: string paramType: path """ data = dict() scope = request.GET.get("scope") share_record = share_service.get_service_share_record_by_ID(ID=share_id, team_name=team_name) if not share_record: result = general_message(404, "share record not found", "分享流程不存在,请退出重试") return Response(result, status=404) if share_record.is_success or share_record.step >= 3: result = general_message(400, "share record is complete", "分享流程已经完成,请重新进行分享") return Response(result, status=400) if not scope: scope = share_record.scope service_info_list = share_service.query_share_service_info(team=self.team, group_id=share_record.group_id, scope=scope) data["share_service_list"] = service_info_list plugins = share_service.get_group_services_used_plugins(group_id=share_record.group_id) data["share_plugin_list"] = plugins result = general_message(200, "query success", "获取成功", bean=data) return Response(result, status=200)
def get(self, request, team_name, share_id, *args, **kwargs): """ 查询分享的所有应用信息和插件信息 --- parameter: - name: team_name description: 团队名 required: true type: string paramType: path - name: share_id description: 分享订单ID required: true type: string paramType: path """ try: share_record = share_service.get_service_share_record_by_ID( ID=share_id, team_name=team_name) if not share_record: result = general_message(404, "share record not found", "分享流程不存在,请退出重试") return Response(result, status=404) if share_record.is_success or share_record.step >= 3: result = general_message(400, "share record is complete", "分享流程已经完成,请重新进行分享") return Response(result, status=400) # 获取分享应用组基本信息 data = dict() share_group_info = dict() share_group = share_service.check_whether_have_share_history( group_id=share_record.group_id) if share_group: share_group_info["group_key"] = share_group.group_key share_group_info["group_name"] = share_group.group_name share_group_info["version"] = share_group.version share_group_info["describe"] = share_group.describe share_group_info["scope"] = share_group.scope share_group_info["share_id"] = share_group.ID share_group_info["pic"] = share_group.pic share_group_info["share_team"] = share_group.share_team share_group_info["share_user"] = share_group.share_user share_group_info["is_shared"] = True data["share_group_info"] = share_group_info else: try: user = user_services.get_user_by_user_name( user_name=request.user) if not user: result = general_message(400, "user failed", "数据紊乱,非当前用户操作页面") return Response(result, status=400) except UserNotExistError as e: result = general_message(400, e.message, "用户不存在") return Response(result, status=400) code, msg, group = group_service.get_group_by_id( tenant=self.team, region=self.response_region, group_id=share_record.group_id) if code == 200: share_group_info["group_key"] = make_uuid() share_group_info["group_name"] = group.get("group_name") share_group_info["version"] = 'v1.0' share_group_info[ "describe"] = 'This is a default description.' share_group_info["scope"] = 'team' share_group_info["share_id"] = share_record.group_id share_group_info["pic"] = '' share_group_info["share_team"] = team_name share_group_info["share_user"] = str(user.user_id) share_group_info["is_shared"] = False data["share_group_info"] = share_group_info else: result = general_message(code=code, msg="failed", msg_show=msg) return Response(result, status=code) service_info_list = share_service.query_share_service_info( team=self.team, group_id=share_record.group_id) data["share_service_list"] = service_info_list plugins = share_service.get_group_services_used_plugins( group_id=share_record.group_id) data["share_plugin_list"] = plugins result = general_message(200, "query success", "获取成功", bean=data) return Response(result, status=200) except ServiceHandleException as e: raise e except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=500)