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

@@ -86,4 +86,18 @@ public class ProjectDao extends BaseDao<ProjectRecord, ProjectPojo> {
+ " where project.deleted = false and `group`.id in " + groupIdIn + " group by `group`.id;";
return dslContext.resultQuery(sql).fetchInto(GroupProjectCountPojo.class);
}
public void deleteByGroupId(Integer groupId) {
dslContext
.update(PROJECT).set(PROJECT.DELETED, true)
.where(PROJECT.GROUP_ID.eq(groupId).and(PROJECT.DELETED.eq(false)))
.execute();
}
public List<Integer> selectProjectIdsByGroupId(Integer groupId) {
return dslContext
.select(PROJECT.ID).from(PROJECT)
.where(PROJECT.GROUP_ID.eq(groupId).and(PROJECT.DELETED.eq(false)))
.fetchInto(Integer.class);
}
}

View File

@@ -95,4 +95,22 @@ public class ProjectSyncRuleDao extends BaseDao<ProjectSyncRuleRecord, ProjectSy
PROJECT_SYNC_RULE.PROJECT_ID.eq(projectId)
.and(PROJECT_SYNC_RULE.AUTO_SYNC_CRON.eq(cron)));
}
public void disableAutoSyncByProjectId(Integer projectId) {
dslContext
.update(PROJECT_SYNC_RULE).set(PROJECT_SYNC_RULE.IS_AUTO_SYNC, false)
.where(PROJECT_SYNC_RULE.PROJECT_ID.eq(projectId))
.execute();
}
public void disableAutoSyncByProjectIds(List<Integer> projectIds) {
if (projectIds == null || projectIds.isEmpty()) {
return;
}
dslContext
.update(PROJECT_SYNC_RULE).set(PROJECT_SYNC_RULE.IS_AUTO_SYNC, false)
.where(PROJECT_SYNC_RULE.PROJECT_ID.in(projectIds))
.execute();
}
}