作者 tangxuhui

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev

# Conflicts:
#	lastupdate.tmp
@@ -2,3 +2,4 @@ @@ -2,3 +2,4 @@
2 /*.exe 2 /*.exe
3 3
4 .idea 4 .idea
  5 +/lastupdate.tmp
1 -{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627895012887669600}  
  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)
  18 + result, err := creationUserGateway.MenusCreate(allied_creation_user.ReqMenus{
  19 + ParentId: createMenuCommand.ParentId,
  20 + MenuName: createMenuCommand.MenuName,
  21 + Code: createMenuCommand.Code,
  22 + AccessCode: createMenuCommand.AccessCode,
  23 + MenuType: createMenuCommand.MenuType,
  24 + Icon: createMenuCommand.Icon,
  25 + Sort: createMenuCommand.Sort,
  26 + Desc: createMenuCommand.Desc,
  27 + IsPublish: createMenuCommand.IsPublish,
  28 + })
  29 + if err != nil {
  30 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  31 + }
  32 + return result, nil
  33 +}
  34 +
  35 +// 返回菜单服务
  36 +func (menuService *MenuService) GetMenu(getMenuQuery *query.GetMenuQuery) (interface{}, error) {
  37 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  38 + getMenuQuery.Operator)
  39 + result, err := creationUserGateway.MenusGet(allied_creation_user.ReqMenusGet{
  40 + MenuId: getMenuQuery.MenuId,
  41 + })
  42 + if err != nil {
  43 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  44 + }
  45 + return result, nil
  46 +}
  47 +
  48 +// 返回菜单服务列表
  49 +func (menuService *MenuService) ListMenu(listMenuQuery *query.ListMenuQuery) (interface{}, error) {
  50 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  51 + listMenuQuery.Operator)
  52 + result, err := creationUserGateway.MenusSearch(allied_creation_user.ReqMenusSearch{
  53 + MenuCategory: listMenuQuery.MenuCategory,
  54 + ParentId: listMenuQuery.ParentId,
  55 + MenuName: listMenuQuery.MenuName,
  56 + })
  57 + if err != nil {
  58 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  59 + }
  60 + return result, nil
  61 +}
  62 +
  63 +// 移除菜单服务
  64 +func (menuService *MenuService) RemoveMenu(removeMenuCommand *command.RemoveMenuCommand) (interface{}, error) {
  65 +
  66 + return struct{}{}, nil
  67 +}
  68 +
  69 +// 更新菜单服务
  70 +func (menuService *MenuService) UpdateMenu(updateMenuCommand *command.UpdateMenuCommand) (interface{}, error) {
  71 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  72 + updateMenuCommand.Operator)
  73 + result, err := creationUserGateway.MenusUpdate(allied_creation_user.ReqMenusUpdate{
  74 + MenuId: updateMenuCommand.MenuId,
  75 + ParentId: updateMenuCommand.ParentId,
  76 + MenuName: updateMenuCommand.MenuName,
  77 + Code: updateMenuCommand.Code,
  78 + AccessCode: updateMenuCommand.AccessCode,
  79 + MenuType: updateMenuCommand.MenuType,
  80 + Icon: updateMenuCommand.Icon,
  81 + Sort: updateMenuCommand.Sort,
  82 + Desc: updateMenuCommand.Desc,
  83 + IsPublish: updateMenuCommand.IsPublish,
  84 + })
  85 + if err != nil {
  86 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  87 + }
  88 + return result, nil
  89 +}
  90 +
  91 +// 批量删除菜单
  92 +func (menuService *MenuService) BatchDeleteMenu(batchDeleteMenu *command.BatchDeleteMenuCommand) (interface{}, error) {
  93 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  94 + batchDeleteMenu.Operator)
  95 + result, err := creationUserGateway.MenusBatchDelete(allied_creation_user.ReqMenusBatchDelete{
  96 + MenuIds: batchDeleteMenu.MenuIds,
  97 + })
  98 + if err != nil {
  99 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  100 + }
  101 + return result, nil
  102 +}
  103 +
  104 +// 批量启用菜单
  105 +func (menuService *MenuService) BatchEnableMenu(batchEnableMenu *command.BatchEnableMenuCommand) (interface{}, error) {
  106 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  107 + batchEnableMenu.Operator)
  108 + result, err := creationUserGateway.MenusBatchEnable(allied_creation_user.ReqMenusBatchEnable{
  109 + MenuIds: batchEnableMenu.MenuIds,
  110 + Status: batchEnableMenu.Status,
  111 + })
  112 + if err != nil {
  113 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  114 + }
  115 + return result, nil
  116 +}
  117 +
  118 +func NewMenuService(options map[string]interface{}) *MenuService {
  119 + newMenuService := &MenuService{}
  120 + return newMenuService
  121 +}
  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 +}
@@ -131,6 +131,22 @@ func (orgsService *OrgsService) OrgUpdate(orgUpdateCommand *command.OrgUpdateCom @@ -131,6 +131,22 @@ func (orgsService *OrgsService) OrgUpdate(orgUpdateCommand *command.OrgUpdateCom
131 return orgUpdateCommand, nil 131 return orgUpdateCommand, nil
132 } 132 }
133 133
  134 +// 返回组织管理
  135 +func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSubDepartmentQuery) (interface{}, error) {
  136 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  137 + orgGetQuery.Operator)
  138 + orgId, _ := strconv.Atoi(orgGetQuery.OrgId)
  139 + result, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{
  140 + OrgId: int64(orgId),
  141 + })
  142 + if err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  144 + }
  145 + return map[string]interface{}{
  146 + "list": result.Orgs,
  147 + }, nil
  148 +}
  149 +
134 func NewOrgsService(options map[string]interface{}) *OrgsService { 150 func NewOrgsService(options map[string]interface{}) *OrgsService {
135 newOrgsService := &OrgsService{} 151 newOrgsService := &OrgsService{}
136 return newOrgsService 152 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 {
@@ -38,7 +38,7 @@ type UserRole struct { @@ -38,7 +38,7 @@ type UserRole struct {
38 RoleID string `json:"roleId"` 38 RoleID string `json:"roleId"`
39 RoleName string `json:"roleName"` 39 RoleName string `json:"roleName"`
40 OrgName string `json:"orgName"` 40 OrgName string `json:"orgName"`
41 - Descript string `json:"descript"` 41 + Description string `json:"desc"`
42 } 42 }
43 43
44 type UserMenu struct { 44 type UserMenu struct {
@@ -31,11 +31,13 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp @@ -31,11 +31,13 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp
31 UserId: userid, 31 UserId: userid,
32 }) 32 })
33 if err != nil { 33 if err != nil {
34 - return nil, err 34 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
35 } 35 }
36 - resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{}) 36 + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
  37 + UserId: userid,
  38 + })
37 if err != nil { 39 if err != nil {
38 - return nil, err 40 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
39 } 41 }
40 var ( 42 var (
41 usersOrg []dto.UserOrg 43 usersOrg []dto.UserOrg
@@ -214,7 +216,7 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw @@ -214,7 +216,7 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
214 if err != nil { 216 if err != nil {
215 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 217 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
216 } 218 }
217 - return companyUserResetPasswordCommand, err 219 + return "123456", err
218 } 220 }
219 221
220 // 更新公司用户信息 222 // 更新公司用户信息
@@ -465,7 +467,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa @@ -465,7 +467,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa
465 RoleID: strconv.Itoa(int(v.RoleID)), 467 RoleID: strconv.Itoa(int(v.RoleID)),
466 RoleName: v.RoleName, 468 RoleName: v.RoleName,
467 OrgName: v.Ext.OrgName, 469 OrgName: v.Ext.OrgName,
468 - Descript: v.Desc, 470 + Description: v.Desc,
469 } 471 }
470 dataList = append(dataList, item) 472 dataList = append(dataList, item)
471 } 473 }
@@ -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,47 +3,189 @@ package allied_creation_user @@ -3,47 +3,189 @@ 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 `json:"menusId"` 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
22 //移除菜单 85 //移除菜单
23 type ( 86 type (
24 ReqMenusRemove struct { 87 ReqMenusRemove struct {
25 - MenuId int64 `json:"roleId"` 88 + MenuId int64
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
32 //返回菜单 107 //返回菜单
33 type ( 108 type (
34 ReqMenusGet struct { 109 ReqMenusGet struct {
35 - MenuId int64 `json:"menuId"` 110 + MenuId int64
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 }