wupengfei
9 小时以前 aebf1603cd6df5341160ffe23c715919bf14c4a7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { MaybeRef, computed, unref } from 'vue';
import * as userResumeServices from '@12333/services/apiV2/userResume';
import * as enterpriseEmployeeServices from '@12333//services/apiV2/enterpriseEmployee';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
 
type UseUserResumeOptions = {
  userId?: MaybeRef<string>;
  enterpriseEmployeeId?: MaybeRef<string>;
};
 
export function useUserResume(options: UseUserResumeOptions = {}) {
  const { userId, enterpriseEmployeeId } = options;
 
  const { data, refetch, isLoading, isError } = useQuery({
    queryKey: ['userResumeServices/getUserResume', userId, enterpriseEmployeeId],
    queryFn: async () => {
      return await userResumeServices.getUserResume(
        { userId: unref(userId), enterpriseEmployeeId: unref(enterpriseEmployeeId) },
        {
          showLoading: false,
        }
      );
    },
    placeholderData: () => ({} as API.GetUserResumeQueryResult),
    enabled: computed(() => !!unref(userId) || !!unref(enterpriseEmployeeId)),
  });
 
  return {
    userResumeInfo: data,
    refetch,
    isLoading,
    isError,
  };
}
 
export function useUpdateResume() {
  const queryClient = useQueryClient();
 
  const updateUserResumeCredentials = () => {
    return queryClient.invalidateQueries({
      queryKey: ['userResumeServices/getUserResumeCredentials'],
    });
  };
 
  const updateUserResume = () => {
    return queryClient.invalidateQueries({
      queryKey: ['userResumeServices/getUserResume'],
    });
  };
 
  return {
    updateUserResumeCredentials,
    updateUserResume,
  };
}
 
type UseGetEnterpriseEmployeeOptions = {
  id?: MaybeRef<string>;
};
 
export function useGetEnterpriseEmployee(options: UseGetEnterpriseEmployeeOptions = {}) {
  const { id } = options;
 
  const { data, refetch, isLoading, isError } = useQuery({
    queryKey: ['enterpriseEmployeeServices/getEnterpriseEmployee', id],
    queryFn: async () => {
      return await enterpriseEmployeeServices.getEnterpriseEmployee(
        { id: unref(id) },
        {
          showLoading: false,
        }
      );
    },
    placeholderData: () => ({} as API.GetEnterpriseEmployeeQueryResult),
    enabled: computed(() => !!unref(id)),
  });
 
  return {
    enterpriseEmployeeInfo: data,
    refetch,
    isLoading,
    isError,
  };
}