package main import ( "context" "fmt" "git.nspix.com/golang/rest/v3" "gorm.io/driver/mysql" "log" ) func main() { var ( err error ) if err = rest.Init(mysql.New(mysql.Config{ DriverName: "mysql", DSN: "root:root@tcp(192.168.9.199:3306)/cci?checkConnLiveness=false&maxAllowedPacket=0", })); err != nil { fmt.Println(err.Error()) } dynamicModel := rest.NewDynamic([]*rest.Schema{ {0, 0, 0, "", "test", "aaa", 1, "id", "ID", rest.TypeInteger, rest.FormatInteger, 1, 1, "", rest.Scenarios{}, rest.Rule{}, rest.Attribute{}, 0}, {0, 0, 0, "", "test", "aaa", 1, "name", "Name", rest.TypeString, rest.FormatString, 1, 0, "", rest.Scenarios{}, rest.Rule{Max: 24}, rest.Attribute{}, 0}, }) if err = rest.AttachModel(context.Background(), dynamicModel); err != nil { log.Println(err) return } dynamicModel2 := rest.NewDynamic([]*rest.Schema{ {0, 0, 0, "", "test", "aab", 1, "id", "ID", rest.TypeInteger, rest.FormatInteger, 1, 1, "", rest.Scenarios{}, rest.Rule{}, rest.Attribute{}, 0}, {0, 0, 0, "", "test", "aab", 1, "age", "Age", rest.TypeInteger, rest.FormatInteger, 1, 0, "", rest.Scenarios{}, rest.Rule{}, rest.Attribute{}, 0}, {0, 0, 0, "", "test", "aab", 1, "gender", "Gender", rest.TypeString, rest.FormatString, 1, 0, "", rest.Scenarios{}, rest.Rule{Max: 20}, rest.Attribute{}, 0}, {0, 0, 0, "", "test", "aab", 1, "score", "Score", rest.TypeInteger, rest.TypeInteger, 1, 0, "", rest.Scenarios{}, rest.Rule{}, rest.Attribute{}, 0}, {0, 0, 0, "", "test", "aab", 1, "enable", "Enable", rest.TypeBoolean, rest.FormatBoolean, 1, 0, "", rest.Scenarios{}, rest.Rule{}, rest.Attribute{}, 0}, }) if err = rest.AttachModel(context.Background(), dynamicModel2); err != nil { log.Println(err) return } }