Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev
# Conflicts: # lastupdate.tmp
正在显示
21 个修改的文件
包含
902 行增加
和
21 行删除
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type BatchDeleteMenuCommand struct { | ||
13 | + //操作人 | ||
14 | + Operator domain.Operator `json:"-"` | ||
15 | + // 菜单ID列表 | ||
16 | + MenuIds []int64 `cname:"菜单ID列表" json:"menuIds,omitempty"` | ||
17 | +} | ||
18 | + | ||
19 | +func (batchDeleteMenuCommand *BatchDeleteMenuCommand) Valid(validation *validation.Validation) { | ||
20 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
21 | +} | ||
22 | + | ||
23 | +func (batchDeleteMenuCommand *BatchDeleteMenuCommand) ValidateCommand() error { | ||
24 | + valid := validation.Validation{} | ||
25 | + b, err := valid.Valid(batchDeleteMenuCommand) | ||
26 | + if err != nil { | ||
27 | + return err | ||
28 | + } | ||
29 | + if !b { | ||
30 | + elem := reflect.TypeOf(batchDeleteMenuCommand).Elem() | ||
31 | + for _, validErr := range valid.Errors { | ||
32 | + field, isExist := elem.FieldByName(validErr.Field) | ||
33 | + if isExist { | ||
34 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
35 | + } else { | ||
36 | + return fmt.Errorf(validErr.Message) | ||
37 | + } | ||
38 | + } | ||
39 | + } | ||
40 | + return nil | ||
41 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type BatchEnableMenuCommand struct { | ||
13 | + //操作人 | ||
14 | + Operator domain.Operator `json:"-"` | ||
15 | + // 菜单ID列表 | ||
16 | + MenuIds []int64 `cname:"菜单ID列表" json:"menuIds,omitempty"` | ||
17 | + // 菜单状态 | ||
18 | + Status int `cname:"菜单状态" json:"status,omitempty"` | ||
19 | +} | ||
20 | + | ||
21 | +func (batchEnableMenuCommand *BatchEnableMenuCommand) Valid(validation *validation.Validation) { | ||
22 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
23 | +} | ||
24 | + | ||
25 | +func (batchEnableMenuCommand *BatchEnableMenuCommand) ValidateCommand() error { | ||
26 | + valid := validation.Validation{} | ||
27 | + b, err := valid.Valid(batchEnableMenuCommand) | ||
28 | + if err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + if !b { | ||
32 | + elem := reflect.TypeOf(batchEnableMenuCommand).Elem() | ||
33 | + for _, validErr := range valid.Errors { | ||
34 | + field, isExist := elem.FieldByName(validErr.Field) | ||
35 | + if isExist { | ||
36 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
37 | + } else { | ||
38 | + return fmt.Errorf(validErr.Message) | ||
39 | + } | ||
40 | + } | ||
41 | + } | ||
42 | + return nil | ||
43 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +type CreateMenuCommand struct { | ||
10 | + //操作人 | ||
11 | + Operator domain.Operator `json:"-"` | ||
12 | + // 父级id | ||
13 | + ParentId int64 `json:"parentId,omitempty"` | ||
14 | + // 菜单名称 | ||
15 | + MenuName string `json:"menuName" valid:"Required"` | ||
16 | + // 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码) | ||
17 | + Code string `json:"code" valid:"Required"` | ||
18 | + // 权限编码 user:edit | ||
19 | + AccessCode string `json:"accessCode"` | ||
20 | + // 菜单类型 (目录catalog、菜单menu、按钮button) | ||
21 | + MenuType string `json:"menuType" valid:"Required"` | ||
22 | + // 菜单图标 | ||
23 | + Icon string `json:"icon,omitempty"` | ||
24 | + // 排序 | ||
25 | + Sort int `json:"sort" valid:"Required"` | ||
26 | + // 菜单说明 | ||
27 | + Desc string `json:"desc,omitempty"` | ||
28 | + // 菜单是否公开状态,[2:隐藏],[1:显示],默认显示 | ||
29 | + IsPublish int `json:"isPublish" valid:"Required"` | ||
30 | + // 启用状态(启用:1 禁用:2),默认启用 | ||
31 | + EnableStatus int `json:"enableStatus" ` | ||
32 | +} | ||
33 | + | ||
34 | +func (createMenuCommand *CreateMenuCommand) Valid(validation *validation.Validation) { | ||
35 | + | ||
36 | +} | ||
37 | + | ||
38 | +func (createMenuCommand *CreateMenuCommand) ValidateCommand() error { | ||
39 | + valid := validation.Validation{} | ||
40 | + b, err := valid.Valid(createMenuCommand) | ||
41 | + if err != nil { | ||
42 | + return err | ||
43 | + } | ||
44 | + if !b { | ||
45 | + for _, validErr := range valid.Errors { | ||
46 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
47 | + } | ||
48 | + } | ||
49 | + return nil | ||
50 | + | ||
51 | + //valid := validation.Validation{} | ||
52 | + //b, err := valid.Valid(createMenuCommand) | ||
53 | + //if err != nil { | ||
54 | + // return err | ||
55 | + //} | ||
56 | + //if !b { | ||
57 | + // elem := reflect.TypeOf(createMenuCommand).Elem() | ||
58 | + // for _, validErr := range valid.Errors { | ||
59 | + // field, isExist := elem.FieldByName(validErr.Field) | ||
60 | + // if isExist { | ||
61 | + // return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
62 | + // } else { | ||
63 | + // return fmt.Errorf(validErr.Message) | ||
64 | + // } | ||
65 | + // } | ||
66 | + //} | ||
67 | + //return nil | ||
68 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + | ||
7 | + "github.com/beego/beego/v2/core/validation" | ||
8 | +) | ||
9 | + | ||
10 | +type RemoveMenuCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + // 菜单编号 | ||
14 | + MenuId int64 `json:"menuId" valid:"Required"` | ||
15 | +} | ||
16 | + | ||
17 | +func (removeMenuCommand *RemoveMenuCommand) Valid(validation *validation.Validation) { | ||
18 | + | ||
19 | +} | ||
20 | + | ||
21 | +func (removeMenuCommand *RemoveMenuCommand) ValidateCommand() error { | ||
22 | + valid := validation.Validation{} | ||
23 | + b, err := valid.Valid(removeMenuCommand) | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if !b { | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
30 | + } | ||
31 | + } | ||
32 | + return nil | ||
33 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + | ||
7 | + "github.com/beego/beego/v2/core/validation" | ||
8 | +) | ||
9 | + | ||
10 | +type UpdateMenuCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + // 菜单编号 | ||
14 | + MenuId int64 `json:"menuId" valid:"Required"` | ||
15 | + // 父级id | ||
16 | + ParentId int64 `json:"parentId,omitempty"` | ||
17 | + // 菜单名称 | ||
18 | + MenuName string `json:"menuName" valid:"Required"` | ||
19 | + // 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码) | ||
20 | + Code string `json:"code" valid:"Required"` | ||
21 | + // 权限编码 user:edit | ||
22 | + AccessCode string `json:"accessCode,omitempty"` | ||
23 | + // 菜单类型 (目录catalog、菜单menu、按钮button) | ||
24 | + MenuType string `json:"menuType" valid:"Required"` | ||
25 | + // 菜单图标 | ||
26 | + Icon string `json:"icon,omitempty"` | ||
27 | + // 排序 | ||
28 | + Sort int `json:"sort" valid:"Required"` | ||
29 | + // 菜单说明 | ||
30 | + Desc string `json:"desc,omitempty"` | ||
31 | + // 菜单是否公开状态,[0:隐藏],[1:显示],默认显示 | ||
32 | + IsPublish int `json:"isPublish,omitempty"` | ||
33 | + // 启用状态(启用:1 禁用:2),默认启用 | ||
34 | + EnableStatus int `json:"enableStatus"` | ||
35 | +} | ||
36 | + | ||
37 | +func (updateMenuCommand *UpdateMenuCommand) Valid(validation *validation.Validation) { | ||
38 | + | ||
39 | +} | ||
40 | + | ||
41 | +func (updateMenuCommand *UpdateMenuCommand) ValidateCommand() error { | ||
42 | + valid := validation.Validation{} | ||
43 | + b, err := valid.Valid(updateMenuCommand) | ||
44 | + if err != nil { | ||
45 | + return err | ||
46 | + } | ||
47 | + if !b { | ||
48 | + for _, validErr := range valid.Errors { | ||
49 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
50 | + } | ||
51 | + } | ||
52 | + return nil | ||
53 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + | ||
7 | + "github.com/beego/beego/v2/core/validation" | ||
8 | +) | ||
9 | + | ||
10 | +type GetMenuQuery struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + // 菜单编号 | ||
14 | + MenuId int64 `json:"menuId" valid:"Required"` | ||
15 | +} | ||
16 | + | ||
17 | +func (getMenuQuery *GetMenuQuery) Valid(validation *validation.Validation) { | ||
18 | + | ||
19 | +} | ||
20 | + | ||
21 | +func (getMenuQuery *GetMenuQuery) ValidateQuery() error { | ||
22 | + valid := validation.Validation{} | ||
23 | + b, err := valid.Valid(getMenuQuery) | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if !b { | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
30 | + } | ||
31 | + } | ||
32 | + return nil | ||
33 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + | ||
7 | + "github.com/beego/beego/v2/core/validation" | ||
8 | +) | ||
9 | + | ||
10 | +type ListMenuQuery struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + // 菜单类别 web app | ||
14 | + MenuCategory string `json:"menuCategory,omitempty"` | ||
15 | + // 菜单父级id 0:查询所有 n:parent_id为n的菜单列表 | ||
16 | + ParentId int64 `json:"parentId,omitempty"` | ||
17 | + // 菜单名称过滤 | ||
18 | + MenuName string `json:"menuName,omitempty"` | ||
19 | + // 结构类型 树型:tree 列表型:list | ||
20 | + StructType string `json:"structType,omitempty"` | ||
21 | + // 查询偏离量 | ||
22 | + Offset int `json:"offset"` | ||
23 | + // 查询限制 | ||
24 | + Limit int `json:"limit"` | ||
25 | + | ||
26 | + // web分页 | ||
27 | + PageNumber int `json:"pageNumber"` | ||
28 | + PageSize int `json:"pageSize"` | ||
29 | +} | ||
30 | + | ||
31 | +func (listMenuQuery *ListMenuQuery) Valid(validation *validation.Validation) { | ||
32 | + if listMenuQuery.PageSize > 0 { | ||
33 | + listMenuQuery.Limit = listMenuQuery.PageSize | ||
34 | + listMenuQuery.Offset = (listMenuQuery.PageNumber - 1) * listMenuQuery.PageSize | ||
35 | + } | ||
36 | +} | ||
37 | + | ||
38 | +func (listMenuQuery *ListMenuQuery) ValidateQuery() error { | ||
39 | + valid := validation.Validation{} | ||
40 | + b, err := valid.Valid(listMenuQuery) | ||
41 | + if err != nil { | ||
42 | + return err | ||
43 | + } | ||
44 | + if !b { | ||
45 | + for _, validErr := range valid.Errors { | ||
46 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
47 | + } | ||
48 | + } | ||
49 | + return nil | ||
50 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/query" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
8 | +) | ||
9 | + | ||
10 | +// 菜单服务 | ||
11 | +type MenuService struct { | ||
12 | +} | ||
13 | + | ||
14 | +// 创建菜单服务 | ||
15 | +func (menuService *MenuService) CreateMenu(createMenuCommand *command.CreateMenuCommand) (interface{}, error) { | ||
16 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
17 | + createMenuCommand.Operator.CompanyId, | ||
18 | + createMenuCommand.Operator.OrgId, | ||
19 | + createMenuCommand.Operator.UserId) | ||
20 | + result, err := creationUserGateway.MenusCreate(allied_creation_user.ReqMenus{ | ||
21 | + ParentId: createMenuCommand.ParentId, | ||
22 | + MenuName: createMenuCommand.MenuName, | ||
23 | + Code: createMenuCommand.Code, | ||
24 | + AccessCode: createMenuCommand.AccessCode, | ||
25 | + MenuType: createMenuCommand.MenuType, | ||
26 | + Icon: createMenuCommand.Icon, | ||
27 | + Sort: createMenuCommand.Sort, | ||
28 | + Desc: createMenuCommand.Desc, | ||
29 | + IsPublish: createMenuCommand.IsPublish, | ||
30 | + }) | ||
31 | + if err != nil { | ||
32 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
33 | + } | ||
34 | + return result, nil | ||
35 | +} | ||
36 | + | ||
37 | +// 返回菜单服务 | ||
38 | +func (menuService *MenuService) GetMenu(getMenuQuery *query.GetMenuQuery) (interface{}, error) { | ||
39 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
40 | + getMenuQuery.Operator.CompanyId, | ||
41 | + getMenuQuery.Operator.OrgId, | ||
42 | + getMenuQuery.Operator.UserId) | ||
43 | + result, err := creationUserGateway.MenusGet(allied_creation_user.ReqMenusGet{ | ||
44 | + MenuId: getMenuQuery.MenuId, | ||
45 | + }) | ||
46 | + if err != nil { | ||
47 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
48 | + } | ||
49 | + return result, nil | ||
50 | +} | ||
51 | + | ||
52 | +// 返回菜单服务列表 | ||
53 | +func (menuService *MenuService) ListMenu(listMenuQuery *query.ListMenuQuery) (interface{}, error) { | ||
54 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
55 | + listMenuQuery.Operator.CompanyId, | ||
56 | + listMenuQuery.Operator.OrgId, | ||
57 | + listMenuQuery.Operator.UserId) | ||
58 | + result, err := creationUserGateway.MenusSearch(allied_creation_user.ReqMenusSearch{ | ||
59 | + MenuCategory: listMenuQuery.MenuCategory, | ||
60 | + ParentId: listMenuQuery.ParentId, | ||
61 | + MenuName: listMenuQuery.MenuName, | ||
62 | + }) | ||
63 | + if err != nil { | ||
64 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
65 | + } | ||
66 | + return result, nil | ||
67 | +} | ||
68 | + | ||
69 | +// 移除菜单服务 | ||
70 | +func (menuService *MenuService) RemoveMenu(removeMenuCommand *command.RemoveMenuCommand) (interface{}, error) { | ||
71 | + | ||
72 | + return struct{}{}, nil | ||
73 | +} | ||
74 | + | ||
75 | +// 更新菜单服务 | ||
76 | +func (menuService *MenuService) UpdateMenu(updateMenuCommand *command.UpdateMenuCommand) (interface{}, error) { | ||
77 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
78 | + updateMenuCommand.Operator.CompanyId, | ||
79 | + updateMenuCommand.Operator.OrgId, | ||
80 | + updateMenuCommand.Operator.UserId) | ||
81 | + result, err := creationUserGateway.MenusUpdate(allied_creation_user.ReqMenusUpdate{ | ||
82 | + MenuId: updateMenuCommand.MenuId, | ||
83 | + ParentId: updateMenuCommand.ParentId, | ||
84 | + MenuName: updateMenuCommand.MenuName, | ||
85 | + Code: updateMenuCommand.Code, | ||
86 | + AccessCode: updateMenuCommand.AccessCode, | ||
87 | + MenuType: updateMenuCommand.MenuType, | ||
88 | + Icon: updateMenuCommand.Icon, | ||
89 | + Sort: updateMenuCommand.Sort, | ||
90 | + Desc: updateMenuCommand.Desc, | ||
91 | + IsPublish: updateMenuCommand.IsPublish, | ||
92 | + }) | ||
93 | + if err != nil { | ||
94 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
95 | + } | ||
96 | + return result, nil | ||
97 | +} | ||
98 | + | ||
99 | +// 批量删除菜单 | ||
100 | +func (menuService *MenuService) BatchDeleteMenu(batchDeleteMenu *command.BatchDeleteMenuCommand) (interface{}, error) { | ||
101 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
102 | + batchDeleteMenu.Operator.CompanyId, | ||
103 | + batchDeleteMenu.Operator.OrgId, | ||
104 | + batchDeleteMenu.Operator.UserId) | ||
105 | + result, err := creationUserGateway.MenusBatchDelete(allied_creation_user.ReqMenusBatchDelete{ | ||
106 | + MenuIds: batchDeleteMenu.MenuIds, | ||
107 | + }) | ||
108 | + if err != nil { | ||
109 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
110 | + } | ||
111 | + return result, nil | ||
112 | +} | ||
113 | + | ||
114 | +// 批量启用菜单 | ||
115 | +func (menuService *MenuService) BatchEnableMenu(batchEnableMenu *command.BatchEnableMenuCommand) (interface{}, error) { | ||
116 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
117 | + batchEnableMenu.Operator.CompanyId, | ||
118 | + batchEnableMenu.Operator.OrgId, | ||
119 | + batchEnableMenu.Operator.UserId) | ||
120 | + result, err := creationUserGateway.MenusBatchEnable(allied_creation_user.ReqMenusBatchEnable{ | ||
121 | + MenuIds: batchEnableMenu.MenuIds, | ||
122 | + Status: batchEnableMenu.Status, | ||
123 | + }) | ||
124 | + if err != nil { | ||
125 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
126 | + } | ||
127 | + return result, nil | ||
128 | +} | ||
129 | + | ||
130 | +func NewMenuService(options map[string]interface{}) *MenuService { | ||
131 | + newMenuService := &MenuService{} | ||
132 | + return newMenuService | ||
133 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/beego/beego/v2/core/validation" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type OrgGetSubDepartmentQuery struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + // 组织ID | ||
14 | + OrgId string `json:"orgId" valid:"Required"` | ||
15 | +} | ||
16 | + | ||
17 | +func (orgGetQuery *OrgGetSubDepartmentQuery) Valid(validation *validation.Validation) { | ||
18 | + | ||
19 | +} | ||
20 | + | ||
21 | +func (orgGetQuery *OrgGetSubDepartmentQuery) ValidateQuery() error { | ||
22 | + valid := validation.Validation{} | ||
23 | + b, err := valid.Valid(orgGetQuery) | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if !b { | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
30 | + } | ||
31 | + } | ||
32 | + return nil | ||
33 | +} |
@@ -141,6 +141,24 @@ func (orgsService *OrgsService) OrgUpdate(orgUpdateCommand *command.OrgUpdateCom | @@ -141,6 +141,24 @@ func (orgsService *OrgsService) OrgUpdate(orgUpdateCommand *command.OrgUpdateCom | ||
141 | return orgUpdateCommand, nil | 141 | return orgUpdateCommand, nil |
142 | } | 142 | } |
143 | 143 | ||
144 | +// 返回组织管理 | ||
145 | +func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSubDepartmentQuery) (interface{}, error) { | ||
146 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
147 | + orgGetQuery.Operator.CompanyId, | ||
148 | + orgGetQuery.Operator.OrgId, | ||
149 | + orgGetQuery.Operator.UserId) | ||
150 | + orgId, _ := strconv.Atoi(orgGetQuery.OrgId) | ||
151 | + result, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{ | ||
152 | + OrgId: int64(orgId), | ||
153 | + }) | ||
154 | + if err != nil { | ||
155 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
156 | + } | ||
157 | + return map[string]interface{}{ | ||
158 | + "list": result.Orgs, | ||
159 | + }, nil | ||
160 | +} | ||
161 | + | ||
144 | func NewOrgsService(options map[string]interface{}) *OrgsService { | 162 | func NewOrgsService(options map[string]interface{}) *OrgsService { |
145 | newOrgsService := &OrgsService{} | 163 | newOrgsService := &OrgsService{} |
146 | return newOrgsService | 164 | return newOrgsService |
@@ -16,15 +16,15 @@ type CompanyUserInfo struct { | @@ -16,15 +16,15 @@ type CompanyUserInfo struct { | ||
16 | Phone string `json:"phone"` | 16 | Phone string `json:"phone"` |
17 | Avatar string `json:"avatar"` | 17 | Avatar string `json:"avatar"` |
18 | EnableStatus int `json:"enableStatus"` | 18 | EnableStatus int `json:"enableStatus"` |
19 | - UsersCode string `json:"usersCode"` | ||
20 | - UsersID string `json:"usersId"` | ||
21 | - UsersName string `json:"usersName"` | 19 | + UsersCode string `json:"userCode"` |
20 | + UsersID string `json:"userId"` | ||
21 | + UsersName string `json:"userName"` | ||
22 | OrgID string `json:"orgId"` | 22 | OrgID string `json:"orgId"` |
23 | OrgName string `json:"orgName"` | 23 | OrgName string `json:"orgName"` |
24 | DepartmentID string `json:"departmentId"` | 24 | DepartmentID string `json:"departmentId"` |
25 | DepartmentName string `json:"departmentName"` | 25 | DepartmentName string `json:"departmentName"` |
26 | - UsersOrg []UserOrg `json:"usersOrg"` | ||
27 | - UsersRole []UserRole `json:"usersRole"` | 26 | + UsersOrg []UserOrg `json:"userOrg"` |
27 | + UsersRole []UserRole `json:"userRole"` | ||
28 | } | 28 | } |
29 | 29 | ||
30 | type UserOrg struct { | 30 | type UserOrg struct { |
@@ -35,10 +35,10 @@ type UserOrg struct { | @@ -35,10 +35,10 @@ type UserOrg struct { | ||
35 | } | 35 | } |
36 | 36 | ||
37 | type UserRole struct { | 37 | type UserRole struct { |
38 | - RoleID string `json:"roleId"` | ||
39 | - RoleName string `json:"roleName"` | ||
40 | - OrgName string `json:"orgName"` | ||
41 | - Descript string `json:"descript"` | 38 | + RoleID string `json:"roleId"` |
39 | + RoleName string `json:"roleName"` | ||
40 | + OrgName string `json:"orgName"` | ||
41 | + Description string `json:"desc"` | ||
42 | } | 42 | } |
43 | 43 | ||
44 | type UserMenu struct { | 44 | type UserMenu struct { |
@@ -32,11 +32,13 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp | @@ -32,11 +32,13 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp | ||
32 | UserId: userid, | 32 | UserId: userid, |
33 | }) | 33 | }) |
34 | if err != nil { | 34 | if err != nil { |
35 | - return nil, err | 35 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
36 | } | 36 | } |
37 | - resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{}) | 37 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ |
38 | + UserId: userid, | ||
39 | + }) | ||
38 | if err != nil { | 40 | if err != nil { |
39 | - return nil, err | 41 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
40 | } | 42 | } |
41 | var ( | 43 | var ( |
42 | usersOrg []dto.UserOrg | 44 | usersOrg []dto.UserOrg |
@@ -221,7 +223,7 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw | @@ -221,7 +223,7 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw | ||
221 | if err != nil { | 223 | if err != nil { |
222 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 224 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
223 | } | 225 | } |
224 | - return companyUserResetPasswordCommand, err | 226 | + return "123456", err |
225 | } | 227 | } |
226 | 228 | ||
227 | // 更新公司用户信息 | 229 | // 更新公司用户信息 |
@@ -485,10 +487,10 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa | @@ -485,10 +487,10 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa | ||
485 | ) | 487 | ) |
486 | for _, v := range result.Roles { | 488 | for _, v := range result.Roles { |
487 | item = dto.UserRole{ | 489 | item = dto.UserRole{ |
488 | - RoleID: strconv.Itoa(int(v.RoleID)), | ||
489 | - RoleName: v.RoleName, | ||
490 | - OrgName: v.Ext.OrgName, | ||
491 | - Descript: v.Desc, | 490 | + RoleID: strconv.Itoa(int(v.RoleID)), |
491 | + RoleName: v.RoleName, | ||
492 | + OrgName: v.Ext.OrgName, | ||
493 | + Description: v.Desc, | ||
492 | } | 494 | } |
493 | dataList = append(dataList, item) | 495 | dataList = append(dataList, item) |
494 | } | 496 | } |
@@ -42,7 +42,7 @@ func (gateway HttplibAlliedCreationUser) MenusCreate(param ReqMenus) (*DataMenus | @@ -42,7 +42,7 @@ func (gateway HttplibAlliedCreationUser) MenusCreate(param ReqMenus) (*DataMenus | ||
42 | 42 | ||
43 | // MenusUpdate 更新菜单 | 43 | // MenusUpdate 更新菜单 |
44 | func (gateway HttplibAlliedCreationUser) MenusUpdate(param ReqMenusUpdate) (*DataMenusUpdate, error) { | 44 | func (gateway HttplibAlliedCreationUser) MenusUpdate(param ReqMenusUpdate) (*DataMenusUpdate, error) { |
45 | - url := gateway.baseUrL + "/menus/" + strconv.FormatInt(param.MenusId, 10) | 45 | + url := gateway.baseUrL + "/menus/" + strconv.FormatInt(param.MenuId, 10) |
46 | method := "put" | 46 | method := "put" |
47 | req := gateway.CreateRequest(url, method) | 47 | req := gateway.CreateRequest(url, method) |
48 | log.Logger.Debug("向用户模块请求数据:更新菜单。", map[string]interface{}{ | 48 | log.Logger.Debug("向用户模块请求数据:更新菜单。", map[string]interface{}{ |
@@ -163,3 +163,65 @@ func (gateway HttplibAlliedCreationUser) MenusSearch(param ReqMenusSearch) (*Dat | @@ -163,3 +163,65 @@ func (gateway HttplibAlliedCreationUser) MenusSearch(param ReqMenusSearch) (*Dat | ||
163 | err = gateway.GetResponseData(result, &data) | 163 | err = gateway.GetResponseData(result, &data) |
164 | return &data, err | 164 | return &data, err |
165 | } | 165 | } |
166 | + | ||
167 | +// MenusBatchDelete 菜单批量删除 | ||
168 | +func (gateway HttplibAlliedCreationUser) MenusBatchDelete(param ReqMenusBatchDelete) (*DataMenusBatchDelete, error) { | ||
169 | + url := gateway.baseUrL + "/menus/batch-delete" | ||
170 | + method := "post" | ||
171 | + req := gateway.CreateRequest(url, method) | ||
172 | + log.Logger.Debug("向用户模块请求数据:菜单批量删除。", map[string]interface{}{ | ||
173 | + "api": method + ":" + url, | ||
174 | + "param": param, | ||
175 | + }) | ||
176 | + req, err := req.JSONBody(param) | ||
177 | + if err != nil { | ||
178 | + return nil, fmt.Errorf("菜单批量删除失败:%w", err) | ||
179 | + } | ||
180 | + | ||
181 | + byteResult, err := req.Bytes() | ||
182 | + if err != nil { | ||
183 | + return nil, fmt.Errorf("菜单批量删除失败:%w", err) | ||
184 | + } | ||
185 | + log.Logger.Debug("获取用户模块请求数据:菜单批量删除。", map[string]interface{}{ | ||
186 | + "result": string(byteResult), | ||
187 | + }) | ||
188 | + var result service_gateway.GatewayResponse | ||
189 | + err = json.Unmarshal(byteResult, &result) | ||
190 | + if err != nil { | ||
191 | + return nil, fmt.Errorf("解析菜单批量删除:%w", err) | ||
192 | + } | ||
193 | + var data DataMenusBatchDelete | ||
194 | + err = gateway.GetResponseData(result, &data) | ||
195 | + return &data, err | ||
196 | +} | ||
197 | + | ||
198 | +// MenusBatchEnable 菜单批量启用、禁用 | ||
199 | +func (gateway HttplibAlliedCreationUser) MenusBatchEnable(param ReqMenusBatchEnable) (*DataMenusBatchEnable, error) { | ||
200 | + url := gateway.baseUrL + "/menus/batch-enable" | ||
201 | + method := "post" | ||
202 | + req := gateway.CreateRequest(url, method) | ||
203 | + log.Logger.Debug("向用户模块请求数据:菜单批量启用、禁用。", map[string]interface{}{ | ||
204 | + "api": method + ":" + url, | ||
205 | + "param": param, | ||
206 | + }) | ||
207 | + req, err := req.JSONBody(param) | ||
208 | + if err != nil { | ||
209 | + return nil, fmt.Errorf("菜单批量启用、禁用失败:%w", err) | ||
210 | + } | ||
211 | + | ||
212 | + byteResult, err := req.Bytes() | ||
213 | + if err != nil { | ||
214 | + return nil, fmt.Errorf("菜单批量启用、禁用失败:%w", err) | ||
215 | + } | ||
216 | + log.Logger.Debug("获取用户模块请求数据:菜单批量启用、禁用。", map[string]interface{}{ | ||
217 | + "result": string(byteResult), | ||
218 | + }) | ||
219 | + var result service_gateway.GatewayResponse | ||
220 | + err = json.Unmarshal(byteResult, &result) | ||
221 | + if err != nil { | ||
222 | + return nil, fmt.Errorf("解析菜单批量启用、禁用:%w", err) | ||
223 | + } | ||
224 | + var data DataMenusBatchEnable | ||
225 | + err = gateway.GetResponseData(result, &data) | ||
226 | + return &data, err | ||
227 | +} |
@@ -362,7 +362,7 @@ func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateB | @@ -362,7 +362,7 @@ func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateB | ||
362 | 362 | ||
363 | //UserUpdateBaseInfo 返回用户有权限的菜单 | 363 | //UserUpdateBaseInfo 返回用户有权限的菜单 |
364 | func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenus) (*DataUserAccessMenus, error) { | 364 | func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenus) (*DataUserAccessMenus, error) { |
365 | - url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/base-info") | 365 | + url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/access-menus") |
366 | method := "get" | 366 | method := "get" |
367 | req := gateway.CreateRequest(url, method) | 367 | req := gateway.CreateRequest(url, method) |
368 | //TODO traceID | 368 | //TODO traceID |
@@ -3,19 +3,82 @@ package allied_creation_user | @@ -3,19 +3,82 @@ package allied_creation_user | ||
3 | //创建菜单 | 3 | //创建菜单 |
4 | type ( | 4 | type ( |
5 | ReqMenus struct { | 5 | ReqMenus struct { |
6 | + // 父级id | ||
7 | + ParentId int64 `json:"parentId,omitempty"` | ||
8 | + // 菜单名称 | ||
9 | + MenuName string `json:"menuName" valid:"Required"` | ||
10 | + // 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码) | ||
11 | + Code string `json:"code" valid:"Required"` | ||
12 | + // 权限编码 user:edit | ||
13 | + AccessCode string `json:"accessCode"` | ||
14 | + // 菜单类型 (目录catalog、菜单menu、按钮button) | ||
15 | + MenuType string `json:"menuType" valid:"Required"` | ||
16 | + // 菜单图标 | ||
17 | + Icon string `json:"icon,omitempty"` | ||
18 | + // 排序 | ||
19 | + Sort int `json:"sort" valid:"Required"` | ||
20 | + // 菜单说明 | ||
21 | + Desc string `json:"desc,omitempty"` | ||
22 | + // 菜单是否公开状态,[2:隐藏],[1:显示],默认显示 | ||
23 | + IsPublish int `json:"isPublish" valid:"Required"` | ||
24 | + // 启用状态(启用:1 禁用:2),默认启用 | ||
25 | + EnableStatus int `json:"enableStatus" ` | ||
6 | } | 26 | } |
7 | 27 | ||
8 | DataMenus struct { | 28 | DataMenus struct { |
29 | + MenuID int `json:"menuId"` | ||
30 | + ParentID int `json:"parentId"` | ||
31 | + MenuName string `json:"menuName"` | ||
32 | + MenuAlias string `json:"menuAlias"` | ||
33 | + Code string `json:"code"` | ||
34 | + AccessCode string `json:"accessCode"` | ||
35 | + MenuType string `json:"menuType"` | ||
36 | + Icon string `json:"icon"` | ||
37 | + Sort int `json:"sort"` | ||
38 | + Category string `json:"category"` | ||
39 | + IsPublish int `json:"isPublish"` | ||
40 | + ParentMenuName string `json:"parentMenuName"` | ||
9 | } | 41 | } |
10 | ) | 42 | ) |
11 | 43 | ||
12 | //更新菜单 | 44 | //更新菜单 |
13 | type ( | 45 | type ( |
14 | ReqMenusUpdate struct { | 46 | ReqMenusUpdate struct { |
15 | - MenusId int64 | 47 | + // 菜单编号 |
48 | + MenuId int64 `json:"menuId" valid:"Required"` | ||
49 | + // 父级id | ||
50 | + ParentId int64 `json:"parentId,omitempty"` | ||
51 | + // 菜单名称 | ||
52 | + MenuName string `json:"menuName" valid:"Required"` | ||
53 | + // 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码) | ||
54 | + Code string `json:"code" valid:"Required"` | ||
55 | + // 权限编码 user:edit | ||
56 | + AccessCode string `json:"accessCode,omitempty"` | ||
57 | + // 菜单类型 (目录catalog、菜单menu、按钮button) | ||
58 | + MenuType string `json:"menuType" valid:"Required"` | ||
59 | + // 菜单图标 | ||
60 | + Icon string `json:"icon,omitempty"` | ||
61 | + // 排序 | ||
62 | + Sort int `json:"sort" valid:"Required"` | ||
63 | + // 菜单说明 | ||
64 | + Desc string `json:"desc,omitempty"` | ||
65 | + // 菜单是否公开状态,[0:隐藏],[1:显示],默认显示 | ||
66 | + IsPublish int `json:"isPublish,omitempty"` | ||
16 | } | 67 | } |
17 | 68 | ||
18 | DataMenusUpdate struct { | 69 | DataMenusUpdate struct { |
70 | + MenuID int `json:"menuId"` | ||
71 | + ParentID int `json:"parentId"` | ||
72 | + MenuName string `json:"menuName"` | ||
73 | + MenuAlias string `json:"menuAlias"` | ||
74 | + Code string `json:"code"` | ||
75 | + AccessCode string `json:"accessCode"` | ||
76 | + MenuType string `json:"menuType"` | ||
77 | + Icon string `json:"icon"` | ||
78 | + Sort int `json:"sort"` | ||
79 | + Category string `json:"category"` | ||
80 | + IsPublish int `json:"isPublish"` | ||
81 | + ParentMenuName string `json:"parentMenuName"` | ||
19 | } | 82 | } |
20 | ) | 83 | ) |
21 | 84 | ||
@@ -26,6 +89,18 @@ type ( | @@ -26,6 +89,18 @@ type ( | ||
26 | } | 89 | } |
27 | 90 | ||
28 | DataMenusRemove struct { | 91 | DataMenusRemove struct { |
92 | + MenuID int `json:"menuId"` | ||
93 | + ParentID int `json:"parentId"` | ||
94 | + MenuName string `json:"menuName"` | ||
95 | + MenuAlias string `json:"menuAlias"` | ||
96 | + Code string `json:"code"` | ||
97 | + AccessCode string `json:"accessCode"` | ||
98 | + MenuType string `json:"menuType"` | ||
99 | + Icon string `json:"icon"` | ||
100 | + Sort int `json:"sort"` | ||
101 | + Category string `json:"category"` | ||
102 | + IsPublish int `json:"isPublish"` | ||
103 | + ParentMenuName string `json:"parentMenuName"` | ||
29 | } | 104 | } |
30 | ) | 105 | ) |
31 | 106 | ||
@@ -36,14 +111,81 @@ type ( | @@ -36,14 +111,81 @@ type ( | ||
36 | } | 111 | } |
37 | 112 | ||
38 | DataMenusGet struct { | 113 | DataMenusGet struct { |
114 | + MenuID int `json:"menuId"` | ||
115 | + ParentID int `json:"parentId"` | ||
116 | + MenuName string `json:"menuName"` | ||
117 | + MenuAlias string `json:"menuAlias"` | ||
118 | + Code string `json:"code"` | ||
119 | + AccessCode string `json:"accessCode"` | ||
120 | + MenuType string `json:"menuType"` | ||
121 | + Icon string `json:"icon"` | ||
122 | + Sort int `json:"sort"` | ||
123 | + Category string `json:"category"` | ||
124 | + IsPublish int `json:"isPublish"` | ||
125 | + ParentMenuName string `json:"parentMenuName"` | ||
39 | } | 126 | } |
40 | ) | 127 | ) |
41 | 128 | ||
42 | //返回菜单列表 | 129 | //返回菜单列表 |
43 | type ( | 130 | type ( |
44 | ReqMenusSearch struct { | 131 | ReqMenusSearch struct { |
132 | + // 菜单类别 web app | ||
133 | + MenuCategory string `json:"menuCategory,omitempty"` | ||
134 | + // 菜单父级id 0:查询所有 n:parent_id为n的菜单列表 | ||
135 | + ParentId int64 `json:"parentId,omitempty"` | ||
136 | + // 菜单名称过滤 | ||
137 | + MenuName string `json:"menuName,omitempty"` | ||
138 | + // 结构类型 树型:tree 列表型:list | ||
139 | + StructType string `json:"structType,omitempty"` | ||
140 | + // 查询偏离量 | ||
141 | + Offset int `json:"offset"` | ||
142 | + // 查询限制 | ||
143 | + Limit int `json:"limit"` | ||
144 | + | ||
145 | + // web分页 | ||
146 | + PageNumber int `json:"pageNumber"` | ||
147 | + PageSize int `json:"pageSize"` | ||
45 | } | 148 | } |
46 | 149 | ||
47 | DataMenusSearch struct { | 150 | DataMenusSearch struct { |
151 | + Count int `json:"count"` | ||
152 | + Menus []struct { | ||
153 | + MenuID int `json:"menuId"` | ||
154 | + ParentID int `json:"parentId"` | ||
155 | + MenuName string `json:"menuName"` | ||
156 | + MenuAlias string `json:"menuAlias"` | ||
157 | + Code string `json:"code"` | ||
158 | + AccessCode string `json:"accessCode,omitempty"` | ||
159 | + MenuType string `json:"menuType"` | ||
160 | + Icon string `json:"icon"` | ||
161 | + Sort int `json:"sort"` | ||
162 | + Remark string `json:"remark,omitempty"` | ||
163 | + Category string `json:"category"` | ||
164 | + IsPublish int `json:"isPublish"` | ||
165 | + EnableStatus int `json:"enableStatus,omitempty"` | ||
166 | + ParentPath string `json:"parentPath,omitempty"` | ||
167 | + } `json:"menus"` | ||
168 | + } | ||
169 | +) | ||
170 | + | ||
171 | +type ( | ||
172 | + ReqMenusBatchDelete struct { | ||
173 | + // 菜单ID列表 | ||
174 | + MenuIds []int64 `cname:"菜单ID列表" json:"menuIds,omitempty"` | ||
175 | + } | ||
176 | + | ||
177 | + DataMenusBatchDelete struct { | ||
178 | + } | ||
179 | +) | ||
180 | + | ||
181 | +type ( | ||
182 | + ReqMenusBatchEnable struct { | ||
183 | + // 菜单ID列表 | ||
184 | + MenuIds []int64 `cname:"菜单ID列表" json:"menuIds,omitempty"` | ||
185 | + // 菜单状态 | ||
186 | + Status int `cname:"菜单状态" json:"status,omitempty"` | ||
187 | + } | ||
188 | + | ||
189 | + DataMenusBatchEnable struct { | ||
48 | } | 190 | } |
49 | ) | 191 | ) |
1 | +package backgroud_client | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | +) | ||
7 | + | ||
8 | +type baseController struct { | ||
9 | + beego.BaseController | ||
10 | +} | ||
11 | + | ||
12 | +func (controller *baseController) returnPageListData(count int64, data interface{}, err error, pageNumber int) { | ||
13 | + dataMap := map[string]interface{}{ | ||
14 | + "grid": map[string]interface{}{ | ||
15 | + "total": count, | ||
16 | + //"pageNumber": pageNumber, | ||
17 | + "list": data, | ||
18 | + }, | ||
19 | + } | ||
20 | + controller.Response(dataMap, err) | ||
21 | +} | ||
22 | + | ||
23 | +func (controller *baseController) GetUserId() int64 { | ||
24 | + return 1 | ||
25 | +} | ||
26 | + | ||
27 | +func (controller *baseController) GetCompanyId() int64 { | ||
28 | + return 1 | ||
29 | +} | ||
30 | + | ||
31 | +func (controller *baseController) GetUserBaseId() int64 { | ||
32 | + return 1 | ||
33 | +} | ||
34 | + | ||
35 | +func (controller *baseController) GetOrgId() int64 { | ||
36 | + return 1 | ||
37 | +} | ||
38 | + | ||
39 | +func (controller *baseController) GetOperator() domain.Operator { | ||
40 | + return domain.Operator{ | ||
41 | + UserId: 9, | ||
42 | + CompanyId: 23, | ||
43 | + OrgId: 45, | ||
44 | + UserBaseId: 1, | ||
45 | + } | ||
46 | +} |
1 | +package backgroud_client | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/command" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/query" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/service" | ||
7 | +) | ||
8 | + | ||
9 | +type MenuController struct { | ||
10 | + baseController | ||
11 | +} | ||
12 | + | ||
13 | +func (controller *MenuController) CreateMenu() { | ||
14 | + menuService := service.NewMenuService(nil) | ||
15 | + createMenuCommand := &command.CreateMenuCommand{} | ||
16 | + controller.Unmarshal(createMenuCommand) | ||
17 | + createMenuCommand.Operator = controller.GetOperator() | ||
18 | + data, err := menuService.CreateMenu(createMenuCommand) | ||
19 | + controller.Response(data, err) | ||
20 | +} | ||
21 | + | ||
22 | +func (controller *MenuController) UpdateMenu() { | ||
23 | + menuService := service.NewMenuService(nil) | ||
24 | + updateMenuCommand := &command.UpdateMenuCommand{} | ||
25 | + controller.Unmarshal(updateMenuCommand) | ||
26 | + Id, _ := controller.GetInt64(":menuId") | ||
27 | + updateMenuCommand.MenuId = Id | ||
28 | + updateMenuCommand.Operator = controller.GetOperator() | ||
29 | + data, err := menuService.UpdateMenu(updateMenuCommand) | ||
30 | + controller.Response(data, err) | ||
31 | +} | ||
32 | + | ||
33 | +func (controller *MenuController) GetMenu() { | ||
34 | + menuService := service.NewMenuService(nil) | ||
35 | + getMenuQuery := &query.GetMenuQuery{} | ||
36 | + Id, _ := controller.GetInt64(":menuId") | ||
37 | + getMenuQuery.MenuId = Id | ||
38 | + getMenuQuery.Operator = controller.GetOperator() | ||
39 | + data, err := menuService.GetMenu(getMenuQuery) | ||
40 | + controller.Response(data, err) | ||
41 | +} | ||
42 | + | ||
43 | +func (controller *MenuController) RemoveMenu() { | ||
44 | + menuService := service.NewMenuService(nil) | ||
45 | + removeMenuCommand := &command.RemoveMenuCommand{} | ||
46 | + controller.Unmarshal(removeMenuCommand) | ||
47 | + Id, _ := controller.GetInt64(":menuId") | ||
48 | + removeMenuCommand.MenuId = Id | ||
49 | + removeMenuCommand.Operator = controller.GetOperator() | ||
50 | + data, err := menuService.RemoveMenu(removeMenuCommand) | ||
51 | + controller.Response(data, err) | ||
52 | +} | ||
53 | + | ||
54 | +func (controller *MenuController) ListMenu() { | ||
55 | + menuService := service.NewMenuService(nil) | ||
56 | + listMenuQuery := &query.ListMenuQuery{} | ||
57 | + offset, _ := controller.GetInt("offset") | ||
58 | + listMenuQuery.Offset = offset | ||
59 | + limit, _ := controller.GetInt("limit") | ||
60 | + listMenuQuery.Limit = limit | ||
61 | + listMenuQuery.MenuCategory = controller.GetString("menuCategory") | ||
62 | + listMenuQuery.ParentId, _ = controller.GetInt64("parentId", 0) | ||
63 | + listMenuQuery.MenuName = controller.GetString("menuName") | ||
64 | + listMenuQuery.StructType = controller.GetString("structType") | ||
65 | + listMenuQuery.Operator = controller.GetOperator() | ||
66 | + data, err := menuService.ListMenu(listMenuQuery) | ||
67 | + controller.Response(data, err) | ||
68 | +} | ||
69 | + | ||
70 | +func (controller *MenuController) SearchMenu() { | ||
71 | + menuService := service.NewMenuService(nil) | ||
72 | + listMenuQuery := &query.ListMenuQuery{} | ||
73 | + controller.Unmarshal(listMenuQuery) | ||
74 | + listMenuQuery.Offset = 0 | ||
75 | + listMenuQuery.Limit = 0 | ||
76 | + listMenuQuery.Operator = controller.GetOperator() | ||
77 | + data, err := menuService.ListMenu(listMenuQuery) | ||
78 | + controller.Response(data, err) | ||
79 | +} | ||
80 | + | ||
81 | +func (controller *MenuController) BatchDeleteMenu() { | ||
82 | + menuService := service.NewMenuService(nil) | ||
83 | + batchDeleteMenuCommand := &command.BatchDeleteMenuCommand{} | ||
84 | + controller.Unmarshal(batchDeleteMenuCommand) | ||
85 | + batchDeleteMenuCommand.Operator = controller.GetOperator() | ||
86 | + data, err := menuService.BatchDeleteMenu(batchDeleteMenuCommand) | ||
87 | + controller.Response(data, err) | ||
88 | +} | ||
89 | + | ||
90 | +func (controller *MenuController) BatchEnableMenu() { | ||
91 | + menuService := service.NewMenuService(nil) | ||
92 | + batchEnableMenu := &command.BatchEnableMenuCommand{} | ||
93 | + controller.Unmarshal(batchEnableMenu) | ||
94 | + batchEnableMenu.Operator = controller.GetOperator() | ||
95 | + data, err := menuService.BatchEnableMenu(batchEnableMenu) | ||
96 | + controller.Response(data, err) | ||
97 | +} |
@@ -57,3 +57,12 @@ func (controller *OrgsController) OrgEnable() { | @@ -57,3 +57,12 @@ func (controller *OrgsController) OrgEnable() { | ||
57 | data, err := orgsService.OrgEnable(orgEnableCommand) | 57 | data, err := orgsService.OrgEnable(orgEnableCommand) |
58 | controller.Response(data, err) | 58 | controller.Response(data, err) |
59 | } | 59 | } |
60 | + | ||
61 | +func (controller *OrgsController) OrgGetSubDepartment() { | ||
62 | + orgsService := service.NewOrgsService(nil) | ||
63 | + orgGetSubDepartmentQuery := &query.OrgGetSubDepartmentQuery{} | ||
64 | + controller.Unmarshal(orgGetSubDepartmentQuery) | ||
65 | + orgGetSubDepartmentQuery.Operator = controller.GetOperator() | ||
66 | + data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery) | ||
67 | + controller.Response(data, err) | ||
68 | +} |
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + web.Router("/v1/background/menus/", &backgroud_client.MenuController{}, "Post:CreateMenu") | ||
10 | + web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Put:UpdateMenu") | ||
11 | + web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Get:GetMenu") | ||
12 | + //web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Delete:RemoveMenu") | ||
13 | + //web.Router("/v1/background/menus/search", &backgroud_client.MenuController{}, "Get:ListMenu") | ||
14 | + web.Router("/v1/background/menus/search", &backgroud_client.MenuController{}, "Post:SearchMenu") | ||
15 | + web.Router("/v1/background/menus/batch-delete", &backgroud_client.MenuController{}, "Post:BatchDeleteMenu") | ||
16 | + web.Router("/v1/background/menus/batch-enable", &backgroud_client.MenuController{}, "Post:BatchEnableMenu") | ||
17 | +} |
@@ -11,4 +11,5 @@ func init() { | @@ -11,4 +11,5 @@ func init() { | ||
11 | web.Router("/v1/web/orgs/search", &web_client.OrgsController{}, "Post:OrgList") | 11 | web.Router("/v1/web/orgs/search", &web_client.OrgsController{}, "Post:OrgList") |
12 | web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet") | 12 | web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet") |
13 | web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable") | 13 | web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable") |
14 | + web.Router("/v1/web/orgs/departments", &web_client.OrgsController{}, "Post:OrgGetSubDepartment") | ||
14 | } | 15 | } |
-
请 注册 或 登录 后发表评论