external.go
661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package configs
import (
"fmt"
"reflect"
)
func Init() bool {
fmt.Println("configs Init")
Initial("./conf/bytes", "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
}