to add a service client for volin-trader server

This commit is contained in:
simple321vip
2022-09-10 12:42:29 +08:00
parent 04b417b6fa
commit 353ddd788d
12 changed files with 80 additions and 52 deletions
+9 -9
View File
@@ -1,11 +1,11 @@
import request from '../utils/request' import { service } from '../utils/request'
const headers = { const headers = {
'Content-Type': 'application/json;charsetset=UTF-8' 'Content-Type': 'application/json;charsetset=UTF-8'
} }
const listAll = () => { const listAll = () => {
return request({ return service({
url: '/auth/api/v1/author/blog/list', url: '/auth/api/v1/author/blog/list',
method: 'GET', method: 'GET',
headers: headers headers: headers
@@ -13,7 +13,7 @@ const listAll = () => {
} }
const updateBtName = (data: Object) => { const updateBtName = (data: Object) => {
return request({ return service({
url: '/auth/api/v1/author/blog_type', url: '/auth/api/v1/author/blog_type',
method: 'POST', method: 'POST',
headers: headers, headers: headers,
@@ -22,7 +22,7 @@ const updateBtName = (data: Object) => {
} }
const putBlogType = (data: Object) => { const putBlogType = (data: Object) => {
return request({ return service({
url: '/auth/api/v1/author/blog_type', url: '/auth/api/v1/author/blog_type',
method: 'PUT', method: 'PUT',
headers: headers, headers: headers,
@@ -31,7 +31,7 @@ const putBlogType = (data: Object) => {
} }
const removeBlogType = (data: Object) => { const removeBlogType = (data: Object) => {
return request({ return service({
url: '/auth/api/v1/author/blog_type', url: '/auth/api/v1/author/blog_type',
method: 'DELETE', method: 'DELETE',
headers: headers, headers: headers,
@@ -40,7 +40,7 @@ const removeBlogType = (data: Object) => {
} }
const getContent = (id: string) => { const getContent = (id: string) => {
return request({ return service({
url: '/auth/api/v1/author/blog/content/' + id, url: '/auth/api/v1/author/blog/content/' + id,
method: 'GET', method: 'GET',
headers: headers, headers: headers,
@@ -48,7 +48,7 @@ const getContent = (id: string) => {
} }
const putBlog = (postData: Object) => { const putBlog = (postData: Object) => {
return request({ return service({
url: '/auth/api/v1/author/blog/content', url: '/auth/api/v1/author/blog/content',
method: 'PUT', method: 'PUT',
headers: headers, headers: headers,
@@ -57,7 +57,7 @@ const putBlog = (postData: Object) => {
} }
const updateContent = (postData: Object) => { const updateContent = (postData: Object) => {
return request({ return service({
url: '/auth/api/v1/author/blog/content', url: '/auth/api/v1/author/blog/content',
method: 'POST', method: 'POST',
headers: headers, headers: headers,
@@ -66,7 +66,7 @@ const updateContent = (postData: Object) => {
} }
const deleteContent = (bid: string) => { const deleteContent = (bid: string) => {
return request({ return service({
url: '/auth/api/v1/author/blog/' + bid, url: '/auth/api/v1/author/blog/' + bid,
method: 'DELETE', method: 'DELETE',
headers: headers, headers: headers,
+6 -6
View File
@@ -1,4 +1,4 @@
import request from '../utils/request' import { service } from '../utils/request'
import Qs from 'qs' import Qs from 'qs'
const headers = { const headers = {
@@ -6,7 +6,7 @@ const headers = {
} }
const getBlogs = (params: Object) => { const getBlogs = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/reader/blogs', url: '/auth/api/v1/reader/blogs',
method: 'GET', method: 'GET',
params: params, params: params,
@@ -17,7 +17,7 @@ const getBlogs = (params: Object) => {
} }
const getBtName = () => { const getBtName = () => {
return request({ return service({
url: '/auth/api/v1/reader/blog_type', url: '/auth/api/v1/reader/blog_type',
method: 'GET', method: 'GET',
headers: headers headers: headers
@@ -25,7 +25,7 @@ const getBtName = () => {
} }
const getBlog = (bid: string) => { const getBlog = (bid: string) => {
return request({ return service({
url: '/auth/api/v1/reader/blog/' + bid, url: '/auth/api/v1/reader/blog/' + bid,
method: 'GET', method: 'GET',
headers: headers headers: headers
@@ -33,14 +33,14 @@ const getBlog = (bid: string) => {
} }
const publishAll = () => { const publishAll = () => {
return request({ return service({
url: '/auth/api/v1/reader/blogs/publish/all', url: '/auth/api/v1/reader/blogs/publish/all',
method: 'GET' method: 'GET'
}) })
} }
const publish = (bid: string) => { const publish = (bid: string) => {
return request({ return service({
url: '/auth/api/v1/reader/blogs/publish/' + bid, url: '/auth/api/v1/reader/blogs/publish/' + bid,
method: 'GET' method: 'GET'
}) })
+6 -6
View File
@@ -1,4 +1,4 @@
import request from '../utils/request' import { service } from '../utils/request'
import Qs from 'qs' import Qs from 'qs'
/** /**
@@ -7,7 +7,7 @@ import Qs from 'qs'
* @returns * @returns
*/ */
const search_bookmark = (params: Object) => { const search_bookmark = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/bookmark', url: '/auth/api/v1/bookmark',
method: 'GET', method: 'GET',
params: params, params: params,
@@ -18,7 +18,7 @@ const search_bookmark = (params: Object) => {
} }
const put_bookmark = (params: Object) => { const put_bookmark = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/bookmark/insert', url: '/auth/api/v1/bookmark/insert',
method: 'PUT', method: 'PUT',
data: params data: params
@@ -26,7 +26,7 @@ const put_bookmark = (params: Object) => {
} }
const update_bookmark = (params: Object) => { const update_bookmark = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/bookmark/update', url: '/auth/api/v1/bookmark/update',
method: 'POST', method: 'POST',
data: params data: params
@@ -34,14 +34,14 @@ const update_bookmark = (params: Object) => {
} }
const delete_bookmark = (query: number) => { const delete_bookmark = (query: number) => {
return request({ return service({
url: '/auth/api/v1/bookmark/delete/' + query, url: '/auth/api/v1/bookmark/delete/' + query,
method: 'DELETE', method: 'DELETE',
}) })
} }
const delete_bookmarks = (params: Object) => { const delete_bookmarks = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/bookmark', url: '/auth/api/v1/bookmark',
method: 'DELETE', method: 'DELETE',
headers: {}, headers: {},
+5 -5
View File
@@ -1,7 +1,7 @@
import request from '../utils/request' import { service } from '../utils/request'
const put_bookmark_type = (params: Object) => { const put_bookmark_type = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/bookmark_type/insert', url: '/auth/api/v1/bookmark_type/insert',
method: 'PUT', method: 'PUT',
data: params data: params
@@ -9,7 +9,7 @@ const put_bookmark_type = (params: Object) => {
} }
const get_bookmark_type = () => { const get_bookmark_type = () => {
return request({ return service({
url: '/auth/api/v1/bookmark_type', url: '/auth/api/v1/bookmark_type',
method: 'GET', method: 'GET',
data: {} data: {}
@@ -17,14 +17,14 @@ const get_bookmark_type = () => {
} }
const delete_bookmark_type = (type_id: string) => { const delete_bookmark_type = (type_id: string) => {
return request({ return service({
url: '/auth/api/v1/bookmark_type/' + type_id, url: '/auth/api/v1/bookmark_type/' + type_id,
method: 'DELETE' method: 'DELETE'
}) })
} }
const post_bookmark_type = (params: Object) => { const post_bookmark_type = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/bookmark_type', url: '/auth/api/v1/bookmark_type',
method: 'POST', method: 'POST',
data: params data: params
+2 -2
View File
@@ -1,11 +1,11 @@
import request from '../utils/request' import { service } from '../utils/request'
const headers = { const headers = {
'Content-Type': 'application/json;charsetset=UTF-8' 'Content-Type': 'application/json;charsetset=UTF-8'
} }
const getAudioInfo = (url: string) => { const getAudioInfo = (url: string) => {
return request({ return service({
url: '/auth/api/v1/common/audio-info', url: '/auth/api/v1/common/audio-info',
method: 'GET', method: 'GET',
params: { url: url }, params: { url: url },
+8 -8
View File
@@ -1,10 +1,10 @@
import request from '../utils/request' import { service2 } from '../utils/request'
"CTA strategy" "CTA strategy"
"strategy list" "strategy list"
const get_strategy_list = () => { const get_strategy_list = () => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
@@ -12,7 +12,7 @@ const get_strategy_list = () => {
"upload a strategy" "upload a strategy"
const upload_strategy = () => { const upload_strategy = () => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
@@ -20,7 +20,7 @@ const upload_strategy = () => {
"load a strategy" "load a strategy"
const load_strategy = (strategy_id: string) => { const load_strategy = (strategy_id: string) => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
@@ -28,7 +28,7 @@ const load_strategy = (strategy_id: string) => {
"unload a strategy" "unload a strategy"
const unload_strategy = (strategy_id: string) => { const unload_strategy = (strategy_id: string) => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
@@ -36,7 +36,7 @@ const unload_strategy = (strategy_id: string) => {
"start a strategy" "start a strategy"
const start_strategy = (strategy_id: string) => { const start_strategy = (strategy_id: string) => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
@@ -44,7 +44,7 @@ const start_strategy = (strategy_id: string) => {
"stop a strategy" "stop a strategy"
const stop_strategy = (strategy_id: string) => { const stop_strategy = (strategy_id: string) => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
@@ -52,7 +52,7 @@ const stop_strategy = (strategy_id: string) => {
"remove a strategy" "remove a strategy"
const remove_strategy = (strategy_id: string) => { const remove_strategy = (strategy_id: string) => {
return request({ return service2({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
}) })
+2 -2
View File
@@ -1,11 +1,11 @@
import request from '../utils/request' import { service } from '../utils/request'
const headers = { const headers = {
'Content-Type': 'application/json;charsetset=UTF-8' 'Content-Type': 'application/json;charsetset=UTF-8'
} }
const getQrCode = () => { const getQrCode = () => {
return request({ return service({
url: '/auth/authorize/baidu', url: '/auth/authorize/baidu',
method: 'GET', method: 'GET',
headers: headers, headers: headers,
+6 -6
View File
@@ -1,7 +1,7 @@
import request from '../utils/request' import { service } from '../utils/request'
const get_notes = (params: Object) => { const get_notes = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/one_note', url: '/auth/api/v1/one_note',
method: 'GET', method: 'GET',
params: params params: params
@@ -9,7 +9,7 @@ const get_notes = (params: Object) => {
} }
const update_page = (params: Object) => { const update_page = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/one_note/update_page', url: '/auth/api/v1/one_note/update_page',
method: 'POST', method: 'POST',
data: params data: params
@@ -17,7 +17,7 @@ const update_page = (params: Object) => {
} }
const update_section = (params: Object) => { const update_section = (params: Object) => {
return request({ return service({
url: '/auth/api/v1/one_note/update_section', url: '/auth/api/v1/one_note/update_section',
method: 'POST', method: 'POST',
data: params data: params
@@ -25,14 +25,14 @@ const update_section = (params: Object) => {
} }
const insert_section = () => { const insert_section = () => {
return request({ return service({
url: '/auth/api/v1/one_note/insert_section', url: '/auth/api/v1/one_note/insert_section',
method: 'PUT' method: 'PUT'
}) })
} }
const insert_page = (params: Object) => { const insert_page = (params: Object) => {
return request({ return service({
url: '/auth/one_note/insert_page', url: '/auth/one_note/insert_page',
method: 'PUT', method: 'PUT',
data: params data: params
+2 -2
View File
@@ -1,7 +1,7 @@
import request from '../utils/request' import { service } from '../utils/request'
const get_stock_data = (data: Object) => { const get_stock_data = (data: Object) => {
return request({ return service({
url: '/auth/api/v1/trader', url: '/auth/api/v1/trader',
method: 'PUT', method: 'PUT',
data: data data: data
+4 -4
View File
@@ -1,6 +1,6 @@
import request from '../utils/request' import { service } from '../utils/request'
const authorize = (params: any) => { const authorize = (params: any) => {
return request({ return service({
url: '/auth/api/v1/authorize', url: '/auth/api/v1/authorize',
method: 'post', method: 'post',
data: params data: params
@@ -8,7 +8,7 @@ const authorize = (params: any) => {
} }
const obtainUserInfo = (token: string) => { const obtainUserInfo = (token: string) => {
return request({ return service({
url: '/auth/api/v1/user_info', url: '/auth/api/v1/user_info',
method: 'GET', method: 'GET',
params: { token: token } params: { token: token }
@@ -16,7 +16,7 @@ const obtainUserInfo = (token: string) => {
} }
const logout = (id: string) => { const logout = (id: string) => {
return request({ return service({
url: '/auth/api/v1/logout/' + id, url: '/auth/api/v1/logout/' + id,
method: 'GET' method: 'GET'
}) })
+29 -1
View File
@@ -1,6 +1,7 @@
import axios from 'axios' import axios from 'axios'
import { getToken, getTenant } from '../utils/auth' import { getToken, getTenant } from '../utils/auth'
// violin-book
const service = axios.create( const service = axios.create(
{ {
baseURL: import.meta.env.VITE_APP_URL as string, baseURL: import.meta.env.VITE_APP_URL as string,
@@ -8,6 +9,14 @@ const service = axios.create(
} }
) )
// violin-trader
const service2 = axios.create(
{
baseURL: import.meta.env.VITE_APP_URL2 as string,
timeout: 5000
}
)
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
if (typeof getToken() === 'string') { if (typeof getToken() === 'string') {
@@ -26,6 +35,25 @@ service.interceptors.request.use(
} }
) )
service2.interceptors.request.use(
config => {
if (typeof getToken() === 'string') {
(config as any).headers['Authorization'] = 'Bearer' + getToken()
}
const tenant = getTenant()
if (typeof tenant === 'string') {
(config as any).headers['id'] = JSON.parse(tenant).id
}
return config
},
error => {
console.log(error)
return Promise.reject(error)
}
)
// service.interceptors.response.use( // service.interceptors.response.use(
// response => { // response => {
// if (response.headers['content-dispostion'] // if (response.headers['content-dispostion']
@@ -54,4 +82,4 @@ service.interceptors.request.use(
// } // }
// ) // )
export default service export { service, service2 }
+1 -1
View File
@@ -870,7 +870,7 @@ mingo@1:
resolved "https://registry.yarnpkg.com/mingo/-/mingo-1.3.3.tgz#6922c4d147efc771a01425a2c4c8f7784478c546" resolved "https://registry.yarnpkg.com/mingo/-/mingo-1.3.3.tgz#6922c4d147efc771a01425a2c4c8f7784478c546"
integrity sha512-Y4wGTD/M7AMqF8QxKaBGps+axq/Z48hdtRAeiKtInkEXMLzUWUwT0OPDzrB26xrav9GF1AOYJfwVWPcLwnkgTA== integrity sha512-Y4wGTD/M7AMqF8QxKaBGps+axq/Z48hdtRAeiKtInkEXMLzUWUwT0OPDzrB26xrav9GF1AOYJfwVWPcLwnkgTA==
moment@^2.29.2: moment@^2.29.4:
version "2.29.4" version "2.29.4"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==