From 1b52e1994dfc61207df6cdcc44fd6c2ac96fb0c9 Mon Sep 17 00:00:00 2001 From: mabofu Date: Fri, 23 Dec 2022 15:40:01 +0800 Subject: [PATCH] Add task list feature --- .../task/controller/TaskController.java | 27 ++++++++++++ .../dsms/modules/task/model/TaskPageVO.java | 24 +++++++++++ .../task/service/impl/TaskServiceImpl.java | 12 ++++++ .../dsms/common/config/MybatisPlusConfig.java | 37 ++++++++++++++++ .../java/com/dsms/common/model/PageParam.java | 43 +++++++++++++++++++ .../taskmanager/service/ITaskService.java | 10 +++++ 6 files changed, 153 insertions(+) create mode 100644 dsms-engine-application/src/main/java/com/dsms/modules/task/model/TaskPageVO.java create mode 100644 dsms-engine-common/src/main/java/com/dsms/common/config/MybatisPlusConfig.java create mode 100644 dsms-engine-common/src/main/java/com/dsms/common/model/PageParam.java diff --git a/dsms-engine-application/src/main/java/com/dsms/modules/task/controller/TaskController.java b/dsms-engine-application/src/main/java/com/dsms/modules/task/controller/TaskController.java index 06d0217..d750cc8 100644 --- a/dsms-engine-application/src/main/java/com/dsms/modules/task/controller/TaskController.java +++ b/dsms-engine-application/src/main/java/com/dsms/modules/task/controller/TaskController.java @@ -16,14 +16,41 @@ package com.dsms.modules.task.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dsms.common.model.Result; +import com.dsms.common.taskmanager.model.Task; +import com.dsms.common.taskmanager.service.ITaskService; +import com.dsms.dfsbroker.node.model.Node; +import com.dsms.modules.task.model.TaskPageVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.Map; + /** * 任务信息表 前端控制器 */ @RestController @RequestMapping("/api/task") +@Api(tags = "任务模块") public class TaskController { + @Autowired + private ITaskService taskService; + + @ApiOperation("任务模块-获取任务列表") + @PostMapping("/list") + public Result> list(@RequestBody TaskPageVO taskPageVO) { + Page taskPage = new Page<>(taskPageVO.getPageNo(), taskPageVO.getPageSize()); + Page taskList = taskService.listPageTask(taskPage, taskPageVO); + + return Result.OK(taskList); + } + } diff --git a/dsms-engine-application/src/main/java/com/dsms/modules/task/model/TaskPageVO.java b/dsms-engine-application/src/main/java/com/dsms/modules/task/model/TaskPageVO.java new file mode 100644 index 0000000..3e8e6c0 --- /dev/null +++ b/dsms-engine-application/src/main/java/com/dsms/modules/task/model/TaskPageVO.java @@ -0,0 +1,24 @@ +/* + * Copyright 2022 The DSMS Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.dsms.modules.task.model; + +import com.dsms.common.model.PageParam; + +public class TaskPageVO extends PageParam { + + +} diff --git a/dsms-engine-application/src/main/java/com/dsms/modules/task/service/impl/TaskServiceImpl.java b/dsms-engine-application/src/main/java/com/dsms/modules/task/service/impl/TaskServiceImpl.java index 89cf09c..0b92d53 100644 --- a/dsms-engine-application/src/main/java/com/dsms/modules/task/service/impl/TaskServiceImpl.java +++ b/dsms-engine-application/src/main/java/com/dsms/modules/task/service/impl/TaskServiceImpl.java @@ -16,16 +16,28 @@ package com.dsms.modules.task.service.impl; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.dsms.common.model.PageParam; import com.dsms.common.taskmanager.model.Task; import com.dsms.common.taskmanager.service.ITaskService; import com.dsms.modules.task.mapper.TaskMapper; import org.springframework.stereotype.Service; +import java.awt.*; +import java.util.List; +import java.util.Map; + /** * 任务信息表 服务实现类 */ @Service public class TaskServiceImpl extends ServiceImpl implements ITaskService { + @Override + public Page listPageTask(Page taskPage, PageParam pageParam) { + Page page = page(taskPage); + return page; + } + } diff --git a/dsms-engine-common/src/main/java/com/dsms/common/config/MybatisPlusConfig.java b/dsms-engine-common/src/main/java/com/dsms/common/config/MybatisPlusConfig.java new file mode 100644 index 0000000..805dea6 --- /dev/null +++ b/dsms-engine-common/src/main/java/com/dsms/common/config/MybatisPlusConfig.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 The DSMS Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.dsms.common.config; + + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MybatisPlusConfig { + /** + * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除) + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MARIADB)); + return interceptor; + } +} diff --git a/dsms-engine-common/src/main/java/com/dsms/common/model/PageParam.java b/dsms-engine-common/src/main/java/com/dsms/common/model/PageParam.java new file mode 100644 index 0000000..d3ebfef --- /dev/null +++ b/dsms-engine-common/src/main/java/com/dsms/common/model/PageParam.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 The DSMS Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.dsms.common.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@ApiModel("分页参数") +@Data +public class PageParam implements Serializable { + + @ApiModelProperty(value = "页码,从 1 开始", required = true,example = "1") + @NotNull(message = "页码不能为空") + @Min(value = 1, message = "页码最小值为 1") + private Integer pageNo = 1; + + @ApiModelProperty(value = "每页条数,最大值为 100", required = true, example = "10") + @NotNull(message = "每页条数不能为空") + @Min(value = 1, message = "每页条数最小值为 1") + @Max(value = 100, message = "每页条数最大值为 100") + private Integer pageSize = 10; + +} diff --git a/dsms-engine-common/src/main/java/com/dsms/common/taskmanager/service/ITaskService.java b/dsms-engine-common/src/main/java/com/dsms/common/taskmanager/service/ITaskService.java index 644457f..2a604bc 100644 --- a/dsms-engine-common/src/main/java/com/dsms/common/taskmanager/service/ITaskService.java +++ b/dsms-engine-common/src/main/java/com/dsms/common/taskmanager/service/ITaskService.java @@ -17,12 +17,22 @@ package com.dsms.common.taskmanager.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.dsms.common.model.PageParam; import com.dsms.common.taskmanager.model.Task; +import java.util.List; +import java.util.Map; + /** * 任务信息表 服务类 */ public interface ITaskService extends IService { + /** + * 任务列表 + */ + Page listPageTask(Page taskPage, PageParam params); + } -- Gitee