1 Star 0 Fork 0

庞飞/multiapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
job.go 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-03 10:28 . 合并主框架
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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.0.9

搜索帮助

0d507c66 1850385 C8b1a773 1850385