@@ -0,0 +1,29 @@ | |||||
package com.ningdatech.kqapi.common.handler; | |||||
import com.baomidou.mybatisplus.annotation.DbType; | |||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | |||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; | |||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
@Configuration | |||||
public class MyBatisPlusConfig { | |||||
/** | |||||
* 插件配置 | |||||
* | |||||
* @return | |||||
*/ | |||||
@Bean | |||||
public MybatisPlusInterceptor mybatisPlusInterceptor() { | |||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); | |||||
// 向MyBatis-Plus的过滤器链中添加分页拦截器,需要设置数据库类型(主要用于分页方言) | |||||
// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); | |||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); | |||||
// 添加乐观锁拦截器 | |||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); | |||||
return interceptor; | |||||
} | |||||
} |
@@ -30,7 +30,7 @@ public class PolicyRegulationsController { | |||||
@ApiOperation(value = "政策条例分页列表", notes = "政策条例分页列表") | @ApiOperation(value = "政策条例分页列表", notes = "政策条例分页列表") | ||||
@GetMapping("/list") | @GetMapping("/list") | ||||
public PageVo<NdKqZzsfwPolicyVO> list(@RequestParam(defaultValue = "1") int pageNumber, @RequestParam(defaultValue = "10") int pageSize) { | |||||
public PageVo<NdKqZzsfwPolicyVO> list(@RequestParam(defaultValue = "1") long pageNumber, @RequestParam(defaultValue = "10") long pageSize) { | |||||
return policyManage.list(pageNumber,pageSize); | return policyManage.list(pageNumber,pageSize); | ||||
} | } | ||||
} | } |
@@ -29,17 +29,17 @@ public class PolicyManage { | |||||
private final INdKqZzsfwPolicyService policyService; | private final INdKqZzsfwPolicyService policyService; | ||||
public PageVo<NdKqZzsfwPolicyVO> list(int pageNumber, int pageSize) { | |||||
public PageVo<NdKqZzsfwPolicyVO> list(long pageNumber, long pageSize) { | |||||
Page<NdKqZzsfwPolicy> page = Page.of(pageNumber,pageSize); | Page<NdKqZzsfwPolicy> page = Page.of(pageNumber,pageSize); | ||||
policyService.page(page,Wrappers.lambdaQuery(NdKqZzsfwPolicy.class) | |||||
Page<NdKqZzsfwPolicy> pageRes = policyService.page(page, Wrappers.lambdaQuery(NdKqZzsfwPolicy.class) | |||||
.orderByAsc(NdKqZzsfwPolicy::getSort)); | .orderByAsc(NdKqZzsfwPolicy::getSort)); | ||||
if(CollUtil.isEmpty(page.getRecords())){ | |||||
if(CollUtil.isEmpty(pageRes.getRecords())){ | |||||
return PageVo.empty(); | return PageVo.empty(); | ||||
} | } | ||||
List<NdKqZzsfwPolicyVO> res = page.getRecords().stream() | |||||
List<NdKqZzsfwPolicyVO> res = pageRes.getRecords().stream() | |||||
.map(p -> BeanUtil.copyProperties(p,NdKqZzsfwPolicyVO.class)) | .map(p -> BeanUtil.copyProperties(p,NdKqZzsfwPolicyVO.class)) | ||||
.collect(Collectors.toList()); | .collect(Collectors.toList()); | ||||
return PageVo.of(res,page.getTotal()); | |||||
return PageVo.of(res,pageRes.getTotal()); | |||||
} | } | ||||
} | } |