feat: 优化项目目录结构
This commit is contained in:
14
apps/frontend/lib/api/admin/web/blog/create.ts
Normal file
14
apps/frontend/lib/api/admin/web/blog/create.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
|
||||
type CreateBlogParams = {
|
||||
title: string;
|
||||
description: string;
|
||||
contentUrl: string;
|
||||
}
|
||||
|
||||
export async function create(data: CreateBlogParams) {
|
||||
return fetcher('/api/admin/web/blog', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
}
|
||||
6
apps/frontend/lib/api/admin/web/blog/get.ts
Normal file
6
apps/frontend/lib/api/admin/web/blog/get.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
|
||||
export async function get(id: string) {
|
||||
return fetcher<Blog>(`/api/admin/web/blog/${id}`)
|
||||
}
|
||||
6
apps/frontend/lib/api/admin/web/blog/index.ts
Normal file
6
apps/frontend/lib/api/admin/web/blog/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './create';
|
||||
export * from './remove';
|
||||
export * from './list';
|
||||
export * from './update';
|
||||
export * from './get';
|
||||
export * from './setPassword';
|
||||
6
apps/frontend/lib/api/admin/web/blog/list.ts
Normal file
6
apps/frontend/lib/api/admin/web/blog/list.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
|
||||
export async function list() {
|
||||
return fetcher<Blog[]>('/api/admin/web/blog')
|
||||
}
|
||||
7
apps/frontend/lib/api/admin/web/blog/remove.ts
Normal file
7
apps/frontend/lib/api/admin/web/blog/remove.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
|
||||
export async function remove(id: string) {
|
||||
return fetcher(`/api/admin/web/blog/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
10
apps/frontend/lib/api/admin/web/blog/setPassword.ts
Normal file
10
apps/frontend/lib/api/admin/web/blog/setPassword.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
|
||||
export async function setPassword(id: string, password: string) {
|
||||
return fetcher<boolean>(`/api/admin/web/blog/${id}/password`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
password,
|
||||
})
|
||||
})
|
||||
}
|
||||
16
apps/frontend/lib/api/admin/web/blog/update.ts
Normal file
16
apps/frontend/lib/api/admin/web/blog/update.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
import { BlogPermission } from "@/lib/types/Blog.Permission.enum";
|
||||
|
||||
type UpdateBlogParams = {
|
||||
title: string;
|
||||
description: string;
|
||||
contentUrl: string;
|
||||
permissions: BlogPermission[],
|
||||
}
|
||||
|
||||
export async function update(id: string, data: UpdateBlogParams) {
|
||||
return fetcher(`/api/admin/web/blog/${id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
}
|
||||
2
apps/frontend/lib/api/admin/web/index.ts
Normal file
2
apps/frontend/lib/api/admin/web/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * as blog from './blog/index';
|
||||
export * as resource from './resource/index';
|
||||
19
apps/frontend/lib/api/admin/web/resource/create.ts
Normal file
19
apps/frontend/lib/api/admin/web/resource/create.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
|
||||
type CreateResourceParams = {
|
||||
title: string;
|
||||
description: string;
|
||||
imageUrl: string;
|
||||
link: string;
|
||||
tags: {
|
||||
name: string;
|
||||
type: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export async function create(data: CreateResourceParams) {
|
||||
return fetcher('/api/admin/web/resource', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
}
|
||||
6
apps/frontend/lib/api/admin/web/resource/get.ts
Normal file
6
apps/frontend/lib/api/admin/web/resource/get.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
import { Resource } from "@/lib/types/resource";
|
||||
|
||||
export async function get(id: string) {
|
||||
return fetcher<Resource>(`/api/admin/web/resource/${id}`)
|
||||
}
|
||||
5
apps/frontend/lib/api/admin/web/resource/index.ts
Normal file
5
apps/frontend/lib/api/admin/web/resource/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './create';
|
||||
export * from './remove';
|
||||
export * from './list';
|
||||
export * from './update';
|
||||
export * from './get';
|
||||
6
apps/frontend/lib/api/admin/web/resource/list.ts
Normal file
6
apps/frontend/lib/api/admin/web/resource/list.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
import { Resource } from "@/lib/types/resource";
|
||||
|
||||
export async function list() {
|
||||
return fetcher<Resource[]>('/api/admin/web/resource')
|
||||
}
|
||||
7
apps/frontend/lib/api/admin/web/resource/remove.ts
Normal file
7
apps/frontend/lib/api/admin/web/resource/remove.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
|
||||
export async function remove(id: string) {
|
||||
return fetcher(`/api/admin/web/resource/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
19
apps/frontend/lib/api/admin/web/resource/update.ts
Normal file
19
apps/frontend/lib/api/admin/web/resource/update.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import fetcher from "@/lib/api/fetcher";
|
||||
|
||||
type UpdateResourceParams = {
|
||||
title: string;
|
||||
description: string;
|
||||
imageUrl: string;
|
||||
link: string;
|
||||
tags: {
|
||||
name: string;
|
||||
type: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export async function update(id: string, data: UpdateResourceParams) {
|
||||
return fetcher(`/api/admin/web/resource/${id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user