Browse Source

制定基本项目结构

yjp 11 months ago
parent
commit
987b318096

+ 3 - 0
api/http.go

@@ -0,0 +1,3 @@
+package api
+
+type Api struct{}

+ 4 - 0
application/application.go

@@ -0,0 +1,4 @@
+package application
+
+type App struct {
+}

+ 9 - 0
baize.go

@@ -0,0 +1,9 @@
+package baize
+
+import (
+	"git.sxidc.com/go-framework/baize.git/application"
+)
+
+func NewApplication() *application.App {
+	return &application.App{}
+}

+ 61 - 0
examples/bind/main.go

@@ -0,0 +1,61 @@
+package main
+
+//import (
+//	DEATH "github.com/vrecan/death"
+//	"go-framework/baize"
+//	"go-tools/api_binding/http_binding"
+//	"go-tools/api_binding/http_binding/binding_context"
+//	"syscall"
+//)
+
+//type Hello struct {
+//	What string `json:"what"`
+//}
+
+func main() {
+	//app, err := baize.NewApplication("10000", baize.NewDBPersistence())
+	//if err != nil {
+	//	panic(err)
+	//}
+	//
+	//app.AddRouter("root", middlewares...).
+	//	GetRouter("root").
+	//	BindRoute(binding, &http_binding.SimpleBindItem[any, map[string]any]{
+	//		Path:         "/version",
+	//		ResponseFunc: response.SendMapResponse,
+	//		BusinessFunc: func(c *binding_context.Context, inputModel any) (map[string]any, error) {
+	//			return map[string]any{
+	//				"version": "v1.0.0",
+	//			}, nil
+	//		},
+	//	})
+	//
+	//app.AddRouter("v1", middlewares...).
+	//	GetRouter("v1").
+	//	BindPost(binding, &http_binding.SimpleBindItem[Hello, map[string]any]{
+	//		Path:         "/hello",
+	//		ResponseFunc: response.SendMapResponse,
+	//		BusinessFunc: func(c *binding_context.Context, inputModel Hello) (map[string]any, error) {
+	//			return map[string]any{
+	//				"version": application.GetVersionService().Version(),
+	//			}, nil
+	//		},
+	//	})
+	//
+	//go func() {
+	//	err := app.Start()
+	//	if err != nil {
+	//		panic(err)
+	//	}
+	//}()
+	//
+	//defer func() {
+	//	err := app.Finish()
+	//	if err != nil {
+	//		panic(err)
+	//	}
+	//}()
+	//
+	//death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
+	//_ = death.WaitForDeath()
+}

+ 62 - 0
examples/common_crud/main.go

@@ -0,0 +1,62 @@
+package main
+
+//import (
+//DEATH "github.com/vrecan/death"
+//"go-framework/baize"
+//"syscall"
+//)
+
+//type Class struct {
+//	domain.IDField
+//	Name string `write:"column:name;" read:"column:name;condition:'${column} LIKE %${value}%'" cache:"key:${field.IDField}"`
+//	domain.TenantIDField
+//	domain.UserIDFields
+//	domain.TimeFields
+//}
+//
+//type Student struct {
+//	domain.IDField
+//	Name string `write:"column:name;" read:"column:name;condition:'${column} LIKE %${value}%'"`
+//	Age  int    `write:"column:age;" read:"column:age;condition:'${column} LIKE %${value}%'" cache:"key:${field.IDField}"`
+//	domain.TenantIDField
+//	domain.UserIDFields
+//	domain.TimeFields
+//}
+
+func main() {
+	//app, err := baize.NewApplication("10000", baize.NewDBPersistence())
+	//if err != nil {
+	//	panic(err)
+	//}
+	//
+	//app.RegisterRouter("v1", middlewares...).
+	//	GetRouter("v1").
+	//	RegisterCommonCrud(&Class{}).
+	//	RegisterCrud(&common.Crud{
+	//		Api:          common.CrudApi{},
+	//		Service:      common.CrudService{},
+	//		DomainObject: &Student{},
+	//	}).
+	//	RegisterRelation(&common.Relation{
+	//		Type:              common.One2Many,
+	//		LeftDomainEntity:  &Class{},
+	//		RightDomainEntity: &Student{},
+	//	})
+	//
+	//go func() {
+	//	err := app.Start()
+	//	if err != nil {
+	//		panic(err)
+	//	}
+	//}()
+	//
+	//defer func() {
+	//	err := app.Finish()
+	//	if err != nil {
+	//		panic(err)
+	//	}
+	//}()
+	//
+	//death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
+	//_ = death.WaitForDeath()
+}

+ 5 - 0
examples/crud/main.go

@@ -0,0 +1,5 @@
+package main
+
+func main() {
+
+}

+ 5 - 0
examples/quick_start/main.go

@@ -0,0 +1,5 @@
+package main
+
+func main() {
+
+}

+ 5 - 0
examples/relation/main.go

@@ -0,0 +1,5 @@
+package main
+
+func main() {
+
+}

+ 1 - 1
go.mod

@@ -1,3 +1,3 @@
-module git.sxidc.com/go-tools/baize
+module git.sxidc.com/go-framework/baize.git
 
 go 1.22.3