瀏覽代碼

Fix 修复优化代码生成部分问题

YueYunyun 2 年之前
父節點
當前提交
3d8954fb9b

+ 14 - 0
SERVER/VberAdmin/_scripts/Cmd/Migrate_Gen.run.xml

@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="Migrate_Gen" type="GoApplicationRunConfiguration" factoryName="Go Application">
+    <module name="VberAdmin" />
+    <working_directory value="$PROJECT_DIR$" />
+    <go_parameters value="-tags=migrate" />
+    <parameters value="-g=true -f=true" />
+    <kind value="PACKAGE" />
+    <package value="VberAdmin" />
+    <directory value="$PROJECT_DIR$" />
+    <filePath value="$PROJECT_DIR$/main.go" />
+    <output_directory value="$PROJECT_DIR$/_scripts/Dev" />
+    <method v="2" />
+  </configuration>
+</component>

+ 2 - 2
SERVER/VberAdmin/_scripts/run

@@ -11,10 +11,10 @@
  go run main.go -a=true
 
  迁移数据库
- go run -tags=mig  main.go
+ go run -tags=migrate  main.go
 
  生成迁移文件(空) 生成后需要自己编写迁移脚本
- go run -tags=mig  main.go -g=true -f=true
+ go run -tags=migrate  main.go -g=true -f=true
 
  创建应用 -n= 指定应用名称
  go run -tags=createApp  main.go -n=

+ 10 - 3
SERVER/VberAdmin/core/project/project.go

@@ -85,7 +85,7 @@ func (info *Info) Build() error {
 	}
 	_vberNew = strings.ToLower(_vberNew)
 
-	fmt.Println("[原项目路径地址 ({})]", _oldProjectDir)
+	fmt.Println("[原项目路径地址 (" + _oldProjectDir + ")]")
 	_projectDirNew = info.ProjectDir
 	if _projectDirNew == "" {
 		_projectDirNew = _oldProjectDir + "_New"
@@ -95,7 +95,7 @@ func (info *Info) Build() error {
 		_projectDirNew = _projectDirNew + "/"
 	}
 
-	fmt.Println("[检测新项目目录 ({})是否存在]", _projectDirNew)
+	fmt.Println("[检测新项目目录 (" + _projectDirNew + ")是否存在]")
 	if _, err := os.Stat(_projectDirNew); !os.IsNotExist(err) {
 		fmt.Printf("[新项目目录检测 (%s) 已存在,请更改新的目录!程序退出]\n", _projectDirNew)
 		return err
@@ -106,7 +106,7 @@ func (info *Info) Build() error {
 		return errors.New("新项目目录存在冲突")
 	}
 
-	fmt.Println("[完成新项目目录检测,新项目路径地址 ({})]", _projectDirNew)
+	fmt.Println("[完成新项目目录检测,新项目路径地址 (" + _projectDirNew + ")]")
 	fmt.Println("[开始获得需要重写的文件,预计需要 10-20 秒]")
 
 	err := processFiles(_oldProjectDir, 0)
@@ -182,6 +182,9 @@ func writeAndCopy(path string, fileInfo os.FileInfo) error {
 			return fmt.Errorf("读取文件失败:%s", err)
 		}
 		newContent := replaceFileContent(string(content))
+		if strings.HasSuffix(path, ".yml") {
+			newContent = replaceConfigFileContent(newContent)
+		}
 		if err := writeFile(path, newContent); err != nil {
 			return fmt.Errorf("写入文件失败:%s", err)
 		}
@@ -208,7 +211,11 @@ func replaceFileContent(content string) string {
 	str = strings.ReplaceAll(str, Vber, _vberNew)
 	str = strings.ReplaceAll(str, strings.ToUpper(Vber), strings.ToUpper(_vberNew))
 	str = strings.ReplaceAll(str, utils.FirstUpper(Vber), utils.FirstUpper(_vberNew))
+	return str
+}
 
+func replaceConfigFileContent(content string) string {
+	str := strings.ReplaceAll(content, "UI/"+UiFile, "UI/"+_uiFileNew)
 	return str
 }
 

+ 2 - 2
SERVER/VberAdmin/template/migrate.template

@@ -5,7 +5,7 @@ import (
 	"runtime"
 
 	"VberAdmin/migration"
-	common "VberAdmin/common/models"
+	"VberAdmin/migration/models"
 )
 
 func init() {
@@ -33,7 +33,7 @@ func _{{.GenerateTime}}Test(db *gorm.DB, version string) error {
         //}
 
 
-		return tx.Create(&common.Migration{
+		return tx.Create(&models.Migration{
 			Version: version,
 		}).Error
 	})

+ 1 - 1
SERVER/VberAdmin/template/v4/no_actions/apis.go.template

@@ -11,7 +11,7 @@ import (
 	"VberAdmin/app/{{.PackageName}}/models"
 	"VberAdmin/app/{{.PackageName}}/service"
 	"VberAdmin/app/{{.PackageName}}/service/dto"
-	"VberAdmin/common/actions"
+	"VberAdmin/common/permission"
 )
 
 // {{.ClassName}}Api {{.FunctionName}}接口

+ 3 - 4
SERVER/VberAdmin/template/v4/no_actions/router_check_role.go.template

@@ -6,7 +6,6 @@ import (
 
 	"VberAdmin/app/{{.PackageName}}/apis"
 	"VberAdmin/common/middleware"
-	"VberAdmin/common/actions"
 )
 
 func init() {
@@ -18,10 +17,10 @@ func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJW
 	api := apis.{{.ClassName}}Api{}
 	r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
 	{
-		r.GET("",  permission.PermissionAction(), api.GetPage)
-		r.GET("/:id",  permission.PermissionAction(), api.Get)
+		r.GET("", api.GetPage)
+		r.GET("/:id", api.Get)
 		r.POST("", api.Insert)
-		r.PUT("/:id",  permission.PermissionAction(), api.Update)
+		r.PUT("/:id", api.Update)
 		r.DELETE("", api.Delete)
 	}
 }

+ 1 - 1
SERVER/VberAdmin/template/v4/no_actions/service.go.template

@@ -8,8 +8,8 @@ import (
 
 	"VberAdmin/app/{{.PackageName}}/models"
 	"VberAdmin/app/{{.PackageName}}/service/dto"
-	"VberAdmin/common/actions"
 	cDto "VberAdmin/common/dto"
+	"VberAdmin/common/permission"
 )
 
 // {{.ClassName}}Service {{.FunctionName}}服务

+ 1 - 1
UI/VAG.VUE/src/api/tools/_gen.ts

@@ -65,7 +65,7 @@ class genApi {
 
 	genCodeCheckRole = (tableId: string, ischeckrole: any) => {
 		return Rs.get({
-			url: "/gen/gen-code/" + tableId + "?ischeckrole=" + ischeckrole,
+			url: "/sys/gen-code/" + tableId + "?ischeckrole=" + ischeckrole,
 			loading: false
 		})
 	}

+ 2 - 2
UI/VAG.VUE/src/components/cell/cell.vue

@@ -1,9 +1,9 @@
 <script setup lang="ts">
-const props = withDefaults(
+withDefaults(
 	defineProps<{
 		value: string
 		label: string
-		border?: Boolean
+		border?: boolean
 		extra?: string
 	}>(),
 	{