def get(self, request, team_name, group_id, *args, **kwargs): """ 查询是否有未确认分享订单记录 --- parameter: - name: team_name description: 团队名 required: true type: string paramType: path - name: group_id description: 应用id required: true type: string paramType: path """ data = [] share_records = share_repo.get_service_share_records_by_groupid(group_id=group_id) if share_records: for share_record in share_records: app = rainbond_app_repo.get_rainbond_app_by_app_id(self.tenant.enterprise_id, share_record.app_id) app_version = rainbond_app_repo.get_rainbond_app_version_by_record_id(share_record.ID) data.append({ "app_id": share_record.app_id, "app_name": app.app_name, "app_version": app_version.version, "scope": app.scope, "create_time": share_record.create_time, "step": share_record.step, "is_success": share_record.is_success }) result = general_message(200, "success", None, list=data) return Response(result, status=200)
def get(self, request, team_name, group_id, record_id, *args, **kwargs): data = None share_record = share_repo.get_service_share_record_by_id( group_id=group_id, record_id=record_id) if share_record: app_model_name = None app_model_id = None version = None version_alias = None upgrade_time = None store_name = None store_version = "1.0" store_id = share_record.share_app_market_name scope = share_record.scope if store_id: extend, market = app_market_service.get_app_market( self.tenant.enterprise_id, share_record.share_app_market_name, extend="true", raise_exception=True) if market: store_name = market.name store_version = extend.get("version", store_version) app = rainbond_app_repo.get_rainbond_app_by_app_id( self.tenant.enterprise_id, share_record.app_id) if app: app_model_id = share_record.app_id app_model_name = app.app_name app_version = rainbond_app_repo.get_rainbond_app_version_by_record_id( share_record.ID) if app_version: version = app_version.version version_alias = app_version.version_alias upgrade_time = app_version.upgrade_time data = { "app_model_id": app_model_id, "app_model_name": app_model_name, "version": version, "version_alias": version_alias, "scope": scope, "create_time": share_record.create_time, "upgrade_time": upgrade_time, "step": share_record.step, "is_success": share_record.is_success, "status": share_record.status, "scope_target": { "store_name": store_name, "store_id": store_id, "store_version": store_version }, "record_id": share_record.ID, } result = general_message(200, "success", None, bean=data) return Response(result, status=200)
def get(self, request, team_name, group_id, *args, **kwargs): data = [] market = dict() cloud_app = dict() page = int(request.GET.get("page", 1)) page_size = int(request.GET.get("page_size", 10)) total, share_records = share_repo.get_service_share_records_by_groupid( team_name=team_name, group_id=group_id, page=page, page_size=page_size) if not share_records: result = general_message(200, "success", "获取成功", bean={'total': total}, list=data) return Response(result, status=200) for share_record in share_records: app_model_name = share_record.share_app_model_name app_model_id = share_record.app_id upgrade_time = None store_name = share_record.share_store_name store_id = share_record.share_app_market_name scope = share_record.scope if scope != "goodrain" and not app_model_name: app = rainbond_app_repo.get_rainbond_app_by_app_id(self.tenant.enterprise_id, share_record.app_id) app_model_name = app.app_name if app else "" app_version = rainbond_app_repo.get_rainbond_app_version_by_record_id(share_record.ID) if app_version: upgrade_time = app_version.upgrade_time share_record.share_version_alias = app_version.version_alias share_record.share_app_version_info = app_version.app_version_info share_record.share_app_model_name = app_model_name share_record.save() if scope == "goodrain" and store_id and share_record.app_id and not app_model_name: try: mkt = market.get(share_record.share_app_market_name, None) if not mkt: mkt = app_market_service.get_app_market_by_name( self.tenant.enterprise_id, share_record.share_app_market_name, raise_exception=True) market[share_record.share_app_market_name] = mkt c_app = cloud_app.get(share_record.app_id, None) if not c_app: c_app = app_market_service.get_market_app_model(mkt, share_record.app_id, True) cloud_app[share_record.app_id] = c_app store_name = c_app.market_name app_model_name = c_app.app_name share_record.share_app_model_name = app_model_name share_record.share_store_name = store_name share_record.save() except ServiceHandleException: app_model_id = share_record.app_id data.append({ "app_model_id": app_model_id, "app_model_name": app_model_name, "version": share_record.share_version, "version_alias": share_record.share_version_alias, "scope": scope, "create_time": share_record.create_time, "upgrade_time": upgrade_time, "step": share_record.step, "is_success": share_record.is_success, "status": share_record.status, "scope_target": { "store_name": store_name, "store_id": store_id, }, "record_id": share_record.ID, "app_version_info": share_record.share_app_version_info, }) result = general_message(200, "success", "获取成功", bean={'total': total}, list=data) return Response(result, status=200)
def get(self, request, team_name, group_id, *args, **kwargs): data = [] share_records = share_repo.get_service_share_records_by_groupid(group_id=group_id) if share_records: for share_record in share_records: app_model_name = None app_model_id = None version_alias = None upgrade_time = None # todo get store name store_name = None store_id = None scope = share_record.scope app = rainbond_app_repo.get_rainbond_app_by_app_id(self.tenant.enterprise_id, share_record.app_id) if app: app_model_id = share_record.app_id app_model_name = app.app_name store_id = share_record.share_app_market_id app_version = rainbond_app_repo.get_rainbond_app_version_by_record_id(share_record.ID) if app_version: version_alias = app_version.version_alias upgrade_time = app_version.upgrade_time else: if share_record.share_app_market_id: store_id = share_record.share_app_market_id try: if store_id and share_record.app_id: cloud_app = market_sycn_service.get_cloud_app( self.tenant.enterprise_id, share_record.share_app_market_id, share_record.app_id) if cloud_app: app_model_id = share_record.app_id app_model_name = cloud_app.name except ServiceHandleException: app_model_id = share_record.app_id data.append({ "app_model_id": app_model_id, "app_model_name": app_model_name, "version": share_record.share_version, "version_alias": (share_record.share_version_alias if share_record.share_version_alias else version_alias), "scope": scope, "create_time": share_record.create_time, "upgrade_time": upgrade_time, "step": share_record.step, "is_success": share_record.is_success, "status": share_record.status, "scope_target": { "store_name": store_name, "store_id": store_id, }, "record_id": share_record.ID, }) result = general_message(200, "success", None, list=data) return Response(result, status=200)