package configs import ( "fmt" "github.com/astaxie/beego" "reflect" ) func Init() bool { fmt.Println("configs Init") conf, _ := beego.AppConfig.GetSection("conf") Initial(conf["path"], "ID") //InitExt() return true } func GetConfig[T any](id string, t T) (obj *T) { var table = GetTable(t) dt := table.GetItem(id) if dt == nil { return nil } obj = dt.(*T) return } func HasConfig[T any](id string, t T) (has bool) { var table = GetTable(t) return table.GetItem(id) != nil } func GetOne[T any](t T) (obj *T) { var table = GetTable(t) if len(table.Items()) > 0 { return table.Items()[0].(*T) } return nil } func GetTable[T any](t T) (table *DataTable) { table = GetDataTable(reflect.TypeOf(t)) return }