Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-user into dev
正在显示
19 个修改的文件
包含
86 行增加
和
27 行删除
| @@ -10,7 +10,7 @@ import ( | @@ -10,7 +10,7 @@ import ( | ||
| 10 | 10 | ||
| 11 | type DestroyAccountCommand struct { | 11 | type DestroyAccountCommand struct { |
| 12 | // 用户Id 用户唯一标识 | 12 | // 用户Id 用户唯一标识 |
| 13 | - UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"` | 13 | + Account string `cname:"账号" json:"account" valid:"Required"` |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) { | 16 | func (destroyAccountCommand *DestroyAccountCommand) Valid(validation *validation.Validation) { |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | type UserBaseDto struct { | 7 | type UserBaseDto struct { |
| 8 | // 用户基础数据id | 8 | // 用户基础数据id |
| 9 | UserBaseId int64 `json:"userBaseId,omitempty"` | 9 | UserBaseId int64 `json:"userBaseId,omitempty"` |
| 10 | + UserType int `json:"userType"` | ||
| 10 | // 用户信息 | 11 | // 用户信息 |
| 11 | UserInfo *domain.UserInfo `json:"userInfo,omitempty"` | 12 | UserInfo *domain.UserInfo `json:"userInfo,omitempty"` |
| 12 | // 手机号码 | 13 | // 手机号码 |
| @@ -28,5 +29,6 @@ type UserBaseDto struct { | @@ -28,5 +29,6 @@ type UserBaseDto struct { | ||
| 28 | func (u *UserBaseDto) LoadDto(ub *domain.UserBase) { | 29 | func (u *UserBaseDto) LoadDto(ub *domain.UserBase) { |
| 29 | u.UserBaseId = ub.UserBaseId | 30 | u.UserBaseId = ub.UserBaseId |
| 30 | u.UserInfo = ub.UserInfo | 31 | u.UserInfo = ub.UserInfo |
| 32 | + u.UserType = domain.UserTypeVisitor | ||
| 31 | u.Im = ub.Im | 33 | u.Im = ub.Im |
| 32 | } | 34 | } |
| @@ -9,11 +9,15 @@ import ( | @@ -9,11 +9,15 @@ import ( | ||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | type UserInfoQuery struct { | 11 | type UserInfoQuery struct { |
| 12 | - Account string `cname:"账号" json:"account" valid:"Required"` | 12 | + Account string `cname:"账号" json:"account"` |
| 13 | + UserBaseId int64 `cname:"用户编号" json:"userBaseId"` | ||
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) { | 16 | func (userInfoQuery *UserInfoQuery) Valid(validation *validation.Validation) { |
| 16 | //validation.SetError("CustomValid", "未实现的自定义认证") | 17 | //validation.SetError("CustomValid", "未实现的自定义认证") |
| 18 | + if len(userInfoQuery.Account) == 0 && userInfoQuery.UserBaseId <= 0 { | ||
| 19 | + validation.SetError("CustomValid", "参数不能为空") | ||
| 20 | + } | ||
| 17 | } | 21 | } |
| 18 | 22 | ||
| 19 | func (userInfoQuery *UserInfoQuery) ValidateQuery() error { | 23 | func (userInfoQuery *UserInfoQuery) ValidateQuery() error { |
| @@ -81,7 +81,7 @@ func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.De | @@ -81,7 +81,7 @@ func (authService *AuthService) DestroyAccount(destroyAccountCommand *command.De | ||
| 81 | if err != nil { | 81 | if err != nil { |
| 82 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 82 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 83 | } | 83 | } |
| 84 | - if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.UserId); err != nil { | 84 | + if err := accountDestroyService.DestroyAccount(nil, destroyAccountCommand.Account); err != nil { |
| 85 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 85 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -319,8 +319,13 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in | @@ -319,8 +319,13 @@ func (authService *AuthService) UserInfo(userInfoQuery *query.UserInfoQuery) (in | ||
| 319 | transactionContext.RollbackTransaction() | 319 | transactionContext.RollbackTransaction() |
| 320 | }() | 320 | }() |
| 321 | 321 | ||
| 322 | + var userBase *domain.UserBase | ||
| 322 | userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0) | 323 | userBaseRepository, _, _ := factory.FastPgUserBase(transactionContext, 0) |
| 323 | - userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account}) | 324 | + if len(userInfoQuery.Account) > 0 { |
| 325 | + userBase, err = userBaseRepository.FindOne(map[string]interface{}{"account": userInfoQuery.Account}) | ||
| 326 | + } else if userInfoQuery.UserBaseId > 0 { | ||
| 327 | + userBase, err = userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userInfoQuery.UserBaseId}) | ||
| 328 | + } | ||
| 324 | if err != nil { | 329 | if err != nil { |
| 325 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 330 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
| 326 | } | 331 | } |
| @@ -25,6 +25,8 @@ type ListOrgQuery struct { | @@ -25,6 +25,8 @@ type ListOrgQuery struct { | ||
| 25 | ParentId int64 `cname:"父级ID" json:"parentId,omitempty"` | 25 | ParentId int64 `cname:"父级ID" json:"parentId,omitempty"` |
| 26 | // 是否是组织(是:1 不是:2) | 26 | // 是否是组织(是:1 不是:2) |
| 27 | IsOrg int `cname:"是否是组织(是:1 不是:2)" json:"isOrg,omitempty"` | 27 | IsOrg int `cname:"是否是组织(是:1 不是:2)" json:"isOrg,omitempty"` |
| 28 | + // 模糊匹配组织名称 | ||
| 29 | + MatchOrgName string `cname:"部门名称" json:"matchOrgName,omitempty"` | ||
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | func (listOrgQuery *ListOrgQuery) Valid(validation *validation.Validation) { | 32 | func (listOrgQuery *ListOrgQuery) Valid(validation *validation.Validation) { |
| @@ -12,7 +12,7 @@ import ( | @@ -12,7 +12,7 @@ import ( | ||
| 12 | type GetRoleRelatedUsersQuery struct { | 12 | type GetRoleRelatedUsersQuery struct { |
| 13 | OperateInfo *domain.OperateInfo `json:"-"` | 13 | OperateInfo *domain.OperateInfo `json:"-"` |
| 14 | // 组织ID | 14 | // 组织ID |
| 15 | - OrgId int64 `cname:"组织ID" json:"orgId,string,omitempty"` | 15 | + OrgId int64 `cname:"组织ID" json:"orgId,omitempty"` |
| 16 | 16 | ||
| 17 | // 角色ID | 17 | // 角色ID |
| 18 | RoleId int64 `cname:"角色ID" json:"roleId" valid:"Required"` | 18 | RoleId int64 `cname:"角色ID" json:"roleId" valid:"Required"` |
| @@ -20,6 +20,8 @@ type GetRoleRelatedUsersQuery struct { | @@ -20,6 +20,8 @@ type GetRoleRelatedUsersQuery struct { | ||
| 20 | DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"` | 20 | DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"` |
| 21 | // 只需要关联的用户 true:仅返回关联用户信息 false:返回所有其他信息(未关联的用户) | 21 | // 只需要关联的用户 true:仅返回关联用户信息 false:返回所有其他信息(未关联的用户) |
| 22 | //OnlyRelatedUser bool `cname:"部门编号" json:"onlyRelatedUser,omitempty"` | 22 | //OnlyRelatedUser bool `cname:"部门编号" json:"onlyRelatedUser,omitempty"` |
| 23 | + // 组织ID | ||
| 24 | + InOrgIds []int64 `cname:"组织ID" json:"orgIds,omitempty"` | ||
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | func (getRoleRelatedUsersQuery *GetRoleRelatedUsersQuery) Valid(validation *validation.Validation) { | 27 | func (getRoleRelatedUsersQuery *GetRoleRelatedUsersQuery) Valid(validation *validation.Validation) { |
| @@ -27,6 +27,8 @@ type ListRoleQuery struct { | @@ -27,6 +27,8 @@ type ListRoleQuery struct { | ||
| 27 | OrgId int64 `cname:"组织ID" json:"orgId,omitempty"` | 27 | OrgId int64 `cname:"组织ID" json:"orgId,omitempty"` |
| 28 | // 匹配多个组织 | 28 | // 匹配多个组织 |
| 29 | InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"` | 29 | InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"` |
| 30 | + // 角色名称 | ||
| 31 | + MatchRoleName string `cname:"匹配角色名称" json:"matchRoleName,omitempty"` | ||
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | func (listRoleQuery *ListRoleQuery) Valid(validation *validation.Validation) { | 34 | func (listRoleQuery *ListRoleQuery) Valid(validation *validation.Validation) { |
| @@ -218,10 +218,15 @@ func (roleService *RoleService) GetRoleRelatedUsers(getRoleRelatedUsersQuery *qu | @@ -218,10 +218,15 @@ func (roleService *RoleService) GetRoleRelatedUsers(getRoleRelatedUsersQuery *qu | ||
| 218 | } | 218 | } |
| 219 | queryOptions := make(map[string]interface{}) | 219 | queryOptions := make(map[string]interface{}) |
| 220 | queryOptions["companyId"] = role.CompanyId | 220 | queryOptions["companyId"] = role.CompanyId |
| 221 | - queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId | ||
| 222 | if getRoleRelatedUsersQuery.DepartmentId > 0 { | 221 | if getRoleRelatedUsersQuery.DepartmentId > 0 { |
| 223 | queryOptions["departmentId"] = getRoleRelatedUsersQuery.DepartmentId | 222 | queryOptions["departmentId"] = getRoleRelatedUsersQuery.DepartmentId |
| 224 | } | 223 | } |
| 224 | + // 按组织过滤 | ||
| 225 | + if len(getRoleRelatedUsersQuery.InOrgIds) > 0 { | ||
| 226 | + queryOptions["inOrgIds"] = getRoleRelatedUsersQuery.InOrgIds | ||
| 227 | + } else { | ||
| 228 | + queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId | ||
| 229 | + } | ||
| 225 | queryOptions["userType"] = domain.UserTypeEmployee | 230 | queryOptions["userType"] = domain.UserTypeEmployee |
| 226 | _, users, err := userRepository.Find(queryOptions) | 231 | _, users, err := userRepository.Find(queryOptions) |
| 227 | if err != nil { | 232 | if err != nil { |
| @@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/query" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/query" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" |
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" | ||
| 12 | "time" | 13 | "time" |
| 13 | ) | 14 | ) |
| 14 | 15 | ||
| @@ -359,12 +360,24 @@ func (userService *UserService) GetUser(getUserQuery *query.GetUserQuery) (inter | @@ -359,12 +360,24 @@ func (userService *UserService) GetUser(getUserQuery *query.GetUserQuery) (inter | ||
| 359 | _, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId) | 360 | _, org, _ := factory.FastPgOrg(transactionContext, user.OrganizationId) |
| 360 | _, company, _ := factory.FastPgCompany(transactionContext, user.CompanyId) | 361 | _, company, _ := factory.FastPgCompany(transactionContext, user.CompanyId) |
| 361 | _, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId) | 362 | _, userBase, _ := factory.FastPgUserBase(transactionContext, user.UserBaseId) |
| 362 | - if dep != nil && org != nil && userBase != nil { | ||
| 363 | - user.Department = dep.ConvDep() | ||
| 364 | - user.Organization = org.CloneSample() | 363 | + if company != nil { |
| 365 | user.Company = company.CloneSample() | 364 | user.Company = company.CloneSample() |
| 365 | + } | ||
| 366 | + if org != nil { | ||
| 367 | + user.Organization = org.CloneSample() | ||
| 368 | + } | ||
| 369 | + if dep != nil { | ||
| 370 | + user.Department = dep.ConvDep() | ||
| 371 | + } | ||
| 372 | + if userBase != nil { | ||
| 366 | user.UserInfo = userBase.UserInfo | 373 | user.UserInfo = userBase.UserInfo |
| 367 | } | 374 | } |
| 375 | + // TODO:后期可以移除有冗余roleType | ||
| 376 | + for i := range user.UserRole { | ||
| 377 | + if _, role, _ := factory.FastPgRole(transactionContext, user.UserRole[i].RoleId); role != nil { | ||
| 378 | + user.UserRole[i].RoleType = role.RoleType | ||
| 379 | + } | ||
| 380 | + } | ||
| 368 | userDto := &dto.UserDto{Im: userBase.Im} | 381 | userDto := &dto.UserDto{Im: userBase.Im} |
| 369 | if err := userDto.LoadDto(user, company); err != nil { | 382 | if err := userDto.LoadDto(user, company); err != nil { |
| 370 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 383 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -486,6 +499,7 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -486,6 +499,7 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
| 486 | userRepository = value | 499 | userRepository = value |
| 487 | } | 500 | } |
| 488 | var company *domain.Company | 501 | var company *domain.Company |
| 502 | + var mapCompany = make(map[int64]*domain.Company) | ||
| 489 | var dtoUsers []*dto.UserDto | 503 | var dtoUsers []*dto.UserDto |
| 490 | queryOptions := utils.ObjectToMap(listUserQuery) | 504 | queryOptions := utils.ObjectToMap(listUserQuery) |
| 491 | if len(listUserQuery.Phone) > 0 { | 505 | if len(listUserQuery.Phone) > 0 { |
| @@ -502,8 +516,14 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | @@ -502,8 +516,14 @@ func (userService *UserService) ListUser(listUserQuery *query.ListUserQuery) (in | ||
| 502 | for i := range users { | 516 | for i := range users { |
| 503 | user := users[i] | 517 | user := users[i] |
| 504 | userDto := &dto.UserDto{} | 518 | userDto := &dto.UserDto{} |
| 505 | - if company == nil && user.CompanyId != 0 { | ||
| 506 | - _, company, _ = factory.FastPgCompany(transactionContext, user.CompanyId) | 519 | + var ok bool |
| 520 | + if company, ok = mapCompany[user.CompanyId]; !ok { | ||
| 521 | + _, company, err = factory.FastPgCompany(transactionContext, user.CompanyId) | ||
| 522 | + if err != nil { | ||
| 523 | + log.Logger.Error(err.Error()) | ||
| 524 | + continue | ||
| 525 | + } | ||
| 526 | + mapCompany[company.CompanyId] = company | ||
| 507 | } | 527 | } |
| 508 | if listUserQuery.PullRealTime { | 528 | if listUserQuery.PullRealTime { |
| 509 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) | 529 | _, dep, _ := factory.FastPgOrg(transactionContext, user.DepartmentId) |
| @@ -127,6 +127,7 @@ func (role *Role) CloneSample() *Role { | @@ -127,6 +127,7 @@ func (role *Role) CloneSample() *Role { | ||
| 127 | RoleId: role.RoleId, | 127 | RoleId: role.RoleId, |
| 128 | RoleName: role.RoleName, | 128 | RoleName: role.RoleName, |
| 129 | Ext: role.Ext, | 129 | Ext: role.Ext, |
| 130 | + RoleType: role.RoleType, | ||
| 130 | } | 131 | } |
| 131 | } | 132 | } |
| 132 | 133 |
| @@ -4,5 +4,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | @@ -4,5 +4,5 @@ import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | ||
| 4 | 4 | ||
| 5 | // PgAuthAccountDestroyService 账号注销服务 | 5 | // PgAuthAccountDestroyService 账号注销服务 |
| 6 | type PgAuthAccountDestroyService interface { | 6 | type PgAuthAccountDestroyService interface { |
| 7 | - DestroyAccount(optUser *domain.User, userId int64) error | 7 | + DestroyAccount(optUser *domain.User, userId string) error |
| 8 | } | 8 | } |
| @@ -13,21 +13,21 @@ type PgAuthAccountDestroyService struct { | @@ -13,21 +13,21 @@ type PgAuthAccountDestroyService struct { | ||
| 13 | transactionContext *pgTransaction.TransactionContext | 13 | transactionContext *pgTransaction.TransactionContext |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | -func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, userId int64) error { | 16 | +func (ptr *PgAuthAccountDestroyService) DestroyAccount(optUser *domain.User, account string) error { |
| 17 | // 1.查询账号记录 | 17 | // 1.查询账号记录 |
| 18 | userRepository, _ := repository.NewUserRepository(ptr.transactionContext) | 18 | userRepository, _ := repository.NewUserRepository(ptr.transactionContext) |
| 19 | - var userBaseId int64 | ||
| 20 | - if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil { | ||
| 21 | - if err == domain.ErrorNotFound { | ||
| 22 | - return fmt.Errorf("该用户不存在") | ||
| 23 | - } | ||
| 24 | - return err | ||
| 25 | - } else { | ||
| 26 | - userBaseId = user.UserBaseId | ||
| 27 | - } | 19 | + //var userBaseId int64 |
| 20 | + //if user, err := userRepository.FindOne(map[string]interface{}{"userId": userId}); err != nil { | ||
| 21 | + // if err == domain.ErrorNotFound { | ||
| 22 | + // return fmt.Errorf("该用户不存在") | ||
| 23 | + // } | ||
| 24 | + // return err | ||
| 25 | + //} else { | ||
| 26 | + // userBaseId = user.UserBaseId | ||
| 27 | + //} | ||
| 28 | 28 | ||
| 29 | userBaseRepository, _ := repository.NewUserBaseRepository(ptr.transactionContext) | 29 | userBaseRepository, _ := repository.NewUserBaseRepository(ptr.transactionContext) |
| 30 | - userBase, err := userBaseRepository.FindOne(map[string]interface{}{"userBaseId": userBaseId}) | 30 | + userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": account}) |
| 31 | if err != nil { | 31 | if err != nil { |
| 32 | return err | 32 | return err |
| 33 | } | 33 | } |
| @@ -14,9 +14,6 @@ type PgBatchAddOrgService struct { | @@ -14,9 +14,6 @@ type PgBatchAddOrgService struct { | ||
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | func (ptr *PgBatchAddOrgService) BatchAddOrg(optUser *domain.OperateInfo, orgList []*domain.BatchAddOrgItem) error { | 16 | func (ptr *PgBatchAddOrgService) BatchAddOrg(optUser *domain.OperateInfo, orgList []*domain.BatchAddOrgItem) error { |
| 17 | - var ( | ||
| 18 | - err error | ||
| 19 | - ) | ||
| 20 | orgRepository, err := repository.NewOrgRepository(ptr.transactionContext) | 17 | orgRepository, err := repository.NewOrgRepository(ptr.transactionContext) |
| 21 | if err != nil { | 18 | if err != nil { |
| 22 | return err | 19 | return err |
| @@ -191,6 +191,9 @@ func (repository *OrgRepository) Find(queryOptions map[string]interface{}) (int6 | @@ -191,6 +191,9 @@ func (repository *OrgRepository) Find(queryOptions map[string]interface{}) (int6 | ||
| 191 | query.SetWhereByQueryOption("org_name = ?", "depName") | 191 | query.SetWhereByQueryOption("org_name = ?", "depName") |
| 192 | query.SetWhereByQueryOption("org_code = ?", "orgCode") | 192 | query.SetWhereByQueryOption("org_code = ?", "orgCode") |
| 193 | query.SetWhereByQueryOption("parent_id = ?", "parentId") | 193 | query.SetWhereByQueryOption("parent_id = ?", "parentId") |
| 194 | + if v, ok := queryOptions["matchOrgName"]; ok && len(v.(string)) > 0 { | ||
| 195 | + query.Where(fmt.Sprintf(`org_name like '%%%v%%'`, v)) | ||
| 196 | + } | ||
| 194 | query.SetOrderDirect("org_id", "ASC") | 197 | query.SetOrderDirect("org_id", "ASC") |
| 195 | if count, err := query.SelectAndCount(); err != nil { | 198 | if count, err := query.SelectAndCount(); err != nil { |
| 196 | return 0, orgs, err | 199 | return 0, orgs, err |
| @@ -185,6 +185,9 @@ func (repository *RoleRepository) Find(queryOptions map[string]interface{}) (int | @@ -185,6 +185,9 @@ func (repository *RoleRepository) Find(queryOptions map[string]interface{}) (int | ||
| 185 | if orgName, ok := queryOptions["orgName"]; ok && len(orgName.(string)) > 0 { | 185 | if orgName, ok := queryOptions["orgName"]; ok && len(orgName.(string)) > 0 { |
| 186 | query.Where(fmt.Sprintf("ext->>'orgName' like '%%%v%%'", orgName)) | 186 | query.Where(fmt.Sprintf("ext->>'orgName' like '%%%v%%'", orgName)) |
| 187 | } | 187 | } |
| 188 | + if matchRoleName, ok := queryOptions["matchRoleName"]; ok && len(matchRoleName.(string)) > 0 { | ||
| 189 | + query.Where(fmt.Sprintf("role_name like '%%%v%%'", matchRoleName)) | ||
| 190 | + } | ||
| 188 | // 包含删除的 | 191 | // 包含删除的 |
| 189 | if v, ok := queryOptions["includeDeleted"]; ok && !(v.(bool)) { | 192 | if v, ok := queryOptions["includeDeleted"]; ok && !(v.(bool)) { |
| 190 | query.Where("deleted_at is null") | 193 | query.Where("deleted_at is null") |
| @@ -92,6 +92,17 @@ func (controller *RoleController) GetRoleRelatedUsers() { | @@ -92,6 +92,17 @@ func (controller *RoleController) GetRoleRelatedUsers() { | ||
| 92 | controller.Response(data, err) | 92 | controller.Response(data, err) |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | +func (controller *RoleController) RoleRelatedUsers() { | ||
| 96 | + roleService := service.NewRoleService(nil) | ||
| 97 | + getRoleRelatedUsersQuery := &query.GetRoleRelatedUsersQuery{} | ||
| 98 | + controller.Unmarshal(getRoleRelatedUsersQuery) | ||
| 99 | + roleId, _ := controller.GetInt64(":roleId") | ||
| 100 | + getRoleRelatedUsersQuery.RoleId = roleId | ||
| 101 | + getRoleRelatedUsersQuery.OperateInfo = ParseOperateInfo(controller.BaseController) | ||
| 102 | + data, err := roleService.GetRoleRelatedUsers(getRoleRelatedUsersQuery) | ||
| 103 | + controller.Response(data, err) | ||
| 104 | +} | ||
| 105 | + | ||
| 95 | func (controller *RoleController) GetRoleAccessMenus() { | 106 | func (controller *RoleController) GetRoleAccessMenus() { |
| 96 | roleService := service.NewRoleService(nil) | 107 | roleService := service.NewRoleService(nil) |
| 97 | getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{} | 108 | getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{} |
| @@ -13,5 +13,5 @@ func init() { | @@ -13,5 +13,5 @@ func init() { | ||
| 13 | web.Router("/auth/reset-phone", &controllers.AuthController{}, "Post:PhoneAuthResetPhone") | 13 | web.Router("/auth/reset-phone", &controllers.AuthController{}, "Post:PhoneAuthResetPhone") |
| 14 | web.Router("/auth/destroy-account", &controllers.AuthController{}, "Post:DestroyAccount") | 14 | web.Router("/auth/destroy-account", &controllers.AuthController{}, "Post:DestroyAccount") |
| 15 | web.Router("/auth/refresh-im", &controllers.AuthController{}, "Post:RefreshIM") | 15 | web.Router("/auth/refresh-im", &controllers.AuthController{}, "Post:RefreshIM") |
| 16 | - web.Router("/auth/user-base-info", &controllers.AuthController{}, "Post:UserInfo") | 16 | + web.Router("/auth/user-info", &controllers.AuthController{}, "Post:UserInfo") |
| 17 | } | 17 | } |
| @@ -12,6 +12,7 @@ func init() { | @@ -12,6 +12,7 @@ func init() { | ||
| 12 | web.Router("/role/:roleId", &controllers.RoleController{}, "Delete:RemoveRole") | 12 | web.Router("/role/:roleId", &controllers.RoleController{}, "Delete:RemoveRole") |
| 13 | web.Router("/role/search", &controllers.RoleController{}, "Post:SearchRole") | 13 | web.Router("/role/search", &controllers.RoleController{}, "Post:SearchRole") |
| 14 | web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Get:GetRoleRelatedUsers") | 14 | web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Get:GetRoleRelatedUsers") |
| 15 | + web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Post:RoleRelatedUsers") | ||
| 15 | web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Get:GetRoleAccessMenus") | 16 | web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Get:GetRoleAccessMenus") |
| 16 | web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Put:UpdateRoleAccessMenus") | 17 | web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Put:UpdateRoleAccessMenus") |
| 17 | web.Router("/role/assign", &controllers.RoleController{}, "Post:AssginRoleToUsers") | 18 | web.Router("/role/assign", &controllers.RoleController{}, "Post:AssginRoleToUsers") |
-
请 注册 或 登录 后发表评论