mart-admin/src/api/article/index.ts
2024-12-23 14:22:39 +08:00

76 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '/@/utils/request';
import { baseUrlHost } from '../baseUrlHost';
/**
* (不建议写成 request.post(xxx),因为这样 post 时,无法 params 与 data 同时传参)
* 注意在写get请求时参数是params而不是data要标注好
*
* 登录api接口集合
* @method getArticleList 获取文章列表
* @method getModuleList 获取模块列表
* @method getLabelList 获取标签列表
* @method deleteArticle 删除文章
* @method getArticleDetail 获取文章详情
* @method saveArticle 保存文章
* @method updateArticle 更新文章
* @method uploadFile 上传文件
*/
export function articleApi() {
return {
getArticleList: (params: object) => {
return request({
url: baseUrlHost + '/cpArticle',
method: 'get',
params,
});
},
getModuleList: () => {
return request({
url: baseUrlHost + '/cpModule/all',
method: 'get',
});
},
getLabelList: (moduleid: Number) => {
return request({
url: baseUrlHost + `/cpLabel/moduleid/${moduleid}`,
method: 'get',
});
},
deleteArticle: (id: Number) => {
return request({
url: baseUrlHost + `/cpArticle/${id}`,
method: 'delete',
});
},
getArticleDetail: (id: Number) => {
return request({
url: baseUrlHost + `/cpArticle/${id}`,
method: 'get',
});
},
saveArticle: (data: object) => {
return request({
url: baseUrlHost + '/cpArticle',
method: 'post',
data,
})
},
updateArticle: (data: object) => {
return request({
url: baseUrlHost + '/cpArticle',
method: 'put',
data,
})
},
uploadFile: (data: object) => {
return request({
url: baseUrlHost + '/enAttachment/upload',
method: 'post',
data,
headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
})
}
};
}