package common import ( "errors" "fmt" "goqs/dbsql" ) type notify struct { ID int `json:"id" gorm:"column:id"` Section string `json:"section" gorm:"column:section"` Name string `json:"name" gorm:"column:name"` Token string `json:"token" gorm:"column:token"` Secret string `json:"secret" gorm:"column:secret"` IsDel int `json:"-" gorm:"column:is_del"` } func (t *notify) TableName() string { return "notify" } func GetNotifyConfig(section, name string) (notify, error) { db, err := dbsql.GetConn(dbsql.DSN) if err != nil { fmt.Println(err) } defer dbsql.Close(db) var n notify db.Model(notify{}).Where("section = ? AND name = ?", section, name).Last(&n) if n.ID < 1 { return n, errors.New("没找到对应的通知设置") } return n, nil }