From aee550a064e0c6800eb01613b2d2b4a16637bda2 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Feb 2022 10:56:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=AE=B0=E5=BD=95=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/validator/group/QueryGroup.java | 19 ++++++++++++++++++ .../dto/form/ImportTaskCommonFormDTO.java | 6 ++++-- .../controller/ImportTaskController.java | 19 ++++++++++++++++-- .../com/epmet/service/ImportTaskService.java | 15 ++++++++++++-- .../service/impl/ImportTaskServiceImpl.java | 20 +++++++++++++++++-- 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java new file mode 100644 index 0000000000..df4536366b --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.validator.group; + +/** + * 查询 Group + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface QueryGroup { + +} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java index 07a6137ca4..0b596b40c7 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java @@ -1,11 +1,13 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.QueryGroup; import lombok.Data; import javax.validation.constraints.NotBlank; @Data -public class ImportTaskCommonFormDTO { +public class ImportTaskCommonFormDTO extends PageFormDTO { public interface Create {} public interface Finish {} @@ -13,7 +15,7 @@ public class ImportTaskCommonFormDTO { /** * 操作者ID */ - @NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class }) + @NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class, QueryGroup.class}) private String operatorId; /** diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java index d6ce2f4be8..24cb53f8d4 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java @@ -1,9 +1,13 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.QueryGroup; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.service.ImportTaskService; @@ -12,8 +16,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; - @RestController @RequestMapping("import-task") public class ImportTaskController { @@ -21,6 +23,19 @@ public class ImportTaskController { @Autowired private ImportTaskService importTaskService; + /** + * desc:分页获取个人导入记录 + * @param tokenDto + * @return + */ + @RequestMapping("page") + public Result> list(@LoginUser TokenDto tokenDto, @RequestBody ImportTaskCommonFormDTO param) { + //tokenDto.setUserId("d8dfc6c1fa2538976059f3900036d419"); + param.setOperatorId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(param, QueryGroup.class); + return new Result().ok(importTaskService.page(param)); + } + /** * 创建导入任务 * @param input diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java index dee9e7984c..dbc4cde7c1 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java @@ -1,8 +1,12 @@ package com.epmet.service; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; + /** - * + * * * @author generator generator@elink-cn.com * @since v1.0.0 2022-02-15 @@ -32,4 +36,11 @@ public interface ImportTaskService { * @param resultDesc 结果描述文本 */ Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc); -} \ No newline at end of file + + /** + * desc:分页获取个人导入记录 + * @param param + * @return + */ + PageData page(ImportTaskCommonFormDTO param); +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java index 987fe3a0ae..6692d1f46e 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -3,17 +3,22 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.ImportTaskDao; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.ImportTaskEntity; import com.epmet.service.ImportTaskService; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; /** - * + * * * @author generator generator@elink-cn.com * @since v1.0.0 2022-02-15 @@ -77,4 +82,15 @@ public class ImportTaskServiceImpl implements ImportTaskService { public Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc) { return importRecordDao.finish(taskId, processStatus, operatorId, resultDesc, resultDescFile) > 0; } -} \ No newline at end of file + + @Override + public PageData page(ImportTaskCommonFormDTO param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId()); + Page page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> { + importRecordDao.selectList(queryWrapper); + }); + PageData result = new PageData<>(page.getResult(),page.getTotal()); + return result; + } +}