diff --git a/logs/service-oa/spring.log b/logs/service-oa/spring.log index ea102c4..9206bfd 100644 --- a/logs/service-oa/spring.log +++ b/logs/service-oa/spring.log @@ -73,3 +73,16 @@ 18:31:15:665 INFO 17940 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8800 (http) with context path '' 18:31:15:722 INFO 17940 --- [main] com.atguigu.auth.ServiceAuthApplication : Started ServiceAuthApplication in 1.437 seconds (JVM running for 1.865) 18:31:21:234 INFO 17940 --- [SpringContextShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' +18:31:22:813 INFO 19156 --- [main] com.atguigu.auth.ServiceAuthApplication : Starting ServiceAuthApplication on bunny with PID 19156 (G:\java项目\guigu-oa-parent\service-oa\target\classes started by 13199 in G:\java项目\guigu-oa-parent) +18:31:22:815 INFO 19156 --- [main] com.atguigu.auth.ServiceAuthApplication : The following profiles are active: dev +18:31:23:234 WARN 19156 --- [main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.atguigu.*.mapper]' package. Please check your configuration. +18:31:23:384 INFO 19156 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8800 (http) +18:31:23:389 INFO 19156 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat] +18:31:23:389 INFO 19156 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39] +18:31:23:424 INFO 19156 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +18:31:23:424 INFO 19156 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 586 ms +18:31:23:601 INFO 19156 --- [main] com.atguigu.config.MybatisPlusConfig : 注入MybatisPlus配置类... +18:31:23:635 INFO 19156 --- [main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' +18:31:24:030 INFO 19156 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8800 (http) with context path '' +18:31:24:091 INFO 19156 --- [main] com.atguigu.auth.ServiceAuthApplication : Started ServiceAuthApplication in 1.485 seconds (JVM running for 1.914) +18:39:42:950 INFO 19156 --- [SpringContextShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' diff --git a/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java b/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java index 61acad3..09f4264 100644 --- a/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java +++ b/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java @@ -3,10 +3,13 @@ package com.atguigu.auth.controller; import com.atguigu.auth.service.SysRoleService; import com.atguigu.common.result.Result; import com.atguigu.model.system.SysRole; +import com.atguigu.vo.system.SysRoleQueryVo; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -25,4 +28,11 @@ public class SysRoleController { List sysRoleList = sysRoleService.list(); return Result.success(sysRoleList); } + + @ApiOperation("角色条件分页查询") + @GetMapping("{page}/{limit}") + public Result> pageResult(@PathVariable Long page, @PathVariable Long limit, SysRoleQueryVo sysRoleQueryVo) { + IPage sysRoleIPage = sysRoleService.pageResult(page, limit, sysRoleQueryVo); + return Result.success(sysRoleIPage); + } } diff --git a/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java b/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java index 365bbf1..e4aa5a0 100644 --- a/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java +++ b/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java @@ -1,7 +1,19 @@ package com.atguigu.auth.service; import com.atguigu.model.system.SysRole; +import com.atguigu.vo.system.SysRoleQueryVo; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; public interface SysRoleService extends IService { + /** + * 角色条件分页查询 + * + * @param page 当前页 + * @param limit 每页记录数 + * @param vo 查询条件 + * @return 分页结果 + */ + IPage pageResult(Long page, Long limit, SysRoleQueryVo vo); } + diff --git a/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java index 7f22e1d..a462fd8 100644 --- a/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java +++ b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java @@ -3,9 +3,32 @@ package com.atguigu.auth.service.impl; import com.atguigu.auth.mapper.SysRoleMapper; import com.atguigu.auth.service.SysRoleService; import com.atguigu.model.system.SysRole; +import com.atguigu.vo.system.SysRoleQueryVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; @Service public class SysRoleServiceImpl extends ServiceImpl implements SysRoleService { + /** + * 角色条件分页查询 + * + * @param page 当前页 + * @param limit 每页记录数 + * @param vo 查询条件 + * @return 分页结果 + */ + @Override + public IPage pageResult(Long page, Long limit, SysRoleQueryVo vo) { + Page pageParam = new Page<>(page, limit); + + String roleName = vo.getRoleName(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.like(!StringUtils.isEmpty(roleName), SysRole::getRoleName, roleName); + + return page(pageParam, wrapper); + } }