예제 #1
0
 def __init__(self, intent: JobIntent):
     filter_positions = None
     if intent.job_intent_min_wages == 0:
         filter_positions = Position.objects.filter(
             (Q(position_tags__icontains=intent.job_intent_type)
              | Q(position_region__icontains=intent.job_intent_region)
              | Q(position_education__icontains=intent.job_intent_education)
              ) & Q(position_state=BaseModel.text2state("正常")))
     else:
         filter_positions = Position.objects.filter(
             (Q(position_tags__icontains=intent.job_intent_type)
              | Q(position_min_wages__lte=intent.job_intent_min_wages)
              | Q(position_max_wages__gte=intent.job_intent_max_wages)
              | Q(position_region__icontains=intent.job_intent_region)
              | Q(position_education__icontains=intent.job_intent_education)
              ) & Q(position_state=BaseModel.text2state("正常")))
     train_set = {}
     uid_pid = BrowsingHistory.objects.all().values(
         'user__user_id', 'position__position_id')
     for query in uid_pid:
         user_id = query["user__user_id"]
         position_id = query["position__position_id"]
         train_set.setdefault(user_id, {})
         train_set[user_id][position_id] = 1
     self.data_set = train_set
     self.filter_positions = filter_positions
     self.recommend_position_ids = {}
예제 #2
0
 def wages_bt(self):
     num_start, num_end = self.check_num()
     res = Position.objects.filter(
         position_min_wages__lte=num_start,
         position_max_wages__gte=num_end,
         position_state=BaseModel.text2state("正常"))
     return res
예제 #3
0
 def position_wages_lt(self):
     num_start, num_end = self.check_num()
     position = self.check_job()
     res = Position.objects.filter(
         position_max_wages__gte=num_start,
         position_tags__icontains=position,
         position_state=BaseModel.text2state("正常"))
     return res
예제 #4
0
 def get(self, request: HttpRequest):
     three_days_ago = datetime.datetime.now() - datetime.timedelta(days=3)
     all_positions = Position.objects.filter(position_send_time__gt=three_days_ago,
                                             company__company_state=BaseModel.text2state("正常")) \
         .order_by('-position_send_time')
     newest = get_std_job_data(all_positions)
     rt = get_value_dict(newest)
     return ret_data(200, rt, "ok")
예제 #5
0
 def position_address(self):
     position = self.check_job()
     address = self.check_address()
     res = Position.objects.filter(
         position_region__icontains=address,
         position_tags__icontains=position,
         position_state=BaseModel.text2state("正常"))
     return res
예제 #6
0
 def get(self, request: HttpRequest):
     position_id = request.GET.get("positionId")
     pr_dict = PositionResume.objects.filter(position_id=position_id) \
         .exclude(position_resume_checked__exact=BaseModel.text2state("已删除")) \
         .values('user__user_name', 'position_resume_time', 'resume__resume_name',
                 'resume__resume_type', 'resume__resume_size', 'resume__resume_id',
                 'resume__resume_file') \
         .order_by("-position_resume_time")
     return ret_data(
         200, get_value_dict(get_job_value_dict(pr_dict, "resume__")), "ok")
예제 #7
0
 def _create_or_update_history(self, position_id, user_id):
     obj, create = BrowsingHistory.objects. \
         update_or_create(position__position_id=position_id,
                          user__user_id=user_id,
                          defaults={
                              "user_id": user_id,
                              "position_id": position_id,
                              "browsing_history_time": datetime.datetime.now(),
                              "browsing_history_state": BaseModel.text2state("正常")
                          })
예제 #8
0
 def wages_lt_address(self):
     num_start, num_end = self.check_num()
     if num_start > num_end:
         num_start, num_end = num_end, num_start
     address = self.check_address()
     res = Position.objects.filter(
         position_max_wages__lte=num_end,
         position_region__icontains=address,
         position_state=BaseModel.text2state("正常"))
     return res
예제 #9
0
 def position(self):
     word_with_type = self.word_with_type
     _type = ''
     for word_type in word_with_type:
         if word_type["type"] == "jb":
             _type = word_type["type"]
             break
     res = Position.objects.filter(
         position_tags__icontains=_type,
         position_state=BaseModel.text2state("正常"))
     return res
