feat: v2(Incomplete,very early version)

This commit is contained in:
mei
2026-04-05 10:36:22 +08:00
parent 2ab9e060eb
commit 6190a8853a
41 changed files with 1131 additions and 766 deletions
+9
View File
@@ -0,0 +1,9 @@
package model
type Account struct {
ID uint `gorm:"primaryKey" json:"id"`
UID uint `json:"uid"`
Name string `json:"name"` // 账号名称
Type string `json:"type"` // 账号类型,如 "bilibili"
Config string `json:"config"` // 存储账号相关配置,如cookie等
}
+11
View File
@@ -0,0 +1,11 @@
package model
type Rule struct {
ID uint `json:"id" gorm:"primaryKey"`
UID uint `json:"uid"`
TimerID uint `json:"timer_id"`
Name string `json:"name"`
AccountID uint `json:"account_id"`
Type string `json:"type"`
ConfigJson string `json:"config_json"`
}
+9
View File
@@ -0,0 +1,9 @@
package model
type Timer struct {
ID uint `gorm:"primaryKey" json:"id"`
UID uint `json:"uid"`
Name string `json:"name"`
SignDerationSeconds int64 `json:"sign_deration_seconds"`
LastSign int64 `json:"last_sign"`
}
+43
View File
@@ -0,0 +1,43 @@
package model
import (
"fmt"
"github.com/ssdomei232/goodBaby/handler/db"
)
type User struct {
ID uint `json:"id" gorm:"primaryKey"`
CreateAt int64 `json:"create_at"`
Username string `json:"username"`
Password string `json:"-"`
DingTalkConfig *string `json:"dingtalk_config"`
}
func (u *User) IsValid() error {
if u.Username == "" || u.Password == "" {
return fmt.Errorf("用户名或密码不能为空")
}
if len(u.Username) > 32 || len(u.Username) < 2 {
return fmt.Errorf("用户名过长或过短")
}
if len(u.Password) > 64 || len(u.Password) < 6 {
return fmt.Errorf("密码过长或过短")
}
return nil
}
func (u *User) IsExist() bool {
db, err := db.GetGormDB()
if err != nil {
return false
}
var count int64
result := db.Where("username = ?", u.Username).Count(&count)
if result.Error != nil {
return false
}
return count > 0
}