package svc import ( {{.configImport}} "errors" "fmt" "net/http" "fusenapi/utils/autoconfig" "fusenapi/initalize" "fusenapi/model/gmodel" "gorm.io/gorm" "github.com/golang-jwt/jwt" ) type ServiceContext struct { Config {{.config}} {{.middleware}} SharedState *fsm.StateCluster MysqlConn *gorm.DB AllModels *gmodel.AllModelsGen } func NewServiceContext(c {{.config}}) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) StateServer := fsm.StartNode(c.Name, fmt.Sprintf("localhost:%d", c.Port-2000), autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, SharedState: StateServer, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), {{.middlewareAssignment}} } }