adjust table name code

This commit is contained in:
engigu
2024-01-14 22:44:10 +08:00
parent ad9f30fce8
commit 753e858763
5 changed files with 11 additions and 36 deletions
+1 -2
View File
@@ -3,7 +3,6 @@ package models
import (
"errors"
"github.com/jinzhu/gorm"
"message-nest/pkg/table"
)
type Settings struct {
@@ -50,7 +49,7 @@ func GetSettingByKey(section string, key string) (Settings, error) {
func GetSettingBySection(section string) ([]Settings, error) {
var settings []Settings
err := db.Table(table.SettingsTableName).Where("`section` = ? ", section).Scan(&settings).Error
err := db.Table(db.NewScope(Settings{}).TableName()).Where("`section` = ? ", section).Scan(&settings).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
return settings, err
}