list_menu.go
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"github.com/beego/beego/v2/core/validation"
)
type ListMenuQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 菜单类别 web app
MenuCategory string `json:"menuCategory,omitempty"`
// 菜单父级id 0:查询所有 n:parent_id为n的菜单列表
ParentId int64 `json:"parentId,omitempty"`
// 菜单名称过滤
MenuName string `json:"menuName,omitempty"`
// 结构类型 树型:tree 列表型:list
StructType string `json:"structType,omitempty"`
// 查询偏离量
Offset int `json:"offset"`
// 查询限制
Limit int `json:"limit"`
// web分页
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
}
func (listMenuQuery *ListMenuQuery) Valid(validation *validation.Validation) {
if listMenuQuery.PageSize > 0 {
listMenuQuery.Limit = listMenuQuery.PageSize
listMenuQuery.Offset = (listMenuQuery.PageNumber - 1) * listMenuQuery.PageSize
}
}
func (listMenuQuery *ListMenuQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listMenuQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}