作者 tangxuhui

角色模块应用层初步实现

package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleAddCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 角色名称
RoleName string `json:"roleName"`
// 描述
Desc string `json:"desc"`
}
func (roleAddCommand *RoleAddCommand) Valid(validation *validation.Validation) {
}
func (roleAddCommand *RoleAddCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(roleAddCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleMenuEditCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 角色ID
RoleId string `json:"roleId" valid:"Required"`
// 关联菜单的id
MenuId []string `json:"menuId"`
}
func (roleMenuEditQuery *RoleMenuEditCommand) Valid(validation *validation.Validation) {
}
func (roleMenuEditQuery *RoleMenuEditCommand) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleMenuEditQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleRemoveCommand struct {
//操作人
Operator domain.Operator `json:"-"`
RoleId []string `json:"roleId"`
}
func (roleRemoveCommand *RoleRemoveCommand) Valid(validation *validation.Validation) {
}
func (roleRemoveCommand *RoleRemoveCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(roleRemoveCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleUpdateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
RoleId string `json:"roleId"`
// 角色名称
RoleName string `json:"roleName"`
// 描述
Desc string `json:"desc"`
}
func (roleUpdateCommand *RoleUpdateCommand) Valid(validation *validation.Validation) {
}
func (roleUpdateCommand *RoleUpdateCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(roleUpdateCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleUserAddCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//角色ID
RoleId string `json:"roleId" valid:"Required"`
// 关联用户的id
UserId []string `json:"userId,omitempty"`
}
func (roleUserAddQuery *RoleUserAddCommand) Valid(validation *validation.Validation) {
}
func (roleUserAddQuery *RoleUserAddCommand) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleUserAddQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleUserDeleteCommand struct {
// 操作人
Operator domain.Operator `json:"-"`
// 角色ID
RoleId string `json:"roleId" valid:"Required"`
// 关联用户的id
UserId []string `json:"userId"`
}
func (roleUserDeleteQuery *RoleUserDeleteCommand) Valid(validation *validation.Validation) {
}
func (roleUserDeleteQuery *RoleUserDeleteCommand) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleUserDeleteQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package dto
//角色列表项
type RoleItem struct {
RoleId string `json:"roleId"`
OrgId string `json:"orgId"`
RoleName string `json:"roleName"`
Describe string `json:"describe"`
OrgName string `json:"orgName"`
RoleType int `json:"roleType"`
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleGetQuery struct {
// 操作人
Operator domain.Operator `json:"-"`
// 角色ID
RoleId string `json:"roleId" valid:"Required"`
}
func (roleGetQuery *RoleGetQuery) Valid(validation *validation.Validation) {
}
func (roleGetQuery *RoleGetQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleGetQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type RoleListQuery struct {
// 操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageNumber"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//角色名
RoleName string `json:"roleName"`
OrgName string `json:"orgName"`
}
func (roleListQuery *RoleListQuery) Valid(validation *validation.Validation) {
}
func (roleListQuery *RoleListQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleListQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type RoleMenuBeforeEditQuery struct {
// 角色ID
RoleId int64 `json:"roleId" valid:"Required"`
}
func (roleMenuBeforeEditQuery *RoleMenuBeforeEditQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (roleMenuBeforeEditQuery *RoleMenuBeforeEditQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleMenuBeforeEditQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type RoleUserBeforeEditQuery struct {
}
func (roleUserBeforeEditQuery *RoleUserBeforeEditQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (roleUserBeforeEditQuery *RoleUserBeforeEditQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleUserBeforeEditQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
)
type RoleUserInfoQuery struct {
// 角色ID
RoleId int64 `json:"roleId" valid:"Required"`
}
func (roleUserInfoQuery *RoleUserInfoQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (roleUserInfoQuery *RoleUserInfoQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(roleUserInfoQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package service
import (
"strconv"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/roles/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/roles/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/roles/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// roles
type RolesService struct {
}
// 创建role
func (rolesService *RolesService) RoleAdd(roleAddCommand *command.RoleAddCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleAddCommand.Operator.CompanyId,
roleAddCommand.Operator.OrgId,
roleAddCommand.Operator.UserId)
_, err := creationUserGateway.RoleCreate(allied_creation_user.ReqRoleCreate{
RoleName: roleAddCommand.RoleName,
Desc: roleAddCommand.Desc,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return roleAddCommand, err
}
// 编辑role
func (rolesService *RolesService) RoleEdit(roleUpdateCommand *command.RoleUpdateCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleUpdateCommand.Operator.CompanyId,
roleUpdateCommand.Operator.OrgId,
roleUpdateCommand.Operator.UserId)
roleId, _ := strconv.Atoi(roleUpdateCommand.RoleId)
_, err := creationUserGateway.RoleUpdate(allied_creation_user.ReqRoleUpdate{
RoleId: int64(roleId),
RoleName: roleUpdateCommand.RoleName,
Desc: roleUpdateCommand.Desc,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return roleUpdateCommand, err
}
// 返单个角色
func (rolesService *RolesService) RoleGet(roleGetQuery *query.RoleGetQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleGetQuery.Operator.CompanyId,
roleGetQuery.Operator.OrgId,
roleGetQuery.Operator.UserId)
roleId, _ := strconv.Atoi(roleGetQuery.RoleId)
result, err := creationUserGateway.RoleGet(allied_creation_user.ReqRoleGet{
RoleId: int64(roleId),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 返角全部详情色
func (rolesService *RolesService) RoleAllDetail(roleGetQuery *query.RoleGetQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleGetQuery.Operator.CompanyId,
roleGetQuery.Operator.OrgId,
roleGetQuery.Operator.UserId)
roleId, _ := strconv.Atoi(roleGetQuery.RoleId)
roleData, err := creationUserGateway.RoleGet(allied_creation_user.ReqRoleGet{
RoleId: int64(roleId),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//TODO 补充字段 :权限数据,关联用户数据
result := map[string]interface{}{
"role": roleData.Role,
}
return result, nil
}
// 返回role列表
func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) (int64, interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleListQuery.Operator.CompanyId,
roleListQuery.Operator.OrgId,
roleListQuery.Operator.UserId)
roleList, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{
Offset: (roleListQuery.PageNumber - 1) * roleListQuery.PageSize,
Limit: roleListQuery.PageSize,
OrgName: roleListQuery.OrgName,
RoleName: roleListQuery.RoleName,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := []dto.RoleItem{}
for _, v := range roleList.Roles {
result = append(result, dto.RoleItem{
RoleId: strconv.Itoa(v.RoleID),
OrgId: strconv.Itoa(v.OrgID),
RoleName: v.RoleName,
Describe: v.Desc,
OrgName: v.Ext.OrgName,
RoleType: v.RoleType,
})
}
var cnt int64 = roleList.Count
return cnt, result, nil
}
// 编辑角色关联权限菜单的前置准备数据
func (rolesService *RolesService) RoleMenuBeforeEdit(roleMenuBeforeEditQuery *query.RoleMenuBeforeEditQuery) (interface{}, error) {
return nil, nil
}
// 编辑角色关联用户的前置准备数据
func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *query.RoleUserBeforeEditQuery) (interface{}, error) {
return nil, nil
}
// 角色编辑关联菜单权限
func (rolesService *RolesService) RoleMenuEdit(roleMenuEditCommand *command.RoleMenuEditCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleMenuEditCommand.Operator.CompanyId,
roleMenuEditCommand.Operator.OrgId,
roleMenuEditCommand.Operator.UserId)
roleId, _ := strconv.Atoi(roleMenuEditCommand.RoleId)
var menuIds []int64
for _, v := range roleMenuEditCommand.MenuId {
id, err := strconv.Atoi(v)
if err == nil {
menuIds = append(menuIds, int64(id))
}
}
_, err := creationUserGateway.RoleSetAccessMenus(allied_creation_user.ReqRoleSetAccessMenus{
RoleId: int64(roleId),
AccessMenus: menuIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return roleMenuEditCommand, err
}
// 移除role
func (rolesService *RolesService) RoleRemove(roleRemoveCommand *command.RoleRemoveCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleRemoveCommand.Operator.CompanyId,
roleRemoveCommand.Operator.OrgId,
roleRemoveCommand.Operator.UserId)
var roleIds []int64
for _, v := range roleRemoveCommand.RoleId {
id, err := strconv.Atoi(v)
if err == nil {
roleIds = append(roleIds, int64(id))
}
}
_, err := creationUserGateway.RoleRemove(allied_creation_user.ReqRoleRemove{
//TODO 修改 为 切片类型
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return roleRemoveCommand, err
}
// 角色添加关联用户
func (rolesService *RolesService) RoleUserAdd(roleUserAddCommand *command.RoleUserAddCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleUserAddCommand.Operator.CompanyId,
roleUserAddCommand.Operator.OrgId,
roleUserAddCommand.Operator.UserId)
roleId, _ := strconv.Atoi(roleUserAddCommand.RoleId)
var userIds []int64
for _, v := range roleUserAddCommand.UserId {
id, err := strconv.Atoi(v)
if err == nil {
userIds = append(userIds, int64(id))
}
}
_, err := creationUserGateway.RoleAssign(allied_creation_user.ReqRoleAssign{
RoleId: int64(roleId),
UserIds: userIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return roleUserAddCommand, err
}
// 角色添加关联用户
func (rolesService *RolesService) RoleUserDelete(roleUserDeleteCommand *command.RoleUserDeleteCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
roleUserDeleteCommand.Operator.CompanyId,
roleUserDeleteCommand.Operator.OrgId,
roleUserDeleteCommand.Operator.UserId)
roleId, _ := strconv.Atoi(roleUserDeleteCommand.RoleId)
var userIds []int64
for _, v := range roleUserDeleteCommand.UserId {
id, err := strconv.Atoi(v)
if err == nil {
userIds = append(userIds, int64(id))
}
}
_, err := creationUserGateway.RoleUnassign(allied_creation_user.ReqRoleUnassign{
RoleId: int64(roleId),
UserIds: userIds,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return roleUserDeleteCommand, err
}
// 角色下关联用户的数据
func (rolesService *RolesService) RoleUserInfo(roleUserInfoQuery *query.RoleUserInfoQuery) (interface{}, error) {
return nil, nil
}
func NewRolesService(options map[string]interface{}) *RolesService {
newRolesService := &RolesService{}
return newRolesService
}
... ...
... ... @@ -67,7 +67,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
userRole = append(userRole, int64(id))
}
}
result, err := creationUserGateway.UserCreate(allied_creation_user.ReqCreateUser{
_, err := creationUserGateway.UserCreate(allied_creation_user.ReqCreateUser{
CompanyId: companyUserAddCommand.Operator.CompanyId,
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType: 1,
... ... @@ -84,7 +84,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
Avatar: companyUserAddCommand.Avator,
Email: companyUserAddCommand.Avator,
})
return result, err
return companyUserAddCommand, err
}
// 启用禁用公司用户信息
... ... @@ -93,11 +93,11 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co
companyUserEnableCommand.Operator.CompanyId,
companyUserEnableCommand.Operator.OrgId,
companyUserEnableCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
_, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: companyUserEnableCommand.UsersIds,
EnableStatus: companyUserEnableCommand.EnableStatus,
})
return result, err
return companyUserEnableCommand, err
}
// 返回公司用户信息列表
... ... @@ -144,11 +144,11 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
companyUserResetPasswordCommand.Operator.CompanyId,
companyUserResetPasswordCommand.Operator.OrgId,
companyUserResetPasswordCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "",
UserIds: companyUserResetPasswordCommand.UsersIds,
})
return result, err
return companyUserResetPasswordCommand, err
}
// 更新公司用户信息
... ... @@ -174,7 +174,7 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
}
}
userId, _ := strconv.Atoi(companyUserUpdateCommand.UsersId)
result, err := creationUserGateway.UserUpdate(allied_creation_user.ReqUpdateUser{
_, err := creationUserGateway.UserUpdate(allied_creation_user.ReqUpdateUser{
UserId: int64(userId),
CompanyId: companyUserUpdateCommand.Operator.CompanyId,
UserCode: companyUserUpdateCommand.UsersCode,
... ... @@ -188,7 +188,7 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
Avatar: companyUserUpdateCommand.Avator,
Email: companyUserUpdateCommand.Avator,
})
return result, err
return companyUserUpdateCommand, err
}
// 创建共创用户信息
... ... @@ -197,7 +197,7 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
cooperationUserAddCommand.Operator.CompanyId,
cooperationUserAddCommand.Operator.OrgId,
cooperationUserAddCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
_, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
CooperationCompany: cooperationUserAddCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserAddCommand.CooperationDeadline, 0),
Email: cooperationUserAddCommand.Email,
... ... @@ -207,9 +207,9 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
Avatar: cooperationUserAddCommand.Avatar,
OrgId: cooperationUserAddCommand.Operator.OrgId,
Phone: cooperationUserAddCommand.Phone,
Password: "",
Password: "", //TODO 填充默认密码
})
return result, err
return cooperationUserAddCommand, err
}
// 启用禁用共创用户信息
... ... @@ -218,11 +218,11 @@ func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCom
cooperationUserEnableCommand.Operator.CompanyId,
cooperationUserEnableCommand.Operator.OrgId,
cooperationUserEnableCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
_, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: cooperationUserEnableCommand.UsersIds,
EnableStatus: cooperationUserEnableCommand.EnableStatus,
})
return result, err
return cooperationUserEnableCommand, err
}
// 获取共创用户信息
... ... @@ -293,11 +293,11 @@ func (usersService *UsersService) CooperationUserResetPassword(cooperationUserRe
cooperationUserResetPasswordCommand.Operator.CompanyId,
cooperationUserResetPasswordCommand.Operator.OrgId,
cooperationUserResetPasswordCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "",
UserIds: cooperationUserResetPasswordCommand.UsersIds,
})
return result, err
return cooperationUserResetPasswordCommand, err
}
// 编辑共创用户信息
... ... @@ -306,7 +306,7 @@ func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCom
cooperationUserUpdateCommand.Operator.CompanyId,
cooperationUserUpdateCommand.Operator.OrgId,
cooperationUserUpdateCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserUpdate(allied_creation_user.ReqUpdateCooperatorUser{
_, err := creationUserGateway.CooperatorUserUpdate(allied_creation_user.ReqUpdateCooperatorUser{
UserId: cooperationUserUpdateCommand.UsersId,
CooperationCompany: cooperationUserUpdateCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserUpdateCommand.CooperationDeadline, 0),
... ... @@ -318,7 +318,7 @@ func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCom
OrgId: cooperationUserUpdateCommand.Operator.OrgId,
Phone: cooperationUserUpdateCommand.Phone,
})
return result, err
return cooperationUserUpdateCommand, err
}
func NewUsersService(options map[string]interface{}) *UsersService {
... ...
... ... @@ -106,7 +106,7 @@ func (gateway HttplibAlliedCreationUser) RoleAssign(param ReqRoleAssign) (*DataR
}
// RoleCreate 创建角色
func (gateway HttplibAlliedCreationUser) RoleCreate(param ReqRole) (*DataRole, error) {
func (gateway HttplibAlliedCreationUser) RoleCreate(param ReqRoleCreate) (*DataRoleCreate, error) {
urlStr := gateway.baseUrL + "/role"
method := "post"
req := gateway.CreateRequest(urlStr, method)
... ... @@ -131,7 +131,7 @@ func (gateway HttplibAlliedCreationUser) RoleCreate(param ReqRole) (*DataRole, e
if err != nil {
return nil, fmt.Errorf("解析创建角色:%w", err)
}
var data DataRole
var data DataRoleCreate
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -9,9 +9,32 @@ type (
Offset int `json:"offset"`
// 查询限制
Limit int `json:"limit"`
//组织名称
OrgName string `json:"orgName"`
//角色码名称
RoleName string `json:"roleName"`
}
DataRoleSearch struct {
Count int64
Roles []struct {
AccessMenus []int `json:"accessMenus"`
CompanyID int `json:"companyId"`
CreatedAt string `json:"createdAt"`
Desc string `json:"desc"`
Ext struct {
DepName string `json:"depName"`
OrgName string `json:"orgName"`
ParentDepName string `json:"parentDepName"`
Phone string `json:"phone"`
UserName string `json:"userName"`
} `json:"ext"`
OrgID int `json:"orgId"`
RoleID int `json:"roleId"`
RoleName string `json:"roleName"`
RoleType int `json:"roleType"`
UpdatedAt string `json:"updatedAt"`
} `json:"role"`
}
)
... ... @@ -22,12 +45,32 @@ type (
}
DataRoleGet struct {
Role struct {
AccessMenus []int `json:"accessMenus"`
CompanyID int `json:"companyId"`
CreatedAt string `json:"createdAt"`
Desc int `json:"desc"`
Ext struct {
DepName string `json:"depName"`
OrgName string `json:"orgName"`
ParentDepName string `json:"parentDepName"`
Phone string `json:"phone"`
UserName string `json:"userName"`
} `json:"ext"`
OrgID int `json:"orgId"`
RoleID int `json:"roleId"`
RoleName string `json:"roleName"`
RoleType int `json:"roleType"`
UpdatedAt string `json:"updatedAt"`
} `json:"role"`
}
)
//分配角色给多个用户
type (
ReqRoleAssign struct {
RoleId int64
UserIds []int64
}
DataRoleAssign struct {
... ... @@ -36,16 +79,22 @@ type (
//创建角色
type (
ReqRole struct {
ReqRoleCreate struct {
// 角色名称
RoleName string `json:"roleName"`
// 描述
Desc string `json:"desc"`
}
DataRole struct {
DataRoleCreate struct {
}
)
//取消用户分配的角色
type (
ReqRoleUnassign struct {
RoleId int64 `json:"roleId"`
UserIds []int64 `json:"userIds"`
}
DataRoleUnassign struct {
... ... @@ -55,7 +104,11 @@ type (
//更新角色
type (
ReqRoleUpdate struct {
RoleId int64
RoleId int64 `json:"roleId"`
// 角色名称
RoleName string `json:"roleName"`
// 描述
Desc string `json:"desc"`
}
DataRoleUpdate struct {
... ... @@ -65,7 +118,7 @@ type (
//移除角色
type (
ReqRoleRemove struct {
RoleId int64
RoleId int64 `json:"roleId"`
}
DataRoleRemove struct {
... ... @@ -75,9 +128,9 @@ type (
//获取角色相关联的用户
type (
ReqRoleGetRelatedUser struct {
RoleId int64
OrgId int64
DepartmentId int64
RoleId int64 `json:"roleId"`
OrgId int64 `json:"orgId"`
DepartmentId int64 `json:"departmentId"`
}
DataRoleGetRelatedUser struct {
... ... @@ -98,6 +151,7 @@ type (
type (
ReqRoleSetAccessMenus struct {
RoleId int64 `json:"roleId"`
AccessMenus []int64 `json:"accessMenus"`
}
DataRoleSetAccessMenus struct {
... ...