feat:回滚自动化生产代码
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/model/request"
|
||||
@@ -143,6 +144,35 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
|
||||
return err
|
||||
}
|
||||
err = utils.AutoInjectionCode(initializeRouterFilePath, "Routers", "router.Init"+autoCode.StructName+"Router(PrivateGroup)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
injectionCodeMeta := strings.Builder{}
|
||||
injectionCodeMeta.WriteString(fmt.Sprintf("%s@%s@%s", initializeGormFilePath, "MysqlTables", "model."+autoCode.StructName+"{},"))
|
||||
injectionCodeMeta.WriteString(";")
|
||||
injectionCodeMeta.WriteString(fmt.Sprintf("%s@%s@%s", initializeRouterFilePath, "Routers", "router.Init"+autoCode.StructName+"Router(PrivateGroup)"))
|
||||
|
||||
// 保存生成信息
|
||||
bf := strings.Builder{}
|
||||
for _, data := range dataList {
|
||||
if len(data.autoMoveFilePath) != 0 {
|
||||
bf.WriteString(data.autoMoveFilePath)
|
||||
bf.WriteString(";")
|
||||
}
|
||||
}
|
||||
|
||||
if autoCode.TableName != "" {
|
||||
err = CreateAutoCodeHistory(bf.String(),
|
||||
injectionCodeMeta.String(),
|
||||
autoCode.TableName,
|
||||
)
|
||||
} else {
|
||||
err = CreateAutoCodeHistory(bf.String(),
|
||||
injectionCodeMeta.String(),
|
||||
autoCode.StructName,
|
||||
)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -215,6 +245,10 @@ func GetColumn(tableName string, dbName string) (err error, Columns []request.Co
|
||||
return err, Columns
|
||||
}
|
||||
|
||||
func DropTable(tableName string) error {
|
||||
return global.GVA_DB.Exec("DROP TABLE " + tableName).Error
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@author: [songzhibin97](https://github.com/songzhibin97)
|
||||
//@function: addAutoMoveFile
|
||||
@@ -361,10 +395,10 @@ func getNeedList(autoCode *model.AutoCodeStruct) (dataList []tplData, fileList [
|
||||
firstDot := strings.Index(origFileName, ".")
|
||||
if firstDot != -1 {
|
||||
var fileName string
|
||||
if origFileName[firstDot:] !=".go"{
|
||||
fileName = autoCode.PackageName+origFileName[firstDot:]
|
||||
}else{
|
||||
fileName = autoCode.HumpPackageName+origFileName[firstDot:]
|
||||
if origFileName[firstDot:] != ".go" {
|
||||
fileName = autoCode.PackageName + origFileName[firstDot:]
|
||||
} else {
|
||||
fileName = autoCode.HumpPackageName + origFileName[firstDot:]
|
||||
}
|
||||
|
||||
dataList[index].autoCodePath = filepath.Join(autoPath, trimBase[:lastSeparator], autoCode.PackageName,
|
||||
|
Reference in New Issue
Block a user