From 23f7ec5f7cd67322617e623361a5620d405dfeda Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期三, 22 十二月 2021 12:00:30 +0800 Subject: [PATCH] refactor: separate api/appointment.ts into several services --- /dev/null | 29 ----------------------------- PAMapp/store/index.ts | 4 ++-- PAMapp/shared/services/appointment.service.ts | 9 +-------- PAMapp/components/Client/ClientCard.vue | 3 ++- PAMapp/shared/services/reviews.service.ts | 5 +++++ PAMapp/shared/services/my-consultant.service.ts | 8 ++++++++ 6 files changed, 18 insertions(+), 40 deletions(-) diff --git a/PAMapp/components/Client/ClientCard.vue b/PAMapp/components/Client/ClientCard.vue index 37300cc..b600629 100644 --- a/PAMapp/components/Client/ClientCard.vue +++ b/PAMapp/components/Client/ClientCard.vue @@ -100,6 +100,7 @@ import { isMobileDevice } from '~/shared/device'; import { hideReviews } from '~/shared/const/hide-reviews'; import { ClientInfo } from '~/shared/models/client.model'; +import myConsultantService from '~/shared/services/my-consultant.service'; @Component({ @@ -198,7 +199,7 @@ } markAppointment() { - appointmentService.markAsContact(this.client.id).then(data => { + myConsultantService.markAsContact(this.client.id).then(data => { // TODO: 閬敺����� updated client 鞈�� - Ben 2021/11/16 const updatedClient = {...this.client}; updatedClient.communicateStatus = 'contacted'; diff --git a/PAMapp/shared/api/appointment.ts b/PAMapp/shared/api/appointment.ts deleted file mode 100644 index 9b0515a..0000000 --- a/PAMapp/shared/api/appointment.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { http } from '~/shared/services/httpClient'; - -import { AppointmentLog } from '../models/appointment.model'; - -// 璅�撌脰蝯� -export function markAsContact(appointmentId: number) { - const headers = { - Authorization: 'Bearer ' + localStorage.getItem('id_token') - } - // TODO: 頝�垢蝣箄���ㄐ��� API 銝�府���� void, ���府���敺���� - Ben 2021/11/16 - return http.post('/appointment/markAsContacted/'+appointmentId, undefined, {headers}) - .then(res => res.data) -} - -export function getMyReviewLog(): Promise<AppointmentLog[]> { - const headers = { - Authorization: 'Bearer ' + localStorage.getItem('id_token') - } - return http.get('/satisfaction/getMySatisfaction', { headers }).then(res => res.data); -} - - -// 憿批��憿舐內����蝑敺孛� -export function allAppointmentsView() { - const headers = { - Authorization: 'Bearer ' + localStorage.getItem('id_token') - } - return http.post('/consultant/record/allAppointmentsView', undefined, {headers}) -} diff --git a/PAMapp/shared/services/appointment.service.ts b/PAMapp/shared/services/appointment.service.ts index ef4cea0..c8c6f9d 100644 --- a/PAMapp/shared/services/appointment.service.ts +++ b/PAMapp/shared/services/appointment.service.ts @@ -16,16 +16,9 @@ }); } + // 憿批��憿舐內����蝑敺孛� private viewAllAppointment(): void { http.post('/consultant/record/allAppointmentsView').then(); - } - - // 璅�撌脰蝯� - markAsContact(appointmentId: number): Promise<void> { - // TODO: 頝�垢蝣箄���ㄐ��� API 銝�府���� void, ���府���敺���� - Ben 2021/11/16 - // return http.post('/appointment/markAsContacted/'+appointmentId, undefined, {headers}) - // .then(res => res.data) - return http.post(`/appointment/markAsContacted/${appointmentId}`); } // 霈�������孛�嚗������������ diff --git a/PAMapp/shared/services/my-consultant.service.ts b/PAMapp/shared/services/my-consultant.service.ts index c4d4fa2..ed06483 100644 --- a/PAMapp/shared/services/my-consultant.service.ts +++ b/PAMapp/shared/services/my-consultant.service.ts @@ -29,6 +29,14 @@ return http.delete(`/consultant/favorite/${agentId}`); } + // 璅�撌脰蝯� + markAsContact(appointmentId: number): Promise<void> { + // TODO: 頝�垢蝣箄���ㄐ��� API 銝�府���� void, ���府���敺���� - Ben 2021/11/16 + // return http.post('/appointment/markAsContacted/'+appointmentId, undefined, {headers}) + // .then(res => res.data) + return http.post(`/appointment/markAsContacted/${appointmentId}`); + } + } export default new MyConsultantService(); diff --git a/PAMapp/shared/services/reviews.service.ts b/PAMapp/shared/services/reviews.service.ts index 9eaa5e4..0580c8b 100644 --- a/PAMapp/shared/services/reviews.service.ts +++ b/PAMapp/shared/services/reviews.service.ts @@ -1,6 +1,7 @@ import { http } from "./httpClient"; import { UserReviewsConsultantsParams } from "../models/reviews.model"; +import { AppointmentLog } from "../models/appointment.model"; class ReviewsService { @@ -8,6 +9,10 @@ userReviewsConsultants(data: UserReviewsConsultantsParams) { return http.post('/satisfaction/create', data ); } + //������������ + async getMyReviewLog(): Promise<AppointmentLog[]> { + return http.get('/satisfaction/getMySatisfaction').then(res => res.data); + } } export default new ReviewsService(); diff --git a/PAMapp/store/index.ts b/PAMapp/store/index.ts index 73ab54c..25d55a2 100644 --- a/PAMapp/store/index.ts +++ b/PAMapp/store/index.ts @@ -1,12 +1,12 @@ import { StrictQueryParams } from '~/shared/models/strict-query.model'; import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' -import { getMyReviewLog } from '~/shared/api/appointment'; import { getFavoriteFromStorage, setFavoriteToStorage } from '~/shared/storageConsultant'; import myConsultantService from '~/shared/services/my-consultant.service'; import queryConsultantService from '~/shared/services/query-consultant.service'; import appointmentService from '~/shared/services/appointment.service'; +import reviewsService from '~/shared/services/reviews.service'; import { Consultant } from '~/shared/models/consultant.model'; import { AppointmentLog } from '~/shared/models/appointment.model'; @@ -136,7 +136,7 @@ @Action storeMyAppointmentReviewLog() { - getMyReviewLog().then((data) => { + reviewsService.getMyReviewLog().then((data) => { const dataWithLatestDate = data.map((item) => { return { ...item, -- Gitblit v1.8.0