Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
990eb10e
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
337
Star
18155
Fork
5506
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
990eb10e
编写于
8月 16, 2021
作者:
Mr.奇淼(
提交者:
GitHub
8月 16, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #622 from flipped-aurora/gva_gormv2_dev
Gva gormv2 dev
上级
f1052887
b05990c9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
143 addition
and
124 deletion
+143
-124
server/api/v1/system/sys_menu.go
server/api/v1/system/sys_menu.go
+1
-1
server/model/common/request/common.go
server/model/common/request/common.go
+1
-1
server/resource/template/web/api.js.tpl
server/resource/template/web/api.js.tpl
+1
-1
server/resource/template/web/form.vue.tpl
server/resource/template/web/form.vue.tpl
+47
-47
server/resource/template/web/table.vue.tpl
server/resource/template/web/table.vue.tpl
+74
-73
server/utils/validator.go
server/utils/validator.go
+18
-0
web/.eslintrc.js
web/.eslintrc.js
+1
-1
未找到文件。
server/api/v1/system/sys_menu.go
浏览文件 @
990eb10e
...
...
@@ -81,7 +81,7 @@ func (a *AuthorityMenuApi) AddMenuAuthority(c *gin.Context) {
// @Produce application/json
// @Param data body request.GetAuthorityId true "角色ID"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/
G
etMenuAuthority [post]
// @Router /menu/
g
etMenuAuthority [post]
func
(
a
*
AuthorityMenuApi
)
GetMenuAuthority
(
c
*
gin
.
Context
)
{
var
param
request
.
GetAuthorityId
_
=
c
.
ShouldBindJSON
(
&
param
)
...
...
server/model/common/request/common.go
浏览文件 @
990eb10e
...
...
@@ -17,7 +17,7 @@ type IdsReq struct {
// Get role by id structure
type
GetAuthorityId
struct
{
AuthorityId
string
// 角色ID
AuthorityId
string
`json:"authorityId" form:"authorityId"`
// 角色ID
}
type
Empty
struct
{}
server/resource/template/web/api.js.tpl
浏览文件 @
990eb10e
...
...
@@ -94,4 +94,4 @@ export const get{{.StructName}}List = (params) => {
method: 'get',
params
})
}
\ No newline at end of file
}
server/resource/template/web/form.vue.tpl
浏览文件 @
990eb10e
...
...
@@ -3,35 +3,35 @@
<el-form
:model=
"formData"
label-position=
"right"
label-width=
"80px"
>
{{- range .Fields}}
<el-form-item
label=
"{{.FieldDesc}}:"
>
{{
if eq .FieldType "bool" -
}}
<el-switch
active-color=
"#13ce66"
inactive-color=
"#ff4949"
active-text=
"是"
inactive-text=
"否"
v-model=
"formData.{{.FieldJson}}"
clearable
></el-switch>
{{
end -
}}
{{
if eq .FieldType "string" -
}}
<el-input
v-model=
"formData.{{.FieldJson}}"
clearable
placeholder=
"请输入"
/>
{{
end -
}}
{{
if eq .FieldType "int" -
}}
{{
if .DictType -
}}
<el-select
v-model=
"formData.{{ .FieldJson }}"
placeholder=
"请选择"
clearable
>
<el-option
v-for=
"(item,key) in {{ .DictType }}Options"
:key=
"key"
:label=
"item.label"
:value=
"item.value"
></el-option
>
</el-select>
{{
else -
}}
<el-input
v-model.number=
"formData.{{ .FieldJson }}"
clearable
placeholder=
"请输入"
/>
{{
end -
}}
{{
end -
}}
{{ if eq .FieldType "time.Time" }}
<el-date-picker
type=
"date"
placeholder=
"选择日期"
v-model=
"formData.{{ .FieldJson }}"
clearable
></el-date-picker>
{{
end -
}}
{{ if eq .FieldType "float64" }}
<el-input-number
v-model=
"formData.{{ .FieldJson }}"
:precision=
"2"
clearable
></el-input-number>
{{
end -
}}
{{
- if eq .FieldType "bool"
}}
<el-switch
active-color=
"#13ce66"
inactive-color=
"#ff4949"
active-text=
"是"
inactive-text=
"否"
v-model=
"formData.{{.FieldJson}}"
clearable
></el-switch>
{{
- end
}}
{{
- if eq .FieldType "string"
}}
<el-input
v-model=
"formData.{{.FieldJson}}"
clearable
placeholder=
"请输入"
/>
{{
- end
}}
{{
- if eq .FieldType "int"
}}
{{
- if .DictType
}}
<el-select
v-model=
"formData.{{ .FieldJson }}"
placeholder=
"请选择"
clearable
>
<el-option
v-for=
"(item,key) in {{ .DictType }}Options"
:key=
"key"
:label=
"item.label"
:value=
"item.value"
/
>
</el-select>
{{
- else
}}
<el-input
v-model.number=
"formData.{{ .FieldJson }}"
clearable
placeholder=
"请输入"
/>
{{
- end
}}
{{
- end
}}
{{
-
if eq .FieldType "time.Time" }}
<el-date-picker
type=
"date"
placeholder=
"选择日期"
v-model=
"formData.{{ .FieldJson }}"
clearable
></el-date-picker>
{{
- end
}}
{{
-
if eq .FieldType "float64" }}
<el-input-number
v-model=
"formData.{{ .FieldJson }}"
:precision=
"2"
clearable
></el-input-number>
{{
- end
}}
</el-form-item>
{{
end -
}}
{{
- end
}}
<el-form-item>
<el-button
size=
"mini"
type=
"primary"
@
click=
"save"
>
保存
</el-button>
<el-button
size=
"mini"
type=
"primary"
@
click=
"back"
>
返回
</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
...
...
@@ -47,29 +47,29 @@ export default {
data
()
{
return
{
type
:
''
,
{
{
range
.
Fields
}
}
{{
-
range
.
Fields
}}
{{
-
if
.
DictType
}}
{{
.
DictType
}}
Options
:
[],
{{
end
-
}}
{
{
end
-
}
}
{{
-
end
}}
{{
-
end
}}
formData
:
{
{
{
range
.
Fields
}
}
{{
-
if
eq
.
FieldType
"
bool
"
-
}}
{{.
FieldJson
}}:
false
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
string
"
-
}}
{{.
FieldJson
}}:
''
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
int
"
-
}}
{{.
FieldJson
}}:
0
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
time.Time
"
-
}}
{{.
FieldJson
}}:
new
Date
(),
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
float64
"
-
}}
{{.
FieldJson
}}:
0
,
{{
end
-
}}
{{
end
}}
{{
-
range
.
Fields
}}
{{
-
if
eq
.
FieldType
"
bool
"
}}
{{.
FieldJson
}}:
false
,
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
string
"
}}
{{.
FieldJson
}}:
''
,
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
int
"
}}
{{.
FieldJson
}}:
0
,
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
time.Time
"
}}
{{.
FieldJson
}}:
new
Date
(),
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
float64
"
}}
{{.
FieldJson
}}:
0
,
{{
-
end
}}
{{
-
end
}}
}
}
},
...
...
@@ -84,10 +84,10 @@ export default {
}
else
{
this
.
type
=
'
create
'
}
{{
range
.
Fields
-
}}
{{
-
range
.
Fields
}}
{{
-
if
.
DictType
}}
await
this
.
getDict
(
"
{{.DictType}}
"
)
{{
end
-
}}
await
this
.
getDict
(
'
{{.DictType}}
'
)
{{
-
end
}}
{{
-
end
}}
},
methods
:
{
...
...
@@ -119,4 +119,4 @@ export default {
</script>
<style>
</style>
\ No newline at end of file
</style>
server/resource/template/web/table.vue.tpl
浏览文件 @
990eb10e
...
...
@@ -19,8 +19,8 @@
</el-form-item>
{{- else }}
<el-form-item
label=
"{{.FieldDesc}}"
>
<el-input
placeholder=
"搜索条件"
v-model=
"searchInfo.{{.FieldJson}}
"
/>
</el-form-item>
{{ end }} {{ end }}
{{ end }}
<el-input
v-model=
"searchInfo.{{.FieldJson}}"
placeholder=
"搜索条件
"
/>
</el-form-item>
{{ end }}{{ end }}
{{ end }}
<el-form-item>
<el-button
size=
"mini"
type=
"primary"
icon=
"el-icon-search"
@
click=
"onSubmit"
>
查询
</el-button>
<el-button
size=
"mini"
type=
"primary"
icon=
"el-icon-plus"
@
click=
"openDialog"
>
新增
</el-button>
...
...
@@ -52,15 +52,16 @@
{{- if .DictType}}
<el-table-column
label=
"{{.FieldDesc}}"
prop=
"{{.FieldJson}}"
width=
"120"
>
<template
slot-scope=
"scope"
>
{
{
"{{"
}
}
filterDict(scope.row.{{.FieldJson}},"{{.DictType}}")
{
{
"}}"
}
}
{
{
"{{"
}
}
filterDict(scope.row.{{.FieldJson}},"{{.DictType}}")
{
{
"}}"
}
}
</template>
</el-table-column>
{{- else if eq .FieldType "bool" }}
<el-table-column
label=
"{{.FieldDesc}}"
prop=
"{{.FieldJson}}"
width=
"120"
>
<template
slot-scope=
"scope"
>
{{ "{
{
scope
.
row
.
"}}{{.FieldJson}}{{"
|
formatBoolean
}
}" }}
</template>
</el-table-column>
{{- else }}
<el-table-column
label=
"{{.FieldDesc}}"
prop=
"{{.FieldJson}}"
width=
"120"
/>
{{ end -}}
{{ end -}}
<el-table-column
label=
"{{.FieldDesc}}"
prop=
"{{.FieldJson}}"
width=
"120"
/>
{{- end }}
{{- end }}
<el-table-column
label=
"按钮组"
>
<template
slot-scope=
"scope"
>
<el-button
size=
"small"
type=
"primary"
icon=
"el-icon-edit"
class=
"table-button"
@
click=
"update{{.StructName}}(scope.row)"
>
变更
</el-button>
...
...
@@ -82,30 +83,30 @@
<el-form
:model=
"formData"
label-position=
"right"
label-width=
"80px"
>
{{- range .Fields}}
<el-form-item
label=
"{{.FieldDesc}}:"
>
{{ if eq .FieldType "bool" }}
{{
-
if eq .FieldType "bool" }}
<el-switch
active-color=
"#13ce66"
inactive-color=
"#ff4949"
active-text=
"是"
inactive-text=
"否"
v-model=
"formData.{{.FieldJson}}"
clearable
></el-switch>
{{
end -
}}
{{ if eq .FieldType "string" }}
{{
- end
}}
{{
-
if eq .FieldType "string" }}
<el-input
v-model=
"formData.{{.FieldJson}}"
clearable
placeholder=
"请输入"
/>
{{
end -
}}
{{ if eq .FieldType "int" }}
{{
- end
}}
{{
-
if eq .FieldType "int" }}
{{- if .DictType}}
<el-select
v-model=
"formData.{{ .FieldJson }}"
placeholder=
"请选择"
clearable
>
<el-option
v-for=
"(item,key) in {{ .DictType }}Options"
:key=
"key"
:label=
"item.label"
:value=
"item.value"
/>
</el-select>
{{ else }}
{{
-
else }}
<el-input
v-model.number=
"formData.{{ .FieldJson }}"
clearable
placeholder=
"请输入"
/>
{{
end -
}}
{{
end -
}}
{{ if eq .FieldType "time.Time" }}
{{
- end
}}
{{
- end
}}
{{
-
if eq .FieldType "time.Time" }}
<el-date-picker
type=
"date"
placeholder=
"选择日期"
v-model=
"formData.{{ .FieldJson }}"
clearable
/>
{{ end -
}}
{{- if eq .FieldType "float64" }}
{{- end
}}
{{- if eq .FieldType "float64" }}
<el-input-number
v-model=
"formData.{{ .FieldJson }}"
:precision=
"2"
clearable
/>
{{ end -
}}
</el-form-item>
{{- end }}
</el-form>
{{- end
}}
</el-form-item>
{{- end }}
</el-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
@
click=
"closeDialog"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"enterDialog"
>
确 定
</el-button>
...
...
@@ -127,6 +128,23 @@ import { formatTimeToStr } from '@/utils/date'
import
infoList
from
'
@/mixins/infoList
'
export
default
{
name
:
'
{{.StructName}}
'
,
filters
:
{
formatDate
:
function
(
time
)
{
if
(
time
!==
null
&&
time
!==
''
)
{
var
date
=
new
Date
(
time
)
return
formatTimeToStr
(
date
,
'
yyyy-MM-dd hh:mm:ss
'
)
}
else
{
return
''
}
},
formatBoolean
:
function
(
bool
)
{
if
(
bool
!=
null
)
{
return
bool
?
'
是
'
:
'
否
'
}
else
{
return
''
}
}
},
mixins
:
[
infoList
],
data
()
{
return
{
...
...
@@ -135,66 +153,49 @@ export default {
type
:
''
,
deleteVisible
:
false
,
multipleSelection
:
[],
{{
range
.
Fields
}}
{{
-
range
.
Fields
}}
{{
-
if
.
DictType
}}
{{
.
DictType
}}
Options
:
[],
{{
end
-
}}
{{
end
}}
{{
-
end
}}
{{
-
end
}}
formData
:
{
{
{
range
.
Fields
}
}
{{
-
if
eq
.
FieldType
"
bool
"
-
}}
{{
-
range
.
Fields
}}
{{
-
if
eq
.
FieldType
"
bool
"
}}
{{.
FieldJson
}}:
false
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
string
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
string
"
}}
{{.
FieldJson
}}:
''
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
int
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
int
"
}}
{{.
FieldJson
}}:
0
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
time.Time
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
time.Time
"
}}
{{.
FieldJson
}}:
new
Date
(),
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
float64
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
float64
"
}}
{{.
FieldJson
}}:
0
,
{{
end
-
}}
{{
end
}}
}
}
},
filters
:
{
formatDate
:
function
(
time
)
{
if
(
time
!==
null
&&
time
!==
''
)
{
var
date
=
new
Date
(
time
);
return
formatTimeToStr
(
date
,
'
yyyy-MM-dd hh:mm:ss
'
);
}
else
{
return
''
}
},
formatBoolean
:
function
(
bool
)
{
if
(
bool
!=
null
)
{
return
bool
?
'
是
'
:
'
否
'
}
else
{
return
''
{{
-
end
}}
{{
-
end
}}
}
}
},
async
created
()
{
await
this
.
getTableData
()
{{
range
.
Fields
-
}}
{{
-
if
.
DictType
}}
{{
-
range
.
Fields
}}
{{
-
if
.
DictType
}}
await
this
.
getDict
(
'
{{.DictType}}
'
)
{{
end
-
}}
{{
-
end
}}
{{
-
end
}}
{{
-
end
}}
},
methods
:
{
// 条件搜索前端看此方法
onSubmit
()
{
this
.
page
=
1
this
.
pageSize
=
10
{{
-
range
.
Fields
}}
{{
-
if
eq
.
FieldType
"
bool
"
}}
{{
-
range
.
Fields
}}{{
-
if
eq
.
FieldType
"
bool
"
}}
if
(
this
.
searchInfo
.{{.
FieldJson
}}
===
""
){
this
.
searchInfo
.{{.
FieldJson
}}
=
null
}
{{
end
}}
{{
end
}}
}
{{
end
}}
{{
end
}}
this
.
getTableData
()
},
handleSelectionChange
(
val
)
{
...
...
@@ -246,23 +247,23 @@ export default {
closeDialog
()
{
this
.
dialogFormVisible
=
false
this
.
formData
=
{
{
{
range
.
Fields
}
}
{{
-
if
eq
.
FieldType
"
bool
"
-
}}
{{
-
range
.
Fields
}}
{{
-
if
eq
.
FieldType
"
bool
"
}}
{{.
FieldJson
}}:
false
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
string
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
string
"
}}
{{.
FieldJson
}}:
''
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
int
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
int
"
}}
{{.
FieldJson
}}:
0
,
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
time.Time
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
time.Time
"
}}
{{.
FieldJson
}}:
new
Date
(),
{{
end
-
}}
{{
-
if
eq
.
FieldType
"
float64
"
-
}}
{{
-
end
}}
{{
-
if
eq
.
FieldType
"
float64
"
}}
{{.
FieldJson
}}:
0
,
{{
end
-
}}
{{
end
}}
{{
-
end
}}
{{
-
end
}}
}
},
async
delete
{{.
StructName
}}(
row
)
{
...
...
@@ -272,7 +273,7 @@ export default {
type
:
'
success
'
,
message
:
'
删除成功
'
})
if
(
this
.
tableData
.
length
===
1
&&
this
.
page
>
1
)
{
if
(
this
.
tableData
.
length
===
1
&&
this
.
page
>
1
)
{
this
.
page
--
}
this
.
getTableData
()
...
...
@@ -281,10 +282,10 @@ export default {
async
enterDialog
()
{
let
res
switch
(
this
.
type
)
{
case
"
create
"
:
case
'
create
'
:
res
=
await
create
{{.
StructName
}}(
this
.
formData
)
break
case
"
update
"
:
case
'
update
'
:
res
=
await
update
{{.
StructName
}}(
this
.
formData
)
break
default
:
...
...
server/utils/validator.go
浏览文件 @
990eb10e
...
...
@@ -3,6 +3,7 @@ package utils
import
(
"errors"
"reflect"
"regexp"
"strconv"
"strings"
)
...
...
@@ -37,6 +38,15 @@ func NotEmpty() string {
return
"notEmpty"
}
//@author: [zooqkl](https://github.com/zooqkl)
//@function: RegexpMatch
//@description: 正则校验 校验输入项是否满足正则表达式
//@param: rule string
//@return: string
func
RegexpMatch
(
rule
string
)
string
{
return
"regexp="
+
rule
}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Lt
//@description: 小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
...
...
@@ -133,6 +143,10 @@ func Verify(st interface{}, roleMap Rules) (err error) {
if
isBlank
(
val
)
{
return
errors
.
New
(
tagVal
.
Name
+
"值不能为空"
)
}
case
strings
.
Split
(
v
,
"="
)[
0
]
==
"regexp"
:
if
!
regexpMatch
(
strings
.
Split
(
v
,
"="
)[
1
],
val
.
String
())
{
return
errors
.
New
(
tagVal
.
Name
+
"格式校验不通过"
)
}
case
compareMap
[
strings
.
Split
(
v
,
"="
)[
0
]]
:
if
!
compareVerify
(
val
,
v
)
{
return
errors
.
New
(
tagVal
.
Name
+
"长度或值不在合法范围,"
+
v
)
...
...
@@ -266,3 +280,7 @@ func compare(value interface{}, VerifyStr string) bool {
return
false
}
}
func
regexpMatch
(
rule
,
matchStr
string
)
bool
{
return
regexp
.
MustCompile
(
rule
)
.
MatchString
(
matchStr
)
}
web/.eslintrc.js
浏览文件 @
990eb10e
...
...
@@ -52,7 +52,7 @@ module.exports = {
properties
:
'
always
'
}
],
'
comma-dangle
'
:
[
2
,
'
never
'
],
'
comma-dangle
'
:
[
2
,
'
only-multiline
'
],
'
comma-spacing
'
:
[
2
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录