package models import ( "github.com/gin-gonic/gin" "github.com/product-definition/helpers" ) type Config struct { Id uint64 `gorm:"primary_key;AUTO_INCREMENT"` Key string Value string } func (Config) TableName() string { return "config" } func GetConfigValue(c *gin.Context, key string) (value string, err error) { var configs []Config err = helpers.MysqlClient.Ctx(c).Where("`key` = ?", key).Find(&configs).Error if err != nil { return value, err } if len(configs) == 0 { return "", err } return configs[0].Value, nil }