Browse Source

修复bug

main
SliverHorn 4 years ago
parent
commit
a01236be5d
  1. 8
      server/service/sys_auto_code.go

8
server/service/sys_auto_code.go

@ -1,6 +1,7 @@
package service package service
import ( import (
"errors"
"fmt" "fmt"
"gin-vue-admin/global" "gin-vue-admin/global"
"gin-vue-admin/model" "gin-vue-admin/model"
@ -101,13 +102,12 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
addAutoMoveFile(&dataList[index]) addAutoMoveFile(&dataList[index])
} }
for _, value := range dataList { // 移动文件 for _, value := range dataList { // 移动文件
err := utils.FileMove(value.autoCodePath, value.autoMoveFilePath)
if err != nil {
if err := utils.FileMove(value.autoCodePath, value.autoMoveFilePath); err != nil {
fmt.Println(err) fmt.Println(err)
return err return err
} }
} }
return
return errors.New("创建代码成功并移动文件成功")
} else { // 打包 } else { // 打包
if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil { if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil {
return err return err
@ -174,7 +174,7 @@ func addAutoMoveFile(data *tplData) {
} else if strings.Contains(data.autoCodePath, "form") { } else if strings.Contains(data.autoCodePath, "form") {
formList := strings.Split(data.autoCodePath, "/") formList := strings.Split(data.autoCodePath, "/")
data.autoMoveFilePath = filepath.Join("../", "web", "view", formList[len(formList)-3], strings.Split(formList[len(formList)-1], ".")[0]+"From.vue") data.autoMoveFilePath = filepath.Join("../", "web", "view", formList[len(formList)-3], strings.Split(formList[len(formList)-1], ".")[0]+"From.vue")
} else if strings.Contains(data.autoCodePath, "form") {
} else if strings.Contains(data.autoCodePath, "table") {
vueList := strings.Split(data.autoCodePath, "/") vueList := strings.Split(data.autoCodePath, "/")
data.autoMoveFilePath = filepath.Join("../", "web", "view", vueList[len(vueList)-3], vueList[len(vueList)-1]) data.autoMoveFilePath = filepath.Join("../", "web", "view", vueList[len(vueList)-3], vueList[len(vueList)-1])
} }

Loading…
Cancel
Save