1 Star 0 Fork 0

庞飞/multiapp

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
repository.go 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-03 17:10 +08:00 . 合并主框架
package repository
import (
"fmt"
"gitee.com/pangxianfei/multiapp/config"
"gitee.com/pangxianfei/multiapp/cmd"
"gitee.com/pangxianfei/multiapp/kernel/debug"
)
func init() {
cmd.Add(&Repository{})
}
type Repository struct {
}
func (s *Repository) Command() string {
return "Repository:make {appname} {DaoModel}"
}
func (s *Repository) Description() string {
return "Create a AppName DaoModel"
}
func (s *Repository) Handler(arg *cmd.Arg) error {
appname, aErr := arg.Get("appname")
if aErr != nil {
return aErr
}
repositoriesName, rErr := arg.Get("DaoModel")
if rErr != nil {
return rErr
}
if appname == nil {
cmd.Warning("You need a app name")
return nil
}
if repositoriesName == nil {
cmd.Warning("You need a DaoModel name")
return nil
}
var AppPath string = config.GetString("app.app_path")
var stubsRepositoryMametPath string = fmt.Sprintf("%s/make/stubs/repository", config.GetString("app.make_stubs"))
newAppName := string(*appname)
newRepositoriesName := string(*repositoriesName)
createModel := cmd.Model{}
Models := createModel.MakeModelFromString(newAppName, newRepositoriesName)
// 拼接目标文件路径
filePath := fmt.Sprintf("%s/%s/repositories/%sRepository.go", AppPath, Models.AppName, Models.StructName)
// 基于模板创建文件(做好变量替换)
createModel.CreateFileFromStub(filePath, stubsRepositoryMametPath, Models)
debug.Dd(Models)
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.2.3

搜索帮助