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