保誠-保戶業務員媒合平台
Tomas
2021-12-22 f36e617e9e534a4b05f2029724d678bbd6c655b3
refactor: separate api/consultant.ts into serveral services
刪除6個檔案
修改14個檔案
新增4個檔案
修改1個檔案名稱
409 ■■■■■ 已變更過的檔案
PAMapp/components/Consultant/ConsultantCard.vue 5 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/components/QuickFilter/QuickFilterSelector.vue 2 ●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/pages/accountSetting/index.vue 7 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/pages/questionnaire/_agentNo.vue 13 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/pages/quickFilter/index.vue 7 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/pages/recommendConsultant/result.vue 2 ●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/api/consultant.ts 164 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/const/quickFilter-questionList.ts 2 ●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/UserReviewsConsultantsParams.ts 4 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/agentOfStrictQuery.ts 12 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/appointment.model.ts 39 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/appointmentParams.ts 12 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/fastQueryParams.model.ts 7 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/quick-filter.model.ts 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/reviews.model.ts 4 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/strict-query.model.ts 24 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/models/strictQueryParams.ts 12 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/account-setting.service.ts 17 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/appointment.service.ts 9 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/my-consultant.service.ts 5 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/query-consultant.service.ts 25 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/reviews.service.ts 13 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/storageRequests.ts 2 ●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/store/index.ts 20 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/store/localStorage.ts 2 ●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/components/Consultant/ConsultantCard.vue
@@ -130,11 +130,12 @@
import { Vue, Component, Prop, Action, namespace } from 'nuxt-property-decorator';
import appointmentService from '~/shared/services/appointment.service';
import reviewsService from '~/shared/services/reviews.service';
import { isMobileDevice } from '~/shared/device';
import { hideReviews } from '~/shared/const/hide-reviews';
import { UserReviewsConsultantsParams, userReviewsConsultants } from '~/shared/api/consultant';
import { Consultant, ConsultantWithAppointmentId } from '~/shared/models/consultant.model';
import { Appointment } from '~/shared/models/appointment.model';
import { UserReviewsConsultantsParams } from '~/shared/models/reviews.model';
const localStorage = namespace('localStorage');
@Component({
@@ -354,7 +355,7 @@
        }
        this.appointmentDetail.satisfactionScore = this.inputScore;
        userReviewsConsultants(reviewParams).then((res) => {
        reviewsService.userReviewsConsultants(reviewParams).then((res) => {
            this.reviewsBtn = false;
            this.storeConsultantList();
        });
PAMapp/components/QuickFilter/QuickFilterSelector.vue
@@ -67,7 +67,7 @@
<script lang="ts">
import { Vue, Component, Prop, Watch, Emit } from 'nuxt-property-decorator';
import { hideReviews } from '~/shared/const/hide-reviews';
import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quickFilter.model';
import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quick-filter.model';
@Component
export default class QuickFilterDrawer extends Vue {
    pickedItem: FastQueryParams = {
PAMapp/pages/accountSetting/index.vue
@@ -70,8 +70,9 @@
<script lang="ts">
import { Vue,Component } from 'vue-property-decorator'
import { getUserAccountSetting, updateAccountSetting } from '~/shared/api/consultant';
import { UserSetting } from '~/shared/models/account.model';
import accountSettingService from '~/shared/services/account-setting.service';
@Component
export default class AccountSetting extends Vue {
@@ -139,7 +140,7 @@
                phone: this.phoneValue,
                email: this.emailValue
            }
            updateAccountSetting(editSettingInfo).then((res: any) => {
            accountSettingService.updateAccountSetting(editSettingInfo).then((res: any) => {
                console.log('updateRes:', res);
                this.resetSettingForm();
            });
@@ -153,7 +154,7 @@
        }
        mounted(){
            getUserAccountSetting().then((userInfo: UserSetting)=>{
            accountSettingService.getUserAccountSetting().then((userInfo: UserSetting)=>{
                this._userSetting = {
                    name: userInfo.name || '',
                    phone: userInfo.phone || '',
PAMapp/pages/questionnaire/_agentNo.vue
@@ -140,13 +140,16 @@
<script lang="ts">
import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator';
import { addFavoriteConsultant, appointmentDemand, AppointmentParams, AppointmentRequests ,editAppointment } from '~/shared/api/consultant';
import { getRequestQuestionFromStorage, getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/shared/storageRequests';
import { getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/shared/storageRequests';
import _ from 'lodash';
import queryConsultantService from '~/shared/services/query-consultant.service';
import appointmentService from '~/shared/services/appointment.service';
import { Consultant } from '~/shared/models/consultant.model';
import { ContactType } from '~/shared/models/enum/ContactType';
import { Gender } from '~/shared/models/enum/Gender';
import { RegisterInfo } from '~/shared/models/registerInfo';
import { AppointmentParams, AppointmentRequests } from '~/shared/models/appointment.model';
  const roleStorage = namespace('localStorage');
  @Component
@@ -350,7 +353,7 @@
      if (this.isEditBtn) {
        this.sentEditAppointmentDemand();
      } else {
        addFavoriteConsultant([this.$route.params.agentNo]).then(res => this.sentAppointmentDemand());
        queryConsultantService.addFavoriteConsultant([this.$route.params.agentNo]).then(res => this.sentAppointmentDemand());
      }
    }
@@ -363,7 +366,7 @@
          agentNo: this.$route.params.agentNo
        };
        appointmentDemand(data).then(res => {
        queryConsultantService.appointmentDemand(data).then(res => {
            this.sendReserve = true;
            this.myRequest.hopeContactTime = [];
            setRequestsToStorage(this.myRequest);
@@ -378,7 +381,7 @@
          id: this.appointmentId,
          otherRequirement: null
        }
        editAppointment(info).then(res => {
        appointmentService.editAppointment(info).then(res => {
          this.sendReserve = true;
          this.myRequest.hopeContactTime = [];
          setRequestsToStorage(this.myRequest);
PAMapp/pages/quickFilter/index.vue
@@ -66,10 +66,11 @@
<script lang="ts">
import { Vue, Component, namespace } from 'nuxt-property-decorator';
import queryConsultantService from '~/shared/services/query-consultant.service';
import { Consultant } from '~/shared/models/consultant.model';
import { fastQuery } from '~/shared/api/consultant';
import { questionList } from '~/shared/const/quickFilter-questionList';
import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quickFilter.model';
import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quick-filter.model';
const localStorage = namespace('localStorage');
@Component
@@ -168,7 +169,7 @@
            status: ''
        }
        fastQuery(data).then((consultantList) => {
        queryConsultantService.fastQuery(data).then((consultantList) => {
            this.consultantList = consultantList;
            this.storageQuickFilter(JSON.stringify(this.confirmItem))
        })
PAMapp/pages/recommendConsultant/result.vue
@@ -83,8 +83,8 @@
</template>
<script lang="ts">
import {Vue,Component, State, namespace, Action} from 'nuxt-property-decorator';
import { AgentOfStrictQuery } from '~/shared/api/consultant';
import { hideReviews } from '~/shared/const/hide-reviews';
import { AgentOfStrictQuery } from '~/shared/models/strict-query.model';
const localStorage = namespace('localStorage');
PAMapp/shared/api/consultant.ts
Àɮפw§R°£
PAMapp/shared/const/quickFilter-questionList.ts
@@ -1,4 +1,4 @@
import { QuestionOption } from "../models/quickFilter.model";
import { QuestionOption } from "~/shared/models/quick-filter.model";
export const questionList: QuestionOption[] = [
    {
PAMapp/shared/models/UserReviewsConsultantsParams.ts
Àɮפw§R°£
PAMapp/shared/models/agentOfStrictQuery.ts
Àɮפw§R°£
PAMapp/shared/models/appointment.model.ts
@@ -55,4 +55,41 @@
  customerId       : number;
  name             : string;
}
export interface AppointmentParams {
  phone          : string;
  email          : string;
  contactType    : string;
  gender         : string;
  age            : string;
  job            : string;
  requirement    : string;
  hopeContactTime: string;
  agentNo        : string;
}
export interface EditAppointmentParams {
  id              : number,
  phone           : string,
  email           : string,
  contactType     : string,
  gender          : string,
  age             : string,
  job             : string,
  requirement     : string,
  hopeContactTime : string,
  otherRequirement: null
}
export interface AppointmentRequests {
  phone          : string,
  email          : string,
  contactType    : string,
  gender         : string,
  age            : string,
  job            : string,
  requirement    : string[],
  hopeContactTime: ContactTime[],
  agentNo        : string,
}
export interface ContactTime {
selectWeekOptions : string[],
selectTimesOptions: string[]
}
PAMapp/shared/models/appointmentParams.ts
Àɮפw§R°£
PAMapp/shared/models/fastQueryParams.model.ts
Àɮפw§R°£
PAMapp/shared/models/quick-filter.model.ts
PAMapp/shared/models/reviews.model.ts
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,4 @@
export interface UserReviewsConsultantsParams{
  appointmentId: number,
  score        : number,
}
PAMapp/shared/models/strict-query.model.ts
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,24 @@
export interface StrictQueryParams {
  gender          : string;
  avgScore        : number;
  status          : string;    //phase 1 disable
  area            : string;
  requirements    : string[];
  otherRequirement: string;
  seniority       : string;
  popularTags     : string[];
  otherPopularTags: string;
}
export interface AgentOfStrictQuery {
  agentNo      : string;
  name         : string;
  img          : string;
  expertise    : string[];
  avgScore     : number;
  contactStatus: null;
  updateTime   : null;
  seniority    : string;
  new          : boolean;
}
PAMapp/shared/models/strictQueryParams.ts
Àɮפw§R°£
PAMapp/shared/services/account-setting.service.ts
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,17 @@
import { http } from "./httpClient";
import { UserSetting } from "~/shared/models/account.model";
class AccountSettingService{
  //取得使用者帳號資訊
  async getUserAccountSetting() : Promise<UserSetting> {
    return http.get<UserSetting>('/customer/info').then(res => res.data);
  }
  //更新使用者帳號資訊
  async updateAccountSetting(params: any) : Promise<any> {
    return http.put('/customer/info', params ).then(res => res.data);
  }
}
export default new AccountSettingService();
PAMapp/shared/services/appointment.service.ts
@@ -1,7 +1,7 @@
import { http } from "./httpClient";
import { ClientInfo } from "../models/client.model";
import { AppointmentDetail } from "../models/appointment.model";
import { ClientInfo } from "~/shared/models/client.model";
import { AppointmentDetail, EditAppointmentParams } from "~/shared/models/appointment.model";
class AppointmentService {
@@ -43,6 +43,11 @@
    return http.delete(`/appointment/${appointmentId}`);
  }
  // ç·¨è¼¯é ç´„
  editAppointment(editAppointmentParams: EditAppointmentParams) {
    return http.put('/appointment', editAppointmentParams);
  }
}
export default new AppointmentService();
PAMapp/shared/services/my-consultant.service.ts
@@ -24,6 +24,11 @@
    return http.get('/consultant/detail', {params:{agentNo:agentNo}}).then((res) => res.data);
  }
  // ç§»é™¤é¡§å•
  async deleteConsultant(agentId: string) {
    return http.delete(`/consultant/favorite/${agentId}`);
  }
}
export default new MyConsultantService();
PAMapp/shared/services/query-consultant.service.ts
@@ -1,6 +1,9 @@
import { http } from "./httpClient";
import { Consultant } from "../models/consultant.model";
import { Consultant } from "~/shared/models/consultant.model";
import { FastQueryParams } from "~/shared/models/quick-filter.model";
import { AgentOfStrictQuery, StrictQueryParams } from "~/shared/models/strict-query.model";
import { AppointmentParams } from "~/shared/models/appointment.model";
class QueryConsultantService {
@@ -9,6 +12,26 @@
      return http.get<Consultant[]>('/consultant/recommend').then((res) => res.data);
    }
  // å¿«é€Ÿç¯©é¸
  async fastQuery(data: FastQueryParams): Promise<Consultant[]> {
    return http.post<Consultant[]>('/consultant/fastQuery', data).then(res => res.data);
  }
  // åš´é¸é…å°
  async strictQuery(data:StrictQueryParams): Promise<AgentOfStrictQuery[]>{
    return http.post('/consultant/strictQuery', data).then((res) => res.data);
  }
  // åŠ å…¥é¡§å•
  async addFavoriteConsultant(agentNoList: string[]) {
    return http.post('/consultant/favorite', { agentNoList });
  }
  // é ç´„前詢問
  async appointmentDemand(data: AppointmentParams) {
    return http.post('/appointment/customer/create', data);
  }
}
export default new QueryConsultantService();
PAMapp/shared/services/reviews.service.ts
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,13 @@
import { http } from "./httpClient";
import { UserReviewsConsultantsParams } from "../models/reviews.model";
class ReviewsService {
  //客戶進行滿意度評分
  userReviewsConsultants(data: UserReviewsConsultantsParams) {
    return http.post('/satisfaction/create', data );
  }
}
export default new ReviewsService();
PAMapp/shared/storageRequests.ts
@@ -1,4 +1,4 @@
import { AppointmentRequests } from "./api/consultant";
import { AppointmentRequests } from "./models/appointment.model";
export function getRequestsFromStorage(): AppointmentRequests {
  const requests = localStorage.getItem('myRequests');
PAMapp/store/index.ts
@@ -1,15 +1,17 @@
import { StrictQueryParams } from '~/shared/models/strict-query.model';
import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators'
import { getMyReviewLog } from '~/shared/api/appointment';
import { recommend, AgentOfStrictQuery, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/shared/api/consultant';
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 { Consultant } from '~/shared/models/consultant.model';
import { AppointmentLog } from '~/shared/models/appointment.model';
import { ClientInfo } from '~/shared/models/client.model';
import { AgentOfStrictQuery } from '~/shared/models/strict-query.model';
@Module
export default class Store extends VuexModule {
    recommendList: Consultant[] = [];
@@ -57,7 +59,7 @@
    @Action
    storeRecommendList() {
        recommend().then(data => {
        queryConsultantService.getRecommendConsultantList().then(data => {
            this.context.commit('updateRecommend', data)
        })
    }
@@ -74,7 +76,7 @@
        if (localData?.length) {
            const agentNoList = localData.map(i => i.agentNo)
            await addFavoriteConsultant(agentNoList).then(res => {
            await queryConsultantService.addFavoriteConsultant(agentNoList).then(res => {
                localStorage.removeItem('favoriteConsultant')
            })
        }
@@ -94,7 +96,7 @@
        if (!this.isUserLogin) {
            setFavoriteToStorage(left);
        } else {
            await deleteConsultant(agentNo)
            await myConsultantService.deleteConsultant(agentNo)
        }
        this.context.commit('updateConsultantList', left)
@@ -109,7 +111,7 @@
            if (!found) {
                const newData = [consultantToAdd].concat(this.myConsultantList);
                if (this.isUserLogin) {
                    await addFavoriteConsultant([consultantToAdd.agentNo])
                    await queryConsultantService.addFavoriteConsultant([consultantToAdd.agentNo])
                } else {
                    setFavoriteToStorage(newData);
                }
@@ -154,11 +156,11 @@
    }
    @Action
    async storeStrictQueryList(strictQueryDto) {
        return await strictQuery(strictQueryDto).then(res=>{
    async storeStrictQueryList(strictQueryDto: StrictQueryParams) {
        return await queryConsultantService.strictQuery(strictQueryDto).then(res=>{
            this.context.commit('localStorage/storageRecommendConsultant', JSON.stringify(strictQueryDto));
            this.context.commit('updateStrictQueryList', res.data)
            return res.data.length;
            this.context.commit('updateStrictQueryList', res)
            return res.length;
        });
    }
PAMapp/store/localStorage.ts
@@ -1,6 +1,6 @@
import { Module, Mutation, VuexModule ,Action } from 'vuex-module-decorators';
import { Role } from '~/shared/models/enum/role';
import { Selected } from '~/shared/models/quickFilter.model';
import { Selected } from '~/shared/models/quick-filter.model';
@Module
export default class LocalStorage extends VuexModule {
  id_token = localStorage.getItem('id_token');