mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +00:00
Fix null field in member role
This commit is contained in:
parent
6a9cd975ff
commit
593f4fd00d
@ -8,25 +8,19 @@ import com.rbkmoney.swag.organizations.model.RoleId;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class MemberRoleConverter {
|
||||
|
||||
public MemberRoleEntity toEntity(MemberRole role, String orgId) {
|
||||
Optional<MemberRoleScope> scope = Optional.ofNullable(role.getScope());
|
||||
MemberRoleScope scope = role.getScope();
|
||||
return MemberRoleEntity.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.organizationId(orgId)
|
||||
.resourceId(scope
|
||||
.map(MemberRoleScope::getResourceId)
|
||||
.orElse(null))
|
||||
.resourceId(Objects.nonNull(scope) ? scope.getResourceId() : null)
|
||||
.roleId(role.getRoleId().toString())
|
||||
.scopeId(scope
|
||||
.map(MemberRoleScope::getId)
|
||||
.map(Objects::toString)
|
||||
.orElse(null))
|
||||
.scopeId(Objects.nonNull(scope) ? scope.getId().toString() : null)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ CREATE TABLE IF NOT EXISTS org_manager.member_role
|
||||
id CHARACTER VARYING NOT NULL,
|
||||
organization_id CHARACTER VARYING NOT NULL,
|
||||
role_id CHARACTER VARYING NOT NULL,
|
||||
scope_id CHARACTER VARYING NOT NULL,
|
||||
resource_id CHARACTER VARYING NOT NULL,
|
||||
scope_id CHARACTER VARYING,
|
||||
resource_id CHARACTER VARYING,
|
||||
CONSTRAINT member_role_pkey PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user