| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package main
- import (
- "git.sxidc.com/go-framework/baize"
- "git.sxidc.com/go-framework/baize/application"
- "git.sxidc.com/go-framework/baize/convenient/value_object"
- "git.sxidc.com/go-framework/baize/examples/example_domain/configuration"
- "git.sxidc.com/go-framework/baize/infrastructure"
- "git.sxidc.com/go-framework/baize/infrastructure/database/operations"
- DEATH "github.com/vrecan/death"
- "syscall"
- )
- // curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test", "value":"test-value"}' "http://localhost:10100/test/v1/configuration/create"
- // curl -X GET "http://localhost:10100/test/v1/configuration/query?scope=global&pageNo=1&pageSize=1"
- // curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test"}' "http://localhost:10100/test/v1/configuration/delete"
- func main() {
- app := baize.NewApplication(application.Config{
- ApiConfig: application.ApiConfig{
- UrlPrefix: "test",
- Port: "10100",
- },
- InfrastructureConfig: application.InfrastructureConfig{
- Database: infrastructure.DatabaseConfig{
- Operations: &operations.Config{
- UserName: "test",
- Password: "123456",
- Address: "localhost",
- Port: "30432",
- Database: "test",
- MaxConnections: 40,
- MaxIdleConnections: 10,
- },
- },
- },
- })
- defer func() {
- baize.DestroyApplication(app)
- }()
- app.Api().
- PrefixRouter().
- RegisterVersionedRouter("v1")
- value_object.BindSimple[configuration.Info](app.Binder("v1"), &value_object.Simple[configuration.Info]{
- ValueObject: &configuration.Entity{},
- TableName: configuration.TableName,
- DomainPath: "/configuration",
- CreateJsonBody: &configuration.CreateConfigurationJsonBody{},
- DeleteQueryParams: &configuration.DeleteConfigurationJsonBody{},
- QueryQueryParams: &configuration.GetConfigurationValuesQueryParams{},
- })
- 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()
- }
|