后端: - 修复登录校验、DB 并发(单例+WAL+纯Go sqlite)、会话密钥持久化等核心缺陷 - 新增 Timer CRUD/签到/手动触发、执行日志、仪表盘、驱动元数据等 API - 统一驱动接口: 带 context 的执行器、真实错误返回、敏感字段掩码、连通性测试 - 补全钉钉执行器; Timer 触发/提醒去重; 配置支持默认值与环境变量覆盖 前端: - Vite+Vue3+TS+Pinia+Element Plus, 由驱动元数据动态渲染配置表单 - 登录/仪表盘(倒计时环)/定时器/规则/账号/日志/设置页面, 支持暗色模式 - 主题色 #66ccff, 信号波纹 logo, go:embed 单二进制部署 构建: Dockerfile 增加前端构建阶段; 补充各驱动配置文档 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package model
|
|
|
|
// Rule 描述一个 Timer 到期后要执行的动作
|
|
type Rule struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
UID uint `gorm:"index" json:"uid"`
|
|
TimerID uint `gorm:"index" json:"timer_id"`
|
|
Name string `json:"name"`
|
|
// 关联账号,部分规则类型(如钉钉)不需要账号,此时为 0
|
|
AccountID uint `json:"account_id"`
|
|
// 规则类型,见 internal/ruleConfigChecker 注册表
|
|
Type string `json:"type"`
|
|
// 规则配置,JSON 字符串
|
|
ConfigJson string `json:"config_json"`
|
|
Enabled bool `gorm:"default:true" json:"enabled"`
|
|
CreateAt int64 `json:"create_at"`
|
|
}
|
|
|
|
// RuleRequest 创建/编辑规则的请求体
|
|
type RuleRequest struct {
|
|
Name string `json:"name"`
|
|
TimerID uint `json:"timer_id"`
|
|
AccountID uint `json:"account_id"`
|
|
Type string `json:"type"`
|
|
ConfigJson string `json:"config_json"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
|
|
// Validate 校验规则请求中与类型无关的通用部分
|
|
func (r *RuleRequest) Validate() error {
|
|
if r.Name == "" {
|
|
return ErrValidation("规则名称不能为空")
|
|
}
|
|
if len(r.Name) > 64 {
|
|
return ErrValidation("规则名称过长")
|
|
}
|
|
if r.Type == "" {
|
|
return ErrValidation("规则类型不能为空")
|
|
}
|
|
if r.TimerID == 0 {
|
|
return ErrValidation("必须关联一个 Timer")
|
|
}
|
|
if r.ConfigJson == "" {
|
|
return ErrValidation("规则配置不能为空")
|
|
}
|
|
return nil
|
|
}
|