From 60e16beaedaf30e166d902ba690fb1cb1ac75b1f Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Sun, 8 Nov 2020 12:47:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BD=93=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/api/v1/sys_auto_code.go | 12 +- server/go.mod | 2 +- server/model/sys_auto_code.go | 4 + server/service/sys_auto_code.go | 35 +- web/src/utils/request.js | 2 +- .../view/dashboard/component/RaddarChart.vue | 120 ------ web/src/view/dashboard/component/Sunburst.vue | 391 ------------------ .../view/dashboard/component/animition.vue | 93 ----- web/src/view/dashboard/component/stackMap.vue | 167 -------- web/src/view/dashboard/index.vue | 27 -- web/src/view/systemTools/autoCode/index.vue | 13 +- 11 files changed, 28 insertions(+), 838 deletions(-) delete mode 100644 web/src/view/dashboard/component/RaddarChart.vue delete mode 100644 web/src/view/dashboard/component/Sunburst.vue delete mode 100644 web/src/view/dashboard/component/animition.vue delete mode 100644 web/src/view/dashboard/component/stackMap.vue diff --git a/server/api/v1/sys_auto_code.go b/server/api/v1/sys_auto_code.go index dcbd49b9..7397b282 100644 --- a/server/api/v1/sys_auto_code.go +++ b/server/api/v1/sys_auto_code.go @@ -8,6 +8,7 @@ import ( "gin-vue-admin/service" "gin-vue-admin/utils" "github.com/gin-gonic/gin" + "github.com/pkg/errors" "go.uber.org/zap" "net/url" "os" @@ -78,9 +79,14 @@ func CreateTemp(c *gin.Context) { } err := service.CreateTemp(a) if err != nil { - c.Writer.Header().Add("success", "false") - c.Writer.Header().Add("msg", url.QueryEscape(err.Error())) - _ = os.Remove("./ginvueadmin.zip") + if errors.Is(err, model.AutoMoveErr) { + response.Ok(c) + } else { + c.Writer.Header().Add("success", "false") + c.Writer.Header().Add("msg", url.QueryEscape(err.Error())) + _ = os.Remove("./ginvueadmin.zip") + } + } else { c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) // fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名 c.Writer.Header().Add("Content-Type", "application/json") diff --git a/server/go.mod b/server/go.mod index 8bc45360..230164e2 100644 --- a/server/go.mod +++ b/server/go.mod @@ -33,7 +33,7 @@ require ( github.com/onsi/ginkgo v1.7.0 // indirect github.com/onsi/gomega v1.4.3 // indirect github.com/pelletier/go-toml v1.6.0 // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/errors v0.9.1 github.com/qiniu/api.v7/v7 v7.4.1 github.com/satori/go.uuid v1.2.0 github.com/shirou/gopsutil v2.20.8+incompatible diff --git a/server/model/sys_auto_code.go b/server/model/sys_auto_code.go index cedf0b21..78b77778 100644 --- a/server/model/sys_auto_code.go +++ b/server/model/sys_auto_code.go @@ -1,5 +1,7 @@ package model +import "errors" + // 初始版本自动化代码工具 type AutoCodeStruct struct { StructName string `json:"structName"` @@ -24,3 +26,5 @@ type Field struct { FieldSearchType string `json:"fieldSearchType"` DictType string `json:"dictType"` } + +var AutoMoveErr error = errors.New("创建代码成功并移动文件成功") diff --git a/server/service/sys_auto_code.go b/server/service/sys_auto_code.go index 949913b9..4f422e63 100644 --- a/server/service/sys_auto_code.go +++ b/server/service/sys_auto_code.go @@ -1,7 +1,6 @@ package service import ( - "errors" "fmt" "gin-vue-admin/global" "gin-vue-admin/model" @@ -107,7 +106,7 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) { return err } } - return errors.New("创建代码成功并移动文件成功") + return model.AutoMoveErr } else { // 打包 if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil { return err @@ -149,38 +148,6 @@ func GetColumn(tableName string, dbName string) (err error, Columns []request.Co return err, Columns } -//func addAutoMoveFile(data *tplData) { -// if strings.Contains(data.autoCodePath, "server") { -// if strings.Contains(data.autoCodePath, "router") { -// apiList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join(apiList[len(apiList)-2], apiList[len(apiList)-1]) -// } else if strings.Contains(data.autoCodePath, "api") { -// apiList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join(apiList[len(apiList)-2], "v1", apiList[len(apiList)-1]) -// } else if strings.Contains(data.autoCodePath, "service") { -// serviceList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join(serviceList[len(serviceList)-2], serviceList[len(serviceList)-1]) -// } else if strings.Contains(data.autoCodePath, "model") { -// modelList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join(modelList[len(modelList)-2], modelList[len(modelList)-1]) -// } else if strings.Contains(data.autoCodePath, "request") { -// requestList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join("model", requestList[len(requestList)-2], requestList[len(requestList)-1]) -// } -// } else if strings.Contains(data.autoCodePath, "web") { -// if strings.Contains(data.autoCodePath, "js") { -// jsList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join("../", "web", "src", jsList[len(jsList)-2], jsList[len(jsList)-1]) -// } else if strings.Contains(data.autoCodePath, "form") { -// formList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", formList[len(formList)-3], strings.Split(formList[len(formList)-1], ".")[0]+"From.vue") -// } else if strings.Contains(data.autoCodePath, "table") { -// vueList := strings.Split(data.autoCodePath, "/") -// data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", vueList[len(vueList)-3], vueList[len(vueList)-1]) -// } -// } -//} - func addAutoMoveFile(data *tplData) { dir := filepath.Base(filepath.Dir(data.autoCodePath)) base := filepath.Base(data.autoCodePath) diff --git a/web/src/utils/request.js b/web/src/utils/request.js index 6a0ffbda..496f7cab 100644 --- a/web/src/utils/request.js +++ b/web/src/utils/request.js @@ -68,7 +68,7 @@ service.interceptors.response.use( Message({ showClose: true, message: response.data.msg || decodeURI(response.headers.msg), - type: 'error', + type: response.headers.messageType||'error', }) if (response.data.data && response.data.data.reload) { store.commit('user/LoginOut') diff --git a/web/src/view/dashboard/component/RaddarChart.vue b/web/src/view/dashboard/component/RaddarChart.vue deleted file mode 100644 index 351f8f72..00000000 --- a/web/src/view/dashboard/component/RaddarChart.vue +++ /dev/null @@ -1,120 +0,0 @@ - - - diff --git a/web/src/view/dashboard/component/Sunburst.vue b/web/src/view/dashboard/component/Sunburst.vue deleted file mode 100644 index 01fac5c6..00000000 --- a/web/src/view/dashboard/component/Sunburst.vue +++ /dev/null @@ -1,391 +0,0 @@ - - - - - diff --git a/web/src/view/dashboard/component/animition.vue b/web/src/view/dashboard/component/animition.vue deleted file mode 100644 index c794062e..00000000 --- a/web/src/view/dashboard/component/animition.vue +++ /dev/null @@ -1,93 +0,0 @@ - - - \ No newline at end of file diff --git a/web/src/view/dashboard/component/stackMap.vue b/web/src/view/dashboard/component/stackMap.vue deleted file mode 100644 index ffb04947..00000000 --- a/web/src/view/dashboard/component/stackMap.vue +++ /dev/null @@ -1,167 +0,0 @@ - - - - - diff --git a/web/src/view/dashboard/index.vue b/web/src/view/dashboard/index.vue index 116249f2..01b49ec1 100644 --- a/web/src/view/dashboard/index.vue +++ b/web/src/view/dashboard/index.vue @@ -1,27 +1,5 @@