SUPPORT-9212: fixes
This commit is contained in:
parent
6848180f0f
commit
6a61ffb1ca
7 changed files with 58 additions and 15 deletions
|
|
@ -26,7 +26,7 @@ public class AccountData {
|
|||
private int version;
|
||||
private ReferenceEntity domain;
|
||||
private ReferenceEntity person;
|
||||
private List<ReferenceEntity> roles;
|
||||
private List<RoleData> roles;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
|
@ -132,11 +132,11 @@ public class AccountData {
|
|||
this.person = person;
|
||||
}
|
||||
|
||||
public List<ReferenceEntity> getRoles() {
|
||||
public List<RoleData> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<ReferenceEntity> roles) {
|
||||
public void setRoles(List<RoleData> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,16 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AccountRoleData {
|
||||
@JsonProperty("sub")
|
||||
@JsonProperty("id_account")
|
||||
private String id;
|
||||
@JsonProperty("id")
|
||||
@JsonProperty("id_role")
|
||||
private String roleId;
|
||||
private long finish;
|
||||
|
||||
public AccountRoleData(String id, String roleId) {
|
||||
public AccountRoleData(String id, String roleId, long finish) {
|
||||
this.id = id;
|
||||
this.roleId = roleId;
|
||||
this.finish = finish;
|
||||
}
|
||||
|
||||
public AccountRoleData() {
|
||||
|
|
@ -36,4 +38,12 @@ public class AccountRoleData {
|
|||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public long getFinish() {
|
||||
return finish;
|
||||
}
|
||||
|
||||
public void setFinish(long finish) {
|
||||
this.finish = finish;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public class RoleData {
|
|||
private long modified;
|
||||
private long deleted;
|
||||
private int version;
|
||||
private long finish;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
|
@ -88,4 +89,12 @@ public class RoleData {
|
|||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public long getFinish() {
|
||||
return finish;
|
||||
}
|
||||
|
||||
public void setFinish(long finish) {
|
||||
this.finish = finish;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import ervu_business_metrics.dao.AccountRoleDataDao;
|
||||
import ervu_business_metrics.model.ReferenceEntity;
|
||||
import ervu_business_metrics.model.idm.AccountData;
|
||||
import ervu_business_metrics.model.idm.AccountRoleData;
|
||||
import ervu_business_metrics.model.idm.RoleData;
|
||||
import ervu_business_metrics.service.processor.LinkDataProcessor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.micord.webbpm.ervu.business_metrics.db_beans.idm_reconcile.tables.records.AccountRoleRecord;
|
||||
|
|
@ -46,6 +46,7 @@ public class AccountRoleDataProcessor
|
|||
AccountRoleRecord accountRoleRecord = dao.newRecord();
|
||||
accountRoleRecord.setAccountId(data.getId());
|
||||
accountRoleRecord.setRoleId(data.getRoleId());
|
||||
accountRoleRecord.setFinish(data.getFinish());
|
||||
return accountRoleRecord;
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +58,8 @@ public class AccountRoleDataProcessor
|
|||
List<String> existingRoleIds = dao.getRoleIdsByAccountId(accountId);
|
||||
Set<String> incomingRoleIds = account.getRoles() == null
|
||||
? Set.of()
|
||||
: account.getRoles()
|
||||
.stream()
|
||||
.map(ReferenceEntity::getId)
|
||||
: account.getRoles().stream()
|
||||
.map(RoleData::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<String> toDelete = existingRoleIds.stream()
|
||||
|
|
@ -70,13 +70,15 @@ public class AccountRoleDataProcessor
|
|||
dao.deleteAccountRolesByAccountIdAndRoleIds(accountId, toDelete);
|
||||
}
|
||||
|
||||
List<String> toAdd = incomingRoleIds.stream()
|
||||
.filter(roleId -> !existingRoleIds.contains(roleId))
|
||||
.toList();
|
||||
List<RoleData> toAdd = account.getRoles() == null
|
||||
? List.of()
|
||||
: account.getRoles().stream()
|
||||
.filter(role -> !existingRoleIds.contains(role.getId()))
|
||||
.toList();
|
||||
|
||||
if (!toAdd.isEmpty()) {
|
||||
List<AccountRoleRecord> newRecords = toAdd.stream()
|
||||
.map(roleId -> mapToRecord(new AccountRoleData(accountId, roleId)))
|
||||
.map(role -> mapToRecord(new AccountRoleData(accountId, role.getId(), role.getFinish())))
|
||||
.toList();
|
||||
accountRoleRecords.addAll(newRecords);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,11 @@ public class AccountRole extends TableImpl<AccountRoleRecord> {
|
|||
*/
|
||||
public final TableField<AccountRoleRecord, String> ROLE_ID = createField(DSL.name("role_id"), SQLDataType.VARCHAR(36).nullable(false), this, "Уникальный идентификатор роли");
|
||||
|
||||
/**
|
||||
* The column <code>idm_reconcile.account_role.finish</code>.
|
||||
*/
|
||||
public final TableField<AccountRoleRecord, Long> FINISH = createField(DSL.name("finish"), SQLDataType.BIGINT.nullable(false), this, "");
|
||||
|
||||
private AccountRole(Name alias, Table<AccountRoleRecord> aliased) {
|
||||
this(alias, aliased, (Field<?>[]) null, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,20 @@ public class AccountRoleRecord extends UpdatableRecordImpl<AccountRoleRecord> {
|
|||
return (String) get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>idm_reconcile.account_role.finish</code>.
|
||||
*/
|
||||
public void setFinish(Long value) {
|
||||
set(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>idm_reconcile.account_role.finish</code>.
|
||||
*/
|
||||
public Long getFinish() {
|
||||
return (Long) get(2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -73,11 +87,12 @@ public class AccountRoleRecord extends UpdatableRecordImpl<AccountRoleRecord> {
|
|||
/**
|
||||
* Create a detached, initialised AccountRoleRecord
|
||||
*/
|
||||
public AccountRoleRecord(String accountId, String roleId) {
|
||||
public AccountRoleRecord(String accountId, String roleId, Long finish) {
|
||||
super(AccountRole.ACCOUNT_ROLE);
|
||||
|
||||
setAccountId(accountId);
|
||||
setRoleId(roleId);
|
||||
setFinish(finish);
|
||||
resetChangedOnNotNull();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@
|
|||
CREATE TABLE IF NOT EXISTS idm_reconcile.account_role (
|
||||
account_id varchar(36) NOT NULL,
|
||||
role_id varchar(36) NOT NULL,
|
||||
finish bigint NOT NULL,
|
||||
|
||||
CONSTRAINT pk_account_role PRIMARY KEY (account_id, role_id));
|
||||
ALTER TABLE idm_reconcile.account_role OWNER TO ervu_business_metrics;
|
||||
|
|
@ -153,6 +154,7 @@
|
|||
COMMENT ON TABLE idm_reconcile.account_role IS 'Связующая таблица для связи многие ко многим между аккаунтами и ролями';
|
||||
COMMENT ON COLUMN idm_reconcile.account_role.account_id IS 'Уникальный идентификатор аккаунта';
|
||||
COMMENT ON COLUMN idm_reconcile.account_role.role_id IS 'Уникальный идентификатор роли';
|
||||
COMMENT ON COLUMN idm_reconcile.account_role.finish IS 'Время окончания роли для аккаунта';
|
||||
</sql>
|
||||
|
||||
</changeSet>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue