Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
caead325
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
345
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看板
提交
caead325
编写于
5月 10, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加验证规则复用
上级
6561ef87
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
89 addition
and
122 deletion
+89
-122
server/api/v1/exa_customer.go
server/api/v1/exa_customer.go
+3
-7
server/api/v1/sys_api.go
server/api/v1/sys_api.go
+14
-18
server/api/v1/sys_authority.go
server/api/v1/sys_authority.go
+18
-22
server/api/v1/sys_menu.go
server/api/v1/sys_menu.go
+8
-12
server/api/v1/sys_user.go
server/api/v1/sys_user.go
+20
-24
server/initialize/router.go
server/initialize/router.go
+0
-1
server/initialize/validator.go
server/initialize/validator.go
+12
-0
server/utils/hasGap.go
server/utils/hasGap.go
+0
-38
server/utils/validator.go
server/utils/validator.go
+14
-0
未找到文件。
server/api/v1/exa_customer.go
浏览文件 @
caead325
...
...
@@ -146,13 +146,9 @@ func GetExaCustomerList(c *gin.Context) {
waitUse
:=
claims
.
(
*
request
.
CustomClaims
)
var
pageInfo
request
.
PageInfo
_
=
c
.
ShouldBindQuery
(
&
pageInfo
)
CustomerVerify
:=
utils
.
Rules
{
"Page"
:
{
utils
.
NotEmpty
()},
"PageSize"
:
{
utils
.
NotEmpty
()},
}
CustomerVerifyErr
:=
utils
.
Verify
(
pageInfo
,
CustomerVerify
)
if
CustomerVerifyErr
!=
nil
{
response
.
FailWithMessage
(
CustomerVerifyErr
.
Error
(),
c
)
PageVerifyErr
:=
utils
.
Verify
(
pageInfo
,
utils
.
CustomizeMap
[
"PageVerify"
])
if
PageVerifyErr
!=
nil
{
response
.
FailWithMessage
(
PageVerifyErr
.
Error
(),
c
)
return
}
err
,
customerList
,
total
:=
service
.
GetCustomerInfoList
(
waitUse
.
AuthorityId
,
pageInfo
)
...
...
server/api/v1/sys_api.go
浏览文件 @
caead325
...
...
@@ -23,13 +23,13 @@ func CreateApi(c *gin.Context) {
var
api
model
.
SysApi
_
=
c
.
ShouldBindJSON
(
&
api
)
ApiVerify
:=
utils
.
Rules
{
"Path"
:
{
utils
.
NotEmpty
()},
"Description"
:
{
utils
.
NotEmpty
()},
"ApiGroup"
:
{
utils
.
NotEmpty
()},
"Path"
:
{
utils
.
NotEmpty
()},
"Description"
:
{
utils
.
NotEmpty
()},
"ApiGroup"
:
{
utils
.
NotEmpty
()},
"Method"
:
{
utils
.
NotEmpty
()},
}
ApiVerifyErr
:=
utils
.
Verify
(
api
,
ApiVerify
)
if
ApiVerifyErr
!=
nil
{
if
ApiVerifyErr
!=
nil
{
response
.
FailWithMessage
(
ApiVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -53,10 +53,10 @@ func DeleteApi(c *gin.Context) {
var
a
model
.
SysApi
_
=
c
.
ShouldBindJSON
(
&
a
)
ApiVerify
:=
utils
.
Rules
{
"ID"
:
{
utils
.
NotEmpty
()},
"ID"
:
{
utils
.
NotEmpty
()},
}
ApiVerifyErr
:=
utils
.
Verify
(
a
.
Model
,
ApiVerify
)
if
ApiVerifyErr
!=
nil
{
if
ApiVerifyErr
!=
nil
{
response
.
FailWithMessage
(
ApiVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -82,13 +82,9 @@ func GetApiList(c *gin.Context) {
// 此结构体仅本方法使用
var
sp
request
.
SearchApiParams
_
=
c
.
ShouldBindJSON
(
&
sp
)
ApiVerify
:=
utils
.
Rules
{
"Page"
:
{
utils
.
NotEmpty
()},
"PageSize"
:
{
utils
.
NotEmpty
()},
}
ApiVerifyErr
:=
utils
.
Verify
(
sp
.
PageInfo
,
ApiVerify
)
if
ApiVerifyErr
!=
nil
{
response
.
FailWithMessage
(
ApiVerifyErr
.
Error
(),
c
)
PageVerifyErr
:=
utils
.
Verify
(
sp
.
PageInfo
,
utils
.
CustomizeMap
[
"PageVerify"
])
if
PageVerifyErr
!=
nil
{
response
.
FailWithMessage
(
PageVerifyErr
.
Error
(),
c
)
return
}
err
,
list
,
total
:=
service
.
GetAPIInfoList
(
sp
.
SysApi
,
sp
.
PageInfo
,
sp
.
OrderKey
,
sp
.
Desc
)
...
...
@@ -119,7 +115,7 @@ func GetApiById(c *gin.Context) {
"Id"
:
{
utils
.
NotEmpty
()},
}
ApiVerifyErr
:=
utils
.
Verify
(
idInfo
,
ApiVerify
)
if
ApiVerifyErr
!=
nil
{
if
ApiVerifyErr
!=
nil
{
response
.
FailWithMessage
(
ApiVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -143,13 +139,13 @@ func UpdateApi(c *gin.Context) {
var
api
model
.
SysApi
_
=
c
.
ShouldBindJSON
(
&
api
)
ApiVerify
:=
utils
.
Rules
{
"Path"
:
{
utils
.
NotEmpty
()},
"Description"
:
{
utils
.
NotEmpty
()},
"ApiGroup"
:
{
utils
.
NotEmpty
()},
"Path"
:
{
utils
.
NotEmpty
()},
"Description"
:
{
utils
.
NotEmpty
()},
"ApiGroup"
:
{
utils
.
NotEmpty
()},
"Method"
:
{
utils
.
NotEmpty
()},
}
ApiVerifyErr
:=
utils
.
Verify
(
api
,
ApiVerify
)
if
ApiVerifyErr
!=
nil
{
if
ApiVerifyErr
!=
nil
{
response
.
FailWithMessage
(
ApiVerifyErr
.
Error
(),
c
)
return
}
...
...
server/api/v1/sys_authority.go
浏览文件 @
caead325
...
...
@@ -23,12 +23,12 @@ func CreateAuthority(c *gin.Context) {
var
auth
model
.
SysAuthority
_
=
c
.
ShouldBindJSON
(
&
auth
)
AuthorityVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityName"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityName"
:
{
utils
.
NotEmpty
()},
"ParentId"
:
{
utils
.
NotEmpty
()},
}
AuthorityVerifyErr
:=
utils
.
Verify
(
auth
,
AuthorityVerify
)
if
AuthorityVerifyErr
!=
nil
{
if
AuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
AuthorityVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -52,20 +52,20 @@ func CopyAuthority(c *gin.Context) {
var
copyInfo
resp
.
SysAuthorityCopyResponse
_
=
c
.
ShouldBindJSON
(
&
copyInfo
)
OldAuthorityVerify
:=
utils
.
Rules
{
"OldAuthorityId"
:
{
utils
.
NotEmpty
()},
"OldAuthorityId"
:
{
utils
.
NotEmpty
()},
}
OldAuthorityVerifyErr
:=
utils
.
Verify
(
copyInfo
,
OldAuthorityVerify
)
if
OldAuthorityVerifyErr
!=
nil
{
if
OldAuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
OldAuthorityVerifyErr
.
Error
(),
c
)
return
}
AuthorityVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityName"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityName"
:
{
utils
.
NotEmpty
()},
"ParentId"
:
{
utils
.
NotEmpty
()},
}
AuthorityVerifyErr
:=
utils
.
Verify
(
copyInfo
.
Authority
,
AuthorityVerify
)
if
AuthorityVerifyErr
!=
nil
{
if
AuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
AuthorityVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -89,10 +89,10 @@ func DeleteAuthority(c *gin.Context) {
var
a
model
.
SysAuthority
_
=
c
.
ShouldBindJSON
(
&
a
)
AuthorityVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
}
AuthorityVerifyErr
:=
utils
.
Verify
(
a
,
AuthorityVerify
)
if
AuthorityVerifyErr
!=
nil
{
if
AuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
AuthorityVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -117,12 +117,12 @@ func UpdateAuthority(c *gin.Context) {
var
auth
model
.
SysAuthority
_
=
c
.
ShouldBindJSON
(
&
auth
)
AuthorityVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityName"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityName"
:
{
utils
.
NotEmpty
()},
"ParentId"
:
{
utils
.
NotEmpty
()},
}
AuthorityVerifyErr
:=
utils
.
Verify
(
auth
,
AuthorityVerify
)
if
AuthorityVerifyErr
!=
nil
{
if
AuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
AuthorityVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -145,13 +145,9 @@ func UpdateAuthority(c *gin.Context) {
func
GetAuthorityList
(
c
*
gin
.
Context
)
{
var
pageInfo
request
.
PageInfo
_
=
c
.
ShouldBindJSON
(
&
pageInfo
)
AuthorityVerify
:=
utils
.
Rules
{
"Page"
:
{
utils
.
NotEmpty
()},
"PageSize"
:
{
utils
.
NotEmpty
()},
}
AuthorityVerifyErr
:=
utils
.
Verify
(
pageInfo
,
AuthorityVerify
)
if
AuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
AuthorityVerifyErr
.
Error
(),
c
)
PageVerifyErr
:=
utils
.
Verify
(
pageInfo
,
utils
.
CustomizeMap
[
"PageVerify"
])
if
PageVerifyErr
!=
nil
{
response
.
FailWithMessage
(
PageVerifyErr
.
Error
(),
c
)
return
}
err
,
list
,
total
:=
service
.
GetAuthorityInfoList
(
pageInfo
)
...
...
@@ -179,10 +175,10 @@ func SetDataAuthority(c *gin.Context) {
var
auth
model
.
SysAuthority
_
=
c
.
ShouldBindJSON
(
&
auth
)
AuthorityVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
}
AuthorityVerifyErr
:=
utils
.
Verify
(
auth
,
AuthorityVerify
)
if
AuthorityVerifyErr
!=
nil
{
if
AuthorityVerifyErr
!=
nil
{
response
.
FailWithMessage
(
AuthorityVerifyErr
.
Error
(),
c
)
return
}
...
...
server/api/v1/sys_menu.go
浏览文件 @
caead325
...
...
@@ -40,12 +40,8 @@ func GetMenu(c *gin.Context) {
func
GetMenuList
(
c
*
gin
.
Context
)
{
var
pageInfo
request
.
PageInfo
_
=
c
.
ShouldBindJSON
(
&
pageInfo
)
PageVerify
:=
utils
.
Rules
{
"Page"
:
{
utils
.
NotEmpty
()},
"PageSize"
:
{
utils
.
NotEmpty
()},
}
PageVerifyErr
:=
utils
.
Verify
(
pageInfo
,
PageVerify
)
if
PageVerifyErr
!=
nil
{
PageVerifyErr
:=
utils
.
Verify
(
pageInfo
,
utils
.
CustomizeMap
[
"PageVerify"
])
if
PageVerifyErr
!=
nil
{
response
.
FailWithMessage
(
PageVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -78,7 +74,7 @@ func AddBaseMenu(c *gin.Context) {
"ParentId"
:
{
utils
.
NotEmpty
()},
"Name"
:
{
utils
.
NotEmpty
()},
"Component"
:
{
utils
.
NotEmpty
()},
"Sort"
:
{
utils
.
Ge
(
"0"
),
"ge=0"
},
"Sort"
:
{
utils
.
Ge
(
"0"
),
"ge=0"
},
}
MenuVerifyErr
:=
utils
.
Verify
(
menu
,
MenuVerify
)
if
MenuVerifyErr
!=
nil
{
...
...
@@ -129,7 +125,7 @@ func AddMenuAuthority(c *gin.Context) {
var
addMenuAuthorityInfo
request
.
AddMenuAuthorityInfo
_
=
c
.
ShouldBindJSON
(
&
addMenuAuthorityInfo
)
MenuVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
"notEmpty"
},
"AuthorityId"
:
{
"notEmpty"
},
}
MenuVerifyErr
:=
utils
.
Verify
(
addMenuAuthorityInfo
,
MenuVerify
)
if
MenuVerifyErr
!=
nil
{
...
...
@@ -156,7 +152,7 @@ func GetMenuAuthority(c *gin.Context) {
var
authorityIdInfo
request
.
AuthorityIdInfo
_
=
c
.
ShouldBindJSON
(
&
authorityIdInfo
)
MenuVerify
:=
utils
.
Rules
{
"AuthorityId"
:
{
"notEmpty"
},
"AuthorityId"
:
{
"notEmpty"
},
}
MenuVerifyErr
:=
utils
.
Verify
(
authorityIdInfo
,
MenuVerify
)
if
MenuVerifyErr
!=
nil
{
...
...
@@ -183,7 +179,7 @@ func DeleteBaseMenu(c *gin.Context) {
var
idInfo
request
.
GetById
_
=
c
.
ShouldBindJSON
(
&
idInfo
)
MenuVerify
:=
utils
.
Rules
{
"Id"
:
{
"notEmpty"
},
"Id"
:
{
"notEmpty"
},
}
MenuVerifyErr
:=
utils
.
Verify
(
idInfo
,
MenuVerify
)
if
MenuVerifyErr
!=
nil
{
...
...
@@ -215,7 +211,7 @@ func UpdateBaseMenu(c *gin.Context) {
"ParentId"
:
{
utils
.
NotEmpty
()},
"Name"
:
{
utils
.
NotEmpty
()},
"Component"
:
{
utils
.
NotEmpty
()},
"Sort"
:
{
utils
.
Ge
(
"0"
),
"ge=0"
},
"Sort"
:
{
utils
.
Ge
(
"0"
),
"ge=0"
},
}
MenuVerifyErr
:=
utils
.
Verify
(
menu
,
MenuVerify
)
if
MenuVerifyErr
!=
nil
{
...
...
@@ -250,7 +246,7 @@ func GetBaseMenuById(c *gin.Context) {
var
idInfo
request
.
GetById
_
=
c
.
ShouldBindJSON
(
&
idInfo
)
MenuVerify
:=
utils
.
Rules
{
"Id"
:
{
"notEmpty"
},
"Id"
:
{
"notEmpty"
},
}
MenuVerifyErr
:=
utils
.
Verify
(
idInfo
,
MenuVerify
)
if
MenuVerifyErr
!=
nil
{
...
...
server/api/v1/sys_user.go
浏览文件 @
caead325
...
...
@@ -28,13 +28,13 @@ func Register(c *gin.Context) {
var
R
request
.
RegisterStruct
_
=
c
.
ShouldBindJSON
(
&
R
)
UserVerify
:=
utils
.
Rules
{
"Username"
:
{
utils
.
NotEmpty
()},
"NickName"
:
{
utils
.
NotEmpty
()},
"Password"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
"Username"
:
{
utils
.
NotEmpty
()},
"NickName"
:
{
utils
.
NotEmpty
()},
"Password"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
}
UserVerifyErr
:=
utils
.
Verify
(
R
,
UserVerify
)
if
UserVerifyErr
!=
nil
{
if
UserVerifyErr
!=
nil
{
response
.
FailWithMessage
(
UserVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -57,13 +57,13 @@ func Login(c *gin.Context) {
var
L
request
.
RegisterAndLoginStruct
_
=
c
.
ShouldBindJSON
(
&
L
)
UserVerify
:=
utils
.
Rules
{
"CaptchaId"
:
{
utils
.
NotEmpty
()},
"Captcha"
:
{
utils
.
NotEmpty
()},
"Username"
:
{
utils
.
NotEmpty
()},
"Password"
:
{
utils
.
NotEmpty
()},
"CaptchaId"
:
{
utils
.
NotEmpty
()},
"Captcha"
:
{
utils
.
NotEmpty
()},
"Username"
:
{
utils
.
NotEmpty
()},
"Password"
:
{
utils
.
NotEmpty
()},
}
UserVerifyErr
:=
utils
.
Verify
(
L
,
UserVerify
)
if
UserVerifyErr
!=
nil
{
if
UserVerifyErr
!=
nil
{
response
.
FailWithMessage
(
UserVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -157,12 +157,12 @@ func ChangePassword(c *gin.Context) {
var
params
request
.
ChangePasswordStruct
_
=
c
.
ShouldBindJSON
(
&
params
)
UserVerify
:=
utils
.
Rules
{
"Username"
:
{
utils
.
NotEmpty
()},
"Password"
:
{
utils
.
NotEmpty
()},
"NewPassword"
:
{
utils
.
NotEmpty
()},
"Username"
:
{
utils
.
NotEmpty
()},
"Password"
:
{
utils
.
NotEmpty
()},
"NewPassword"
:
{
utils
.
NotEmpty
()},
}
UserVerifyErr
:=
utils
.
Verify
(
params
,
UserVerify
)
if
UserVerifyErr
!=
nil
{
if
UserVerifyErr
!=
nil
{
response
.
FailWithMessage
(
UserVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -225,13 +225,9 @@ func UploadHeaderImg(c *gin.Context) {
func
GetUserList
(
c
*
gin
.
Context
)
{
var
pageInfo
request
.
PageInfo
_
=
c
.
ShouldBindJSON
(
&
pageInfo
)
UserVerify
:=
utils
.
Rules
{
"Page"
:
{
utils
.
NotEmpty
()},
"PageSize"
:
{
utils
.
NotEmpty
()},
}
UserVerifyErr
:=
utils
.
Verify
(
pageInfo
,
UserVerify
)
if
UserVerifyErr
!=
nil
{
response
.
FailWithMessage
(
UserVerifyErr
.
Error
(),
c
)
PageVerifyErr
:=
utils
.
Verify
(
pageInfo
,
utils
.
CustomizeMap
[
"PageVerify"
])
if
PageVerifyErr
!=
nil
{
response
.
FailWithMessage
(
PageVerifyErr
.
Error
(),
c
)
return
}
err
,
list
,
total
:=
service
.
GetUserInfoList
(
pageInfo
)
...
...
@@ -259,11 +255,11 @@ func SetUserAuthority(c *gin.Context) {
var
sua
request
.
SetUserAuth
_
=
c
.
ShouldBindJSON
(
&
sua
)
UserVerify
:=
utils
.
Rules
{
"UUID"
:
{
utils
.
NotEmpty
()},
"UUID"
:
{
utils
.
NotEmpty
()},
"AuthorityId"
:
{
utils
.
NotEmpty
()},
}
UserVerifyErr
:=
utils
.
Verify
(
sua
,
UserVerify
)
if
UserVerifyErr
!=
nil
{
if
UserVerifyErr
!=
nil
{
response
.
FailWithMessage
(
UserVerifyErr
.
Error
(),
c
)
return
}
...
...
@@ -290,7 +286,7 @@ func DeleteUser(c *gin.Context) {
"Id"
:
{
utils
.
NotEmpty
()},
}
UserVerifyErr
:=
utils
.
Verify
(
reqId
,
UserVerify
)
if
UserVerifyErr
!=
nil
{
if
UserVerifyErr
!=
nil
{
response
.
FailWithMessage
(
UserVerifyErr
.
Error
(),
c
)
return
}
...
...
server/initialize/router.go
浏览文件 @
caead325
...
...
@@ -14,7 +14,6 @@ import (
func
Routers
()
*
gin
.
Engine
{
var
Router
=
gin
.
Default
()
//Router.Use(middleware.LoadTls()) // 打开就能玩https了
global
.
GVA_LOG
.
Debug
(
"use middleware logger"
)
// 跨域
...
...
server/initialize/validator.go
0 → 100644
浏览文件 @
caead325
package
initialize
import
"gin-vue-admin/utils"
func
init
()
{
_
=
utils
.
RegisterRule
(
"PageVerify"
,
utils
.
Rules
{
"Page"
:
{
utils
.
NotEmpty
()},
"PageSize"
:
{
utils
.
NotEmpty
()},
},
)
}
server/utils/hasGap.go
已删除
100644 → 0
浏览文件 @
6561ef87
// 空值校验工具 仅用于检验空字符串 其余类型请勿使用
package
utils
import
(
"errors"
"fmt"
"reflect"
)
func
HasGap
(
input
interface
{})
error
{
getType
:=
reflect
.
TypeOf
(
input
)
getValue
:=
reflect
.
ValueOf
(
input
)
// 获取方法字段
for
i
:=
0
;
i
<
getType
.
NumField
();
i
++
{
field
:=
getType
.
Field
(
i
)
value
:=
getValue
.
Field
(
i
)
.
Interface
()
switch
value
.
(
type
)
{
case
string
:
if
value
==
""
{
fmt
.
Printf
(
"%s为空"
,
field
.
Name
)
return
errors
.
New
(
fmt
.
Sprintf
(
"%s为空"
,
field
.
Name
))
}
default
:
if
value
==
nil
{
fmt
.
Printf
(
"%s为空"
,
field
.
Name
)
return
errors
.
New
(
fmt
.
Sprintf
(
"%s为空"
,
field
.
Name
))
}
}
}
// 获取方法
// 1. 先获取interface的reflect.Type,然后通过.NumMethod进行遍历
//for i := 0; i < getType.NumMethod(); i++ {
// m := getType.Method(i)
// fmt.Printf("%s: %v\n", m.Name, m.Type)
//}
return
nil
}
server/utils/validator.go
浏览文件 @
caead325
...
...
@@ -9,6 +9,20 @@ import (
type
Rules
map
[
string
][]
string
type
RulesMap
map
[
string
]
Rules
var
CustomizeMap
=
make
(
map
[
string
]
Rules
)
// 注册自定义规则方案建议在路由初始化层即注册
func
RegisterRule
(
key
string
,
rule
Rules
)
(
err
error
)
{
if
CustomizeMap
[
key
]
!=
nil
{
return
errors
.
New
(
key
+
"已注册,无法重复注册"
)
}
else
{
CustomizeMap
[
key
]
=
rule
return
nil
}
}
// 非空 不能为其对应类型的0值
func
NotEmpty
()
string
{
return
"notEmpty"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录