班级号 3~4 位并存,按用户名前缀/包含匹配时 ks251 会捞到 ks2510~ks2519。 新增 classPrefixCondition:ks + 3 位以上数字按具体班级匹配(后面不能再跟数字), 1~2 位仍是年级前缀。后台首页的用户排名、随机抽签,以及题单的学生进度筛选 (只填数字时补上 ks)都改用它。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41cd141769
commit
23844ae301
4 files changed
+46
-9
No files matched your search
@@ -34,7 +34,7 @@ import { revokeUserSessions } from "../../auth/session"
|
||||
import { requireSuperAdmin, type AppEnv } from "../../auth/middleware"
|
||||
import { db, schema } from "../../db"
|
||||
import { failure, parseBody, success } from "../../http"
|
||||
import { queryInteger, sampleUser } from "../helpers"
|
||||
import { classPrefixCondition, queryInteger, sampleUser } from "../helpers"
|
||||
|
||||
export const adminAccountRoutes = new Hono<AppEnv>()
|
||||
|
||||
@@ -130,7 +130,11 @@ adminAccountRoutes.get("/rankings/users", requireSuperAdmin, async (c) => {
|
||||
const where = and(
|
||||
inArray(schema.user.adminType, [...STUDENT_ROLES]),
|
||||
eq(schema.user.isDisabled, false),
|
||||
keyword ? ilike(schema.user.username, `%${keyword}%`) : undefined,
|
||||
// 输入班级前缀(ks251)按班级匹配,否则照旧按用户名包含
|
||||
keyword
|
||||
? (classPrefixCondition(keyword) ??
|
||||
ilike(schema.user.username, `%${keyword}%`))
|
||||
: undefined,
|
||||
)
|
||||
|
||||
const [totalRows, rows] = await Promise.all([
|
||||
|
||||
Reference in new issue
Block a user