38 lines
735 B
Smarty
38 lines
735 B
Smarty
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
|
|
RabbitMq *initalize.RabbitMqHandle
|
|
}
|
|
|
|
func NewServiceContext(c {{.config}}) *ServiceContext {
|
|
conn := initalize.InitMysql(c.SourceMysql)
|
|
|
|
return &ServiceContext{
|
|
Config: c,
|
|
MysqlConn: conn,
|
|
SharedState: nil,
|
|
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
|
RabbitMq:initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
|
{{.middlewareAssignment}}
|
|
}
|
|
} |