feat: 优化项目目录结构

This commit is contained in:
2025-12-12 17:25:26 +08:00
parent ae627d0496
commit b89f83291e
235 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
export * as user from './user/index';
export * as web from './web/index';

View File

@@ -0,0 +1,20 @@
import { User } from "@/lib/types/user";
import fetcher from "../../fetcher";
interface createUserParams {
username: string | null;
nickname: string | null;
email: string | null;
phone: string | null;
password: string | null;
}
export async function create(data: createUserParams) {
return fetcher<User>("/api/admin/user", {
method: "POST",
body: JSON.stringify(data),
headers: {
"Content-Type": "application/json",
},
});
}

View File

@@ -0,0 +1,6 @@
import { User } from "@/lib/types/user";
import fetcher from "../../fetcher";
export function get(userId: string) {
return fetcher<User>(`/api/admin/user/${userId}`);
}

View File

@@ -0,0 +1,6 @@
export * from './list';
export * from './get';
export * from './create';
export * from './update';
export * from './set-password';
export * from './remove';

View File

@@ -0,0 +1,22 @@
import { User } from "@/lib/types/user"
import fetcher from "../../fetcher"
export interface UserListParams {
page?: number
pageSize?: number
}
export interface UserListResponse {
items: User[],
total: number
page: number
pageSize: number
}
export function list(params?: UserListParams): Promise<UserListResponse> {
const searchParams = new URLSearchParams()
if (params?.page) searchParams.set('page', params.page.toString())
if (params?.pageSize) searchParams.set('pageSize', params.pageSize.toString())
return fetcher<UserListResponse>('/api/admin/user')
}

View File

@@ -0,0 +1,7 @@
import fetcher from "../../fetcher";
export async function remove(userId: string, soft: boolean) {
return fetcher(`/api/admin/user/${userId}?soft=${soft}`, {
method: 'DELETE',
})
}

View File

@@ -0,0 +1,10 @@
import fetcher from "../../fetcher";
export async function setPassword(userId: string, password: string) {
return fetcher(`/api/admin/user/${userId}/password`, {
method: 'POST',
body: JSON.stringify({
password,
}),
})
}

View File

@@ -0,0 +1,16 @@
import { User } from "@/lib/types/user";
import fetcher from "../../fetcher";
export type updateUser = {
username: string ;
nickname: string ;
email: string | null;
phone: string | null;
}
export async function update(userId: string, user: updateUser) {
return fetcher<User>(`/api/admin/user/${userId}`, {
body: JSON.stringify(user),
method: "PUT",
});
}

View 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)
})
}

View 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}`)
}

View File

@@ -0,0 +1,6 @@
export * from './create';
export * from './remove';
export * from './list';
export * from './update';
export * from './get';
export * from './setPassword';

View 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')
}

View 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',
})
}

View 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,
})
})
}

View 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)
})
}

View File

@@ -0,0 +1,2 @@
export * as blog from './blog/index';
export * as resource from './resource/index';

View 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)
})
}

View 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}`)
}

View File

@@ -0,0 +1,5 @@
export * from './create';
export * from './remove';
export * from './list';
export * from './update';
export * from './get';

View 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')
}

View 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',
})
}

View 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)
})
}