Преглед на файлове

feat(api): 分流接入API

gemercheung преди 3 години
родител
ревизия
d9691224f9

+ 2 - 2
.env.development

@@ -6,14 +6,14 @@ VITE_PUBLIC_PATH = /
 
 # Cross-domain proxy, you can configure multiple
 # Please note that no line breaks
-VITE_PROXY = [["/basic-api","http://192.168.0.47:8190"],["/upload","http://localhost:3300/upload"],["/zfb","http://192.168.0.47:7081"]]
+VITE_PROXY = [["/basic-api","http://192.168.0.47:8190"],["/upload","http://localhost:3300/upload"],["/zfb-api","http://192.168.0.47:7081"]]
 # VITE_PROXY=[["/api","https://vvbin.cn/test"]]
 
 # Delete console
 VITE_DROP_CONSOLE = false
 
 # Basic interface address SPA
-VITE_GLOB_API_URL=/basic-api
+VITE_GLOB_API_URL=
 
 # File upload address, optional
 VITE_GLOB_UPLOAD_URL=/upload

+ 1 - 1
mock/company/selectCompanyNum.ts

@@ -66,7 +66,7 @@ const demoList = (() => {
 
 export default [
   {
-    url: '/basic-api/zfb/company/selectCompanyNum',
+    url: '/basic-api/mock/zfb/company/selectCompanyNum',
     timeout: 1000,
     method: 'get',
     response: ({ query }) => {

+ 5 - 4
src/api/advertisement/list.ts

@@ -2,8 +2,8 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, ListGetResultModel } from './model';
 
 enum Api {
-  selectAll = '/zfb/rotation/selectAll',
-  recommend = '/zfb/recommend/selectByType',
+  selectAll = '/zfb-api/zfb/rotation/selectAll',
+  recommend = '/zfb-api/zfb/recommend/selectByType',
 }
 
 /**
@@ -11,16 +11,17 @@ enum Api {
  */
 
 export const ListApi = (params: PageParams) =>
-  defHttp.get<ListGetResultModel>({
+  defHttp.post<ListGetResultModel>({
     url: Api.selectAll,
     params,
+
     headers: {
       // @ts-ignore
       ignoreCancelToken: true,
     },
   });
 export const RecommendListApi = (params: PageParams) =>
-  defHttp.get<ListGetResultModel>({
+  defHttp.post<ListGetResultModel>({
     url: Api.recommend,
     params,
     headers: {

+ 1 - 1
src/api/bulletin/rent.ts

@@ -2,7 +2,7 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, RentListGetResultModel } from './model';
 
 enum Api {
-  selectHouseByType = '/zfb/house/selectHouseByType',
+  selectHouseByType = '/zfb-api//zfb/house/selectHouseByType',
 }
 
 /**

+ 4 - 4
src/api/corporation/list.ts

@@ -2,8 +2,8 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, CorporationListGetResultModel } from './model';
 
 enum Api {
-  selectCompanyNum = '/zfb/company/selectCompanyNum',
-  selectCompanyByType = '/zfb/company/selectCompanyByType',
+  selectCompanyNum = '/zfb-api/zfb/company/selectCompanyNum',
+  selectCompanyByType = '/zfb-api/zfb/company/selectCompanyByType',
 }
 
 /**
@@ -11,7 +11,7 @@ enum Api {
  */
 
 export const ListApi = (params: PageParams) =>
-  defHttp.get<CorporationListGetResultModel>({
+  defHttp.post<CorporationListGetResultModel>({
     url: Api.selectCompanyNum,
     params,
     headers: {
@@ -20,7 +20,7 @@ export const ListApi = (params: PageParams) =>
     },
   });
 export const ListVerifyApi = (params: PageParams) =>
-  defHttp.get<CorporationListGetResultModel>({
+  defHttp.post<CorporationListGetResultModel>({
     url: Api.selectCompanyByType,
     params,
     headers: {

+ 1 - 1
src/api/device/list.ts

@@ -2,7 +2,7 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, RentListGetResultModel } from './model';
 
 enum Api {
-  pageList = '/zfb/camera/pageList',
+  pageList = '/zfb-api/zfb/camera/pageList',
 }
 
 /**

+ 2 - 2
src/api/sys/user.ts

@@ -4,9 +4,9 @@ import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userMod
 import { ErrorMessageMode } from '/#/axios';
 
 enum Api {
-  Login = '/sys/login',
+  Login = '/basic-api/sys/login',
   Logout = '/logout',
-  GetUserInfo = '/getUserInfo',
+  GetUserInfo = '/basic-api/getUserInfo',
   GetPermCode = '/getPermCode',
 }
 

+ 1 - 0
src/enums/httpEnum.ts

@@ -3,6 +3,7 @@
  */
 export enum ResultEnum {
   SUCCESS = 0,
+  NORMAL = 200,
   ERROR = 1,
   TIMEOUT = 401,
   TYPE = 'success',

+ 8 - 2
src/utils/http/axios/index.ts

@@ -51,9 +51,12 @@ const transform: AxiosTransform = {
     //  这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
 
     const { code, result, message } = data;
-
+    // TODO
     // 这里逻辑可以根据项目进行修改
-    const hasSuccess = data && Reflect.has(data, 'code') && code === ResultEnum.SUCCESS;
+    const hasSuccess =
+      data &&
+      Reflect.has(data, 'code') &&
+      (code === ResultEnum.SUCCESS || code === ResultEnum.NORMAL);
     if (hasSuccess) {
       return result || data;
     }
@@ -145,6 +148,9 @@ const transform: AxiosTransform = {
       (config as Recordable).headers.Authorization = options.authenticationScheme
         ? `${options.authenticationScheme} ${token}`
         : token;
+      (config as Recordable).headers.token = options.authenticationScheme
+        ? `${options.authenticationScheme} ${token}`
+        : token;
     }
     return config;
   },