This repository has been archived by the owner on Nov 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
186 lines (143 loc) · 5.37 KB
/
api.js
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import axios from 'axios'
import cookie from 'js-cookie'
import {Loading} from 'element-ui'
const host = 'http://192.168.1.9:8099'
let loading
axios.defaults.timeout = 10000
axios.interceptors.request.use(config => {
loading = Loading.service({})
// 加时间戳,防止缓存
config.url = host + config.url + (config.url.includes('?') ? '&' : '?') + 'timestamp=' + new Date().getTime()
config.headers = {
'Content-Type': 'application/json',
token: cookie.get('token')
}
return config
}, error => {
return Promise.resolve(error)
})
axios.interceptors.response.use(response => {
loading.close()
return response.data
}, error => {
loading.close()
if (error.response !== undefined) {
console.error(error.response.data)
return Promise.resolve(error.response.data)
}
return Promise.resolve(error.response)
})
export const requestSaveJob = (id, workTimeStart, workTimeEnd, company, workWay, workDiary) => {
return axios.put('/user/job', {id, workTimeStart, workTimeEnd, company, workWay, workDiary})
}
export const requestUpdateJobStatus = (jobId, status) => {
return axios.patch(`/user/job/${jobId}/status?status=${status}`)
}
export const requestListOvertime = (status, offset, size) => {
return axios.get(`/user/job/overtime?status=${status}&offset=${offset}&size=${size}`)
}
export const requestListWorked = (company, offset, size) => {
return axios.get(`/user/job?company=${company}&offset=${offset}&size=${size}`)
}
export const requestWriteDiary = (jobId, wordDiary) => {
return axios.patch(`/user/job/${jobId}/diary`, wordDiary)
}
export const requestCompanies = () => {
return axios.get('/user/job/companies')
}
export const requestFinishWork = (jobId, workWay, company) => {
return axios.patch(`/user/job/${jobId}/finish?workWay=${workWay}&company=${company}`)
}
export const requestStartWorking = (workWay, company) => {
return axios.post(`/user/job/start?workWay=${workWay}&company=${company}`)
}
export const requestJobOfToday = () => {
return axios.get('/user/job/today')
}
export const requestListTodoCount = (start, end) => {
return axios.get(`/user/todo/count/list?start=${start}&end=${end}`)
}
export const requestListDaily = (start, end) => {
return axios.get(`/user/daily/list?start=${start}&end=${end}`)
}
export const requestListIncomeYear = (startYear, endYear) => {
return axios.get(`/user/asset/income/year/list?startYear=${startYear}&endYear=${endYear}`)
}
export const requestListIncomeMonth = (startMonth, endMonth) => {
return axios.get(`/user/asset/income/month/list?startMonth=${startMonth}&endMonth=${endMonth}`)
}
export const requestListUndo = date => {
return axios.get(`/user/todo/undo/list?date=${date}`)
}
export const requestRemoveTodo = id => {
return axios.delete(`/user/todo/remove?todoId=${id}`)
}
export const requestUpdateTodo = (id, content) => {
return axios.patch(`/user/todo/update?todoId=${id}&content=${content}`)
}
export const requestToggleTodoStatus = (id, status) => {
return axios.patch(`/user/todo/status/toggle?todoId=${id}&status=${status}`)
}
export const requestListTodo = date => {
return axios.get(`/user/todo/list?date=${date}`)
}
export const requestSaveTodo = (doingDate, content, offset, repeat) => {
return axios.post(`/user/todo/create`, {doingDate, content, offset, repeat})
}
export const requestRemoveDailies = dailiesId => {
return axios.delete(`/user/daily/detail/remove?dailiesId=${dailiesId}`)
}
export const requestListDailies = dailyId => {
return axios.get(`/user/daily/detail/list?dailyId=${dailyId}`)
}
export const requestUpdateDailies = (dailiesId, params) => {
return axios.put(`/user/daily/detail/${dailiesId}/update`, params)
}
export const requestSaveDailies = (dailyId, params) => {
return axios.post(`/user/daily/detail/append/${dailyId}`, params)
}
export const requestGetDaily = date => {
return axios.get(`/user/daily/get?date=${date}`)
}
export const requestUpdateDaily = (params) => {
return axios.put(`/user/daily/${params.id}/update`, params)
}
export const requestSaveDaily = params => {
return axios.post('/user/daily/create', params)
}
export const requestRemoveIncome = id => {
return axios.delete(`/user/asset/income/remove?incomeId=${id}`)
}
export const requestAssetBalance = () => {
return axios.get('/user/asset/balance')
}
export const requestListIncome = (category, start, end) => {
return axios.get(`/user/asset/income/list?category=${category}&start=${start}&end=${end}`)
}
export const requestUpdateIncome = (id, params) => {
return axios.put(`/user/asset/income/${id}/update`, params)
}
export const requestSaveIncome = params => {
return axios.post('/user/asset/income/append', params)
}
export const requestListCategory = () => {
return axios.get('/user/category/list')
}
export const requestSaveCategory = name => {
return axios.post('/user/category/append?name=' + name)
}
export const requestLogin = (loginName, password) => {
return axios.post(`/user/login?loginName=${loginName}&password=${password}`)
}
export const requestRegister = params => {
return axios.post('/user/register', params)
}
export const requestVerifyCode = email => {
return axios.post('/common/vcode/send?email=' + email)
}
export const requestValidateVerifyCode = (email, vcode) => {
return axios.get(`/common/vcode/verify?email=${email}&vcode=${vcode}`)
}
export const requestResetPassword = params => {
return axios.patch('/user/password/reset', params)
}