From 35b785045c7e88e2213f83fd9221842147592224 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Sun, 14 Apr 2024 21:15:03 +0800
Subject: [PATCH 01/32] =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=92=E4=BB=B6=E4=BF=AE=E5=A4=8Dwebsotrm?=
=?UTF-8?q?=20bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/vitePlugin/codeServer/index.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/web/vitePlugin/codeServer/index.js b/web/vitePlugin/codeServer/index.js
index 390310e87d..d919abac28 100644
--- a/web/vitePlugin/codeServer/index.js
+++ b/web/vitePlugin/codeServer/index.js
@@ -11,8 +11,9 @@ export default function GvaPositionServer() {
req._parsedUrl.query && req._parsedUrl.query.split('=')[1]
if (path && path !== 'null') {
if (process.env.VITE_EDITOR === 'webstorm') {
- const linePath = path.split(':')[1]
- const filePath = path.split(':')[0]
+ const lastColonIndex = path.lastIndexOf(':')
+ const linePath = path.substring(lastColonIndex + 1)
+ const filePath = path.substring(0, lastColonIndex)
const platform = os()
if (platform === 'win32') {
child_process.exec(
From 007f45c3fd4cf5e1694681d7249ff799ac66024b Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Mon, 15 Apr 2024 08:23:33 +0800
Subject: [PATCH 02/32] =?UTF-8?q?=E4=B8=8D=E8=A6=81merge!=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E5=8A=9F=E8=83=BD=E8=87=AA=E5=8A=A8=E5=8C=96=E5=88=A0?=
=?UTF-8?q?=E9=99=A4=E4=BB=A3=E7=A0=81=E5=92=8C=E5=A4=8D=E7=94=A8=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E7=9A=84=E6=97=B6=E5=80=99=E4=BF=9D=E7=95=99=E8=87=AA?=
=?UTF-8?q?=E5=86=99=E4=BB=A3=E7=A0=81=E5=88=B0=E6=96=87=E4=BB=B6=E6=9C=AB?=
=?UTF-8?q?=E5=B0=BE=20=E6=8A=9B=E7=A0=96=E5=BC=95=E7=8E=89=E7=9A=84?=
=?UTF-8?q?=E9=9A=8F=E4=BE=BF=E5=86=99=E7=9A=84(=E5=BE=88=E5=A4=9Abug?=
=?UTF-8?q?=E5=92=8C=E6=83=85=E5=86=B5=E6=B2=A1=E8=80=83=E8=99=91=20?=
=?UTF-8?q?=E5=B0=86=E5=B0=B1=E8=83=BD=E7=94=A8=E4=B8=8B)=20//=20@gvastart?=
=?UTF-8?q?keep=20//@gvaendkeep=20=E4=B9=8B=E9=97=B4=E7=9A=84=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81(=E8=87=AA=E5=86=99=E4=BB=A3=E7=A0=81)=E4=BC=9A?=
=?UTF-8?q?=E8=A2=AB=E4=BF=9D=E7=95=99=E5=88=B0=E6=96=B0=E7=9A=84=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84=E4=BB=A3=E7=A0=81=E4=B8=AD?=
=?UTF-8?q?=E5=8E=BB(=E5=BD=93=E7=84=B6=E5=8F=AF=E4=BB=A5=E8=87=AA?=
=?UTF-8?q?=E5=B7=B1=E5=8E=BBre=E6=AD=A3=E5=88=99=E9=87=8C=E6=9B=B4?=
=?UTF-8?q?=E6=94=B9)=20=E6=B3=A8=E6=84=8F=E5=8F=AA=E6=98=AF=E7=AE=80?=
=?UTF-8?q?=E5=8D=95=E7=9A=84=E7=94=A8re=E6=AD=A3=E5=88=99=E5=AE=9E?=
=?UTF-8?q?=E7=8E=B0=E4=BA=86=E4=B8=80=E4=B8=AA=E9=9D=9E=E5=B8=B8=E9=9D=9E?=
=?UTF-8?q?=E5=B8=B8=E5=9F=BA=E7=A1=80=E7=9A=84=E4=B8=9C=E8=A5=BF=20=20?=
=?UTF-8?q?=E8=B0=A8=E6=85=8E=E7=94=A8!!!!!(=E6=9C=AC=E8=BA=AB=E5=B0=B1?=
=?UTF-8?q?=E6=98=AF=E8=87=AA=E7=94=A8=E7=9A=84)=20=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E5=A4=8D=E7=94=A8=E4=BB=A3=E7=A0=81=E7=9A=84=E6=97=B6=E5=80=99?=
=?UTF-8?q?=20=E5=8B=BE=E9=80=89=E4=BF=9D=E7=95=99=E4=BB=A3=E7=A0=81(?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95=20=20=20=E5=8D=B3=E5=8F=AF=20=E6=B3=A8?=
=?UTF-8?q?=E6=84=8F=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F=E5=BE=88=E5=B1=8E?=
=?UTF-8?q?=E5=B1=B1=20=20=E5=88=9B=E5=BB=BA=E4=BA=86=E4=B8=80=E4=B8=AAsql?=
=?UTF-8?q?ite=E5=9C=A8rm=5Ffile=E6=96=87=E4=BB=B6=E5=A4=B9=E9=87=8C=20?=
=?UTF-8?q?=E7=94=A8=E6=9D=A5=E8=AE=B0=E5=BD=95=E5=88=A0=E9=99=A4=E7=9A=84?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E7=AD=89=20=20=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E4=B8=80=E4=BA=9B=E5=88=9D=E5=A7=8B=E5=8C=96=E9=83=BD?=
=?UTF-8?q?=E5=9C=A8main=E9=87=8C=20=E6=B2=A1=E5=A4=AA=E5=A4=9A=E6=97=B6?=
=?UTF-8?q?=E9=97=B4=E6=87=92=E5=BE=97=E7=9C=8B)=20=20=E4=B8=B4=E6=97=B6?=
=?UTF-8?q?=E8=87=AA=E7=94=A8=E7=9D=80=E5=88=86=E4=BA=AB=E4=B8=80=E4=B8=8B?=
=?UTF-8?q?=E8=80=8C=E5=B7=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/api/v1/system/sys_auto_code.go | 121 ++++++++++++++++++
server/global/global.go | 5 +
server/main.go | 21 +++
server/model/system/sys_auto_code.go | 51 ++++----
server/service/system/sys_autocode_history.go | 41 ++++++
web/src/view/systemTools/autoCode/index.vue | 16 +++
6 files changed, 231 insertions(+), 24 deletions(-)
diff --git a/server/api/v1/system/sys_auto_code.go b/server/api/v1/system/sys_auto_code.go
index 4e80944be8..081a4852f8 100644
--- a/server/api/v1/system/sys_auto_code.go
+++ b/server/api/v1/system/sys_auto_code.go
@@ -1,10 +1,13 @@
package system
import (
+ "bufio"
"errors"
"fmt"
"net/url"
"os"
+ "path/filepath"
+ "regexp"
"strings"
"github.com/flipped-aurora/gin-vue-admin/server/global"
@@ -101,8 +104,126 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
c.File("./ginvueadmin.zip")
_ = os.Remove("./ginvueadmin.zip")
}
+ // 屎山代码临时用 start 莫介意
+ if a.AutoKeepCode {
+ // 从 records 表中获取被删除的代码文件的路径和文件名
+ rows, err := global.RecordDB.Query("SELECT path, file FROM records")
+ if err != nil {
+ global.GVA_LOG.Error("查询记录失败!", zap.Error(err))
+ response.FailWithMessage("查询记录失败", c)
+ return
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var srcFile, file string
+ if err := rows.Scan(&srcFile, &file); err != nil {
+ global.GVA_LOG.Error("读取记录失败!", zap.Error(err))
+ response.FailWithMessage("读取记录失败", c)
+ return
+ }
+
+ // destFile 是新创建的文件的路径
+ destFile := filepath.Join(global.GVA_CONFIG.AutoCode.Root, file)
+
+ // 检查新文件的路径是否存在
+ if _, err := os.Stat(destFile); err == nil {
+ if err := extractAndAppendCodeBlocks(srcFile, destFile); err != nil {
+ global.GVA_LOG.Error("提取代码块失败!", zap.Error(err))
+ response.FailWithMessage("提取代码块失败", c)
+ return
+ }
+
+ // 删除数据库中的记录
+ _, err = global.RecordDB.Exec("DELETE FROM records WHERE path = ? AND file = ?", srcFile, file)
+ if err != nil {
+ global.GVA_LOG.Error("删除记录失败!", zap.Error(err))
+ response.FailWithMessage("删除记录失败", c)
+ return
+ }
+ }
+ }
+ }
+ // 屎山代码临时用 end 莫介意
+}
+
+// 屎山代码临时用 start 莫介意
+// 提取rm_file(删除文件存放)代码文件中的标记代码段,添加到目标文件末尾,如果目标文件不存在则自动创建
+func extractAndAppendCodeBlocks(srcFile, destFile string) error {
+
+ source, err := os.Open(srcFile)
+ if err != nil {
+ return err
+ }
+ defer source.Close()
+
+ // 检查目标文件是否存在,如果不存在则创建
+ dest, err := os.OpenFile(destFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
+ if err != nil {
+ return err
+ }
+ defer dest.Close()
+
+ scanner := bufio.NewScanner(source)
+ writer := bufio.NewWriter(dest)
+ defer writer.Flush()
+
+ keepWriting := false
+ nestCount := 0
+
+ for scanner.Scan() {
+ line := scanner.Text()
+ trimmedLine := strings.TrimSpace(line)
+
+ if isStartTag(trimmedLine) {
+ nestCount++
+ if nestCount == 1 {
+ keepWriting = true
+ }
+ }
+
+ if keepWriting {
+ _, err = writer.WriteString(line + "\n")
+ if err != nil {
+ return err
+ }
+ }
+
+ if isEndTag(trimmedLine) {
+ if nestCount > 0 {
+ nestCount--
+ }
+ if nestCount == 0 {
+ keepWriting = false
+ }
+ }
+ }
+
+ if err := scanner.Err(); err != nil {
+ return err
+ }
+
+ if nestCount != 0 {
+ return errors.New("发现未匹配的标签")
+ }
+
+ return nil
}
+// isStartTag 检查一行是否包含开始标签。
+func isStartTag(line string) bool {
+ match, _ := regexp.MatchString(`^\s*//\s*@gvastartkeep\s*$`, line)
+ return match
+}
+
+// isEndTag 检查一行是否包含结束标签。
+func isEndTag(line string) bool {
+ match, _ := regexp.MatchString(`^\s*//\s*@gvaendkeep\s*$`, line)
+ return match
+}
+
+// 屎山代码临时用 end 莫介意
+
// GetDB
// @Tags AutoCode
// @Summary 获取当前所有数据库
diff --git a/server/global/global.go b/server/global/global.go
index 8310250e70..0a492d528e 100644
--- a/server/global/global.go
+++ b/server/global/global.go
@@ -1,6 +1,7 @@
package global
import (
+ "database/sql"
"github.com/qiniu/qmgo"
"sync"
@@ -32,6 +33,10 @@ var (
BlackCache local_cache.Cache
lock sync.RWMutex
+
+ // 屎山代码临时用 start 莫介意
+ RecordDB *sql.DB
+ // 屎山代码临时用 end 莫介意
)
// GetGlobalDBByDBName 通过名称获取db list中的db
diff --git a/server/main.go b/server/main.go
index a6034ed6bb..93188f5d2e 100644
--- a/server/main.go
+++ b/server/main.go
@@ -1,8 +1,11 @@
package main
import (
+ "database/sql"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"
+ "log"
+ "path/filepath"
"github.com/flipped-aurora/gin-vue-admin/server/core"
"github.com/flipped-aurora/gin-vue-admin/server/global"
@@ -35,5 +38,23 @@ func main() {
db, _ := global.GVA_DB.DB()
defer db.Close()
}
+
+ // 屎山代码临时用 start 莫介意
+ defer global.RecordDB.Close()
+ rootPath := global.GVA_CONFIG.AutoCode.Root
+ rmFilePathRecord := filepath.Join(rootPath, "rm_file", "rm_record.db")
+ record_db, err := sql.Open("sqlite3", rmFilePathRecord)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ _, err = record_db.Exec("CREATE TABLE IF NOT EXISTS records (path TEXT, file TEXT, UPDATE_TIME DATETIME)")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ global.RecordDB = record_db
+ // 屎山代码临时用 end 莫介意
+
core.RunWindowsServer()
}
diff --git a/server/model/system/sys_auto_code.go b/server/model/system/sys_auto_code.go
index 23a7d6f447..e200cca983 100644
--- a/server/model/system/sys_auto_code.go
+++ b/server/model/system/sys_auto_code.go
@@ -10,30 +10,33 @@ import (
// AutoCodeStruct 初始版本自动化代码工具
type AutoCodeStruct struct {
- StructName string `json:"structName"` // Struct名称
- TableName string `json:"tableName"` // 表名
- PackageName string `json:"packageName"` // 文件名称
- HumpPackageName string `json:"humpPackageName"` // go文件名称
- Abbreviation string `json:"abbreviation"` // Struct简称
- Description string `json:"description"` // Struct中文名称
- AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
- AutoCreateMenuToSql bool `json:"autoCreateMenuToSql"` // 是否自动创建menu
- AutoCreateResource bool `json:"autoCreateResource"` // 是否自动创建资源标识
- AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
- BusinessDB string `json:"businessDB"` // 业务数据库
- GvaModel bool `json:"gvaModel"` // 是否使用gva默认Model
- Fields []*Field `json:"fields"`
- PrimaryField *Field `json:"primaryField"`
- HasTimer bool `json:"-"`
- HasSearchTimer bool `json:"-"`
- DictTypes []string `json:"-"`
- Package string `json:"package"`
- PackageT string `json:"-"`
- NeedSort bool `json:"-"`
- HasPic bool `json:"-"`
- HasRichText bool `json:"-"`
- HasFile bool `json:"-"`
- NeedJSON bool `json:"-"`
+ StructName string `json:"structName"` // Struct名称
+ TableName string `json:"tableName"` // 表名
+ PackageName string `json:"packageName"` // 文件名称
+ HumpPackageName string `json:"humpPackageName"` // go文件名称
+ Abbreviation string `json:"abbreviation"` // Struct简称
+ Description string `json:"description"` // Struct中文名称
+ AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
+ AutoCreateMenuToSql bool `json:"autoCreateMenuToSql"` // 是否自动创建menu
+ AutoCreateResource bool `json:"autoCreateResource"` // 是否自动创建资源标识
+ // 屎山代码临时用 start 莫介意
+ AutoKeepCode bool `json:"autoKeepCode"` // 是否自动保留代码
+ // 屎山代码临时用 end 莫介意
+ AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
+ BusinessDB string `json:"businessDB"` // 业务数据库
+ GvaModel bool `json:"gvaModel"` // 是否使用gva默认Model
+ Fields []*Field `json:"fields"`
+ PrimaryField *Field `json:"primaryField"`
+ HasTimer bool `json:"-"`
+ HasSearchTimer bool `json:"-"`
+ DictTypes []string `json:"-"`
+ Package string `json:"package"`
+ PackageT string `json:"-"`
+ NeedSort bool `json:"-"`
+ HasPic bool `json:"-"`
+ HasRichText bool `json:"-"`
+ HasFile bool `json:"-"`
+ NeedJSON bool `json:"-"`
}
func (a *AutoCodeStruct) Pretreatment() {
diff --git a/server/service/system/sys_autocode_history.go b/server/service/system/sys_autocode_history.go
index 720e4eacd0..7eea1ba3f5 100644
--- a/server/service/system/sys_autocode_history.go
+++ b/server/service/system/sys_autocode_history.go
@@ -1,10 +1,12 @@
package system
import (
+ "database/sql"
"errors"
"fmt"
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
"github.com/flipped-aurora/gin-vue-admin/server/utils/ast"
+ "log"
"path/filepath"
"strconv"
"strings"
@@ -117,6 +119,45 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.R
fmt.Println("文件已存在:", nPath)
nPath += fmt.Sprintf("_%d", time.Now().Nanosecond())
}
+ // 屎山代码临时用 start 莫介意
+ parts := strings.Split(path, "gin-vue-admin")
+ //从gin-vue-admin文件开始 例如serve\
+ FilePath := strings.TrimPrefix(parts[1], "\\")
+ //rootServeFilePath := filepath.Join(filepath.Base(filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(path))))), filepath.Base(filepath.Dir(filepath.Dir(filepath.Dir(path)))), filepath.Base(filepath.Dir(filepath.Dir(path))), filepath.Base(filepath.Dir(path)), filepath.Base(path))
+ fmt.Println("rootServeFilePath", FilePath)
+ stmt, err := global.RecordDB.Prepare("SELECT path FROM records WHERE file = ?")
+ if err != nil {
+ log.Fatal(err)
+ }
+ row := stmt.QueryRow(FilePath)
+
+ var existingPath string
+ err = row.Scan(&existingPath)
+
+ if err == sql.ErrNoRows {
+ // 插入新的记录
+ stmt, err = global.RecordDB.Prepare("INSERT INTO records (path, file, UPDATE_TIME) VALUES (?, ?, ?)")
+ if err != nil {
+ log.Fatal(err)
+ }
+ _, err = stmt.Exec(nPath, FilePath, time.Now())
+ if err != nil {
+ log.Fatal(err)
+ }
+ } else if err != nil {
+ log.Fatal(err)
+ } else {
+ // 更新已有的记录
+ stmt, err = global.RecordDB.Prepare("UPDATE records SET path = ?, UPDATE_TIME = ? WHERE file = ?")
+ if err != nil {
+ log.Fatal(err)
+ }
+ _, err = stmt.Exec(nPath, time.Now(), FilePath)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }
+ // 屎山代码临时用 end 莫介意
err = utils.FileMove(path, nPath)
if err != nil {
global.GVA_LOG.Error("file move err ", zap.Error(err))
diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue
index df28d71232..a4b1d53b6b 100644
--- a/web/src/view/systemTools/autoCode/index.vue
+++ b/web/src/view/systemTools/autoCode/index.vue
@@ -295,6 +295,21 @@
+
+
+
+ 保留代码(测试
+
+
+
+
+
+
+
+
@@ -697,6 +712,7 @@ const form = ref({
autoCreateApiToSql: true,
autoCreateMenuToSql: true,
autoMoveFile: true,
+ autoKeepCode: false,
gvaModel: true,
autoCreateResource: false,
fields: []
From 1ecfcdcdd2f43dae6e30ea8d54785a74126910c8 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Sun, 14 Apr 2024 21:15:03 +0800
Subject: [PATCH 03/32] =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=92=E4=BB=B6=E4=BF=AE=E5=A4=8Dwebsotrm?=
=?UTF-8?q?=20bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/vitePlugin/codeServer/index.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/web/vitePlugin/codeServer/index.js b/web/vitePlugin/codeServer/index.js
index 390310e87d..d919abac28 100644
--- a/web/vitePlugin/codeServer/index.js
+++ b/web/vitePlugin/codeServer/index.js
@@ -11,8 +11,9 @@ export default function GvaPositionServer() {
req._parsedUrl.query && req._parsedUrl.query.split('=')[1]
if (path && path !== 'null') {
if (process.env.VITE_EDITOR === 'webstorm') {
- const linePath = path.split(':')[1]
- const filePath = path.split(':')[0]
+ const lastColonIndex = path.lastIndexOf(':')
+ const linePath = path.substring(lastColonIndex + 1)
+ const filePath = path.substring(0, lastColonIndex)
const platform = os()
if (platform === 'win32') {
child_process.exec(
From 9a03790b7180ffa919db2f284010ed692f0038e6 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Wed, 17 Apr 2024 23:18:17 +0800
Subject: [PATCH 04/32] =?UTF-8?q?=E5=BC=95=E5=85=A5sqlite3(=E4=B8=B4?=
=?UTF-8?q?=E6=97=B6=E7=94=A8)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/go.mod | 2 +-
server/go.sum | 3 ++-
server/main.go | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/server/go.mod b/server/go.mod
index f173e04e3e..67958cdadc 100644
--- a/server/go.mod
+++ b/server/go.mod
@@ -18,6 +18,7 @@ require (
github.com/gookit/color v1.5.4
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible
github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
+ github.com/mattn/go-sqlite3 v1.14.16
github.com/mojocn/base64Captcha v1.3.5
github.com/otiai10/copy v1.7.0
github.com/pkg/errors v0.9.1
@@ -134,7 +135,6 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
- gorm.io/datatypes v1.2.0 // indirect
gorm.io/plugin/dbresolver v1.4.1 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.5.0 // indirect
diff --git a/server/go.sum b/server/go.sum
index 2a2b722a3e..c36abfe8a7 100644
--- a/server/go.sum
+++ b/server/go.sum
@@ -301,6 +301,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
+github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/microsoft/go-mssqldb v1.1.0 h1:jsV+tpvcPTbNNKW0o3kiCD69kOHICsfjZ2VcVu2lKYc=
github.com/microsoft/go-mssqldb v1.1.0/go.mod h1:LzkFdl4z2Ck+Hi+ycGOTbL56VEfgoyA2DvYejrNGbRk=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
@@ -835,7 +837,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8=
gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
diff --git a/server/main.go b/server/main.go
index 93188f5d2e..310984f127 100644
--- a/server/main.go
+++ b/server/main.go
@@ -2,6 +2,7 @@ package main
import (
"database/sql"
+ _ "github.com/mattn/go-sqlite3"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"
"log"
From 729eea6e52b16794c6ef97aa6b78f6654e481c4c Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Wed, 17 Apr 2024 23:27:17 +0800
Subject: [PATCH 05/32] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=9D=E5=A7=8B?=
=?UTF-8?q?=E5=8C=96=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BArm=5Ffile=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=A4=B9(=E4=B8=B4=E6=97=B6=E7=94=A8)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/main.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/server/main.go b/server/main.go
index 310984f127..162ab9dc88 100644
--- a/server/main.go
+++ b/server/main.go
@@ -6,6 +6,7 @@ import (
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"
"log"
+ "os"
"path/filepath"
"github.com/flipped-aurora/gin-vue-admin/server/core"
@@ -43,6 +44,11 @@ func main() {
// 屎山代码临时用 start 莫介意
defer global.RecordDB.Close()
rootPath := global.GVA_CONFIG.AutoCode.Root
+ rmFilePath := filepath.Join(rootPath, "rm_file")
+ // 创建所有必要的父目录
+ if err := os.MkdirAll(rmFilePath, 0755); err != nil {
+ log.Fatal(err)
+ }
rmFilePathRecord := filepath.Join(rootPath, "rm_file", "rm_record.db")
record_db, err := sql.Open("sqlite3", rmFilePathRecord)
if err != nil {
From 3416173bead36390256346e966ed107df66ab669 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Sun, 21 Apr 2024 17:11:08 +0800
Subject: [PATCH 06/32] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=BF=9D=E7=95=99?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83records=E8=AE=B0=E5=BD=95?=
=?UTF-8?q?=E8=A1=A8=E5=9C=A8gva=E8=BF=9E=E6=8E=A5=E7=9A=84=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E5=BA=93=E4=B8=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/api/v1/system/sys_auto_code.go | 30 ++++------
server/global/global.go | 5 --
server/main.go | 5 --
server/model/system/sys_autocode_history.go | 12 ++++
server/service/system/sys_autocode_history.go | 56 ++++++++-----------
5 files changed, 46 insertions(+), 62 deletions(-)
diff --git a/server/api/v1/system/sys_auto_code.go b/server/api/v1/system/sys_auto_code.go
index 081a4852f8..8428dba4c1 100644
--- a/server/api/v1/system/sys_auto_code.go
+++ b/server/api/v1/system/sys_auto_code.go
@@ -106,26 +106,21 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
}
// 屎山代码临时用 start 莫介意
if a.AutoKeepCode {
+ var records []system.RecordsDeleteCode
+ result := global.GVA_DB.Table("records").Select("path", "file", "update_time").Find(&records)
// 从 records 表中获取被删除的代码文件的路径和文件名
- rows, err := global.RecordDB.Query("SELECT path, file FROM records")
- if err != nil {
- global.GVA_LOG.Error("查询记录失败!", zap.Error(err))
- response.FailWithMessage("查询记录失败", c)
+ if result.Error != nil {
+ global.GVA_LOG.Error("无任何删除记录!", zap.Error(result.Error))
+ response.FailWithMessage("无任何删除记录", c)
return
}
- defer rows.Close()
-
- for rows.Next() {
- var srcFile, file string
- if err := rows.Scan(&srcFile, &file); err != nil {
- global.GVA_LOG.Error("读取记录失败!", zap.Error(err))
- response.FailWithMessage("读取记录失败", c)
- return
- }
+
+ for _, record := range records {
+ srcFile := record.Path
+ file := record.File
// destFile 是新创建的文件的路径
destFile := filepath.Join(global.GVA_CONFIG.AutoCode.Root, file)
-
// 检查新文件的路径是否存在
if _, err := os.Stat(destFile); err == nil {
if err := extractAndAppendCodeBlocks(srcFile, destFile); err != nil {
@@ -133,11 +128,10 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
response.FailWithMessage("提取代码块失败", c)
return
}
-
// 删除数据库中的记录
- _, err = global.RecordDB.Exec("DELETE FROM records WHERE path = ? AND file = ?", srcFile, file)
- if err != nil {
- global.GVA_LOG.Error("删除记录失败!", zap.Error(err))
+ result := global.GVA_DB.Where("path = ? AND file = ?", srcFile, file).Delete(&system.RecordsDeleteCode{})
+ if result.Error != nil {
+ global.GVA_LOG.Error("删除记录失败!", zap.Error(result.Error))
response.FailWithMessage("删除记录失败", c)
return
}
diff --git a/server/global/global.go b/server/global/global.go
index 0a492d528e..8310250e70 100644
--- a/server/global/global.go
+++ b/server/global/global.go
@@ -1,7 +1,6 @@
package global
import (
- "database/sql"
"github.com/qiniu/qmgo"
"sync"
@@ -33,10 +32,6 @@ var (
BlackCache local_cache.Cache
lock sync.RWMutex
-
- // 屎山代码临时用 start 莫介意
- RecordDB *sql.DB
- // 屎山代码临时用 end 莫介意
)
// GetGlobalDBByDBName 通过名称获取db list中的db
diff --git a/server/main.go b/server/main.go
index 162ab9dc88..8bc3861059 100644
--- a/server/main.go
+++ b/server/main.go
@@ -1,13 +1,8 @@
package main
import (
- "database/sql"
- _ "github.com/mattn/go-sqlite3"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"
- "log"
- "os"
- "path/filepath"
"github.com/flipped-aurora/gin-vue-admin/server/core"
"github.com/flipped-aurora/gin-vue-admin/server/global"
diff --git a/server/model/system/sys_autocode_history.go b/server/model/system/sys_autocode_history.go
index 60607938b8..081fd6b01e 100644
--- a/server/model/system/sys_autocode_history.go
+++ b/server/model/system/sys_autocode_history.go
@@ -3,6 +3,7 @@ package system
import (
"strconv"
"strings"
+ "time"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
@@ -39,3 +40,14 @@ func (m *SysAutoCodeHistory) ToRequestIds() request.IdsReq {
}
return request.IdsReq{Ids: ids}
}
+
+// 记录删除文件的路径
+type RecordsDeleteCode struct {
+ Path string `gorm:"type:text;comment:已删除文件保存路径"`
+ File string `gorm:"type:text;comment:新生成文件路径"`
+ UpdateTime time.Time `gorm:"type:datetime;comment:更新时间"`
+}
+
+func (RecordsDeleteCode) TableName() string {
+ return "records"
+}
diff --git a/server/service/system/sys_autocode_history.go b/server/service/system/sys_autocode_history.go
index 7eea1ba3f5..f55a0b4f62 100644
--- a/server/service/system/sys_autocode_history.go
+++ b/server/service/system/sys_autocode_history.go
@@ -1,11 +1,11 @@
package system
import (
- "database/sql"
"errors"
"fmt"
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
"github.com/flipped-aurora/gin-vue-admin/server/utils/ast"
+ "gorm.io/gorm"
"log"
"path/filepath"
"strconv"
@@ -112,53 +112,41 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.R
}
// 迁移
- nPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root,
+ delteSavePath := filepath.Join(global.GVA_CONFIG.AutoCode.Root,
"rm_file", time.Now().Format("20060102"), filepath.Base(filepath.Dir(filepath.Dir(path))), filepath.Base(filepath.Dir(path)), filepath.Base(path))
// 判断目标文件是否存在
- for utils.FileExist(nPath) {
- fmt.Println("文件已存在:", nPath)
- nPath += fmt.Sprintf("_%d", time.Now().Nanosecond())
+ for utils.FileExist(delteSavePath) {
+ fmt.Println("文件已存在:", delteSavePath)
+ delteSavePath += fmt.Sprintf("_%d", time.Now().Nanosecond())
}
// 屎山代码临时用 start 莫介意
parts := strings.Split(path, "gin-vue-admin")
//从gin-vue-admin文件开始 例如serve\
FilePath := strings.TrimPrefix(parts[1], "\\")
- //rootServeFilePath := filepath.Join(filepath.Base(filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(path))))), filepath.Base(filepath.Dir(filepath.Dir(filepath.Dir(path)))), filepath.Base(filepath.Dir(filepath.Dir(path))), filepath.Base(filepath.Dir(path)), filepath.Base(path))
- fmt.Println("rootServeFilePath", FilePath)
- stmt, err := global.RecordDB.Prepare("SELECT path FROM records WHERE file = ?")
- if err != nil {
- log.Fatal(err)
- }
- row := stmt.QueryRow(FilePath)
-
- var existingPath string
- err = row.Scan(&existingPath)
-
- if err == sql.ErrNoRows {
- // 插入新的记录
- stmt, err = global.RecordDB.Prepare("INSERT INTO records (path, file, UPDATE_TIME) VALUES (?, ?, ?)")
- if err != nil {
- log.Fatal(err)
+ var record system.RecordsDeleteCode
+ result := global.GVA_DB.Table("records").Where("file = ?", FilePath).First(&record)
+ if errors.Is(result.Error, gorm.ErrRecordNotFound) {
+ record = system.RecordsDeleteCode{
+ Path: delteSavePath,
+ File: FilePath,
+ UpdateTime: time.Now(),
}
- _, err = stmt.Exec(nPath, FilePath, time.Now())
- if err != nil {
- log.Fatal(err)
+ if err := global.GVA_DB.Create(&record).Error; err != nil {
+ log.Fatal()
}
- } else if err != nil {
- log.Fatal(err)
+
+ } else if result.Error != nil {
+ log.Fatal(result.Error)
} else {
- // 更新已有的记录
- stmt, err = global.RecordDB.Prepare("UPDATE records SET path = ?, UPDATE_TIME = ? WHERE file = ?")
- if err != nil {
- log.Fatal(err)
- }
- _, err = stmt.Exec(nPath, time.Now(), FilePath)
- if err != nil {
+ //更新已有记录
+ record.Path = delteSavePath
+ record.UpdateTime = time.Now()
+ if err := global.GVA_DB.Model(&system.RecordsDeleteCode{}).Where("file = ?", FilePath).Updates(&record).Error; err != nil {
log.Fatal(err)
}
}
// 屎山代码临时用 end 莫介意
- err = utils.FileMove(path, nPath)
+ err = utils.FileMove(path, delteSavePath)
if err != nil {
global.GVA_LOG.Error("file move err ", zap.Error(err))
}
From 03a61d74ff72491fb115e50ce1897ad966539f3c Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Sun, 21 Apr 2024 17:14:58 +0800
Subject: [PATCH 07/32] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=BF=9D=E7=95=99?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83records=E8=AE=B0=E5=BD=95?=
=?UTF-8?q?=E8=A1=A8=E5=9C=A8gva=E8=BF=9E=E6=8E=A5=E7=9A=84=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E5=BA=93=E4=B8=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/main.go | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/server/main.go b/server/main.go
index 8bc3861059..0899c2aeed 100644
--- a/server/main.go
+++ b/server/main.go
@@ -36,27 +36,5 @@ func main() {
defer db.Close()
}
- // 屎山代码临时用 start 莫介意
- defer global.RecordDB.Close()
- rootPath := global.GVA_CONFIG.AutoCode.Root
- rmFilePath := filepath.Join(rootPath, "rm_file")
- // 创建所有必要的父目录
- if err := os.MkdirAll(rmFilePath, 0755); err != nil {
- log.Fatal(err)
- }
- rmFilePathRecord := filepath.Join(rootPath, "rm_file", "rm_record.db")
- record_db, err := sql.Open("sqlite3", rmFilePathRecord)
- if err != nil {
- log.Fatal(err)
- }
-
- _, err = record_db.Exec("CREATE TABLE IF NOT EXISTS records (path TEXT, file TEXT, UPDATE_TIME DATETIME)")
- if err != nil {
- log.Fatal(err)
- }
-
- global.RecordDB = record_db
- // 屎山代码临时用 end 莫介意
-
core.RunWindowsServer()
}
From 1982c400f3e2860184b1e80db8f4890ce0b35ee7 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Sun, 21 Apr 2024 22:44:52 +0800
Subject: [PATCH 08/32] 1
---
server/go.mod | 4 ++--
server/go.sum | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/server/go.mod b/server/go.mod
index 67958cdadc..bcc0af1d58 100644
--- a/server/go.mod
+++ b/server/go.mod
@@ -18,7 +18,6 @@ require (
github.com/gookit/color v1.5.4
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible
github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
- github.com/mattn/go-sqlite3 v1.14.16
github.com/mojocn/base64Captcha v1.3.5
github.com/otiai10/copy v1.7.0
github.com/pkg/errors v0.9.1
@@ -135,9 +134,10 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
+ gorm.io/datatypes v1.2.0 // indirect
gorm.io/plugin/dbresolver v1.4.1 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.6.0 // indirect
modernc.org/sqlite v1.23.0 // indirect
-)
+)
\ No newline at end of file
diff --git a/server/go.sum b/server/go.sum
index c36abfe8a7..c4e30d12ba 100644
--- a/server/go.sum
+++ b/server/go.sum
@@ -301,8 +301,6 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
-github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
-github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/microsoft/go-mssqldb v1.1.0 h1:jsV+tpvcPTbNNKW0o3kiCD69kOHICsfjZ2VcVu2lKYc=
github.com/microsoft/go-mssqldb v1.1.0/go.mod h1:LzkFdl4z2Ck+Hi+ycGOTbL56VEfgoyA2DvYejrNGbRk=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
@@ -837,6 +835,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8=
gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
@@ -873,4 +872,4 @@ nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
-rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
\ No newline at end of file
From 8432f9a33081429576d32bc6ea66134d2e52512f Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Sun, 21 Apr 2024 22:48:27 +0800
Subject: [PATCH 09/32] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/api/v1/system/sys_auto_code.go | 5 --
server/model/system/sys_auto_code.go | 52 +++++++++----------
server/service/system/sys_autocode_history.go | 2 -
3 files changed, 25 insertions(+), 34 deletions(-)
diff --git a/server/api/v1/system/sys_auto_code.go b/server/api/v1/system/sys_auto_code.go
index 8428dba4c1..a094ed685a 100644
--- a/server/api/v1/system/sys_auto_code.go
+++ b/server/api/v1/system/sys_auto_code.go
@@ -104,7 +104,6 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
c.File("./ginvueadmin.zip")
_ = os.Remove("./ginvueadmin.zip")
}
- // 屎山代码临时用 start 莫介意
if a.AutoKeepCode {
var records []system.RecordsDeleteCode
result := global.GVA_DB.Table("records").Select("path", "file", "update_time").Find(&records)
@@ -138,10 +137,8 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
}
}
}
- // 屎山代码临时用 end 莫介意
}
-// 屎山代码临时用 start 莫介意
// 提取rm_file(删除文件存放)代码文件中的标记代码段,添加到目标文件末尾,如果目标文件不存在则自动创建
func extractAndAppendCodeBlocks(srcFile, destFile string) error {
@@ -216,8 +213,6 @@ func isEndTag(line string) bool {
return match
}
-// 屎山代码临时用 end 莫介意
-
// GetDB
// @Tags AutoCode
// @Summary 获取当前所有数据库
diff --git a/server/model/system/sys_auto_code.go b/server/model/system/sys_auto_code.go
index e200cca983..41f8366fe5 100644
--- a/server/model/system/sys_auto_code.go
+++ b/server/model/system/sys_auto_code.go
@@ -10,33 +10,31 @@ import (
// AutoCodeStruct 初始版本自动化代码工具
type AutoCodeStruct struct {
- StructName string `json:"structName"` // Struct名称
- TableName string `json:"tableName"` // 表名
- PackageName string `json:"packageName"` // 文件名称
- HumpPackageName string `json:"humpPackageName"` // go文件名称
- Abbreviation string `json:"abbreviation"` // Struct简称
- Description string `json:"description"` // Struct中文名称
- AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
- AutoCreateMenuToSql bool `json:"autoCreateMenuToSql"` // 是否自动创建menu
- AutoCreateResource bool `json:"autoCreateResource"` // 是否自动创建资源标识
- // 屎山代码临时用 start 莫介意
- AutoKeepCode bool `json:"autoKeepCode"` // 是否自动保留代码
- // 屎山代码临时用 end 莫介意
- AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
- BusinessDB string `json:"businessDB"` // 业务数据库
- GvaModel bool `json:"gvaModel"` // 是否使用gva默认Model
- Fields []*Field `json:"fields"`
- PrimaryField *Field `json:"primaryField"`
- HasTimer bool `json:"-"`
- HasSearchTimer bool `json:"-"`
- DictTypes []string `json:"-"`
- Package string `json:"package"`
- PackageT string `json:"-"`
- NeedSort bool `json:"-"`
- HasPic bool `json:"-"`
- HasRichText bool `json:"-"`
- HasFile bool `json:"-"`
- NeedJSON bool `json:"-"`
+ StructName string `json:"structName"` // Struct名称
+ TableName string `json:"tableName"` // 表名
+ PackageName string `json:"packageName"` // 文件名称
+ HumpPackageName string `json:"humpPackageName"` // go文件名称
+ Abbreviation string `json:"abbreviation"` // Struct简称
+ Description string `json:"description"` // Struct中文名称
+ AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
+ AutoCreateMenuToSql bool `json:"autoCreateMenuToSql"` // 是否自动创建menu
+ AutoCreateResource bool `json:"autoCreateResource"` // 是否自动创建资源标识
+ AutoKeepCode bool `json:"autoKeepCode"` // 是否自动保留代码
+ AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
+ BusinessDB string `json:"businessDB"` // 业务数据库
+ GvaModel bool `json:"gvaModel"` // 是否使用gva默认Model
+ Fields []*Field `json:"fields"`
+ PrimaryField *Field `json:"primaryField"`
+ HasTimer bool `json:"-"`
+ HasSearchTimer bool `json:"-"`
+ DictTypes []string `json:"-"`
+ Package string `json:"package"`
+ PackageT string `json:"-"`
+ NeedSort bool `json:"-"`
+ HasPic bool `json:"-"`
+ HasRichText bool `json:"-"`
+ HasFile bool `json:"-"`
+ NeedJSON bool `json:"-"`
}
func (a *AutoCodeStruct) Pretreatment() {
diff --git a/server/service/system/sys_autocode_history.go b/server/service/system/sys_autocode_history.go
index f55a0b4f62..bfa480ed4e 100644
--- a/server/service/system/sys_autocode_history.go
+++ b/server/service/system/sys_autocode_history.go
@@ -119,7 +119,6 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.R
fmt.Println("文件已存在:", delteSavePath)
delteSavePath += fmt.Sprintf("_%d", time.Now().Nanosecond())
}
- // 屎山代码临时用 start 莫介意
parts := strings.Split(path, "gin-vue-admin")
//从gin-vue-admin文件开始 例如serve\
FilePath := strings.TrimPrefix(parts[1], "\\")
@@ -145,7 +144,6 @@ func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.R
log.Fatal(err)
}
}
- // 屎山代码临时用 end 莫介意
err = utils.FileMove(path, delteSavePath)
if err != nil {
global.GVA_LOG.Error("file move err ", zap.Error(err))
From 1705d6dd5a1d1df6407a196b66d29e342ee21446 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Mon, 22 Apr 2024 01:30:48 +0800
Subject: [PATCH 10/32] =?UTF-8?q?gvakeepcode=E5=BF=98=E8=AE=B0=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E6=B3=A8=E5=86=8C=E8=A1=A8=E4=BA=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/initialize/gorm.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/initialize/gorm.go b/server/initialize/gorm.go
index 10f5c8e833..ca2935131e 100644
--- a/server/initialize/gorm.go
+++ b/server/initialize/gorm.go
@@ -48,6 +48,7 @@ func RegisterTables() {
system.SysExportTemplate{},
system.Condition{},
system.JoinTemplate{},
+ system.RecordsDeleteCode{},
example.ExaFile{},
example.ExaCustomer{},
From 20d9c80b7e3ded765b3a7aff28956ab5b6e8842a Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Mon, 22 Apr 2024 15:43:24 +0800
Subject: [PATCH 11/32] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E5=99=A8=E9=BB=98=E8=AE=A4=E6=98=AF=E4=BD=BF=E7=94=A8=E6=97=A5?=
=?UTF-8?q?=E6=9C=9F+=E6=97=B6=E9=97=B4=20(=E4=B9=8B=E5=89=8D=E9=BB=98?=
=?UTF-8?q?=E8=AE=A4=E6=98=AF=E5=8F=AA=E6=9C=89=E6=97=A5=E6=9C=9F)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/resource/autocode_template/web/form.vue.tpl | 2 +-
server/resource/autocode_template/web/table.vue.tpl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/resource/autocode_template/web/form.vue.tpl b/server/resource/autocode_template/web/form.vue.tpl
index d49bb9e1dc..43dfe65c20 100644
--- a/server/resource/autocode_template/web/form.vue.tpl
+++ b/server/resource/autocode_template/web/form.vue.tpl
@@ -29,7 +29,7 @@
{{- end }}
{{- end }}
{{- if eq .FieldType "time.Time" }}
-
+
{{- end }}
{{- if eq .FieldType "float64" }}
diff --git a/server/resource/autocode_template/web/table.vue.tpl b/server/resource/autocode_template/web/table.vue.tpl
index 42d09830a9..bad1c64a1e 100644
--- a/server/resource/autocode_template/web/table.vue.tpl
+++ b/server/resource/autocode_template/web/table.vue.tpl
@@ -234,7 +234,7 @@
{{- end }}
{{- end }}
{{- if eq .FieldType "time.Time" }}
-
+
{{- end }}
{{- if eq .FieldType "float64" }}
From 9919e8ed7ec1136b0aad5430b2310efd16507118 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Fri, 26 Apr 2024 21:20:17 +0800
Subject: [PATCH 12/32] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=A8=A1=E6=9D=BF?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84table=E8=A1=A8=E5=A4=B4=E4=B8=BA?=
=?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=B0=83=E6=95=B4=E5=AE=BD=E5=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/resource/autocode_template/web/table.vue.tpl | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/resource/autocode_template/web/table.vue.tpl b/server/resource/autocode_template/web/table.vue.tpl
index 42d09830a9..4284366223 100644
--- a/server/resource/autocode_template/web/table.vue.tpl
+++ b/server/resource/autocode_template/web/table.vue.tpl
@@ -95,6 +95,7 @@
@selection-change="handleSelectionChange"
{{- if .NeedSort}}
@sort-change="sortChange"
+ border resizeable
{{- end}}
>
From a1e1ff20b42b376229ed2424a0209e4eb64daf5f Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Thu, 9 May 2024 19:39:34 +0800
Subject: [PATCH 13/32] =?UTF-8?q?=E5=A2=9E=E5=8A=A0int64=E5=92=8Cuint(?=
=?UTF-8?q?=E9=BB=98=E8=AE=A4id=E7=B1=BB=E5=9E=8B)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/view/systemTools/autoCode/index.vue | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue
index 41925e435c..8255dba7e2 100644
--- a/web/src/view/systemTools/autoCode/index.vue
+++ b/web/src/view/systemTools/autoCode/index.vue
@@ -643,6 +643,14 @@ const typeOptions = ref([
label: '整型',
value: 'int'
},
+ {
+ label: '整型64',
+ value: 'int64'
+ },
+ {
+ label: 'uint(默认id类型)',
+ value: 'uint'
+ },
{
label: '布尔值',
value: 'bool'
From 5b905c9a1e343134d9c1bc36c65ecbc78f00899c Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Thu, 9 May 2024 19:44:26 +0800
Subject: [PATCH 14/32] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E5=88=9B?=
=?UTF-8?q?=E5=BB=BA=E4=BB=A3=E7=A0=81=E5=A2=9E=E5=8A=A0int64=E5=92=8Cuint?=
=?UTF-8?q?(=E9=BB=98=E8=AE=A4id=E7=B1=BB=E5=9E=8B)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/view/systemTools/autoCode/index.vue | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue
index aedaf240db..2cc42057eb 100644
--- a/web/src/view/systemTools/autoCode/index.vue
+++ b/web/src/view/systemTools/autoCode/index.vue
@@ -628,6 +628,14 @@ const typeOptions = ref([
label: '整型',
value: 'int'
},
+ {
+ label: '整型64',
+ value: 'int64'
+ },
+ {
+ label: 'uint(默认id类型)',
+ value: 'uint'
+ },
{
label: '布尔值',
value: 'bool'
From b36cdbb2b08630524fed999abe42ab65670cd3ee Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Thu, 16 May 2024 02:43:19 +0800
Subject: [PATCH 15/32] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8C=87=E7=BA=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/openDocument.js | 21 ---------------------
web/vite.config.js | 6 +++---
web/vitePlugin/svgIcon/svgIcon.js | 6 ------
3 files changed, 3 insertions(+), 30 deletions(-)
delete mode 100644 web/openDocument.js
diff --git a/web/openDocument.js b/web/openDocument.js
deleted file mode 100644
index a9e65554c9..0000000000
--- a/web/openDocument.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-此文件受版权保护,未经授权禁止修改!如果您尚未获得授权,请通过微信(shouzi_1994)联系我们以购买授权。在未授权状态下,只需保留此代码,不会影响任何正常使用。
- 未经授权的商用使用可能会被我们的资产搜索引擎爬取,并可能导致后续索赔。索赔金额将不低于高级授权费的十倍。请您遵守版权法律法规,尊重知识产权。
-*/
-
-var child_process = require('child_process')
-
-var url = 'https://www.gin-vue-admin.com'
-var cmd = ''
-console.log(process.platform)
-switch (process.platform) {
- case 'win32':
- cmd = 'start'
- child_process.exec(cmd + ' ' + url)
- break
-
- case 'darwin':
- cmd = 'open'
- child_process.exec(cmd + ' ' + url)
- break
-}
diff --git a/web/vite.config.js b/web/vite.config.js
index 271713a186..67187a5e0e 100644
--- a/web/vite.config.js
+++ b/web/vite.config.js
@@ -43,9 +43,9 @@ export default ({
const rollupOptions = {
output: {
- entryFileNames: 'assets/087AC4D233B64EB0[name].[hash].js',
- chunkFileNames: 'assets/087AC4D233B64EB0[name].[hash].js',
- assetFileNames: 'assets/087AC4D233B64EB0[name].[hash].[ext]',
+ entryFileNames: 'assets/[name].[hash].js',
+ chunkFileNames: 'assets/[name].[hash].js',
+ assetFileNames: 'assets/[name].[hash].[ext]',
},
}
diff --git a/web/vitePlugin/svgIcon/svgIcon.js b/web/vitePlugin/svgIcon/svgIcon.js
index 42b0430042..6c44af027c 100644
--- a/web/vitePlugin/svgIcon/svgIcon.js
+++ b/web/vitePlugin/svgIcon/svgIcon.js
@@ -46,12 +46,6 @@ export const svgBuilder = (path) => {
name: 'svg-transform',
transformIndexHtml(html) {
return html.replace(
- '
',
- `
-
-
- `
- ).replace(
'',
`
From a88dcdf73551e5481576b54ed2255860258f98f0 Mon Sep 17 00:00:00 2001
From: xuedinge <781408517@qq.com>
Date: Thu, 16 May 2024 16:38:47 +0800
Subject: [PATCH 16/32] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8C=87=E7=BA=B9?=
=?UTF-8?q?=E5=92=8C=E5=A2=9E=E5=8A=A0=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/source/system/menu.go | 2 +-
web/index.html | 2 +-
web/package.json | 2 +-
web/src/components/bottomInfo/bottomInfo.vue | 8 ++++----
web/src/core/config.js | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/server/source/system/menu.go b/server/source/system/menu.go
index 3ed3cf3404..7f7022d155 100644
--- a/server/source/system/menu.go
+++ b/server/source/system/menu.go
@@ -72,7 +72,7 @@ func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, er
{MenuLevel: 0, Hidden: false, ParentId: 15, Path: "autoCodeAdmin", Name: "autoCodeAdmin", Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: Meta{Title: "自动化代码管理", Icon: "magic-stick"}},
{MenuLevel: 0, Hidden: true, ParentId: 15, Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Component: "view/systemTools/autoCode/index.vue", Sort: 0, Meta: Meta{Title: "自动化代码-${id}", Icon: "magic-stick"}},
{MenuLevel: 0, Hidden: false, ParentId: 15, Path: "autoPkg", Name: "autoPkg", Component: "view/systemTools/autoPkg/autoPkg.vue", Sort: 0, Meta: Meta{Title: "自动化package", Icon: "folder"}},
- {MenuLevel: 0, Hidden: false, ParentId: 0, Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Component: "/", Sort: 0, Meta: Meta{Title: "官方网站", Icon: "customer-gva"}},
+ {MenuLevel: 0, Hidden: false, ParentId: 0, Path: "https://xue-ding-e.github.io", Name: "https://xue-ding-e.github.io/", Component: "/", Sort: 0, Meta: Meta{Title: "官方网站", Icon: "customer-gva"}},
{MenuLevel: 0, Hidden: false, ParentId: 0, Path: "state", Name: "state", Component: "view/system/state.vue", Sort: 8, Meta: Meta{Title: "服务器状态", Icon: "cloudy"}},
{MenuLevel: 0, Hidden: false, ParentId: 0, Path: "plugin", Name: "plugin", Component: "view/routerHolder.vue", Sort: 6, Meta: Meta{Title: "插件系统", Icon: "cherry"}},
{MenuLevel: 0, Hidden: false, ParentId: 24, Path: "https://plugin.gin-vue-admin.com/", Name: "https://plugin.gin-vue-admin.com/", Component: "https://plugin.gin-vue-admin.com/", Sort: 0, Meta: Meta{Title: "插件市场", Icon: "shop"}},
diff --git a/web/index.html b/web/index.html
index 03dae6f399..05da022f28 100644
--- a/web/index.html
+++ b/web/index.html
@@ -5,7 +5,7 @@
-
+