potato/internal/model/auth.go

24 lines
492 B
Go
Raw Permalink Normal View History

2021-06-10 19:03:15 +08:00
/*
* @Date: 2021-06-10 18:21:37
* @LastEditors: viletyy
2021-06-11 15:46:30 +08:00
* @LastEditTime: 2021-06-11 15:41:04
2021-06-10 19:03:15 +08:00
* @FilePath: /potato/internal/model/auth.go
*/
package model
2022-07-15 19:04:33 +08:00
import "gorm.io/gorm"
2021-06-10 19:03:15 +08:00
type Auth struct {
2021-06-11 10:40:27 +08:00
*Model
2021-06-10 19:03:15 +08:00
AppKey string `json:"app_key"`
AppSecret string `json:"app_secret"`
}
2021-06-11 15:46:30 +08:00
func (a Auth) Get(db *gorm.DB) (auth Auth, err error) {
2022-07-15 19:04:33 +08:00
if err := db.Where("app_key = ? AND app_secret = ?", a.AppKey, a.AppSecret).First(&auth).Error; err != nil {
return a, err
2021-06-10 19:03:15 +08:00
}
return auth, nil
}