Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -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 || {};
|
||||
|
||||
Reference in New Issue
Block a user