feat(songs): 歌曲管理支持批量驳回、投稿留言自动审查与排期范围可见性过滤
- 新增 /api/admin/songs/batch-reject.post 批量驳回接口(事务清排期/投票/扣接纳数/黑名单去重/异步通知) - requireSongAdmin 三角色校验 + createApiError 统一错误包装 - scheduleDaysBefore/After 四字段排期可见范围限制(开放 API 与公开排期接口三处缓存路径 + DB 条件过滤) - submissionNoteAutoModeration 基于黑名单 KEYWORD/LANGUAGE/GENRE 自动判定留言 publicStatus,命中自动关闭 submissionNotePublic - 更新 songs/request.post 与 songs/[id]/update.put 接入自动审查逻辑
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
export const smartSort = (a: string, b: string) => {
|
||||
const gradeOrder: Record<string, number> = {
|
||||
'初一': 1, '初二': 2, '初三': 3,
|
||||
'高一': 4, '高二': 5, '高三': 6,
|
||||
'大一': 7, '大二': 8, '大三': 9, '大四': 10,
|
||||
'教师': 99, '教职工': 99
|
||||
}
|
||||
|
||||
const weightA = gradeOrder[a]
|
||||
const weightB = gradeOrder[b]
|
||||
|
||||
if (weightA !== undefined && weightB !== undefined) return weightA - weightB
|
||||
if (weightA !== undefined) return -1
|
||||
if (weightB !== undefined) return 1
|
||||
|
||||
return a.localeCompare(b, 'zh-CN', { numeric: true })
|
||||
}
|
||||
|
||||
export interface GradeClassOption {
|
||||
grade: string
|
||||
class: string
|
||||
}
|
||||
|
||||
export const resolveGradeClassOptions = (
|
||||
configItems: GradeClassOption[],
|
||||
fallbackItems: GradeClassOption[]
|
||||
): GradeClassOption[] => {
|
||||
const source = configItems.length > 0 ? configItems : fallbackItems
|
||||
|
||||
return source
|
||||
.filter((item): item is GradeClassOption => Boolean(item.grade?.trim()) && Boolean(item.class?.trim()))
|
||||
.sort((a, b) => {
|
||||
const gradeResult = smartSort(a.grade, b.grade)
|
||||
return gradeResult || smartSort(a.class, b.class)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user