refactor(系统管理): 组织项目定时任务修改

This commit is contained in:
song-cc-rock 2024-01-25 19:52:52 +08:00
parent 379f46c795
commit 3927bb271b
8 changed files with 14 additions and 16 deletions

View File

@ -147,7 +147,7 @@ public class BugController {
@GetMapping("/sync/check/{projectId}")
@Operation(summary = "缺陷管理-列表-校验缺陷同步状态")
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
@CheckOwner(resourceId = "#projectId", resourceType = "project")
public BugSyncResult checkStatus(@PathVariable String projectId) {
return bugSyncService.checkSyncStatus(projectId);

View File

@ -2,10 +2,10 @@ package io.metersphere.bug.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.bug.dto.request.BugHistoryPageRequest;
import io.metersphere.bug.service.BugHistoryService;
import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.dto.OperationHistoryDTO;
import io.metersphere.system.dto.request.OperationHistoryRequest;
import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
@ -34,7 +34,7 @@ public class BugHistoryController {
@Operation(summary = "缺陷管理-变更历史-列表")
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public Pager<List<OperationHistoryDTO>> page(@Validated @RequestBody BugHistoryPageRequest request) {
public Pager<List<OperationHistoryDTO>> page(@Validated @RequestBody OperationHistoryRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "id desc");
return PageUtils.setPageInfo(page, bugHistoryService.list(request));

View File

@ -1,8 +1,8 @@
package io.metersphere.bug.service;
import io.metersphere.bug.dto.request.BugHistoryPageRequest;
import io.metersphere.sdk.util.CommonBeanFactory;
import io.metersphere.system.dto.OperationHistoryDTO;
import io.metersphere.system.dto.request.OperationHistoryRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -12,7 +12,7 @@ import java.util.List;
@Transactional(rollbackFor = Exception.class)
public class BugHistoryService {
public List<OperationHistoryDTO> list(BugHistoryPageRequest request) {
public List<OperationHistoryDTO> list(OperationHistoryRequest request) {
XpackBugService bugService = CommonBeanFactory.getBean(XpackBugService.class);
if (bugService != null) {
return bugService.listHis(request);

View File

@ -1,9 +1,9 @@
package io.metersphere.bug.service;
import io.metersphere.bug.dto.request.BugHistoryPageRequest;
import io.metersphere.bug.dto.request.BugSyncRequest;
import io.metersphere.project.domain.Project;
import io.metersphere.system.dto.OperationHistoryDTO;
import io.metersphere.system.dto.request.OperationHistoryRequest;
import java.util.List;
@ -30,5 +30,5 @@ public interface XpackBugService {
* @param request 请求参数
* @return 变更历史集合
*/
List<OperationHistoryDTO> listHis(BugHistoryPageRequest request);
List<OperationHistoryDTO> listHis(OperationHistoryRequest request);
}

View File

@ -1,7 +1,7 @@
package io.metersphere.bug.controller;
import io.metersphere.bug.dto.request.BugHistoryPageRequest;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.dto.request.OperationHistoryRequest;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@ -26,8 +26,8 @@ public class BugHistoryControllerTests extends BaseTest {
@Order(1)
@Sql(scripts = {"/dml/init_bug_history.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
void testBugHistoryPageSuccess() throws Exception {
BugHistoryPageRequest request = new BugHistoryPageRequest();
request.setBugId("bug-history-id");
OperationHistoryRequest request = new OperationHistoryRequest();
request.setSourceId("bug-history-id");
request.setProjectId("100001100001");
request.setCurrent(1);
request.setPageSize(10);

View File

@ -1,10 +1,10 @@
package io.metersphere.bug.mock;
import io.metersphere.bug.dto.request.BugHistoryPageRequest;
import io.metersphere.bug.dto.request.BugSyncRequest;
import io.metersphere.bug.service.XpackBugService;
import io.metersphere.project.domain.Project;
import io.metersphere.system.dto.OperationHistoryDTO;
import io.metersphere.system.dto.request.OperationHistoryRequest;
import org.springframework.stereotype.Service;
import java.util.List;
@ -23,7 +23,7 @@ public class XpackBugMockServiceImpl implements XpackBugService {
}
@Override
public List<OperationHistoryDTO> listHis(BugHistoryPageRequest request) {
public List<OperationHistoryDTO> listHis(OperationHistoryRequest request) {
return List.of();
}
}

View File

@ -31,8 +31,7 @@ public class CleanOrganizationJob {
public void cleanOrganization() {
LogUtils.info("clean up organization start.");
try {
//TODO 为了测试改成一天 正是后改成一个月
LocalDate date = LocalDate.now().minusDays(1);
LocalDate date = LocalDate.now().minusMonths(1);
long timestamp = date.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
this.doCleanupOrganization(timestamp);
} catch (Exception e) {

View File

@ -28,8 +28,7 @@ public class CleanProjectJob {
@QuartzScheduled(cron = "0 0 3 * * ?")
public void cleanupProject() {
LogUtils.info("clean up project start.");
//TODO 为了测试改成一天 正是后改成一个月
LocalDate date = LocalDate.now().minusDays(1);
LocalDate date = LocalDate.now().minusMonths(1);
long timestamp = date.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
this.doCleanupProject(timestamp);
LogUtils.info("clean up project end.");