提交 694dc42f authored 作者: mooncake's avatar mooncake

fix

上级 3d3f2557
...@@ -354,13 +354,14 @@ type Redis struct { ...@@ -354,13 +354,14 @@ type Redis struct {
WriteTimeout int `yaml:"writeTimeout" json:"writeTimeout" mapstructure:"writeTimeout"` WriteTimeout int `yaml:"writeTimeout" json:"writeTimeout" mapstructure:"writeTimeout"`
} }
// 目前仅支持mysql
type Database struct { type Database struct {
Name string `yaml:"name" json:"name" mapstructure:"name"` Name string `yaml:"name" json:"name" mapstructure:"name"`
Driver string `yaml:"driver" json:"driver" mapstructure:"driver"` Driver string `yaml:"driver" json:"driver" mapstructure:"driver"`
Mongodb Mongodb `yaml:"mongodb" json:"mongodb" mapstructure:"mongodb"` // Mongodb Mongodb `yaml:"mongodb" json:"mongodb" mapstructure:"mongodb"`
Mysql Mysql `yaml:"mysql" json:"mysql" mapstructure:"mysql"` Mysql Mysql `yaml:"mysql" json:"mysql" mapstructure:"mysql"`
Postgresql Mysql `yaml:"postgresql" json:"postgresql" mapstructure:"postgresql"` // Postgresql Mysql `yaml:"postgresql" json:"postgresql" mapstructure:"postgresql"`
Sqlite Sqlite `yaml:"sqlite" json:"sqlite" mapstructure:"sqlite"` // Sqlite Sqlite `yaml:"sqlite" json:"sqlite" mapstructure:"sqlite"`
} }
type Mongodb struct { type Mongodb struct {
......
package consts
var (
// DefaultSchema string
RootRoute string
)
// func SetDefaultSchema(schema string) {
// DefaultSchema = schema
// }
func SetRootRoute(v string) {
RootRoute = v
}
...@@ -54,7 +54,7 @@ func (x XDB) DB() *sgorm.DB { ...@@ -54,7 +54,7 @@ func (x XDB) DB() *sgorm.DB {
func DB(name string) *sgorm.DB { func DB(name string) *sgorm.DB {
conn, ok := gdbs[name] conn, ok := gdbs[name]
if !ok { if !ok {
err := xerror.Newf("gdb[%s] not initialized", name) err := xerror.Newf("database[%s] not initialized", name)
panic(err) panic(err)
} }
return conn return conn
......
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
swaggerFiles "github.com/swaggo/files" swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"gitlab.wanzhuangkj.com/tush/xpkg/config" "gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/handlerfunc" "gitlab.wanzhuangkj.com/tush/xpkg/gin/handlerfunc"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware" "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware"
metrics "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/metrics_wz" metrics "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/metrics_wz"
...@@ -125,13 +124,14 @@ func New() *gin.Engine { ...@@ -125,13 +124,14 @@ func New() *gin.Engine {
weblogutils.Init() weblogutils.Init()
if config.IsNotProd() { if config.IsNotProd() {
r.GET(consts.RootRoute+"/config", gin.WrapF(errcode.ShowConfig([]byte(config.Show())))) contextPath := app.ContextPath
r.GET(consts.RootRoute+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) r.GET(contextPath+"/config", gin.WrapF(errcode.ShowConfig([]byte(config.Show()))))
r.GET(contextPath+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
eventbus.Eb.Subscribe(eventbus.TopicPrintSwagger, func(ctx context.Context) { eventbus.Eb.Subscribe(eventbus.TopicPrintSwagger, func(ctx context.Context) {
fmt.Println(text.Blue(fmt.Sprintf("swagger: http://localhost:%d"+consts.RootRoute+"/swagger/index.html", httpCfg.Port))) fmt.Println(text.Blue(fmt.Sprintf("swagger: http://localhost:%d"+contextPath+"/swagger/index.html", httpCfg.Port)))
ip := ips.GetLocalHost() ip := ips.GetLocalHost()
if ip != "" { if ip != "" {
fmt.Println(text.Blue(fmt.Sprintf("swagger: https://%s:%d"+consts.RootRoute+"/swagger/index.html", ip, httpCfg.Port))) fmt.Println(text.Blue(fmt.Sprintf("swagger: https://%s:%d"+contextPath+"/swagger/index.html", ip, httpCfg.Port)))
} }
}) })
} }
......
...@@ -11,58 +11,14 @@ import ( ...@@ -11,58 +11,14 @@ import (
) )
const ( const (
bizTag_agent = "qt.operator.agent.id"
bizTag_agent_operator = "qt.operator.agent.operator.id"
bizTag_api_notify = "qt.operator.api.notify.id"
bizTag_app_module = "qt.operator.app.module.id"
bizTag_auth_role = "qt.operator.auth.role.id"
bizTag_cron_job = "qt.operator.cron.job.id"
bizTag_cron_job_log = "qt.operator.cron.job.log.id"
bizTag_cron_job_record = "qt.operator.cron.job.record.id"
bizTag_email = "qt.operator.email.id" bizTag_email = "qt.operator.email.id"
bizTag_email_receiver = "qt.operator.email.receiver.id" bizTag_email_receiver = "qt.operator.email.receiver.id"
bizTag_email_send = "qt.operator.email.send.id" bizTag_email_send = "qt.operator.email.send.id"
bizTag_email_send_log = "qt.operator.email.send.log.id" bizTag_email_send_log = "qt.operator.email.send.log.id"
bizTag_email_tpl = "qt.operator.email.tpl.id" bizTag_email_tpl = "qt.operator.email.tpl.id"
bizTag_email_tpl_receiver = "qt.operator.email.tpl.receiver.id" bizTag_email_tpl_receiver = "qt.operator.email.tpl.receiver.id"
bizTag_intake = "qt.operator.intake.id"
bizTag_operator = "qt.operator.operator.id"
bizTag_platform_config = "qt.operator.platform.config.id"
bizTag_share = "qt.operator.share.id"
bizTag_site = "qt.operator.site.id"
bizTag_site_share = "qt.operator.site.share.id"
bizTag_site_user = "qt.operator.site.user.id"
bizTag_sms_code = "qt.operator.sms.code.id"
bizTag_user = "qt.operator.user.id"
bizTag_user_token = "qt.operator.user.token.id"
bizTag_web_log = "qt.operator.web.log.id"
bizTag_withdraw = "qt.operator.withdraw.id"
) )
func AgentID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_agent)
}
func AgentOperatorID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_agent_operator)
}
func ApiNotifyID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_api_notify)
}
func AppModuleID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_app_module)
}
func AuthRoleID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_auth_role)
}
func CronJobID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_cron_job)
}
func CronJobLogID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_cron_job_log)
}
func CronJobRecordID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_cron_job_record)
}
func EmailID(ctx context.Context) xsf.ID { func EmailID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_email) return generateID(ctx, bizTag_email)
} }
...@@ -81,43 +37,6 @@ func EmailTplID(ctx context.Context) xsf.ID { ...@@ -81,43 +37,6 @@ func EmailTplID(ctx context.Context) xsf.ID {
func EmailTplReceiverID(ctx context.Context) xsf.ID { func EmailTplReceiverID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_email_tpl_receiver) return generateID(ctx, bizTag_email_tpl_receiver)
} }
func IntakeID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_intake)
}
func OperatorID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_operator)
}
func PlatformConfigID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_platform_config)
}
func ShareID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_share)
}
func SiteID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_site)
}
func SiteShareID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_site_share)
}
func SiteUserID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_site_user)
}
func SmsCodeID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_sms_code)
}
func UserID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_user)
}
func UserTokenID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_user_token)
}
func WebLogID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_web_log)
}
func WithdrawID(ctx context.Context) xsf.ID {
return generateID(ctx, bizTag_withdraw)
}
func generateID(ctx context.Context, bizTag string) xsf.ID { func generateID(ctx context.Context, bizTag string) xsf.ID {
xsf, err := dxsf.GenerateID(ctx, bizTag) xsf, err := dxsf.GenerateID(ctx, bizTag)
if err != nil { if err != nil {
...@@ -127,29 +46,9 @@ func generateID(ctx context.Context, bizTag string) xsf.ID { ...@@ -127,29 +46,9 @@ func generateID(ctx context.Context, bizTag string) xsf.ID {
return xsf return xsf
} }
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.agent.id',100000,2000,'qt.operator.agent.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.agent.operator.id',100000,2000,'qt.operator.agent.operator.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.api.notify.id',100000,2000,'qt.operator.api.notify.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.app.module.id',100000,2000,'qt.operator.app.module.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.auth.role.id',100000,2000,'qt.operator.auth.role.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.cron.job.id',100000,2000,'qt.operator.cron.job.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.cron.job.log.id',100000,2000,'qt.operator.cron.job.log.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.cron.job.record.id',100000,2000,'qt.operator.cron.job.record.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.id',100000,2000,'qt.operator.email.id'); // insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.id',100000,2000,'qt.operator.email.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.receiver.id',100000,2000,'qt.operator.email.receiver.id'); // insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.receiver.id',100000,2000,'qt.operator.email.receiver.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.send.id',100000,2000,'qt.operator.email.send.id'); // insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.send.id',100000,2000,'qt.operator.email.send.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.send.log.id',100000,2000,'qt.operator.email.send.log.id'); // insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.send.log.id',100000,2000,'qt.operator.email.send.log.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.tpl.id',100000,2000,'qt.operator.email.tpl.id'); // insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.tpl.id',100000,2000,'qt.operator.email.tpl.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.tpl.receiver.id',100000,2000,'qt.operator.email.tpl.receiver.id'); // insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.tpl.receiver.id',100000,2000,'qt.operator.email.tpl.receiver.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.intake.id',100000,2000,'qt.operator.intake.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.operator.id',100000,2000,'qt.operator.operator.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.platform.config.id',100000,2000,'qt.operator.platform.config.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.share.id',100000,2000,'qt.operator.share.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.site.id',100000,2000,'qt.operator.site.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.site.share.id',100000,2000,'qt.operator.site.share.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.site.user.id',100000,2000,'qt.operator.site.user.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.sms.code.id',100000,2000,'qt.operator.sms.code.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.user.id',100000,2000,'qt.operator.user.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.user.token.id',100000,2000,'qt.operator.user.token.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.web.log.id',100000,2000,'qt.operator.web.log.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.withdraw.id',100000,2000,'qt.operator.withdraw.id');
...@@ -19,6 +19,6 @@ const ( ...@@ -19,6 +19,6 @@ const (
TopicRdInit string = "event:application:rd:init" // TopicRdInit string = "event:application:rd:init" //
TopicRdInitFinish string = "event:application:rd:init:finish" // TopicRdInitFinish string = "event:application:rd:init:finish" //
TopicGinEngineCreated string = "event:application:gin:engine:created" // TopicGinEngineCreated string = "event:application:gin:engine:created" //
TopicPrintSwagger string = "event:swagger:print" // TopicPrintSwagger string = "event:application:swagger:print" //
TopicApplicationClose string = "event:application:close" // TopicApplicationClose string = "event:application:close" //
) )
...@@ -55,17 +55,17 @@ func Init() error { ...@@ -55,17 +55,17 @@ func Init() error {
func GenerateID(ctx context.Context, bizTag string) (xsf.ID, error) { func GenerateID(ctx context.Context, bizTag string) (xsf.ID, error) {
if idGenerateType == "snowflake" { if idGenerateType == "snowflake" {
return GenerateSFID(ctx, bizTag) return generateSFID(ctx, bizTag)
} else { } else {
return GenerateApiID(ctx, bizTag) return generateApiID(ctx, bizTag)
} }
} }
func GenerateSFID(ctx context.Context, bizTag string) (xsf.ID, error) { func generateSFID(_ context.Context, _ string) (xsf.ID, error) {
return xsf.GenerateID(), nil return xsf.GenerateID(), nil
} }
func GenerateApiID(ctx context.Context, bizTag string) (xsf.ID, error) { func generateApiID(ctx context.Context, bizTag string) (xsf.ID, error) {
url := fmt.Sprintf(`%s/api/leaf?biz_tag=%s`, leafAddr, bizTag) url := fmt.Sprintf(`%s/api/leaf?biz_tag=%s`, leafAddr, bizTag)
var id xsf.ID var id xsf.ID
reply := &IDReply{ reply := &IDReply{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论