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