From 90549a09e142bda0d929810a914093e75ccd96c6 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Thu, 25 Apr 2024 21:02:43 +0800 Subject: [PATCH 001/205] =?UTF-8?q?feature:=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF=E5=8F=AF=E6=8E=A7=E6=98=BE?= =?UTF-8?q?=E9=9A=90=E5=92=8C=E8=87=AA=E5=AE=9A=E4=B9=89class=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/model/system/sys_auto_code.go | 3 + server/service/system/sys_auto_code.go | 141 +++++++----------- .../autoCode/component/fieldDialog.vue | 6 + web/src/view/systemTools/autoCode/index.vue | 22 ++- 4 files changed, 84 insertions(+), 88 deletions(-) diff --git a/server/model/system/sys_auto_code.go b/server/model/system/sys_auto_code.go index 003781ca31..0f0262d778 100644 --- a/server/model/system/sys_auto_code.go +++ b/server/model/system/sys_auto_code.go @@ -34,6 +34,7 @@ type AutoCodeStruct struct { HasRichText bool `json:"-"` HasFile bool `json:"-"` NeedJSON bool `json:"-"` + FrontFields []*Field `json:"-"` } func (a *AutoCodeStruct) Pretreatment() { @@ -67,6 +68,8 @@ type Field struct { ColumnName string `json:"columnName"` // 数据库字段 FieldSearchType string `json:"fieldSearchType"` // 搜索条件 DictType string `json:"dictType"` // 字典 + Front bool `json:"front"` // 是否前端可见 + Class string `json:"class"` // 前端样式类 Require bool `json:"require"` // 是否必填 DefaultValue string `json:"defaultValue"` // 是否必填 ErrorText string `json:"errorText"` // 校验失败文字 diff --git a/server/service/system/sys_auto_code.go b/server/service/system/sys_auto_code.go index fbb1ce9f97..c19776c3de 100644 --- a/server/service/system/sys_auto_code.go +++ b/server/service/system/sys_auto_code.go @@ -133,50 +133,7 @@ var AutoCodeServiceApp = new(AutoCodeService) // @return: map[string]string, error func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStruct) (map[string]string, error) { - makeDictTypes(&autoCode) - for i := range autoCode.Fields { - if autoCode.Fields[i].FieldType == "time.Time" { - autoCode.HasTimer = true - if autoCode.Fields[i].FieldSearchType != "" { - autoCode.HasSearchTimer = true - } - } - if autoCode.Fields[i].Sort { - autoCode.NeedSort = true - } - if autoCode.Fields[i].FieldType == "picture" { - autoCode.HasPic = true - } - if autoCode.Fields[i].FieldType == "video" { - autoCode.HasPic = true - } - if autoCode.Fields[i].FieldType == "richtext" { - autoCode.HasRichText = true - } - if autoCode.Fields[i].FieldType == "pictures" { - autoCode.HasPic = true - autoCode.NeedJSON = true - } - if autoCode.Fields[i].FieldType == "file" { - autoCode.HasFile = true - autoCode.NeedJSON = true - } - - if autoCode.GvaModel { - autoCode.PrimaryField = &system.Field{ - FieldName: "ID", - FieldType: "uint", - FieldDesc: "ID", - FieldJson: "ID", - DataTypeLong: "20", - Comment: "主键ID", - ColumnName: "id", - } - } - if !autoCode.GvaModel && autoCode.PrimaryField == nil && autoCode.Fields[i].PrimaryKey { - autoCode.PrimaryField = autoCode.Fields[i] - } - } + fmtField(&autoCode) dataList, _, needMkdir, err := autoCodeService.getNeedList(&autoCode) if err != nil { return nil, err @@ -255,49 +212,7 @@ func makeDictTypes(autoCode *system.AutoCodeStruct) { // @return: err error func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruct, menuID uint, ids ...uint) (err error) { - makeDictTypes(&autoCode) - for i := range autoCode.Fields { - if autoCode.Fields[i].FieldType == "time.Time" { - autoCode.HasTimer = true - if autoCode.Fields[i].FieldSearchType != "" { - autoCode.HasSearchTimer = true - } - } - if autoCode.Fields[i].Sort { - autoCode.NeedSort = true - } - if autoCode.Fields[i].FieldType == "picture" { - autoCode.HasPic = true - } - if autoCode.Fields[i].FieldType == "video" { - autoCode.HasPic = true - } - if autoCode.Fields[i].FieldType == "richtext" { - autoCode.HasRichText = true - } - if autoCode.Fields[i].FieldType == "pictures" { - autoCode.NeedJSON = true - autoCode.HasPic = true - } - if autoCode.Fields[i].FieldType == "file" { - autoCode.NeedJSON = true - autoCode.HasFile = true - } - if autoCode.GvaModel { - autoCode.PrimaryField = &system.Field{ - FieldName: "ID", - FieldType: "uint", - FieldDesc: "ID", - FieldJson: "ID", - DataTypeLong: "20", - Comment: "主键ID", - ColumnName: "id", - } - } - if !autoCode.GvaModel && autoCode.PrimaryField == nil && autoCode.Fields[i].PrimaryKey { - autoCode.PrimaryField = autoCode.Fields[i] - } - } + fmtField(&autoCode) // 增加判断: 重复创建struct if autoCode.AutoMoveFile && AutoCodeHistoryServiceApp.Repeat(autoCode.BusinessDB, autoCode.StructName, autoCode.Package) { return RepeatErr @@ -1030,3 +945,55 @@ func (autoCodeService *AutoCodeService) doZip(zipWriter *zip.Writer, serverPath, }) return err } + +func fmtField(autoCode *system.AutoCodeStruct) { + makeDictTypes(autoCode) + for i := range autoCode.Fields { + + if autoCode.Fields[i].Front { + autoCode.FrontFields = append(autoCode.FrontFields, autoCode.Fields[i]) + } + + if autoCode.Fields[i].FieldType == "time.Time" { + autoCode.HasTimer = true + if autoCode.Fields[i].FieldSearchType != "" { + autoCode.HasSearchTimer = true + } + } + if autoCode.Fields[i].Sort { + autoCode.NeedSort = true + } + if autoCode.Fields[i].FieldType == "picture" { + autoCode.HasPic = true + } + if autoCode.Fields[i].FieldType == "video" { + autoCode.HasPic = true + } + if autoCode.Fields[i].FieldType == "richtext" { + autoCode.HasRichText = true + } + if autoCode.Fields[i].FieldType == "pictures" { + autoCode.HasPic = true + autoCode.NeedJSON = true + } + if autoCode.Fields[i].FieldType == "file" { + autoCode.HasFile = true + autoCode.NeedJSON = true + } + + if autoCode.GvaModel { + autoCode.PrimaryField = &system.Field{ + FieldName: "ID", + FieldType: "uint", + FieldDesc: "ID", + FieldJson: "ID", + DataTypeLong: "20", + Comment: "主键ID", + ColumnName: "id", + } + } + if !autoCode.GvaModel && autoCode.PrimaryField == nil && autoCode.Fields[i].PrimaryKey { + autoCode.PrimaryField = autoCode.Fields[i] + } + } +} diff --git a/web/src/view/systemTools/autoCode/component/fieldDialog.vue b/web/src/view/systemTools/autoCode/component/fieldDialog.vue index 67024e2260..dda2e08460 100644 --- a/web/src/view/systemTools/autoCode/component/fieldDialog.vue +++ b/web/src/view/systemTools/autoCode/component/fieldDialog.vue @@ -135,9 +135,15 @@ placeholder="请输入默认值" /> + + + + + + diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue index 4cafe54490..537f608511 100644 --- a/web/src/view/systemTools/autoCode/index.vue +++ b/web/src/view/systemTools/autoCode/index.vue @@ -383,6 +383,13 @@ > + + + + + + { errorText: '', clearable: true, fieldSearchType: '', - dictType: '' + dictType: '', + front: true }) } }) From d23d6c342a8c68983d8a5d10cd8b58f43be9f0a7 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Thu, 25 Apr 2024 21:13:55 +0800 Subject: [PATCH 002/205] =?UTF-8?q?feature:=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF=E5=8F=AF=E6=8E=A7=E6=98=BE?= =?UTF-8?q?=E9=9A=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/model/system/sys_auto_code.go | 1 - .../autocode_template/web/table.vue.tpl | 109 ++---------------- server/service/system/sys_auto_code.go | 3 + .../autoCode/component/fieldDialog.vue | 3 - web/src/view/systemTools/autoCode/index.vue | 11 -- 5 files changed, 11 insertions(+), 116 deletions(-) diff --git a/server/model/system/sys_auto_code.go b/server/model/system/sys_auto_code.go index 0f0262d778..f91c30c390 100644 --- a/server/model/system/sys_auto_code.go +++ b/server/model/system/sys_auto_code.go @@ -69,7 +69,6 @@ type Field struct { FieldSearchType string `json:"fieldSearchType"` // 搜索条件 DictType string `json:"dictType"` // 字典 Front bool `json:"front"` // 是否前端可见 - Class string `json:"class"` // 前端样式类 Require bool `json:"require"` // 是否必填 DefaultValue string `json:"defaultValue"` // 是否必填 ErrorText string `json:"errorText"` // 校验失败文字 diff --git a/server/resource/autocode_template/web/table.vue.tpl b/server/resource/autocode_template/web/table.vue.tpl index b61a6b115c..304090fbd8 100644 --- a/server/resource/autocode_template/web/table.vue.tpl +++ b/server/resource/autocode_template/web/table.vue.tpl @@ -103,7 +103,7 @@ {{ end }} - {{- range .Fields}} + {{- range .FrontFields}} {{- if .DictType}} - {{- range .Fields}} + {{- range .FrontFields}} {{- if eq .FieldType "bool" }} @@ -270,52 +270,6 @@ {{- end }} - - - - - {{- range .Fields}} - - {{- if .DictType}} - {{"{{"}} filterDict(formData.{{.FieldJson}},{{.DictType}}Options) {{"}}"}} - {{- else if eq .FieldType "picture" }} - - {{- else if eq .FieldType "video" }} - - {{- else if eq .FieldType "pictures" }} - - {{- else if eq .FieldType "file" }} -
- - - {{"{{"}} item.name {{"}}"}} - -
- {{- else if eq .FieldType "bool" }} - {{"{{"}} formatBoolean(formData.{{.FieldJson}}) {{"}}"}} - {{- else if eq .FieldType "time.Time" }} - {{"{{"}} formatDate(formData.{{.FieldJson}}) {{"}}"}} - {{- else if eq .FieldType "richtext" }} - [富文本内容] - {{- else if eq .FieldType "json" }} - [JSON] - {{- else}} - {{"{{"}} formData.{{.FieldJson}} {{"}}"}} - {{- end }} -
- {{- end }} -
-
@@ -362,7 +316,7 @@ defineOptions({ const {{ $element }}Options = ref([]) {{- end }} const formData = ref({ - {{- range .Fields}} + {{- range .FrontFields}} {{- if eq .FieldType "bool" }} {{.FieldJson}}: false, {{- end }} @@ -402,7 +356,7 @@ const formData = ref({ // 验证规则 const rule = reactive({ - {{- range .Fields }} + {{- range .FrontFields }} {{- if eq .Require true }} {{.FieldJson }} : [{ required: true, @@ -435,7 +389,7 @@ const searchRule = reactive({ } }, trigger: 'change' } ], - {{- range .Fields }} + {{- range .FrontFields }} {{- if .FieldSearchType}} {{- if eq .FieldType "time.Time" }} {{.FieldJson }} : [{ validator: (rule, value, callback) => { @@ -468,7 +422,7 @@ const searchInfo = ref({}) // 排序 const sortChange = ({ prop, order }) => { const sortMap = { - {{- range .Fields}} + {{- range .FrontFields}} {{- if and .Sort}} {{- if not (eq .ColumnName "")}} {{.FieldJson}}: '{{.ColumnName}}', @@ -500,7 +454,7 @@ const onSubmit = () => { if (!valid) return page.value = 1 pageSize.value = 10 - {{- range .Fields}}{{- if eq .FieldType "bool" }} + {{- range .FrontFields}}{{- if eq .FieldType "bool" }} if (searchInfo.value.{{.FieldJson}} === ""){ searchInfo.value.{{.FieldJson}}=null }{{ end }}{{ end }} @@ -629,53 +583,6 @@ const delete{{.StructName}}Func = async (row) => { // 弹窗控制标记 const dialogFormVisible = ref(false) - -// 查看详情控制标记 -const detailShow = ref(false) - - -// 打开详情弹窗 -const openDetailShow = () => { - detailShow.value = true -} - - -// 打开详情 -const getDetails = async (row) => { - // 打开弹窗 - const res = await find{{.StructName}}({ {{.PrimaryField.FieldJson}}: row.{{.PrimaryField.FieldJson}} }) - if (res.code === 0) { - formData.value = res.data.re{{.Abbreviation}} - openDetailShow() - } -} - - -// 关闭详情弹窗 -const closeDetailShow = () => { - detailShow.value = false - formData.value = { - {{- range .Fields}} - {{- if eq .FieldType "bool" }} - {{.FieldJson}}: false, - {{- end }} - {{- if eq .FieldType "string" }} - {{.FieldJson}}: '', - {{- end }} - {{- if eq .FieldType "int" }} - {{.FieldJson}}: {{- if .DictType }} undefined{{ else }} 0{{- end }}, - {{- end }} - {{- if eq .FieldType "time.Time" }} - {{.FieldJson}}: new Date(), - {{- end }} - {{- if eq .FieldType "float64" }} - {{.FieldJson}}: 0, - {{- end }} - {{- end }} - } -} - - // 打开弹窗 const openDialog = () => { type.value = 'create' @@ -686,7 +593,7 @@ const openDialog = () => { const closeDialog = () => { dialogFormVisible.value = false formData.value = { - {{- range .Fields}} + {{- range .FrontFields}} {{- if eq .FieldType "bool" }} {{.FieldJson}}: false, {{- end }} diff --git a/server/service/system/sys_auto_code.go b/server/service/system/sys_auto_code.go index c19776c3de..21ab1cbea0 100644 --- a/server/service/system/sys_auto_code.go +++ b/server/service/system/sys_auto_code.go @@ -976,6 +976,9 @@ func fmtField(autoCode *system.AutoCodeStruct) { autoCode.HasPic = true autoCode.NeedJSON = true } + if autoCode.Fields[i].FieldType == "json" { + autoCode.NeedJSON = true + } if autoCode.Fields[i].FieldType == "file" { autoCode.HasFile = true autoCode.NeedJSON = true diff --git a/web/src/view/systemTools/autoCode/component/fieldDialog.vue b/web/src/view/systemTools/autoCode/component/fieldDialog.vue index dda2e08460..7b1bd6af93 100644 --- a/web/src/view/systemTools/autoCode/component/fieldDialog.vue +++ b/web/src/view/systemTools/autoCode/component/fieldDialog.vue @@ -135,9 +135,6 @@ placeholder="请输入默认值" /> - - - diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue index 537f608511..19b5c9dc78 100644 --- a/web/src/view/systemTools/autoCode/index.vue +++ b/web/src/view/systemTools/autoCode/index.vue @@ -452,16 +452,6 @@
- - - Date: Sat, 27 Apr 2024 17:16:42 +0800 Subject: [PATCH 003/205] =?UTF-8?q?feature:v2.6.3=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/server.go | 2 +- server/docs/docs.go | 2 +- server/docs/swagger.json | 2 +- server/docs/swagger.yaml | 2 +- server/main.go | 2 +- web/package.json | 2 +- web/src/core/config.js | 2 +- web/src/core/gin-vue-admin.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/core/server.go b/server/core/server.go index 9b7bd252ec..af01f3cc66 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -38,7 +38,7 @@ func RunWindowsServer() { fmt.Printf(` 欢迎使用 gin-vue-admin - 当前版本:v2.6.2 + 当前版本:v2.6.3 加群方式:微信号:shouzi_1994 QQ群:470239250 插件市场:https://plugin.gin-vue-admin.com GVA讨论社区:https://support.qq.com/products/371961 diff --git a/server/docs/docs.go b/server/docs/docs.go index 2626dd92dc..f3ca5452e7 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -7001,7 +7001,7 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ - Version: "v2.6.2", + Version: "v2.6.3", Host: "", BasePath: "", Schemes: []string{}, diff --git a/server/docs/swagger.json b/server/docs/swagger.json index e6ef634e09..6aec79c49c 100644 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -4,7 +4,7 @@ "description": "使用gin+vue进行极速开发的全栈开发基础平台", "title": "Gin-Vue-Admin Swagger API接口文档", "contact": {}, - "version": "v2.6.2" + "version": "v2.6.3" }, "paths": { "/api/createApi": { diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index 7ebd7259ca..11e17dfc23 100644 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -1585,7 +1585,7 @@ info: contact: {} description: 使用gin+vue进行极速开发的全栈开发基础平台 title: Gin-Vue-Admin Swagger API接口文档 - version: v2.6.2 + version: v2.6.3 paths: /api/createApi: post: diff --git a/server/main.go b/server/main.go index a6034ed6bb..b7e7c9be32 100644 --- a/server/main.go +++ b/server/main.go @@ -15,7 +15,7 @@ import ( //go:generate go mod download // @title Gin-Vue-Admin Swagger API接口文档 -// @version v2.6.2 +// @version v2.6.3 // @description 使用gin+vue进行极速开发的全栈开发基础平台 // @securityDefinitions.apikey ApiKeyAuth // @in header diff --git a/web/package.json b/web/package.json index a819ca5446..39081ed971 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "gin-vue-admin", - "version": "2.6.2", + "version": "2.6.3", "private": true, "scripts": { "serve": "node openDocument.js && vite --host --mode development", diff --git a/web/src/core/config.js b/web/src/core/config.js index 549f35df02..01093f023f 100644 --- a/web/src/core/config.js +++ b/web/src/core/config.js @@ -19,7 +19,7 @@ export const viteLogo = (env) => { ) console.log( chalk.green( - `> 当前版本:v2.6.2` + `> 当前版本:v2.6.3` ) ) console.log( diff --git a/web/src/core/gin-vue-admin.js b/web/src/core/gin-vue-admin.js index c8402d51f5..fdd4fda7a7 100644 --- a/web/src/core/gin-vue-admin.js +++ b/web/src/core/gin-vue-admin.js @@ -10,7 +10,7 @@ export default { register(app) console.log(` 欢迎使用 Gin-Vue-Admin - 当前版本:v2.6.2 + 当前版本:v2.6.3 加群方式:微信:shouzi_1994 QQ群:622360840 GVA讨论社区:https://support.qq.com/products/371961 插件市场:https://plugin.gin-vue-admin.com From d9a43ea1d66e5d1cf5a2deb2d79deaf6282e7e85 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Sat, 27 Apr 2024 21:35:29 +0800 Subject: [PATCH 004/205] =?UTF-8?q?feature:=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/api/v1/system/sys_system.go | 1 - server/model/system/sys_auto_code.go | 92 ++++++++++--------- .../autocode_template/server/api.go.tpl | 19 ++++ .../autocode_template/server/router.go.tpl | 3 + .../autocode_template/server/service.go.tpl | 9 ++ .../resource/autocode_template/web/api.js.tpl | 16 ++++ .../autocode_template/web/form.vue.tpl | 25 +++-- .../autocode_template/web/table.vue.tpl | 35 +++++-- server/service/system/sys_auto_code.go | 11 +++ web/src/utils/format.js | 5 + .../autoCode/component/fieldDialog.vue | 36 +++++++- web/src/view/systemTools/autoCode/index.vue | 14 ++- 12 files changed, 207 insertions(+), 59 deletions(-) diff --git a/server/api/v1/system/sys_system.go b/server/api/v1/system/sys_system.go index af6ab71334..aa41c2f469 100644 --- a/server/api/v1/system/sys_system.go +++ b/server/api/v1/system/sys_system.go @@ -6,7 +6,6 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/model/system" systemRes "github.com/flipped-aurora/gin-vue-admin/server/model/system/response" "github.com/flipped-aurora/gin-vue-admin/server/utils" - "github.com/gin-gonic/gin" "go.uber.org/zap" ) diff --git a/server/model/system/sys_auto_code.go b/server/model/system/sys_auto_code.go index f91c30c390..360fd0aa78 100644 --- a/server/model/system/sys_auto_code.go +++ b/server/model/system/sys_auto_code.go @@ -10,31 +10,39 @@ 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:"-"` - FrontFields []*Field `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"` // 是否自动创建资源标识 + 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:"-"` + FrontFields []*Field `json:"-"` + HasDataSource bool `json:"-"` + DataSourceMap map[string]*DataSource `json:"-"` +} + +type DataSource struct { + Table string `json:"table"` + Label string `json:"label"` + Value string `json:"value"` } func (a *AutoCodeStruct) Pretreatment() { @@ -59,22 +67,24 @@ func (a *AutoCodeStruct) SuffixTest() { } type Field struct { - FieldName string `json:"fieldName"` // Field名 - FieldDesc string `json:"fieldDesc"` // 中文名 - FieldType string `json:"fieldType"` // Field数据类型 - FieldJson string `json:"fieldJson"` // FieldJson - DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度 - Comment string `json:"comment"` // 数据库字段描述 - ColumnName string `json:"columnName"` // 数据库字段 - FieldSearchType string `json:"fieldSearchType"` // 搜索条件 - DictType string `json:"dictType"` // 字典 - Front bool `json:"front"` // 是否前端可见 - Require bool `json:"require"` // 是否必填 - DefaultValue string `json:"defaultValue"` // 是否必填 - ErrorText string `json:"errorText"` // 校验失败文字 - Clearable bool `json:"clearable"` // 是否可清空 - Sort bool `json:"sort"` // 是否增加排序 - PrimaryKey bool `json:"primaryKey"` // 是否主键 + FieldName string `json:"fieldName"` // Field名 + FieldDesc string `json:"fieldDesc"` // 中文名 + FieldType string `json:"fieldType"` // Field数据类型 + FieldJson string `json:"fieldJson"` // FieldJson + DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度 + Comment string `json:"comment"` // 数据库字段描述 + ColumnName string `json:"columnName"` // 数据库字段 + FieldSearchType string `json:"fieldSearchType"` // 搜索条件 + DictType string `json:"dictType"` // 字典 + Front bool `json:"front"` // 是否前端可见 + Require bool `json:"require"` // 是否必填 + DefaultValue string `json:"defaultValue"` // 是否必填 + ErrorText string `json:"errorText"` // 校验失败文字 + Clearable bool `json:"clearable"` // 是否可清空 + Sort bool `json:"sort"` // 是否增加排序 + PrimaryKey bool `json:"primaryKey"` // 是否主键 + DataSource *DataSource `json:"dataSource"` // 数据源 + CheckDataSource bool `json:"checkDataSource"` // 是否检查数据源 } var ErrAutoMove error = errors.New("创建代码成功并移动文件成功") diff --git a/server/resource/autocode_template/server/api.go.tpl b/server/resource/autocode_template/server/api.go.tpl index 0fa88e9a44..3ddfff6568 100644 --- a/server/resource/autocode_template/server/api.go.tpl +++ b/server/resource/autocode_template/server/api.go.tpl @@ -166,6 +166,25 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Co } } +{{- if .HasDataSource }} +// Get{{.StructName}}DataSource 获取{{.StructName}}的数据源 +// @Tags {{.StructName}} +// @Summary 获取{{.StructName}}的数据源 +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /{{.Abbreviation}}/get{{.StructName}}DataSource [get] +func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}DataSource(c *gin.Context) { + // 此接口为获取数据源定义的数据 + if dataSource, err := {{.Abbreviation}}Service.Get{{.StructName}}DataSource(); err != nil { + global.GVA_LOG.Error("查询失败!", zap.Error(err)) + response.FailWithMessage("查询失败", c) + } else { + response.OkWithData(dataSource, c) + } +} +{{- end }} + // Get{{.StructName}}Public 不需要鉴权的{{.Description}}接口 // @Tags {{.StructName}} // @Summary 不需要鉴权的{{.Description}}接口 diff --git a/server/resource/autocode_template/server/router.go.tpl b/server/resource/autocode_template/server/router.go.tpl index 4aef21c3f7..b2b7325a3a 100644 --- a/server/resource/autocode_template/server/router.go.tpl +++ b/server/resource/autocode_template/server/router.go.tpl @@ -27,6 +27,9 @@ func (s *{{.StructName}}Router) Init{{.StructName}}Router(Router *gin.RouterGrou {{.Abbreviation}}RouterWithoutRecord.GET("get{{.StructName}}List", {{.Abbreviation}}Api.Get{{.StructName}}List) // 获取{{.Description}}列表 } { + {{- if .HasDataSource}} + {{.Abbreviation}}RouterWithoutAuth.GET("get{{.StructName}}DataSource", {{.Abbreviation}}Api.Get{{.StructName}}DataSource) // 获取{{.Description}}数据源 + {{- end}} {{.Abbreviation}}RouterWithoutAuth.GET("get{{.StructName}}Public", {{.Abbreviation}}Api.Get{{.StructName}}Public) // 获取{{.Description}}列表 } } diff --git a/server/resource/autocode_template/server/service.go.tpl b/server/resource/autocode_template/server/service.go.tpl index 1d521c0385..dd411339f8 100644 --- a/server/resource/autocode_template/server/service.go.tpl +++ b/server/resource/autocode_template/server/service.go.tpl @@ -137,3 +137,12 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoLis err = db.Find(&{{.Abbreviation}}s).Error return {{.Abbreviation}}s, total, err } + +{{- if .HasDataSource }} +func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}DataSource() (res map[string][]map[string]any, err error) { + {{range $key, $value := .DataSourceMap}} + {{$db}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&res["{{$key}}"]) + {{- end }} + return +} +{{- end }} \ No newline at end of file diff --git a/server/resource/autocode_template/web/api.js.tpl b/server/resource/autocode_template/web/api.js.tpl index 883d364908..cf9d553050 100644 --- a/server/resource/autocode_template/web/api.js.tpl +++ b/server/resource/autocode_template/web/api.js.tpl @@ -95,3 +95,19 @@ export const get{{.StructName}}List = (params) => { params }) } + +{{- if .HasDataSource}} +// @Tags {{.StructName}} +// @Summary 获取数据源 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" +// @Router /{{.Abbreviation}}/find{{.StructName}}DataSource [get] +export const get{{.StructName}}DataSource = () => { + return service({ + url: '/{{.Abbreviation}}/get{{.StructName}}DataSource', + method: 'get', + }) +} +{{- end}} diff --git a/server/resource/autocode_template/web/form.vue.tpl b/server/resource/autocode_template/web/form.vue.tpl index d49bb9e1dc..e28e9e09d5 100644 --- a/server/resource/autocode_template/web/form.vue.tpl +++ b/server/resource/autocode_template/web/form.vue.tpl @@ -4,6 +4,11 @@ {{- range .Fields}} + {{- if .CheckDataSource}} + + + + {{- else }} {{- if eq .FieldType "bool" }} {{- end }} @@ -20,14 +25,8 @@ {{- end }} {{- if eq .FieldType "int" }} - {{- if .DictType }} - - - - {{- else }} {{- end }} - {{- end }} {{- if eq .FieldType "time.Time" }} {{- end }} @@ -55,6 +54,7 @@ // 此字段为json结构,可以前端自行控制展示和数据绑定模式 需绑定json的key为 formData.{{.FieldJson}} 后端会按照json的类型进行存取 {{"{{"}} formData.{{.FieldJson}} {{"}}"}} {{- end }} + {{- end }} {{- end }} @@ -68,6 +68,9 @@ - - diff --git a/web/src/components/selectImage/selectImage.vue b/web/src/components/selectImage/selectImage.vue index a08393d0f4..07e2854d8a 100644 --- a/web/src/components/selectImage/selectImage.vue +++ b/web/src/components/selectImage/selectImage.vue @@ -110,38 +110,25 @@
- - - - - - - 查询 - - - + + 查询 +
{ } } -.upload-btn-media-library { - margin-left: 20px; -} - .media { display: flex; flex-wrap: wrap; - + gap: 12px; .media-box { width: 120px; - margin-left: 20px; - .img-title { white-space: nowrap; overflow: hidden; diff --git a/web/src/view/superAdmin/user/user.vue b/web/src/view/superAdmin/user/user.vue index ee8707a750..23c260d115 100644 --- a/web/src/view/superAdmin/user/user.vue +++ b/web/src/view/superAdmin/user/user.vue @@ -215,28 +215,10 @@ label="头像" label-width="80px" > -
- 头像 -
从媒体库选择
- -
+ -
@@ -253,12 +235,12 @@ import { import { getAuthorityList } from '@/api/authority' import CustomPic from '@/components/customPic/index.vue' -import ChooseImg from '@/components/chooseImg/index.vue' import WarningBar from '@/components/warningBar/warningBar.vue' import { setUserInfo, resetPassword } from '@/api/user.js' import { nextTick, ref, watch } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' +import SelectImage from '@/components/selectImage/selectImage.vue' defineOptions({ name: 'User', From e15351e1c5d02a508d9bb4e5e90eecdf427891b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?PiexlMax=28=E5=A5=87=E6=B7=BC?= <165128580+pixelmaxQm@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:10:22 +0800 Subject: [PATCH 007/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66fefe31e3..075db6c5b0 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm ``` - node版本 > v16.8.3 -- golang版本 >= v1.16 +- golang版本 >= v1.22 - IDE推荐:Goland ``` From 5fa7bbbc0f83fd27c4dcec54a5ef87a5d980c571 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Mon, 6 May 2024 21:10:01 +0800 Subject: [PATCH 008/205] =?UTF-8?q?fixed:=E5=AF=BC=E5=87=BA=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=A1=BA=E5=BA=8F=E4=B8=80=E8=87=B4=E6=80=A7=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/service/system/sys_export_template.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/service/system/sys_export_template.go b/server/service/system/sys_export_template.go index 3bc2bc49af..5751d83646 100644 --- a/server/service/system/sys_export_template.go +++ b/server/service/system/sys_export_template.go @@ -269,14 +269,18 @@ func (sysExportTemplateService *SysExportTemplateService) ExportTemplate(templat return } var templateInfoMap = make(map[string]string) + + columns, err := utils.GetJSONKeys(template.TemplateInfo) + err = json.Unmarshal([]byte(template.TemplateInfo), &templateInfoMap) if err != nil { return nil, "", err } var tableTitle []string - for key := range templateInfoMap { + for _, key := range columns { tableTitle = append(tableTitle, templateInfoMap[key]) } + for i := range tableTitle { fErr := f.SetCellValue("Sheet1", fmt.Sprintf("%s%d", getColumnName(i+1), 1), tableTitle[i]) if fErr != nil { From 0265801830463356fff2ba14c23b16e92173433e Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Mon, 6 May 2024 21:15:37 +0800 Subject: [PATCH 009/205] =?UTF-8?q?fixed:=E8=A1=A8=E6=A0=BC=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=88=A0=E9=99=A4=E6=9F=A5=E7=9C=8B=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/autocode_template/web/table.vue.tpl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/resource/autocode_template/web/table.vue.tpl b/server/resource/autocode_template/web/table.vue.tpl index 39c7f22f79..230a7825ab 100644 --- a/server/resource/autocode_template/web/table.vue.tpl +++ b/server/resource/autocode_template/web/table.vue.tpl @@ -176,10 +176,6 @@ {{- end }} From ab163fc0ef3f611059f1526ab1aba5e6c718e6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?PiexlMax=28=E5=A5=87=E6=B7=BC?= <165128580+pixelmaxQm@users.noreply.github.com> Date: Mon, 6 May 2024 21:20:20 +0800 Subject: [PATCH 010/205] Update ci.yaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 65812ade7d..3283fc4235 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.21] + go-version: [1.22] steps: - name: Set up Go ${{ matrix.go-version }} uses: actions/setup-go@v1 @@ -84,7 +84,7 @@ jobs: strategy: matrix: node-version: [16.8.0] - go-version: [1.21] + go-version: [1.22] steps: - name: Check out branch uses: actions/checkout@v2 From db4c7a8bdaff35c4a4ac96245c296069afb8d7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?pixelMax=28=E5=A5=87=E6=B7=BC?= Date: Thu, 9 May 2024 10:12:20 +0800 Subject: [PATCH 011/205] =?UTF-8?q?fixed:=E4=BF=AE=E5=A4=8D=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/autocode_template/web/table.vue.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/resource/autocode_template/web/table.vue.tpl b/server/resource/autocode_template/web/table.vue.tpl index 230a7825ab..ee5ec6b657 100644 --- a/server/resource/autocode_template/web/table.vue.tpl +++ b/server/resource/autocode_template/web/table.vue.tpl @@ -193,7 +193,7 @@ />
- +