예제 #10
0
 def position_wages_address(self):
     num_start, num_end = self.check_num()
     if num_start > num_end:
         num_start, num_end = num_end, num_start
     address = self.check_address()
     position = self.check_job()
     res = Position.objects.filter(
         Q(position_min_wages__lte=num_start)
         & Q(position_max_wages__gte=num_end),
         position_tags__icontains=position,
         position_region__icontains=address,
         position_state=BaseModel.text2state("正常"))
     return res
예제 #11
0
 def post(self, request: HttpRequest):
     position = Position()
     position.position_name = request.POST.get("positionName")
     position.position_type = request.POST.get("jobType")
     position.position_min_wages = request.POST.get("minWages")
     position.position_max_wages = request.POST.get("maxWages")
     position.position_education = request.POST.get("minEducation")
     position.position_experience = request.POST.get("minExperience")
     position.position_region = request.POST.get("region")
     position.position_detailed_location = request.POST.get(
         "detailedLocation")
     position.position_tags = request.POST.get("choosedTags")
     position.position_sender_position = request.POST.get("senderPosition")
     position.position_detail = request.POST.get("positionDetail")
     position.company_id = request.POST.get("companyId")
     position.position_state = BaseModel.text2state("待审核")
     position.save()
     return ret_data(200, None, "ok")
예제 #12
0
        def post(self, request: HttpRequest):
            code = request.POST.get("jsCode")
            nick_name = request.POST.get("nickName")
            sex = request.POST.get("sex")
            avatar_url = request.POST.get("avatarUrl")

            res = get_openid(code)
            if res["state"] == 200:
                openid = res["openid"]
                obj, create = User.objects.get_or_create(
                    user_openid=openid,
                    defaults={
                        "user_openid": openid,
                        "user_nickname": nick_name,
                        "user_sex": BaseModel.text2state(sex),
                        "user_avatar_url": avatar_url,
                    })
                obj.user_sex = BaseModel.state2text(obj.user_sex)
                obj.user_openid = None
                return ret_data(status=200, data=obj.dict(), msg="ok")
            return ret_data(status=500, data={}, msg="wx server error")
예제 #13
0
 def queryset(self, request, queryset):
     if self.value() == "unaudited":
         return queryset.filter(company_state=BaseModel.text2state("待审核"))
예제 #14
0
 def post(self, request: HttpRequest):
     position_resume_id = request.POST.get("positionResumeId")
     position_resume = PositionResume.objects.get(pk=position_resume_id)
     position_resume.position_resume_checked = BaseModel.text2state("已删除")
     position_resume.save()
     return ret_data(200, None, "ok")
예제 #15
0
 def post(self, request: HttpRequest):
     company_id = request.POST.get("companyId")
     company = Company.objects.get(pk=company_id)
     company.company_state = BaseModel.text2state("已删除")
     company.save()
     return ret_data(200, None, "ok")
예제 #16
0
    def get(self, request: HttpRequest):
        user_id = request.GET.get("userId")
        companies = Company.objects.filter(company_owner__user_id=user_id, company_state=BaseModel.text2state("正常")) \
            .values('company_id', 'company_name', 'company_establishment_date',
                    'company_logo_id',
                    position_count=Count('position'))

        return ret_data(200, get_value_dict(companies), "ok")
예제 #17
0
 def get(self, request: HttpRequest):
     company_id = request.GET.get("companyId")
     # 加上过滤state为删除状态
     positions = Position.objects.filter(company__company_id=company_id, position_state=BaseModel.text2state("正常")) \
         .values('company_id', 'position_id', 'position_name', 'position_min_wages',
                 'position_max_wages', 'position_tags', 'position_region',
                 resume_count=Count('positionresume'))
     return ret_data(200, get_value_dict(positions), "ok")
예제 #18
0
 def post(self, request: HttpRequest):
     position_id = request.POST.get("positionId")
     position = Position.objects.get(pk=position_id)
     position.position_state = BaseModel.text2state("已删除")
     position.save()
     return ret_data(200, None, "ok")