def get(self, request, *args, **kwargs): """ 查看用户列表, 查询参数 text, is_superuser, is_active,排序参数 order 查询字段包括 name, mobile, email """ text = request.query_params.get('text') is_superuser = request.query_params.get('is_superuser') is_active = request.query_params.get('is_active') order = request.query_params.get('order') queryset = User.objects.all() if text: queryset = queryset.filter( Q(name=text) | Q(mobile=text) | Q(email=text)) if is_superuser: queryset = queryset.filter(is_superuser=self.dic[is_superuser]) if is_active: queryset = queryset.filter(is_active=self.dic[is_active]) if order: queryset = queryset.order_by(order) data = get_results(request, queryset, self, UserSerializer) return Response({ 'count': queryset.count(), 'users': data }, status.HTTP_200_OK)
def get(self, request, expert_id, *args, **kwargs): """ 查看某专家的期刊, 路径参数 expert_id 排序参数 order """ order = request.query_params.get('order') queryset = Periodical.filter_by_expert_id(expert_id) if queryset: if order: queryset = queryset.order_by(order) data = get_results(request, queryset, self, PeriodicalListSerializer) return Response({'count': queryset.count(), 'periodicals': data}, status.HTTP_200_OK) else: return Response({'error': 'there is no such expert'}, status.HTTP_404_NOT_FOUND)
def get(self, request, *args, **kwargs): """ 查看期刊列表, 查询参数 text,排序参数 order 模糊查询字段包括 title, keywords 精准查询字段包括 doi, first_creator """ text = request.query_params.get('text') order = request.query_params.get('order') queryset = Periodical.objects.all() if text: queryset = queryset.filter( Q(doi=text) | Q(title__contains=text) | Q(first_creator=text) | Q(keywords__contains=text) ) if order: queryset = queryset.order_by(order) data = get_results(request, queryset, self, PeriodicalDetailSerializer) return Response({'count': queryset.count(), 'periodicals': data}, status.HTTP_200_OK)
def get(self, request, expert_id, *args, **kwargs): """ 查看某一个专家的科技成果列表 路径参数 expert_id,排序参数 order """ order = request.query_params.get('order') queryset = Achievement.filter_by_expert_id(expert_id) if queryset: if order: queryset = queryset.order_by(order) data = get_results(request, queryset, self, AchievementListSerializer) return Response({ 'count': queryset.count(), 'achievements': data }, status.HTTP_200_OK) else: return Response({'error': 'there is nos such expert'}, status.HTTP_404_NOT_FOUND)
def get(self, request, *args, **kwargs): """ 查看专家列表, 查询字段 text,排序参数 order 模糊查询字段包括 major, research_areas, keywords 精准查询字段包括 name, organization """ text = request.query_params.get('text') order = request.query_params.get('order') queryset = Expert.objects.all() if text: queryset = queryset.filter( Q(name=text) | Q(organization=text) | Q(major__contains=text) | Q(research_areas__contains=text) | Q(keywords__contains=text) ) if order: queryset = queryset.order_by(order) data = get_results(request, queryset, self, ExpertListSerializer) return Response({'count': queryset.count(), 'experts': data}, status.HTTP_200_OK)
def get(self, request, *args, **kwargs): """ 查看专利列表, 查询参数 text,排序参数 order 模糊查询字段包括 name, inventors 精准查询字段包括 patent_code, publication_number """ text = request.query_params.get('text') order = request.query_params.get('order') queryset = Patent.objects.all() if text: queryset = queryset.filter( Q(patent_code=text) | Q(publication_number=text) | Q(name__contains=text) | Q(inventors__contains=text)) if order: queryset = queryset.order_by(order_params) data = get_results(request, queryset, self, PatentListSerializer) return Response({ 'count': queryset.count(), 'patents': data }, status.HTTP_200_OK)
def get(self, request, *args, **kwargs): """ 查看科技成果列表, 查询参数 text,排序字段 order 模糊查询字段包括 title, keywords, organizations, creators 精准查询字段包括 sn """ text = request.query_params.get('text') order = request.query_params.get('order') queryset = Achievement.objects.all() if text: queryset = queryset.filter( Q(sn=text) | Q(title__contains=text) | Q(keywords__contains=text) | Q(organizations__contains=text) | Q(creators__contains=text)) if order: queryset = queryset.order_by(order) data = get_results(request, queryset, self, AchievementListSerializer) return Response({ 'count': queryset.count(), 'achievements': data }, status.HTTP_200_OK)