SUPPORT-9422: edit for a new format
This commit is contained in:
parent
9476bd4d3f
commit
dfbb9b712d
18 changed files with 53 additions and 40 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package ru.micord.ervu.account_applications.dao;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
|
@ -83,11 +84,11 @@ public abstract class AbstractDataDao<T extends UpdatableRecord<T>> {
|
|||
.fetch(selectField);
|
||||
}
|
||||
|
||||
protected <V, F> void setFieldByField(Field<V> targetField, V value, Field<F> whereField,
|
||||
F whereValue) {
|
||||
protected <V, F> void setFieldWhereIn(Field<V> targetField, V value, Field<F> whereField,
|
||||
Collection<F> whereValues) {
|
||||
dsl.update(getTable())
|
||||
.set(targetField, value)
|
||||
.where(whereField.eq(whereValue))
|
||||
.where(whereField.in(whereValues))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,11 @@ public class RecruitmentDao extends AbstractDataDao<RecruitmentRecord> {
|
|||
return getValueByField(Recruitment.RECRUITMENT.ID, Recruitment.RECRUITMENT.IDM_ID, idmId);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id, boolean active) {
|
||||
setFieldByField(Recruitment.RECRUITMENT.ACTIVE, active, Recruitment.RECRUITMENT.IDM_ID, id);
|
||||
public void setActiveStatus(List<String> ids, boolean active) {
|
||||
setFieldWhereIn(
|
||||
Recruitment.RECRUITMENT.ACTIVE, active,
|
||||
Recruitment.RECRUITMENT.IDM_ID, ids
|
||||
);
|
||||
}
|
||||
|
||||
public boolean exists(Long appNumber, String domainId, boolean checkParents) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package ru.micord.ervu.account_applications.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Table;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
|
@ -21,10 +23,10 @@ public class RoleDao extends AbstractDataDao<UserApplicationRoleRecord> {
|
|||
return Tables.USER_APPLICATION_ROLE;
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id, boolean active) {
|
||||
setFieldByField(
|
||||
public void setActiveStatus(List<String> ids, boolean active) {
|
||||
setFieldWhereIn(
|
||||
Tables.USER_APPLICATION_ROLE.ACTIVE, active,
|
||||
Tables.USER_APPLICATION_ROLE.USER_ROLE_ID, id
|
||||
Tables.USER_APPLICATION_ROLE.USER_ROLE_ID, ids
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package ru.micord.ervu.account_applications.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Table;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
|
@ -16,8 +18,11 @@ public class SolutionDao extends AbstractDataDao<SolutionRecord> {
|
|||
super(dsl);
|
||||
}
|
||||
|
||||
public void setActiveStatus(String id, boolean active) {
|
||||
setFieldByField(Tables.SOLUTION.ACTIVE, active, Tables.SOLUTION.ID, id);
|
||||
public void setActiveStatus(List<String> ids, boolean active) {
|
||||
setFieldWhereIn(
|
||||
Tables.SOLUTION.ACTIVE, active,
|
||||
Tables.SOLUTION.ID, ids
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package ru.micord.ervu.account_applications.kafka.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import ru.micord.ervu.account_applications.model.ReferenceEntity;
|
||||
|
||||
|
|
@ -9,13 +11,13 @@ import ru.micord.ervu.account_applications.model.ReferenceEntity;
|
|||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ChangeActiveMessage {
|
||||
private boolean success;
|
||||
private ReferenceEntity data;
|
||||
private List<String> data;
|
||||
|
||||
public ReferenceEntity getData() {
|
||||
public List<String> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(ReferenceEntity data) {
|
||||
public void setData(List<String> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import org.springframework.context.annotation.DependsOn;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import ru.micord.ervu.account_applications.exception.IdmDirectoriesException;
|
||||
|
|
@ -98,13 +99,13 @@ public class ErvuDirectoriesService {
|
|||
ChangeActiveMessage.class
|
||||
);
|
||||
|
||||
if (changeActiveMessage.isSuccess() && changeActiveMessage.getData() != null) {
|
||||
if (changeActiveMessage.isSuccess() && !CollectionUtils.isEmpty(changeActiveMessage.getData())) {
|
||||
DataProcessor<T, ?> processor = (DataProcessor<T, ?>) dataProcessors.get(entityClass);
|
||||
if (processor == null) {
|
||||
throw new IllegalStateException("No processor found for " + entityClass.getSimpleName());
|
||||
}
|
||||
|
||||
processor.changeActiveStatus(changeActiveMessage.getData().getId(), active);
|
||||
processor.changeActiveStatus(changeActiveMessage.getData(), active);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package ru.micord.ervu.account_applications.service.processor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Adel Kalimullin
|
||||
*/
|
||||
public interface DataProcessor<T, R> {
|
||||
void upsertData(T data);
|
||||
|
||||
void changeActiveStatus(String id, boolean active);
|
||||
void changeActiveStatus(List<String> ids, boolean active);
|
||||
|
||||
Class<T> getType();
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class RecruitmentIpProcessor
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeActiveStatus(String id, boolean active) {
|
||||
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.micord.ervu.account_applications.service.processor.impl;
|
|||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
@ -56,8 +57,8 @@ public class RecruitmentProcessor implements DataProcessor<RecruitmentData, Recr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeActiveStatus(String id, boolean active) {
|
||||
dao.setActiveStatus(id, active);
|
||||
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||
dao.setActiveStatus(ids, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class RecruitmentSolutionProcessor
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeActiveStatus(String id, boolean active) {
|
||||
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ package ru.micord.ervu.account_applications.service.processor.impl;
|
|||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
@ -41,8 +42,8 @@ public class RoleProcessor implements DataProcessor<RoleData, UserApplicationRol
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeActiveStatus(String id, boolean active) {
|
||||
dao.setActiveStatus(id, active);
|
||||
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||
dao.setActiveStatus(ids, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.micord.ervu.account_applications.service.processor.impl;
|
|||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -40,8 +41,8 @@ public class SolutionProcessor implements DataProcessor<SolutionData, SolutionRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeActiveStatus(String id, boolean active) {
|
||||
dao.setActiveStatus(id, active);
|
||||
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||
dao.setActiveStatus(ids, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class SolutionRoleProcessor
|
|||
}
|
||||
|
||||
@Override
|
||||
public void changeActiveStatus(String id, boolean active) {
|
||||
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue