File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { NextRequest , NextResponse } from "next/server" ;
2
2
import { query } from "@/lib/db/client" ;
3
+ import { ensureUserTableExists } from "@/lib/db/users" ;
3
4
4
5
export async function GET ( req : NextRequest ) {
5
6
try {
7
+ // 确保表结构正确
8
+ await ensureUserTableExists ( ) ;
9
+
6
10
const { searchParams } = new URL ( req . url ) ;
7
11
const page = parseInt ( searchParams . get ( "page" ) || "1" ) ;
8
12
const pageSize = parseInt ( searchParams . get ( "pageSize" ) || "20" ) ;
Original file line number Diff line number Diff line change @@ -134,7 +134,6 @@ async function ensureDeletedColumnExists() {
134
134
}
135
135
136
136
export async function deleteUser ( userId : string ) {
137
- await ensureUserTableExists ( ) ;
138
137
await ensureDeletedColumnExists ( ) ;
139
138
140
139
const updateResult = await query (
@@ -163,7 +162,6 @@ export async function getUsers({
163
162
sortOrder = null ,
164
163
search = null ,
165
164
} : GetUsersOptions = { } ) {
166
- await ensureUserTableExists ( ) ;
167
165
await ensureDeletedColumnExists ( ) ;
168
166
169
167
const offset = ( page - 1 ) * pageSize ;
@@ -221,9 +219,6 @@ export async function getUsers({
221
219
}
222
220
223
221
export async function getAllUsers ( includeDeleted : boolean = false ) {
224
- await ensureUserTableExists ( ) ;
225
- await ensureDeletedColumnExists ( ) ;
226
-
227
222
const whereClause = includeDeleted
228
223
? ""
229
224
: "WHERE (deleted = FALSE OR deleted IS NULL)" ;
You can’t perform that action at this time.
0 commit comments