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 06d0217bf26940a7724fb716a1c1533bef40c6fa..d750cc89969c691e57950d6afc7708b11dfac8a0 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 0000000000000000000000000000000000000000..3e8e6c01ef58b7d796dd54acb26290d83f0b5a50 --- /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 89cf09c3609809474736e834db0891e065723faa..0b92d534ae0845a0cefe27e163cf2b9b06c4af7b 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 0000000000000000000000000000000000000000..805dea6e5a2c3acc3e58bc84ae3dfa029a049c30 --- /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 0000000000000000000000000000000000000000..d3ebfef7e1acc97f083e21715089e58aede00204 --- /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 644457f67326bd878599b7d2fad3ddb7d84f5ff1..2a604bcc7ea16f805b59c2880b65ec5c9c8117df 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); + }