def post(self, request):
        post_data = json.loads(request.body)
        form = FeedStep1Form(post_data)
        if not form.is_valid():
            return JsonResponse({
                'status': 'form_error',
                'msg': '表单错误',
                'errors': form.errors,
            })

        form_data = form.cleaned_data
        result = ParseUtils.parse_jd(form_data)

        data = result.get('data', {})
        return JsonResponse({
            'status': 'ok',
            'data': {
                'analyze_keywords': [i.strip() for i in data.get('keywords', []) if i.strip()],
                'analyze_job_domain': list(CompanyCategory.objects.filter(
                    category__in=data.get('job_domain', []),
                ).values('id', 'category')),
                'analyze_titles': [i.strip() for i in data.get('extend_titles', []) if i.strip()],
                'feed_extra_info': {
                    'language': data.get('language', ''),
                    'degree': data.get('degree') or 0,
                    'gender': data.get('gender', ''),
                    'major': data.get('major', ''),
                    'job_type': data.get('job_type', ''),
                },
            },
        })
Exemple #2
0
    def post(self, request):
        post_data = json.loads(request.body)
        form = FeedStep1Form(post_data)
        if not form.is_valid():
            return JsonResponse({
                'status': 'form_error',
                'msg': '表单错误',
                'errors': form.errors,
            })

        form_data = form.cleaned_data
        result = ParseUtils.parse_jd(form_data)

        data = result.get('data', {})
        return JsonResponse({
            'status': 'ok',
            'data': {
                'analyze_keywords':
                [i.strip() for i in data.get('keywords', []) if i.strip()],
                'analyze_job_domain':
                list(
                    CompanyCategory.objects.filter(category__in=data.get(
                        'job_domain', []), ).values('id', 'category')),
                'analyze_titles': [
                    i.strip() for i in data.get('extend_titles', [])
                    if i.strip()
                ],
                'feed_extra_info': {
                    'language': data.get('language', ''),
                    'degree': data.get('degree') or 0,
                    'gender': data.get('gender', ''),
                    'major': data.get('major', ''),
                    'job_type': data.get('job_type', ''),
                },
            },
        })