add login

This commit is contained in:
AceDataCloud committed 2021-09-10 02:11:08 +08:00
1 parent 1ac9441a4d
commit 89e65f373f
19 files changed
+183 -28

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { AxiosResponse } from 'axios';
import httpClient from '../../instance';
import { IArticle, IArticleDetailResponse, IArticleListResponse } from './types';
class ArticleService {
key = 'articles';
async getAll(): Promise<AxiosResponse<IArticleListResponse>> {
return await httpClient.get(`/${this.key}`);
}
async get(id: string | string[]): Promise<AxiosResponse<IArticleDetailResponse>> {
return httpClient.get(`/${this.key}/${id}`);
}
async create(data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
return httpClient.post(`/${this.key}`, data);
}
async update(id: string | string[], data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
return httpClient.put(`/${this.key}/${id}`, data);
}
async delete(id: string | string[]): Promise<AxiosResponse<null>> {
return httpClient.delete(`/${this.key}/${id}`);
}
}
export default new ArticleService();