Skip to content

Commit c9477d3

Browse files
pixelmaxQmkrank666SliverHornokatu-loli
authored
V2.7.2版本发布 (flipped-aurora#1853)
* feat: 自动化代码增加json导出和导入功能 * feat: 自动化代码前端可见分为Table和Form分别选中 * feature: 调整代码预览为左边栏模式的tabs。 * feat: 增加方法自动添加前端api * feat: 自动化生成前端支持详情功能 * feat: 增加自动创建可控权限按钮功能 * fixed: 顶栏样式菜单样式细节bug修复 * fixed: 修改视频地址 * fixed: 自动获取表结构和数据库表列结构保持一致 * fixed: casbin 设置空权限无需调用 AddPolicies 方法 (flipped-aurora#1850) * feat:对象存储支持配置Cloudflare R2 (flipped-aurora#1849) * fixed:设为首页和菜单勾选互为必选 --------- Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: 千石 <CN_QianShi@hotmail.com> * feat: 复杂数据类型的查询将不会生成查询语句,会以string形式接收参数,用户自行实现复杂查询逻辑。 * feat: 创建新角色默认携带字典和长传权限。 禁止删除有首页占用的菜单。 不允许切换至无首页的角色。 自动化代码创建失败将返回错误信息。 * feat: 当package或plugin结构异常时候,阻止创建自动化代码。 --------- Co-authored-by: krank <emosick@qq.com> Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: 千石 <CN_QianShi@hotmail.com>
1 parent 3b5c96d commit c9477d3

File tree

40 files changed

+617
-198
lines changed

40 files changed

+617
-198
lines changed

server/api/v1/system/sys_menu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (a *AuthorityMenuApi) DeleteBaseMenu(c *gin.Context) {
171171
err = baseMenuService.DeleteBaseMenu(menu.ID)
172172
if err != nil {
173173
global.GVA_LOG.Error("删除失败!", zap.Error(err))
174-
response.FailWithMessage("删除失败", c)
174+
response.FailWithMessage("删除失败:"+err.Error(), c)
175175
return
176176
}
177177
response.OkWithMessage("删除成功", c)

server/core/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func RunWindowsServer() {
3838

3939
fmt.Printf(`
4040
欢迎使用 gin-vue-admin
41-
当前版本:v2.7.1
41+
当前版本:v2.7.2
4242
加群方式:微信号:shouzi_1994 QQ群:470239250
4343
项目地址:https://github.com/flipped-aurora/gin-vue-admin
4444
插件市场:https://plugin.gin-vue-admin.com

server/docs/docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8087,7 +8087,7 @@ const docTemplate = `{
80878087

80888088
// SwaggerInfo holds exported Swagger Info so clients can modify it
80898089
var SwaggerInfo = &swag.Spec{
8090-
Version: "v2.7.1",
8090+
Version: "v2.7.2",
80918091
Host: "",
80928092
BasePath: "",
80938093
Schemes: []string{},

server/docs/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "使用gin+vue进行极速开发的全栈开发基础平台",
55
"title": "Gin-Vue-Admin Swagger API接口文档",
66
"contact": {},
7-
"version": "v2.7.1"
7+
"version": "v2.7.2"
88
},
99
"paths": {
1010
"/api/createApi": {

server/docs/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ info:
16341634
contact: {}
16351635
description: 使用gin+vue进行极速开发的全栈开发基础平台
16361636
title: Gin-Vue-Admin Swagger API接口文档
1637-
version: v2.7.1
1637+
version: v2.7.2
16381638
paths:
16391639
/api/createApi:
16401640
post:

server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
//go:generate go mod download
1616

1717
// @title Gin-Vue-Admin Swagger API接口文档
18-
// @version v2.7.1
18+
// @version v2.7.2
1919
// @description 使用gin+vue进行极速开发的全栈开发基础平台
2020
// @securityDefinitions.apikey ApiKeyAuth
2121
// @in header

server/model/system/request/sys_auto_code.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ type AutoCode struct {
2424
AutoCreateResource bool `json:"autoCreateResource" example:"false"` // 是否自动创建资源标识
2525
AutoCreateApiToSql bool `json:"autoCreateApiToSql" example:"false"` // 是否自动创建api
2626
AutoCreateMenuToSql bool `json:"autoCreateMenuToSql" example:"false"` // 是否自动创建menu
27+
AutoCreateBtnAuth bool `json:"autoCreateBtnAuth" example:"false"` // 是否自动创建按钮权限
2728
Fields []*AutoCodeField `json:"fields"`
2829
DictTypes []string `json:"-"`
29-
FrontFields []*AutoCodeField `json:"-"`
3030
PrimaryField *AutoCodeField `json:"primaryField"`
3131
DataSourceMap map[string]*DataSource `json:"-"`
3232
HasPic bool `json:"-"`
@@ -114,7 +114,6 @@ func (r *AutoCode) Pretreatment() error {
114114
} // test
115115
length := len(r.Fields)
116116
dict := make(map[string]string, length)
117-
r.FrontFields = make([]*AutoCodeField, 0, length)
118117
r.DataSourceMap = make(map[string]*DataSource, length)
119118
for i := 0; i < length; i++ {
120119
if r.Fields[i].DictType != "" {
@@ -123,9 +122,6 @@ func (r *AutoCode) Pretreatment() error {
123122
if r.Fields[i].Sort {
124123
r.NeedSort = true
125124
}
126-
if r.Fields[i].Front {
127-
r.FrontFields = append(r.FrontFields, r.Fields[i])
128-
}
129125
switch r.Fields[i].FieldType {
130126
case "file":
131127
r.HasFile = true
@@ -204,17 +200,20 @@ func (r *AutoCode) History() SysAutoHistoryCreate {
204200
}
205201

206202
type AutoCodeField struct {
207-
FieldName string `json:"fieldName"` // Field名
208-
FieldDesc string `json:"fieldDesc"` // 中文名
209-
FieldType string `json:"fieldType"` // Field数据类型
210-
FieldJson string `json:"fieldJson"` // FieldJson
211-
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
212-
Comment string `json:"comment"` // 数据库字段描述
213-
ColumnName string `json:"columnName"` // 数据库字段
214-
FieldSearchType string `json:"fieldSearchType"` // 搜索条件
215-
FieldSearchHide bool `json:"fieldSearchHide"` // 是否隐藏查询条件
216-
DictType string `json:"dictType"` // 字典
217-
Front bool `json:"front"` // 是否前端可见
203+
FieldName string `json:"fieldName"` // Field名
204+
FieldDesc string `json:"fieldDesc"` // 中文名
205+
FieldType string `json:"fieldType"` // Field数据类型
206+
FieldJson string `json:"fieldJson"` // FieldJson
207+
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
208+
Comment string `json:"comment"` // 数据库字段描述
209+
ColumnName string `json:"columnName"` // 数据库字段
210+
FieldSearchType string `json:"fieldSearchType"` // 搜索条件
211+
FieldSearchHide bool `json:"fieldSearchHide"` // 是否隐藏查询条件
212+
DictType string `json:"dictType"` // 字典
213+
//Front bool `json:"front"` // 是否前端可见
214+
Form bool `json:"form"` // 是否前端新建/编辑
215+
Table bool `json:"table"` // 是否前端表格列
216+
Desc bool `json:"desc"` // 是否前端详情
218217
Require bool `json:"require"` // 是否必填
219218
DefaultValue string `json:"defaultValue"` // 是否必填
220219
ErrorText string `json:"errorText"` // 校验失败文字

server/model/system/request/sys_casbin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ func DefaultCasbin() []CasbinInfo {
1717
{Path: "/menu/getMenu", Method: "POST"},
1818
{Path: "/jwt/jsonInBlacklist", Method: "POST"},
1919
{Path: "/base/login", Method: "POST"},
20-
{Path: "/user/admin_register", Method: "POST"},
2120
{Path: "/user/changePassword", Method: "POST"},
2221
{Path: "/user/setUserAuthority", Method: "POST"},
23-
{Path: "/user/setUserInfo", Method: "PUT"},
2422
{Path: "/user/getUserInfo", Method: "GET"},
23+
{Path: "/user/setSelfInfo", Method: "PUT"},
24+
{Path: "/fileUploadAndDownload/upload", Method: "POST"},
25+
{Path: "/sysDictionary/findSysDictionary", Method: "GET"},
2526
}
2627
}

server/resource/function/api.js.tpl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{if .IsPlugin}}
2+
// {{.FuncName}} 等待开发的的{{.Description}}接口
3+
// @Tags {{.StructName}}
4+
// @Summary 等待开发的的{{.Description}}接口
5+
// @accept application/json
6+
// @Produce application/json
7+
// @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表"
8+
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
9+
// @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}]
10+
export const {{.Router}} = () => {
11+
return service({
12+
url: '/{{.Abbreviation}}/{{.Router}}',
13+
method: '{{.Method}}'
14+
})
15+
}
16+
17+
{{- else -}}
18+
19+
// {{.FuncName}} 等待开发的的{{.Description}}接口
20+
// @Tags {{.StructName}}
21+
// @Summary 等待开发的的{{.Description}}接口
22+
// @accept application/json
23+
// @Produce application/json
24+
// @Param data query {{.Package}}Req.{{.StructName}}Search true "成功"
25+
// @Success 200 {object} response.Response{data=object,msg=string} "成功"
26+
// @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}]
27+
export const {{.Router}} = () => {
28+
return service({
29+
url: '/{{.Abbreviation}}/{{.Router}}',
30+
method: '{{.Method}}'
31+
})
32+
}
33+
34+
{{- end -}}

server/resource/package/server/api/api.go.tpl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Create{{.StructName}}(c *gin.Con
3636
err = {{.Abbreviation}}Service.Create{{.StructName}}(&{{.Abbreviation}})
3737
if err != nil {
3838
global.GVA_LOG.Error("创建失败!", zap.Error(err))
39-
response.FailWithMessage("创建失败", c)
39+
response.FailWithMessage("创建失败:" + err.Error(), c)
4040
return
4141
}
4242
response.OkWithMessage("创建成功", c)
@@ -59,7 +59,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}(c *gin.Con
5959
err := {{.Abbreviation}}Service.Delete{{.StructName}}({{.PrimaryField.FieldJson}} {{- if .AutoCreateResource -}},userID{{- end -}})
6060
if err != nil {
6161
global.GVA_LOG.Error("删除失败!", zap.Error(err))
62-
response.FailWithMessage("删除失败", c)
62+
response.FailWithMessage("删除失败:" + err.Error(), c)
6363
return
6464
}
6565
response.OkWithMessage("删除成功", c)
@@ -81,7 +81,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}ByIds(c *gi
8181
err := {{.Abbreviation}}Service.Delete{{.StructName}}ByIds({{.PrimaryField.FieldJson}}s{{- if .AutoCreateResource }},userID{{- end }})
8282
if err != nil {
8383
global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
84-
response.FailWithMessage("批量删除失败", c)
84+
response.FailWithMessage("批量删除失败:" + err.Error(), c)
8585
return
8686
}
8787
response.OkWithMessage("批量删除成功", c)
@@ -109,7 +109,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Update{{.StructName}}(c *gin.Con
109109
err = {{.Abbreviation}}Service.Update{{.StructName}}({{.Abbreviation}})
110110
if err != nil {
111111
global.GVA_LOG.Error("更新失败!", zap.Error(err))
112-
response.FailWithMessage("更新失败", c)
112+
response.FailWithMessage("更新失败:" + err.Error(), c)
113113
return
114114
}
115115
response.OkWithMessage("更新成功", c)
@@ -129,7 +129,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Conte
129129
re{{.Abbreviation}}, err := {{.Abbreviation}}Service.Get{{.StructName}}({{.PrimaryField.FieldJson}})
130130
if err != nil {
131131
global.GVA_LOG.Error("查询失败!", zap.Error(err))
132-
response.FailWithMessage("查询失败", c)
132+
response.FailWithMessage("查询失败:" + err.Error(), c)
133133
return
134134
}
135135
response.OkWithData(re{{.Abbreviation}}, c)
@@ -154,7 +154,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Co
154154
list, total, err := {{.Abbreviation}}Service.Get{{.StructName}}InfoList(pageInfo)
155155
if err != nil {
156156
global.GVA_LOG.Error("获取失败!", zap.Error(err))
157-
response.FailWithMessage("获取失败", c)
157+
response.FailWithMessage("获取失败:" + err.Error(), c)
158158
return
159159
}
160160
response.OkWithDetailed(response.PageResult{
@@ -178,7 +178,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}DataSource(c *
178178
dataSource, err := {{.Abbreviation}}Service.Get{{.StructName}}DataSource()
179179
if err != nil {
180180
global.GVA_LOG.Error("查询失败!", zap.Error(err))
181-
response.FailWithMessage("查询失败", c)
181+
response.FailWithMessage("查询失败:" + err.Error(), c)
182182
return
183183
}
184184
response.OkWithData(dataSource, c)

server/resource/package/server/model/request/request.go.tpl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@ type {{.StructName}}Search struct{
1616
Start{{.FieldName}} *{{.FieldType}} `json:"start{{.FieldName}}" form:"start{{.FieldName}}"`
1717
End{{.FieldName}} *{{.FieldType}} `json:"end{{.FieldName}}" form:"end{{.FieldName}}"`
1818
{{- else }}
19-
{{- if eq .FieldType "enum" }}
20-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}"`
21-
{{- else if eq .FieldType "picture" }}
22-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
23-
{{- else if eq .FieldType "video" }}
24-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
25-
{{- else if eq .FieldType "richtext" }}
26-
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
19+
{{- if or (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "richtext") (eq .FieldType "json") }}
20+
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
2721
{{- else if ne .FieldType "string" }}
2822
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" `
2923
{{- else }}

server/resource/package/server/service/service.go.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoLis
9393
{{- end }}
9494
{{- range .Fields}}
9595
{{- if .FieldSearchType}}
96-
{{- if or (eq .FieldType "string") (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "richtext") }}
96+
{{- if or (eq .FieldType "string") (eq .FieldType "enum") (eq .FieldType "picture") (eq .FieldType "video") (eq .FieldType "richtext") (eq .FieldType "json") }}
9797
if info.{{.FieldName}} != "" {
98+
{{- if or (eq .FieldType "enum") (eq .FieldType "string") }}
9899
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
100+
{{- else}}
101+
// 数据类型为复杂类型,请根据业务需求自行实现复杂类型的查询业务
102+
{{- end}}
99103
}
100104
{{- else if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
101105
if info.Start{{.FieldName}} != nil && info.End{{.FieldName}} != nil {

server/resource/package/web/view/form.vue.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<div class="gva-form-box">
44
<el-form :model="formData" ref="elFormRef" label-position="right" :rules="rule" label-width="80px">
55
{{- range .Fields}}
6+
{{- if .Form }}
67
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}">
78
{{- if .CheckDataSource}}
89
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
@@ -56,6 +57,7 @@
5657
{{- end }}
5758
{{- end }}
5859
</el-form-item>
60+
{{- end }}
5961
{{- end }}
6062
<el-form-item>
6163
<el-button type="primary" @click="save">保存</el-button>
@@ -106,6 +108,7 @@ const {{ $element }}Options = ref([])
106108
{{- end }}
107109
const formData = ref({
108110
{{- range .Fields}}
111+
{{- if .Form }}
109112
{{- if eq .FieldType "bool" }}
110113
{{.FieldJson}}: false,
111114
{{- end }}
@@ -142,6 +145,7 @@ const formData = ref({
142145
{{- if eq .FieldType "array" }}
143146
{{.FieldJson}}: [],
144147
{{- end }}
148+
{{- end }}
145149
{{- end }}
146150
})
147151
// 验证规则

0 commit comments

Comments
 (0)