Init
This commit is contained in:
parent
264c97183e
commit
3faede7b1c
74 changed files with 6228 additions and 1 deletions
37
database/settings.go
Normal file
37
database/settings.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"govd/models"
|
||||
)
|
||||
|
||||
func GetGroupSettings(
|
||||
chatID int64,
|
||||
) (*models.GroupSettings, error) {
|
||||
var groupSettings models.GroupSettings
|
||||
err := DB.
|
||||
Where(&models.GroupSettings{
|
||||
ChatID: chatID,
|
||||
}).
|
||||
FirstOrCreate(&groupSettings).
|
||||
Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &groupSettings, nil
|
||||
}
|
||||
|
||||
func UpdateGroupSettings(
|
||||
chatID int64,
|
||||
settings *models.GroupSettings,
|
||||
) error {
|
||||
err := DB.
|
||||
Where(&models.GroupSettings{
|
||||
ChatID: chatID,
|
||||
}).
|
||||
Updates(settings).
|
||||
Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue