feat:添加组件实例
This commit is contained in:
39
src/api/post/index.js
Normal file
39
src/api/post/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { defAxios } from '@/utils/http'
|
||||
|
||||
export function getPosts(data = {}) {
|
||||
return defAxios({
|
||||
url: '/posts',
|
||||
method: 'get',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function getPostById({ id }) {
|
||||
return defAxios({
|
||||
url: `/post/${id}`,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function savePost(id, data = {}) {
|
||||
if (id) {
|
||||
return defAxios({
|
||||
url: `/post/${id}`,
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
return defAxios({
|
||||
url: '/post',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function deletePost(id) {
|
||||
return defAxios({
|
||||
url: `/post/${id}`,
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user