代码拉取完成,页面将自动刷新
package job
import (
"fmt"
"gitee.com/pangxianfei/library/config"
"gitee.com/pangxianfei/multiapp/cmd"
"gitee.com/pangxianfei/multiapp/kernel/debug"
)
func init() {
cmd.Add(&job{})
}
type job struct {
}
func (s *job) Command() string {
return "job:make {appname} {name}"
}
func (s *job) Description() string {
return "Create a AppName Job"
}
func (s *job) Handler(arg *cmd.Arg) error {
appname, aErr := arg.Get("appname")
if aErr != nil {
return aErr
}
modelName, rErr := arg.Get("name")
if rErr != nil {
return rErr
}
if appname == nil {
cmd.Warning("You need a app name")
return nil
}
if modelName == nil {
cmd.Warning("You need a services name")
return nil
}
var AppPath string = config.GetString("app.app_path")
var stubsJobnametPath string = fmt.Sprintf("%s/make/stubs/job", config.GetString("app.make_stubs"))
var stubsJobPbnametPath string = fmt.Sprintf("%s/make/stubs/job.pb", config.GetString("app.make_stubs"))
debug.Dd(stubsJobnametPath)
debug.Dd(stubsJobPbnametPath)
newAppName := string(*appname)
newRequestName := string(*modelName)
createModel := cmd.Model{}
Models := createModel.MakeModelFromString(newAppName, newRequestName)
// 拼接目标文件路径
filePath := fmt.Sprintf("%s/%s/jobs/%sJob.go", AppPath, Models.AppName, Models.StructName)
debug.Dd(filePath)
// 基于模板创建文件(做好变量替换)
createModel.CreateFileFromStub(filePath, stubsJobnametPath, Models)
// 拼接目标文件路径
filePath = fmt.Sprintf("%s/%s/jobs/proto3/%sJobs.proto", AppPath, Models.AppName, Models.StructName)
// 基于模板创建文件(做好变量替换)
createModel.CreateFileFromStub(filePath, stubsJobPbnametPath, Models)
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。