SUPPORT-9212: фикс на ревью
This commit is contained in:
parent
226c554eaf
commit
491f75cb71
5 changed files with 25 additions and 11 deletions
|
|
@ -3,7 +3,11 @@ package ervu_business_metrics.dao;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.*;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UpdatableRecord;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
/**
|
||||
|
|
@ -62,17 +66,11 @@ public abstract class AbstractDataDao<T extends UpdatableRecord<T>> {
|
|||
.fetch(selectField);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id, boolean isActive) {
|
||||
Field<Boolean> activeField = getTable().field("active", Boolean.class);
|
||||
Field<String> idField = getTable().field("id", String.class);
|
||||
|
||||
if (activeField == null || idField == null) {
|
||||
throw new IllegalArgumentException("Table must have 'id' and 'active' fields");
|
||||
}
|
||||
|
||||
protected <V, F> void setFieldByField(Field<V> targetField, V value, Field<F> whereField,
|
||||
F whereValue) {
|
||||
dsl.update(getTable())
|
||||
.set(activeField, isActive)
|
||||
.where(idField.eq(id))
|
||||
.set(targetField, value)
|
||||
.where(whereField.eq(whereValue))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ public class AccountDataDao extends AbstractDataDao<AccountRecord> {
|
|||
return getValuesByField(Tables.ACCOUNT.ID, Tables.ACCOUNT.PERSON_ID, personId);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id, boolean active) {
|
||||
setFieldByField(Tables.ACCOUNT.ACTIVE, active, Tables.ACCOUNT.ID, id);
|
||||
}
|
||||
|
||||
public void deleteByIds(List<String> ids) {
|
||||
deleteByFieldInValues(Tables.ACCOUNT.ID, ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ public class DomainDataDao extends AbstractDataDao<DomainRecord> {
|
|||
super(dsl);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id , boolean active){
|
||||
setFieldByField(Tables.DOMAIN.ACTIVE, active, Tables.DOMAIN.ID, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Table<DomainRecord> getTable() {
|
||||
return Tables.DOMAIN;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ public class PersonDataDao extends AbstractDataDao<PersonRecord> {
|
|||
super(dsl);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id , boolean active){
|
||||
setFieldByField(Tables.PERSON.ACTIVE, active, Tables.PERSON.ID, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Table<PersonRecord> getTable() {
|
||||
return Tables.PERSON;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ public class RoleDataDao extends AbstractDataDao<RoleRecord> {
|
|||
super(dsl);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id , boolean active){
|
||||
setFieldByField(Tables.ROLE.ACTIVE, active, Tables.ROLE.ID, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Table<RoleRecord> getTable() {
|
||||
return Tables.ROLE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue