Skip to content

Commit

Permalink
fix: role
Browse files Browse the repository at this point in the history
  • Loading branch information
foliet committed Oct 11, 2023
1 parent 06a0fff commit 8b3f702
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions biz/application/service/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ func (s *SystemServiceImpl) UpdateUserRole(ctx context.Context, req *system.Upda
return nil, consts.ErrInvalidObjectId
}

roles := make([]db.Role, len(req.Roles))
roles := make([]*db.Role, len(req.Roles))
for i, role := range req.Roles {
if RoleTypeName[role.RoleType] == db.RoleCommunityAdmin {
id, _ := s.CheckCommunityIdExist(ctx, *role.CommunityId)
if id == primitive.NilObjectID {
return nil, consts.ErrCommunityIdNotFound
}
}
roles[i] = db.Role{
roles[i] = &db.Role{
Type: RoleTypeName[role.RoleType],
CommunityId: role.GetCommunityId(),
}
Expand Down Expand Up @@ -462,7 +462,7 @@ func (s *SystemServiceImpl) HandleApply(ctx context.Context, req *system.HandleA
if err != nil {
return nil, err
}
userRole.Roles = append(userRole.Roles, db.Role{
userRole.Roles = append(userRole.Roles, &db.Role{
Type: db.RoleCommunityAdmin,
CommunityId: apply.CommunityId,
})
Expand Down
2 changes: 1 addition & 1 deletion biz/infrastructure/data/db/user_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Role struct {

type UserRole struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Roles []Role `bson:"roles,omitempty" json:"roles,omitempty"`
Roles []*Role `bson:"roles,omitempty" json:"roles,omitempty"`
UpdateAt time.Time `bson:"updateAt,omitempty" json:"updateAt,omitempty"`
CreateAt time.Time `bson:"createAt,omitempty" json:"createAt,omitempty"`
}

0 comments on commit 8b3f702

Please sign in to comment.