fix: disable auto sync after delete project/group (#5)

This commit is contained in:
vran
2022-01-26 17:35:56 +08:00
committed by GitHub
parent 4bf7f5161a
commit 82feab3f1a
4 changed files with 44 additions and 9 deletions

View File

@@ -4,10 +4,7 @@ import com.databasir.core.domain.DomainErrors;
import com.databasir.core.domain.group.converter.GroupPojoConverter;
import com.databasir.core.domain.group.converter.GroupResponseConverter;
import com.databasir.core.domain.group.data.*;
import com.databasir.dao.impl.GroupDao;
import com.databasir.dao.impl.ProjectDao;
import com.databasir.dao.impl.UserDao;
import com.databasir.dao.impl.UserRoleDao;
import com.databasir.dao.impl.*;
import com.databasir.dao.tables.pojos.GroupPojo;
import com.databasir.dao.tables.pojos.UserPojo;
import com.databasir.dao.tables.pojos.UserRolePojo;
@@ -36,6 +33,8 @@ public class GroupService {
private final ProjectDao projectDao;
private final ProjectSyncRuleDao projectSyncRuleDao;
private final GroupPojoConverter groupPojoConverter;
private final GroupResponseConverter groupResponseConverter;
@@ -78,6 +77,9 @@ public class GroupService {
public void delete(Integer groupId) {
groupDao.deleteById(groupId);
userRoleDao.deleteByGroupId(groupId);
List<Integer> projectIds = projectDao.selectProjectIdsByGroupId(groupId);
projectSyncRuleDao.disableAutoSyncByProjectIds(projectIds);
projectDao.deleteByGroupId(groupId);
}
public Page<GroupPageResponse> list(Pageable pageable, GroupPageCondition condition) {

View File

@@ -49,11 +49,11 @@ public class ProjectService {
public ProjectDetailResponse getOne(Integer id) {
return projectDao.selectOptionalById(id)
.map(schemaSource -> {
DataSourcePojo dataSource = dataSourceDao.selectByProjectId(id);
List<DataSourcePropertyPojo> properties = dataSourcePropertyDao.selectByDataSourceId(dataSource.getId());
ProjectDetailResponse.DataSourceResponse dataSourceResponse = projectResponseConverter.toResponse(dataSource, properties);
ProjectSyncRulePojo rule = projectSyncRuleDao.selectByProjectId(id);
ProjectDetailResponse.ProjectSyncRuleResponse ruleResponse = projectResponseConverter.toResponse(rule);
var dataSource = dataSourceDao.selectByProjectId(id);
var properties = dataSourcePropertyDao.selectByDataSourceId(dataSource.getId());
var dataSourceResponse = projectResponseConverter.toResponse(dataSource, properties);
var projectSyncRule = projectSyncRuleDao.selectOptionalByProjectId(id).orElse(null);
var ruleResponse = projectResponseConverter.toResponse(projectSyncRule);
return projectResponseConverter.toResponse(schemaSource, dataSourceResponse, ruleResponse);
})
.orElseThrow(DomainErrors.PROJECT_NOT_FOUND::exception);
@@ -125,6 +125,7 @@ public class ProjectService {
public void delete(Integer projectId) {
projectDao.updateDeletedById(true, projectId);
projectSyncRuleDao.disableAutoSyncByProjectId(projectId);
}
public Page<ProjectSimpleResponse> list(Pageable page, ProjectListCondition condition) {