Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev
正在显示
30 个修改的文件
包含
1198 行增加
和
1 行删除
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 UserInfoCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (userInfoCommand *UserInfoCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (userInfoCommand *UserInfoCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(userInfoCommand) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 UserMenusCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (userMenusCommand *UserMenusCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (userMenusCommand *UserMenusCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(userMenusCommand) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 UserOrgCommand struct { | ||
10 | + //操作人 | ||
11 | + Operator domain.Operator `json:"-"` | ||
12 | +} | ||
13 | + | ||
14 | +func (userOrgCommand *UserOrgCommand) Valid(validation *validation.Validation) { | ||
15 | + | ||
16 | +} | ||
17 | + | ||
18 | +func (userOrgCommand *UserOrgCommand) ValidateCommand() error { | ||
19 | + valid := validation.Validation{} | ||
20 | + b, err := valid.Valid(userOrgCommand) | ||
21 | + if err != nil { | ||
22 | + return err | ||
23 | + } | ||
24 | + if !b { | ||
25 | + for _, validErr := range valid.Errors { | ||
26 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
27 | + } | ||
28 | + } | ||
29 | + return nil | ||
30 | +} |
@@ -326,3 +326,77 @@ loopUser1: | @@ -326,3 +326,77 @@ loopUser1: | ||
326 | "expiresIn": currentAccess.AccessExpired - nowTime, | 326 | "expiresIn": currentAccess.AccessExpired - nowTime, |
327 | }, nil | 327 | }, nil |
328 | } | 328 | } |
329 | + | ||
330 | +//GetUserMenus 获取用户信息 | ||
331 | +func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (interface{}, error) { | ||
332 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
333 | + userInfoCommand.Operator) | ||
334 | + resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{ | ||
335 | + UserId: int(userInfoCommand.Operator.UserId), | ||
336 | + }) | ||
337 | + if err != nil { | ||
338 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
339 | + } | ||
340 | + var user = map[string]interface{}{ | ||
341 | + "userId": resultUser.UserId, | ||
342 | + "userInfo": map[string]interface{}{ | ||
343 | + "userName": resultUser.UserInfo.UserName, | ||
344 | + "userPhone": resultUser.UserInfo.Phone, | ||
345 | + "userAvatar": resultUser.UserInfo.Avatar, | ||
346 | + }, | ||
347 | + "department": resultUser.Department, | ||
348 | + "company": map[string]interface{}{ | ||
349 | + "companyId": resultUser.Company.CompanyId, | ||
350 | + "companyName": resultUser.Company.CompanyName, | ||
351 | + "logo": resultUser.Company.Log, | ||
352 | + }, | ||
353 | + "im": resultUser.IM, | ||
354 | + "org": resultUser.Org, | ||
355 | + } | ||
356 | + | ||
357 | + return map[string]interface{}{ | ||
358 | + "user": user, | ||
359 | + }, nil | ||
360 | +} | ||
361 | + | ||
362 | +//GetUserMenus 获取用户菜单 | ||
363 | +func (srv AuthService) GetUserMenus(userMenusCommand *command.UserMenusCommand) (interface{}, error) { | ||
364 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
365 | + userMenusCommand.Operator) | ||
366 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
367 | + UserId: int(userMenusCommand.Operator.UserId), | ||
368 | + }) | ||
369 | + if err != nil { | ||
370 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
371 | + } | ||
372 | + return map[string]interface{}{ | ||
373 | + "accessMenus": resultMenu.Menus, | ||
374 | + }, nil | ||
375 | +} | ||
376 | + | ||
377 | +//GetUserMenus 获取用户组织 | ||
378 | +func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (interface{}, error) { | ||
379 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(userOrgCommand.Operator) | ||
380 | + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
381 | + Offset: 0, | ||
382 | + Limit: 100, | ||
383 | + UserBaseId: userOrgCommand.Operator.UserBaseId, | ||
384 | + UserType: domain.UserTypeEmployee, | ||
385 | + EnableStatus: domain.UserStatusEnable, | ||
386 | + PullRealTime: true, | ||
387 | + }) | ||
388 | + if err != nil { | ||
389 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
390 | + } | ||
391 | + var res = make([]interface{}, 0) | ||
392 | + for i := range result.Users { | ||
393 | + for j := range result.Users[i].UserOrg { | ||
394 | + org := result.Users[i].UserOrg[j] | ||
395 | + res = append(res, map[string]interface{}{ | ||
396 | + "orgId": org.OrgID, | ||
397 | + "orgName": org.OrgName, | ||
398 | + }) | ||
399 | + } | ||
400 | + } | ||
401 | + return res, nil | ||
402 | +} |
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 | +// Command | ||
10 | +type DividendsStatisticsCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *DividendsStatisticsCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 | +// Command | ||
10 | +type GetDividendContractsCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *GetDividendContractsCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *GetDividendContractsCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 | +// Command | ||
10 | +type SearchDividendsEstimatesCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *SearchDividendsEstimatesCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *SearchDividendsEstimatesCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 | +// Command | ||
10 | +type CooperationDividendsStatisticsCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *CooperationDividendsStatisticsCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *CooperationDividendsStatisticsCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 | +// Command | ||
10 | +type CooperationPersonStatisticsCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *CooperationPersonStatisticsCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *CooperationPersonStatisticsCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 | +// Command | ||
10 | +type GoodsStatisticsCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *GoodsStatisticsCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *GoodsStatisticsCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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 | +// Command | ||
10 | +type IndexStatisticsCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | +} | ||
14 | + | ||
15 | +func (cmd *IndexStatisticsCommand) Valid(validation *validation.Validation) { | ||
16 | + | ||
17 | +} | ||
18 | + | ||
19 | +func (cmd *IndexStatisticsCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(cmd) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
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/mobile/cooperation/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
7 | +) | ||
8 | + | ||
9 | +// 企业端分红服务 | ||
10 | +type CompanyDividendsService struct { | ||
11 | +} | ||
12 | + | ||
13 | +// IndexStatistics TODO:企业的合约列表(分红信息按合约划分) | ||
14 | +func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (interface{}, error) { | ||
15 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
16 | + userMenusCommand.Operator) | ||
17 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
18 | + UserId: int(userMenusCommand.Operator.UserId), | ||
19 | + }) | ||
20 | + if err != nil { | ||
21 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
22 | + } | ||
23 | + return map[string]interface{}{ | ||
24 | + "accessMenus": resultMenu.Menus, | ||
25 | + }, nil | ||
26 | +} | ||
27 | + | ||
28 | +// IndexStatistics TODO:企业的合约统计(分红统计) | ||
29 | +func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) { | ||
30 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
31 | + userMenusCommand.Operator) | ||
32 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
33 | + UserId: int(userMenusCommand.Operator.UserId), | ||
34 | + }) | ||
35 | + if err != nil { | ||
36 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
37 | + } | ||
38 | + return map[string]interface{}{ | ||
39 | + "accessMenus": resultMenu.Menus, | ||
40 | + }, nil | ||
41 | +} | ||
42 | + | ||
43 | +// IndexStatistics TODO:企业的合约明细列表(分红预算信息) | ||
44 | +func (srv CompanyStatisticsService) SearchDividendsEstimates(userMenusCommand *command.SearchDividendsEstimatesCommand) (interface{}, error) { | ||
45 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
46 | + userMenusCommand.Operator) | ||
47 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
48 | + UserId: int(userMenusCommand.Operator.UserId), | ||
49 | + }) | ||
50 | + if err != nil { | ||
51 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
52 | + } | ||
53 | + return map[string]interface{}{ | ||
54 | + "accessMenus": resultMenu.Menus, | ||
55 | + }, nil | ||
56 | +} |
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/mobile/cooperation/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
7 | +) | ||
8 | + | ||
9 | +// 企业端统计 | ||
10 | +type CompanyStatisticsService struct { | ||
11 | +} | ||
12 | + | ||
13 | +// IndexStatistics TODO:首页统计 (入口页面统计数据) | ||
14 | +func (srv CompanyStatisticsService) IndexStatistics(userMenusCommand *command.IndexStatisticsCommand) (interface{}, error) { | ||
15 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
16 | + userMenusCommand.Operator) | ||
17 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
18 | + UserId: int(userMenusCommand.Operator.UserId), | ||
19 | + }) | ||
20 | + if err != nil { | ||
21 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
22 | + } | ||
23 | + return map[string]interface{}{ | ||
24 | + "accessMenus": resultMenu.Menus, | ||
25 | + }, nil | ||
26 | +} | ||
27 | + | ||
28 | +// IndexStatistics TODO:共创人员统计(共创人员明细) | ||
29 | +func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) { | ||
30 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
31 | + userMenusCommand.Operator) | ||
32 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
33 | + UserId: int(userMenusCommand.Operator.UserId), | ||
34 | + }) | ||
35 | + if err != nil { | ||
36 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
37 | + } | ||
38 | + return map[string]interface{}{ | ||
39 | + "accessMenus": resultMenu.Menus, | ||
40 | + }, nil | ||
41 | +} | ||
42 | + | ||
43 | +// IndexStatistics TODO:产品统计排行榜 年月榜 | ||
44 | +func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.GoodsStatisticsCommand) (interface{}, error) { | ||
45 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
46 | + userMenusCommand.Operator) | ||
47 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
48 | + UserId: int(userMenusCommand.Operator.UserId), | ||
49 | + }) | ||
50 | + if err != nil { | ||
51 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
52 | + } | ||
53 | + return map[string]interface{}{ | ||
54 | + "accessMenus": resultMenu.Menus, | ||
55 | + }, nil | ||
56 | +} | ||
57 | + | ||
58 | +// IndexStatistics TODO:共创分红支出统计 | ||
59 | +func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) { | ||
60 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
61 | + userMenusCommand.Operator) | ||
62 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
63 | + UserId: int(userMenusCommand.Operator.UserId), | ||
64 | + }) | ||
65 | + if err != nil { | ||
66 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
67 | + } | ||
68 | + return map[string]interface{}{ | ||
69 | + "accessMenus": resultMenu.Menus, | ||
70 | + }, nil | ||
71 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + "time" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type CreateCompanyCommand struct { | ||
13 | + // 企业名称 | ||
14 | + CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"` | ||
15 | + // 规模 | ||
16 | + Scale string `cname:"规模" json:"scale" valid:"Required"` | ||
17 | + // 公司Logo地址 | ||
18 | + Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"` | ||
19 | + // 公司地址 | ||
20 | + Address string `cname:"公司地址" json:"address" valid:"Required"` | ||
21 | + // 所属行业 | ||
22 | + IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"` | ||
23 | + // 联系人 | ||
24 | + Contacts string `cname:"联系人" json:"contacts" valid:"Required"` | ||
25 | + // 注册时间 | ||
26 | + RegisteredTime time.Time `cname:"注册时间" json:"registeredTime,omitempty"` | ||
27 | + // 注册状态 1:已注册 2:待认证 3:已认证 | ||
28 | + Status int `cname:"注册状态 1:已注册 2:待认证 3:已认证" json:"status,omitempty"` | ||
29 | +} | ||
30 | + | ||
31 | +func (createCompanyCommand *CreateCompanyCommand) Valid(validation *validation.Validation) { | ||
32 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
33 | +} | ||
34 | + | ||
35 | +func (createCompanyCommand *CreateCompanyCommand) ValidateCommand() error { | ||
36 | + valid := validation.Validation{} | ||
37 | + b, err := valid.Valid(createCompanyCommand) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + if !b { | ||
42 | + elem := reflect.TypeOf(createCompanyCommand).Elem() | ||
43 | + for _, validErr := range valid.Errors { | ||
44 | + field, isExist := elem.FieldByName(validErr.Field) | ||
45 | + if isExist { | ||
46 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
47 | + } else { | ||
48 | + return fmt.Errorf(validErr.Message) | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + return nil | ||
53 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListCompanyCustomizeMenusCommand struct { | ||
12 | + // 企业id | ||
13 | + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` | ||
14 | + // 菜单类别 web app | ||
15 | + MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) { | ||
19 | + | ||
20 | +} | ||
21 | + | ||
22 | +func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) ValidateCommand() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(listCompanyCustomizeMenusCommand) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(listCompanyCustomizeMenusCommand).Elem() | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + field, isExist := elem.FieldByName(validErr.Field) | ||
32 | + if isExist { | ||
33 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
34 | + } else { | ||
35 | + return fmt.Errorf(validErr.Message) | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + return nil | ||
40 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type RemoveCompanyCommand struct { | ||
12 | + // 企业id | ||
13 | + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeCompanyCommand *RemoveCompanyCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeCompanyCommand *RemoveCompanyCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeCompanyCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeCompanyCommand).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
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 UpdateCompanyCommand struct { | ||
13 | + //操作人 | ||
14 | + Operator domain.Operator `json:"-"` | ||
15 | + // 企业名称 | ||
16 | + CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"` | ||
17 | + // 公司地址 | ||
18 | + Address string `cname:"公司地址" json:"address" valid:"Required"` | ||
19 | + // 系统名称 | ||
20 | + SystemName string `cname:"系统名称" json:"systemName" valid:"Required"` | ||
21 | + // 公司Logo地址 | ||
22 | + Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"` | ||
23 | +} | ||
24 | + | ||
25 | +func (updateCompanyCommand *UpdateCompanyCommand) Valid(validation *validation.Validation) { | ||
26 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
27 | +} | ||
28 | + | ||
29 | +func (updateCompanyCommand *UpdateCompanyCommand) ValidateCommand() error { | ||
30 | + valid := validation.Validation{} | ||
31 | + b, err := valid.Valid(updateCompanyCommand) | ||
32 | + if err != nil { | ||
33 | + return err | ||
34 | + } | ||
35 | + if !b { | ||
36 | + elem := reflect.TypeOf(updateCompanyCommand).Elem() | ||
37 | + for _, validErr := range valid.Errors { | ||
38 | + field, isExist := elem.FieldByName(validErr.Field) | ||
39 | + if isExist { | ||
40 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
41 | + } else { | ||
42 | + return fmt.Errorf(validErr.Message) | ||
43 | + } | ||
44 | + } | ||
45 | + } | ||
46 | + return nil | ||
47 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type UpdateCompanyCustomizeMenusCommand struct { | ||
12 | + // 企业id | ||
13 | + CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"` | ||
14 | + // 菜单编号 | ||
15 | + MenuId int64 `cname:"菜单编号" json:"menuId" valid:"Required"` | ||
16 | + // 菜单名称 | ||
17 | + //MenuName string `cname:"菜单名称" json:"menuName" valid:"Required"` | ||
18 | + // 菜单别名 | ||
19 | + MenuAlias string `cname:"菜单别名" json:"menuAlias" valid:"Required"` | ||
20 | + // 排序 | ||
21 | + Sort int `cname:"排序" json:"sort" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) { | ||
25 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) ValidateCommand() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(updateCompanyCustomizeMenusCommand) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(updateCompanyCustomizeMenusCommand).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type GetCompanyQuery struct { | ||
12 | + // 企业id | ||
13 | + CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (getCompanyQuery *GetCompanyQuery) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (getCompanyQuery *GetCompanyQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(getCompanyQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(getCompanyQuery).Elem() | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + field, isExist := elem.FieldByName(validErr.Field) | ||
30 | + if isExist { | ||
31 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
32 | + } else { | ||
33 | + return fmt.Errorf(validErr.Message) | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListCompanyQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) { | ||
19 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | +} | ||
21 | + | ||
22 | +func (listCompanyQuery *ListCompanyQuery) ValidateQuery() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(listCompanyQuery) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(listCompanyQuery).Elem() | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + field, isExist := elem.FieldByName(validErr.Field) | ||
32 | + if isExist { | ||
33 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
34 | + } else { | ||
35 | + return fmt.Errorf(validErr.Message) | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | + return nil | ||
40 | +} |
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/web/company/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/query" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
8 | +) | ||
9 | + | ||
10 | +// 企业 | ||
11 | +type CompanyService struct { | ||
12 | +} | ||
13 | + | ||
14 | +// 创建企业 | ||
15 | +func (companyService *CompanyService) CreateCompany(createCompanyCommand *command.CreateCompanyCommand) (interface{}, error) { | ||
16 | + return nil, nil | ||
17 | +} | ||
18 | + | ||
19 | +// 返回企业 | ||
20 | +func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompanyQuery) (interface{}, error) { | ||
21 | + return nil, nil | ||
22 | +} | ||
23 | + | ||
24 | +// 返回企业列表 | ||
25 | +func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCompanyQuery) (interface{}, error) { | ||
26 | + return nil, nil | ||
27 | +} | ||
28 | + | ||
29 | +// 返回自定义菜单列表(匹配有设置的菜单) | ||
30 | +func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand *command.ListCompanyCustomizeMenusCommand) (interface{}, error) { | ||
31 | + return nil, nil | ||
32 | +} | ||
33 | + | ||
34 | +// 移除企业 | ||
35 | +func (companyService *CompanyService) RemoveCompany(removeCompanyCommand *command.RemoveCompanyCommand) (interface{}, error) { | ||
36 | + return nil, nil | ||
37 | +} | ||
38 | + | ||
39 | +// 更新企业 | ||
40 | +func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *command.UpdateCompanyCommand) (interface{}, error) { | ||
41 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(updateCompanyCommand.Operator) | ||
42 | + _, err := creationUserGateway.CompanyUpdate(allied_creation_user.ReqCompanyUpdate{ | ||
43 | + CompanyId: updateCompanyCommand.Operator.CompanyId, | ||
44 | + CompanyName: updateCompanyCommand.CompanyName, | ||
45 | + Address: updateCompanyCommand.Address, | ||
46 | + SystemName: updateCompanyCommand.SystemName, | ||
47 | + Logo: updateCompanyCommand.Logo, | ||
48 | + }) | ||
49 | + if err != nil { | ||
50 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
51 | + } | ||
52 | + return updateCompanyCommand, nil | ||
53 | +} | ||
54 | + | ||
55 | +// 更新自定义菜单 | ||
56 | +func (companyService *CompanyService) UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand *command.UpdateCompanyCustomizeMenusCommand) (interface{}, error) { | ||
57 | + return nil, nil | ||
58 | +} | ||
59 | + | ||
60 | +func NewCompanyService(options map[string]interface{}) *CompanyService { | ||
61 | + newCompanyService := &CompanyService{} | ||
62 | + return newCompanyService | ||
63 | +} |
pkg/domain/enums.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +/***** 1.用户模块 *****/ | ||
4 | +// 用户类型 | ||
5 | +const ( | ||
6 | + UserTypeEmployee = 1 | ||
7 | + UserTypeCooperation = 2 | ||
8 | + UserTypeCompanyAdmin = 1024 | ||
9 | +) | ||
10 | + | ||
11 | +// 用户状态 | ||
12 | +const ( | ||
13 | + UserStatusEnable int = 1 | ||
14 | + UserStatusDisable int = 2 | ||
15 | + UserStatusDestroy int = 3 | ||
16 | +) | ||
17 | + | ||
18 | +/***** 2.菜单模块 *****/ | ||
19 | +// 菜单启用状态 结合用户菜单权限 | ||
20 | +const ( | ||
21 | + MenuStatusEnable = 1 // 菜单启用 | ||
22 | + MenuStatusDisable = 2 // 菜单禁用 | ||
23 | +) | ||
24 | + | ||
25 | +// 菜单公开状态 | ||
26 | +const ( | ||
27 | + MenuPublic = 1 // 菜单公开 | ||
28 | + MenuPrivate = 2 // 菜单未公开 | ||
29 | +) | ||
30 | + | ||
31 | +const ( | ||
32 | + WebMenuCode = "web" | ||
33 | + AppMenuCode = "app" | ||
34 | +) | ||
35 | + | ||
36 | +/***** 3.组织模块 *****/ | ||
37 | +const ( | ||
38 | + IsOrgFlag = 1 // 标记为组织 | ||
39 | + IsNotOrgFlag = 2 // 标记为非组织 | ||
40 | +) | ||
41 | + | ||
42 | +const ( | ||
43 | + OrgStatusEnable = 1 | ||
44 | + OrgStatusDisable = 2 | ||
45 | +) |
@@ -12,7 +12,11 @@ type ( | @@ -12,7 +12,11 @@ type ( | ||
12 | //更新企业 | 12 | //更新企业 |
13 | type ( | 13 | type ( |
14 | ReqCompanyUpdate struct { | 14 | ReqCompanyUpdate struct { |
15 | - CompanyId int64 | 15 | + CompanyId int64 |
16 | + CompanyName string `json:"companyName"` | ||
17 | + Address string `json:"address"` | ||
18 | + SystemName string `json:"systemName"` | ||
19 | + Logo string `json:"logo"` | ||
16 | } | 20 | } |
17 | 21 | ||
18 | DataCompanyUpdate struct { | 22 | DataCompanyUpdate struct { |
@@ -31,6 +31,9 @@ type UserDetail struct { | @@ -31,6 +31,9 @@ type UserDetail struct { | ||
31 | IndustryCategory string `json:"industryCategory"` | 31 | IndustryCategory string `json:"industryCategory"` |
32 | RegisteredTime time.Time `json:"registeredTime"` | 32 | RegisteredTime time.Time `json:"registeredTime"` |
33 | Status int64 `json:"status"` | 33 | Status int64 `json:"status"` |
34 | + Log string `json:"log"` | ||
35 | + Address string `json:"address"` | ||
36 | + SystemName string `json:"systemName"` | ||
34 | } `json:"company,omitempty"` | 37 | } `json:"company,omitempty"` |
35 | Org *struct { | 38 | Org *struct { |
36 | OrgId int `json:"orgId"` | 39 | OrgId int `json:"orgId"` |
@@ -55,6 +58,11 @@ type UserDetail struct { | @@ -55,6 +58,11 @@ type UserDetail struct { | ||
55 | DeletedAt time.Time `json:"deletedAt"` | 58 | DeletedAt time.Time `json:"deletedAt"` |
56 | OrgName string `json:"orgName"` | 59 | OrgName string `json:"orgName"` |
57 | } `json:"userOrg"` | 60 | } `json:"userOrg"` |
61 | + IM struct { | ||
62 | + Accid string `json:"accid"` | ||
63 | + ImToken string `json:"imToken"` | ||
64 | + CsAccountID string `json:"csAccountId"` | ||
65 | + } `json:"im"` | ||
58 | } | 66 | } |
59 | 67 | ||
60 | //搜索用户列表 | 68 | //搜索用户列表 |
@@ -64,6 +72,8 @@ type ( | @@ -64,6 +72,8 @@ type ( | ||
64 | Offset int `json:"offset"` | 72 | Offset int `json:"offset"` |
65 | // 查询限制 | 73 | // 查询限制 |
66 | Limit int `json:"limit"` | 74 | Limit int `json:"limit"` |
75 | + // 用户基础id | ||
76 | + UserBaseId int64 ` json:"userBaseId"` | ||
67 | // 企业id | 77 | // 企业id |
68 | CompanyId int64 ` json:"companyId"` | 78 | CompanyId int64 ` json:"companyId"` |
69 | // 组织ID | 79 | // 组织ID |
@@ -84,6 +94,8 @@ type ( | @@ -84,6 +94,8 @@ type ( | ||
84 | InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"` | 94 | InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"` |
85 | // 实时拉取数据 (获取最新的) | 95 | // 实时拉取数据 (获取最新的) |
86 | PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"` | 96 | PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"` |
97 | + // 状态(1:启用 2:禁用 3:注销) | ||
98 | + EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"` | ||
87 | } | 99 | } |
88 | 100 | ||
89 | //DataUserSearch 搜索用户列表 | 101 | //DataUserSearch 搜索用户列表 |
@@ -44,3 +44,42 @@ func (controller *AuthController) RefreshAuthAccessToken() { | @@ -44,3 +44,42 @@ func (controller *AuthController) RefreshAuthAccessToken() { | ||
44 | data, err := authService.RefreshAuthAccessToken(refreshTokenCmd) | 44 | data, err := authService.RefreshAuthAccessToken(refreshTokenCmd) |
45 | controller.Response(data, err) | 45 | controller.Response(data, err) |
46 | } | 46 | } |
47 | + | ||
48 | +func (controller *AuthController) GetUserInfo() { | ||
49 | + authService := service.AuthService{} | ||
50 | + userInfoCommand := &command.UserInfoCommand{} | ||
51 | + err := controller.Unmarshal(userInfoCommand) | ||
52 | + if err != nil { | ||
53 | + controller.Response(nil, err) | ||
54 | + return | ||
55 | + } | ||
56 | + userInfoCommand.Operator = controller.GetOperator() | ||
57 | + data, err := authService.GetUserInfo(userInfoCommand) | ||
58 | + controller.Response(data, err) | ||
59 | +} | ||
60 | + | ||
61 | +func (controller *AuthController) GetUserMenus() { | ||
62 | + authService := service.AuthService{} | ||
63 | + userMenusCommand := &command.UserMenusCommand{} | ||
64 | + err := controller.Unmarshal(userMenusCommand) | ||
65 | + if err != nil { | ||
66 | + controller.Response(nil, err) | ||
67 | + return | ||
68 | + } | ||
69 | + userMenusCommand.Operator = controller.GetOperator() | ||
70 | + data, err := authService.GetUserMenus(userMenusCommand) | ||
71 | + controller.Response(data, err) | ||
72 | +} | ||
73 | + | ||
74 | +func (controller *AuthController) GetUserOrg() { | ||
75 | + authService := service.AuthService{} | ||
76 | + userOrgCommand := &command.UserOrgCommand{} | ||
77 | + err := controller.Unmarshal(userOrgCommand) | ||
78 | + if err != nil { | ||
79 | + controller.Response(nil, err) | ||
80 | + return | ||
81 | + } | ||
82 | + userOrgCommand.Operator = controller.GetOperator() | ||
83 | + data, err := authService.GetUserOrg(userOrgCommand) | ||
84 | + controller.Response(data, err) | ||
85 | +} |
1 | +package mobile_client | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/service" | ||
6 | +) | ||
7 | + | ||
8 | +// Controller | ||
9 | +type CooperationController struct { | ||
10 | + baseController | ||
11 | +} | ||
12 | + | ||
13 | +/***** CompanyDividends 企业端分红 *****/ | ||
14 | +func (controller *CooperationController) GetDividendContracts() { | ||
15 | + svr := service.CompanyStatisticsService{} | ||
16 | + cmd := &command.GetDividendContractsCommand{} | ||
17 | + err := controller.Unmarshal(cmd) | ||
18 | + if err != nil { | ||
19 | + controller.Response(nil, err) | ||
20 | + return | ||
21 | + } | ||
22 | + cmd.Operator = controller.GetOperator() | ||
23 | + data, err := svr.GetDividendContracts(cmd) | ||
24 | + controller.Response(data, err) | ||
25 | +} | ||
26 | + | ||
27 | +func (controller *CooperationController) DividendsStatistics() { | ||
28 | + svr := service.CompanyStatisticsService{} | ||
29 | + cmd := &command.DividendsStatisticsCommand{} | ||
30 | + err := controller.Unmarshal(cmd) | ||
31 | + if err != nil { | ||
32 | + controller.Response(nil, err) | ||
33 | + return | ||
34 | + } | ||
35 | + cmd.Operator = controller.GetOperator() | ||
36 | + data, err := svr.DividendsStatistics(cmd) | ||
37 | + controller.Response(data, err) | ||
38 | +} | ||
39 | + | ||
40 | +func (controller *CooperationController) SearchDividendsEstimates() { | ||
41 | + svr := service.CompanyStatisticsService{} | ||
42 | + cmd := &command.SearchDividendsEstimatesCommand{} | ||
43 | + err := controller.Unmarshal(cmd) | ||
44 | + if err != nil { | ||
45 | + controller.Response(nil, err) | ||
46 | + return | ||
47 | + } | ||
48 | + cmd.Operator = controller.GetOperator() | ||
49 | + data, err := svr.SearchDividendsEstimates(cmd) | ||
50 | + controller.Response(data, err) | ||
51 | +} | ||
52 | + | ||
53 | +/***** CompanyStatistics 企业端统计 *****/ | ||
54 | + | ||
55 | +func (controller *CooperationController) IndexStatistics() { | ||
56 | + svr := service.CompanyStatisticsService{} | ||
57 | + cmd := &command.IndexStatisticsCommand{} | ||
58 | + err := controller.Unmarshal(cmd) | ||
59 | + if err != nil { | ||
60 | + controller.Response(nil, err) | ||
61 | + return | ||
62 | + } | ||
63 | + cmd.Operator = controller.GetOperator() | ||
64 | + data, err := svr.IndexStatistics(cmd) | ||
65 | + controller.Response(data, err) | ||
66 | +} | ||
67 | + | ||
68 | +func (controller *CooperationController) CooperationPersonStatistics() { | ||
69 | + svr := service.CompanyStatisticsService{} | ||
70 | + cmd := &command.CooperationPersonStatisticsCommand{} | ||
71 | + err := controller.Unmarshal(cmd) | ||
72 | + if err != nil { | ||
73 | + controller.Response(nil, err) | ||
74 | + return | ||
75 | + } | ||
76 | + cmd.Operator = controller.GetOperator() | ||
77 | + data, err := svr.CooperationPersonStatistics(cmd) | ||
78 | + controller.Response(data, err) | ||
79 | +} | ||
80 | + | ||
81 | +func (controller *CooperationController) GoodsStatistics() { | ||
82 | + svr := service.CompanyStatisticsService{} | ||
83 | + cmd := &command.GoodsStatisticsCommand{} | ||
84 | + err := controller.Unmarshal(cmd) | ||
85 | + if err != nil { | ||
86 | + controller.Response(nil, err) | ||
87 | + return | ||
88 | + } | ||
89 | + cmd.Operator = controller.GetOperator() | ||
90 | + data, err := svr.GoodsStatistics(cmd) | ||
91 | + controller.Response(data, err) | ||
92 | +} | ||
93 | + | ||
94 | +func (controller *CooperationController) CooperationDividendsStatistics() { | ||
95 | + svr := service.CompanyStatisticsService{} | ||
96 | + cmd := &command.CooperationDividendsStatisticsCommand{} | ||
97 | + err := controller.Unmarshal(cmd) | ||
98 | + if err != nil { | ||
99 | + controller.Response(nil, err) | ||
100 | + return | ||
101 | + } | ||
102 | + cmd.Operator = controller.GetOperator() | ||
103 | + data, err := svr.CooperationDividendsStatistics(cmd) | ||
104 | + controller.Response(data, err) | ||
105 | +} |
1 | +package web_client | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/command" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/query" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/company/service" | ||
7 | +) | ||
8 | + | ||
9 | +type CompanyController struct { | ||
10 | + baseController | ||
11 | +} | ||
12 | + | ||
13 | +func (controller *CompanyController) CreateCompany() { | ||
14 | + companyService := service.NewCompanyService(nil) | ||
15 | + createCompanyCommand := &command.CreateCompanyCommand{} | ||
16 | + controller.Unmarshal(createCompanyCommand) | ||
17 | + data, err := companyService.CreateCompany(createCompanyCommand) | ||
18 | + controller.Response(data, err) | ||
19 | +} | ||
20 | + | ||
21 | +func (controller *CompanyController) UpdateCompany() { | ||
22 | + companyService := service.NewCompanyService(nil) | ||
23 | + updateCompanyCommand := &command.UpdateCompanyCommand{} | ||
24 | + controller.Unmarshal(updateCompanyCommand) | ||
25 | + updateCompanyCommand.Operator = controller.GetOperator() | ||
26 | + data, err := companyService.UpdateCompany(updateCompanyCommand) | ||
27 | + controller.Response(data, err) | ||
28 | +} | ||
29 | + | ||
30 | +func (controller *CompanyController) GetCompany() { | ||
31 | + companyService := service.NewCompanyService(nil) | ||
32 | + getCompanyQuery := &query.GetCompanyQuery{} | ||
33 | + companyId, _ := controller.GetInt64(":companyId") | ||
34 | + getCompanyQuery.CompanyId = companyId | ||
35 | + data, err := companyService.GetCompany(getCompanyQuery) | ||
36 | + controller.Response(data, err) | ||
37 | +} | ||
38 | + | ||
39 | +func (controller *CompanyController) RemoveCompany() { | ||
40 | + companyService := service.NewCompanyService(nil) | ||
41 | + removeCompanyCommand := &command.RemoveCompanyCommand{} | ||
42 | + controller.Unmarshal(removeCompanyCommand) | ||
43 | + companyId, _ := controller.GetInt64(":companyId") | ||
44 | + removeCompanyCommand.CompanyId = companyId | ||
45 | + data, err := companyService.RemoveCompany(removeCompanyCommand) | ||
46 | + controller.Response(data, err) | ||
47 | +} | ||
48 | + | ||
49 | +func (controller *CompanyController) ListCompany() { | ||
50 | + companyService := service.NewCompanyService(nil) | ||
51 | + listCompanyQuery := &query.ListCompanyQuery{} | ||
52 | + data, err := companyService.ListCompany(listCompanyQuery) | ||
53 | + controller.Response(data, err) | ||
54 | +} | ||
55 | + | ||
56 | +func (controller *CompanyController) ListCompanyCustomizeMenus() { | ||
57 | + companyService := service.NewCompanyService(nil) | ||
58 | + listCompanyCustomizeMenusCommand := &command.ListCompanyCustomizeMenusCommand{} | ||
59 | + controller.Unmarshal(listCompanyCustomizeMenusCommand) | ||
60 | + companyId, _ := controller.GetInt64(":companyId") | ||
61 | + listCompanyCustomizeMenusCommand.CompanyId = companyId | ||
62 | + listCompanyCustomizeMenusCommand.MenuCategory = controller.GetString("menuCategory") | ||
63 | + data, err := companyService.ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand) | ||
64 | + controller.Response(data, err) | ||
65 | +} | ||
66 | + | ||
67 | +func (controller *CompanyController) UpdateCompanyCustomizeMenus() { | ||
68 | + companyService := service.NewCompanyService(nil) | ||
69 | + updateCompanyCustomizeMenusCommand := &command.UpdateCompanyCustomizeMenusCommand{} | ||
70 | + controller.Unmarshal(updateCompanyCustomizeMenusCommand) | ||
71 | + companyId, _ := controller.GetInt64(":companyId") | ||
72 | + updateCompanyCustomizeMenusCommand.CompanyId = companyId | ||
73 | + data, err := companyService.UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand) | ||
74 | + controller.Response(data, err) | ||
75 | +} |
@@ -11,4 +11,8 @@ func init() { | @@ -11,4 +11,8 @@ func init() { | ||
11 | web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login") | 11 | web.Router("/v1/app/auth/login", &mobile_client.AuthController{}, "Post:Login") |
12 | web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken") | 12 | web.Router("/v1/app/auth/access-token", &mobile_client.AuthController{}, "Post:GetAuthAccessToken") |
13 | web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken") | 13 | web.Router("/v1/app/auth/refresh-token", &mobile_client.AuthController{}, "Post:RefreshAuthAccessToken") |
14 | + | ||
15 | + web.Router("/v1/app/auth/user-info", &mobile_client.AuthController{}, "Post:GetUserInfo") | ||
16 | + web.Router("/v1/app/auth/user-menu", &mobile_client.AuthController{}, "Post:GetUserMenus") | ||
17 | + web.Router("/v1/app/auth/user-orgs", &mobile_client.AuthController{}, "Post:GetUserOrg") | ||
14 | } | 18 | } |
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/mobile_client" | ||
6 | +) | ||
7 | + | ||
8 | +// router | ||
9 | + | ||
10 | +func init() { | ||
11 | + | ||
12 | + /***** CompanyDividends 企业端分红 *****/ | ||
13 | + web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Get:GetDividendContracts") | ||
14 | + web.Router("/v1/app/cooperation/company/dividends/sum", &mobile_client.CooperationController{}, "Post:DividendsStatistics") | ||
15 | + web.Router("/v1/app/cooperation/company/dividends-estimates/search", &mobile_client.CooperationController{}, "Post:SearchDividendsEstimates") | ||
16 | + | ||
17 | + /***** CompanyStatistics 企业端统计 *****/ | ||
18 | + web.Router("/v1/app/cooperation/index", &mobile_client.CooperationController{}, "Get:IndexStatistics") | ||
19 | + web.Router("/v1/app/cooperation/person/statistics", &mobile_client.CooperationController{}, "Post:CooperationPersonStatistics") | ||
20 | + web.Router("/v1/app/cooperation/goods/statistics", &mobile_client.CooperationController{}, "Post:GoodsStatistics") | ||
21 | + web.Router("/v1/app/cooperation-dividends-statistics/statistics", &mobile_client.CooperationController{}, "Post:CooperationDividendsStatistics") | ||
22 | +} |
pkg/port/beego/routers/web_company_router.go
0 → 100644
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/web_client" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + //web.Router("/company/", &web_client.CompanyController{}, "Post:CreateCompany") | ||
10 | + web.Router("/v1/web/company/", &web_client.CompanyController{}, "Put:UpdateCompany") | ||
11 | + //web.Router("/company/:companyId", &web_client.CompanyController{}, "Get:GetCompany") | ||
12 | + //web.Router("/company/:companyId", &web_client.CompanyController{}, "Delete:RemoveCompany") | ||
13 | + //web.Router("/company/search", &web_client.CompanyController{}, "Post:ListCompany") | ||
14 | + //web.Router("/company/:companyId/customize-menus/", &web_client.CompanyController{}, "Get:ListCompanyCustomizeMenus") | ||
15 | + //web.Router("/company/:companyId/customize-menus", &web_client.CompanyController{}, "Put:UpdateCompanyCustomizeMenus") | ||
16 | +} |
-
请 注册 或 登录 后发表评论