Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-24 22:07:06 +08:00
parent d95452b807
commit ebe68b31c9
13 changed files with 519 additions and 1615 deletions

View File

@@ -1,5 +1,6 @@
import { desc, eq, count, or, like } from 'drizzle-orm';
import { schema, app, db } from '@/app.ts'
import z from 'zod';
const xhsUser = schema.xhsUser;
app.route({
@@ -14,6 +15,12 @@ app.route({
`,
metadata: {
tags: ['小红书', '用户'],
args: {
page: z.number().int().positive().optional().describe('页码默认为1'),
pageSize: z.number().int().positive().optional().describe('每页数量默认为20'),
search: z.string().optional().describe('搜索关键词,支持在昵称、用户名和描述中搜索'),
sort: z.enum(['ASC', 'DESC']).optional().describe('排序方式默认为DESC')
}
}
}).define(async (ctx) => {
const { page = 1, pageSize = 20, search, sort = 'DESC' } = ctx.query || {};
@@ -117,6 +124,11 @@ app.route({
description: '删除小红书用户, 参数: data.id 用户ID',
metadata: {
tags: ['小红书', '用户'],
args: {
data: z.object({
id: z.string().describe('用户ID')
}).describe('请求数据对象包含用户ID')
}
}
}).define(async (ctx) => {
const { id } = ctx.query.data || {};
@@ -138,6 +150,11 @@ app.route({
description: '获取单个小红书用户, 参数: data.id 用户ID',
metadata: {
tags: ['小红书', '用户'],
args: {
data: z.object({
id: z.string().describe('用户ID')
}).describe('请求数据对象包含用户ID')
}
}
}).define(async (ctx) => {
const { id } = ctx.query.data || {};