This commit is contained in:
ayflying
2025-02-10 16:05:26 +08:00
parent 33c45920e3
commit 9461ad77ed

View File

@@ -62,16 +62,19 @@ func (c *cMake) Api() {
func (c *cMake) Act(id int) (err error) { func (c *cMake) Act(id int) (err error) {
filePath := fmt.Sprintf("api/act/v1/act%v.go", id) filePath := fmt.Sprintf("api/act/v1/act%v.go", id)
//生成文件不覆盖 //生成文件不覆盖
if gfile.Exists(filePath) { if !gfile.Exists(filePath) {
return err = gfile.PutContents(filePath, "package v1\n")
} }
err = gfile.PutContents(filePath, "package v1\n")
filePath = fmt.Sprintf("internal/game/act/act%d/act%d.go", id, id) filePath = fmt.Sprintf("internal/game/act/act%d/act%d.go", id, id)
//fileStr := gfile.GetContents(getFilePath) //生成文件不覆盖
get, err := fs.ReadFile(ConfigFiles, "make/act") if !gfile.Exists(filePath) {
fileStr := string(get) //fileStr := gfile.GetContents(getFilePath)
fileStr = gstr.Replace(fileStr, "{id}", gconv.String(id)) get, _ := fs.ReadFile(ConfigFiles, "make/act")
err = gfile.PutContents(filePath, fileStr) fileStr := string(get)
fileStr = gstr.Replace(fileStr, "{id}", gconv.String(id))
err = gfile.PutContents(filePath, fileStr)
}
return return
} }
@@ -79,15 +82,14 @@ func (c *cMake) Act(id int) (err error) {
func (c *cMake) Logic(name string) (err error) { func (c *cMake) Logic(name string) (err error) {
var filePath = fmt.Sprintf("internal/logic/%s/%s.go", name, name) var filePath = fmt.Sprintf("internal/logic/%s/%s.go", name, name)
//生成文件不覆盖 //生成文件不覆盖
if gfile.Exists(filePath) { if !gfile.Exists(filePath) {
return //fileStr := gfile.GetContents("./make/logic")
get, _ := fs.ReadFile(ConfigFiles, "make/act")
fileStr := string(get)
fileStr = gstr.Replace(fileStr, "{package}", name)
fileStr = gstr.Replace(fileStr, "{name}", gstr.CaseCamel(name))
err = gfile.PutContents(filePath, fileStr)
} }
//fileStr := gfile.GetContents("./make/logic")
get, err := fs.ReadFile(ConfigFiles, "make/act")
fileStr := string(get)
fileStr = gstr.Replace(fileStr, "{package}", name)
fileStr = gstr.Replace(fileStr, "{name}", gstr.CaseCamel(name))
err = gfile.PutContents(filePath, fileStr)
return return
} }