Skip to content

Commit

Permalink
fix: 字段长度验证与模型对齐 (opsre#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
eryajf authored Nov 11, 2023
1 parent 88c7f15 commit 41c245d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions model/request/group_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ type GroupListAllReq struct {
// GroupAddReq 添加资源结构体
type GroupAddReq struct {
GroupType string `json:"groupType" validate:"required,min=1,max=20"`
GroupName string `json:"groupName" validate:"required,min=1,max=20"`
GroupName string `json:"groupName" validate:"required,min=1,max=128"`
//父级Id 大于等于0 必填
ParentId uint `json:"parentId" validate:"omitempty,min=0"`
Remark string `json:"remark" validate:"min=0,max=100"` // 分组的中文描述
Remark string `json:"remark" validate:"min=0,max=128"` // 分组的中文描述
}

// DingTalkGroupAddReq 添加钉钉资源结构体
type DingGroupAddReq struct {
GroupType string `json:"groupType" validate:"required,min=1,max=20"`
GroupName string `json:"groupName" validate:"required,min=1,max=20"`
GroupName string `json:"groupName" validate:"required,min=1,max=128"`
//父级Id 大于等于0 必填
ParentId uint `json:"parentId" validate:"omitempty,min=0"`
Remark string `json:"remark" validate:"min=0,max=100"` // 分组的中文描述
Remark string `json:"remark" validate:"min=0,max=128"` // 分组的中文描述
SourceDeptId string `json:"sourceDeptId"`
Source string `json:"source"`
SourceDeptParentId string `json:"SourceDeptParentId"`
Expand All @@ -44,10 +44,10 @@ type DingGroupAddReq struct {
// WeComGroupAddReq 添加企业微信资源结构体
type WeComGroupAddReq struct {
GroupType string `json:"groupType" validate:"required,min=1,max=20"`
GroupName string `json:"groupName" validate:"required,min=1,max=20"`
GroupName string `json:"groupName" validate:"required,min=1,max=128"`
//父级Id 大于等于0 必填
ParentId uint `json:"parentId" validate:"omitempty,min=0"`
Remark string `json:"remark" validate:"min=0,max=100"` // 分组的中文描述
Remark string `json:"remark" validate:"min=0,max=128"` // 分组的中文描述
SourceDeptId string `json:"sourceDeptId"`
Source string `json:"source"`
SourceDeptParentId string `json:"SourceDeptParentId"`
Expand All @@ -57,8 +57,8 @@ type WeComGroupAddReq struct {
// GroupUpdateReq 更新资源结构体
type GroupUpdateReq struct {
ID uint `json:"id" form:"id" validate:"required"`
GroupName string `json:"groupName" validate:"required,min=1,max=20"`
Remark string `json:"remark" validate:"min=0,max=100"` // 分组的中文描述
GroupName string `json:"groupName" validate:"required,min=1,max=128"`
Remark string `json:"remark" validate:"min=0,max=128"` // 分组的中文描述
}

// GroupDeleteReq 删除资源结构体
Expand Down
46 changes: 23 additions & 23 deletions model/request/user_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,63 @@ package request

// UserAddReq 创建资源结构体
type UserAddReq struct {
Username string `json:"username" validate:"required,min=2,max=20"`
Username string `json:"username" validate:"required,min=2,max=50"`
Password string `json:"password"`
Nickname string `json:"nickname" validate:"required,min=0,max=20"`
GivenName string `json:"givenName" validate:"min=0,max=20"`
Nickname string `json:"nickname" validate:"required,min=0,max=50"`
GivenName string `json:"givenName" validate:"min=0,max=50"`
Mail string `json:"mail" validate:"required,min=0,max=100"`
JobNumber string `json:"jobNumber" validate:"required,min=0,max=20"`
PostalAddress string `json:"postalAddress" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=255"`
Position string `json:"position" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=512"`
Position string `json:"position" validate:"min=0,max=128"`
Mobile string `json:"mobile" validate:"required,checkMobile"`
Avatar string `json:"avatar"`
Introduction string `json:"introduction" validate:"min=0,max=255"`
Status uint `json:"status" validate:"oneof=1 2"`
DepartmentId []uint `json:"departmentId" validate:"required"`
Source string `json:"source" validate:"min=0,max=20"`
Source string `json:"source" validate:"min=0,max=50"`
RoleIds []uint `json:"roleIds" validate:"required"`
}

// DingUserAddReq 钉钉用户创建资源结构体
type DingUserAddReq struct {
Username string `json:"username" validate:"required,min=2,max=20"`
Username string `json:"username" validate:"required,min=2,max=50"`
Password string `json:"password"`
Nickname string `json:"nickname" validate:"required,min=0,max=20"`
GivenName string `json:"givenName" validate:"min=0,max=20"`
Nickname string `json:"nickname" validate:"required,min=0,max=50"`
GivenName string `json:"givenName" validate:"min=0,max=50"`
Mail string `json:"mail" validate:"required,min=0,max=100"`
JobNumber string `json:"jobNumber" validate:"required,min=0,max=20"`
PostalAddress string `json:"postalAddress" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=255"`
Position string `json:"position" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=512"`
Position string `json:"position" validate:"min=0,max=128"`
Mobile string `json:"mobile" validate:"required,checkMobile"`
Avatar string `json:"avatar"`
Introduction string `json:"introduction" validate:"min=0,max=255"`
Status uint `json:"status" validate:"oneof=1 2"`
DepartmentId []uint `json:"departmentId" validate:"required"`
Source string `json:"source" validate:"min=0,max=20"`
Source string `json:"source" validate:"min=0,max=50"`
RoleIds []uint `json:"roleIds" validate:"required"`
SourceUserId string `json:"sourceUserId"` // 第三方用户id
SourceUnionId string `json:"sourceUnionId"` // 第三方唯一unionId
}

// WeComUserAddReq 企业微信用户创建资源结构体
type WeComUserAddReq struct {
Username string `json:"username" validate:"required,min=2,max=20"`
Username string `json:"username" validate:"required,min=2,max=50"`
Password string `json:"password"`
Nickname string `json:"nickname" validate:"required,min=0,max=20"`
GivenName string `json:"givenName" validate:"min=0,max=20"`
Nickname string `json:"nickname" validate:"required,min=0,max=50"`
GivenName string `json:"givenName" validate:"min=0,max=50"`
Mail string `json:"mail" validate:"required,min=0,max=100"`
JobNumber string `json:"jobNumber" validate:"required,min=0,max=20"`
PostalAddress string `json:"postalAddress" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=255"`
Position string `json:"position" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=512"`
Position string `json:"position" validate:"min=0,max=128"`
Mobile string `json:"mobile" validate:"required,checkMobile"`
Avatar string `json:"avatar"`
Introduction string `json:"introduction" validate:"min=0,max=255"`
Status uint `json:"status" validate:"oneof=1 2"`
DepartmentId []uint `json:"departmentId" validate:"required"`
Source string `json:"source" validate:"min=0,max=20"`
Source string `json:"source" validate:"min=0,max=50"`
RoleIds []uint `json:"roleIds" validate:"required"`
SourceUserId string `json:"sourceUserId"` // 第三方用户id
SourceUnionId string `json:"sourceUnionId"` // 第三方唯一unionId
Expand All @@ -67,19 +67,19 @@ type WeComUserAddReq struct {
// UserUpdateReq 更新资源结构体
type UserUpdateReq struct {
ID uint `json:"id" validate:"required"`
Username string `json:"username" validate:"required,min=2,max=20"`
Username string `json:"username" validate:"required,min=2,max=50"`
Nickname string `json:"nickname" validate:"min=0,max=20"`
GivenName string `json:"givenName" validate:"min=0,max=20"`
GivenName string `json:"givenName" validate:"min=0,max=50"`
Mail string `json:"mail" validate:"min=0,max=100"`
JobNumber string `json:"jobNumber" validate:"min=0,max=20"`
PostalAddress string `json:"postalAddress" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=255"`
Position string `json:"position" validate:"min=0,max=255"`
Departments string `json:"departments" validate:"min=0,max=512"`
Position string `json:"position" validate:"min=0,max=128"`
Mobile string `json:"mobile" validate:"checkMobile"`
Avatar string `json:"avatar"`
Introduction string `json:"introduction" validate:"min=0,max=255"`
DepartmentId []uint `json:"departmentId" validate:"required"`
Source string `json:"source" validate:"min=0,max=20"`
Source string `json:"source" validate:"min=0,max=50"`
RoleIds []uint `json:"roleIds" validate:"required"`
}

Expand Down

0 comments on commit 41c245d

Please sign in to comment.