2023-06-05 17:56:55 +08:00
|
|
|
package svc
|
|
|
|
|
|
|
|
import (
|
|
|
|
{{.configImport}}
|
2023-06-21 12:21:56 +08:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
2023-07-26 10:52:33 +08:00
|
|
|
"fusenapi/utils/autoconfig"
|
2023-06-12 14:05:35 +08:00
|
|
|
"fusenapi/initalize"
|
2023-06-21 12:21:56 +08:00
|
|
|
"fusenapi/model/gmodel"
|
|
|
|
|
2023-06-12 14:05:35 +08:00
|
|
|
"gorm.io/gorm"
|
2023-06-13 12:15:06 +08:00
|
|
|
"github.com/golang-jwt/jwt"
|
2023-06-05 17:56:55 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type ServiceContext struct {
|
|
|
|
Config {{.config}}
|
|
|
|
{{.middleware}}
|
2023-07-26 10:52:33 +08:00
|
|
|
|
|
|
|
SharedState *fsm.StateCluster
|
2023-06-12 14:05:35 +08:00
|
|
|
MysqlConn *gorm.DB
|
2023-06-21 12:21:56 +08:00
|
|
|
AllModels *gmodel.AllModelsGen
|
2023-07-28 17:15:37 +08:00
|
|
|
RabbitMq *initalize.RabbitMqHandle
|
2023-06-05 17:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewServiceContext(c {{.config}}) *ServiceContext {
|
2023-07-26 10:52:33 +08:00
|
|
|
conn := initalize.InitMysql(c.SourceMysql)
|
2023-06-12 15:17:42 +08:00
|
|
|
|
2023-06-05 17:56:55 +08:00
|
|
|
return &ServiceContext{
|
2023-07-26 10:52:33 +08:00
|
|
|
Config: c,
|
|
|
|
MysqlConn: conn,
|
2023-08-11 17:39:18 +08:00
|
|
|
SharedState: nil,
|
2023-07-26 10:52:33 +08:00
|
|
|
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
2023-07-28 17:15:37 +08:00
|
|
|
RabbitMq:initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
2023-06-05 17:56:55 +08:00
|
|
|
{{.middlewareAssignment}}
|
|
|
|
}
|
2023-06-12 15:17:42 +08:00
|
|
|
}
|