浏览代码

补充了角色字段查询

yourname 6 月之前
父节点
当前提交
2f2735d2ea
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      server/middlewares.ts
  2. 2 2
      server/routes_users.ts

+ 1 - 1
server/middlewares.ts

@@ -9,7 +9,7 @@ declare module '@d8d-appcontainer/auth' {
   interface User {
     id: number
     username: string
-    role: 'admin' | 'student' | 'follower'
+    role: 'admin' | 'student' | 'fan' | 'teacher'
     student_expires_at?: string | null
   }
 }

+ 2 - 2
server/routes_users.ts

@@ -27,7 +27,7 @@ export function createUserRoutes(withAuth: WithAuth) {
       }
       
       const total = await query.clone().count()
-      const users = await query.select('id', 'username', 'nickname', 'email', 'phone', 'created_at')
+      const users = await query.select('id', 'username', 'nickname', 'email', 'phone', 'role', 'created_at') 
         .limit(pageSize).offset(offset)
       
       return c.json({
@@ -40,7 +40,7 @@ export function createUserRoutes(withAuth: WithAuth) {
       })
     } catch (error) {
       console.error('获取用户列表失败:', error)
-      return c.json({ error: '获取用户列表失败' }, 500)
+      return c.json({ error: '获取用户列表失败'}, 500)
     }
   })