mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 20:29:03 +08:00
先提交上去
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { Service } from "../shared/kernel"
|
||||
import { ClientContext } from "../ClientContext"
|
||||
|
||||
export interface AutoScoreRule {
|
||||
id: number
|
||||
enabled: boolean
|
||||
name: string
|
||||
studentNames: string[]
|
||||
lastExecuted?: string
|
||||
triggers?: { event: string; value?: string; relation?: "AND" | "OR" }[]
|
||||
actions?: { event: string; value?: string; reason?: string }[]
|
||||
}
|
||||
|
||||
export interface AutoScoreRuleInput {
|
||||
enabled: boolean
|
||||
name: string
|
||||
studentNames: string[]
|
||||
triggers?: { event: string; value?: string; relation?: "AND" | "OR" }[]
|
||||
actions?: { event: string; value?: string; reason?: string }[]
|
||||
}
|
||||
|
||||
declare module "../shared/kernel" {
|
||||
interface Context {
|
||||
autoScore: AutoScoreService
|
||||
}
|
||||
}
|
||||
|
||||
export class AutoScoreService extends Service {
|
||||
constructor(ctx: ClientContext) {
|
||||
super(ctx, "autoScore")
|
||||
}
|
||||
|
||||
async getRules(): Promise<{ success: boolean; data?: AutoScoreRule[]; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:getRules", {})
|
||||
}
|
||||
|
||||
async addRule(
|
||||
rule: AutoScoreRuleInput
|
||||
): Promise<{ success: boolean; data?: number; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:addRule", rule)
|
||||
}
|
||||
|
||||
async updateRule(
|
||||
rule: Partial<AutoScoreRule> & { id: number }
|
||||
): Promise<{ success: boolean; data?: boolean; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:updateRule", rule)
|
||||
}
|
||||
|
||||
async deleteRule(
|
||||
ruleId: number
|
||||
): Promise<{ success: boolean; data?: boolean; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:deleteRule", ruleId)
|
||||
}
|
||||
|
||||
async toggleRule(
|
||||
ruleId: number,
|
||||
enabled: boolean
|
||||
): Promise<{ success: boolean; data?: boolean; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:toggleRule", { ruleId, enabled })
|
||||
}
|
||||
|
||||
async sortRules(
|
||||
ruleIds: number[]
|
||||
): Promise<{ success: boolean; data?: boolean; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:sortRules", ruleIds)
|
||||
}
|
||||
|
||||
async getStatus(): Promise<{ success: boolean; data?: { enabled: boolean }; message?: string }> {
|
||||
return await (window as any).api.invoke("auto-score:getStatus", {})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Service } from "../shared/kernel"
|
||||
import { ClientContext } from "../ClientContext"
|
||||
|
||||
declare module "../shared/kernel" {
|
||||
interface Context {
|
||||
students: StudentService
|
||||
}
|
||||
}
|
||||
|
||||
export class StudentService extends Service {
|
||||
constructor(ctx: ClientContext) {
|
||||
super(ctx, "students")
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
return await (window as any).api.queryStudents({})
|
||||
}
|
||||
|
||||
async create(data: any) {
|
||||
return await (window as any).api.createStudent(data)
|
||||
}
|
||||
|
||||
async update(id: number, data: any) {
|
||||
return await (window as any).api.updateStudent(id, data)
|
||||
}
|
||||
|
||||
async delete(id: number) {
|
||||
return await (window as any).api.deleteStudent(id)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user