Browse Source

政策条例

master
PoffyZhang 1 year ago
parent
commit
631b4dae9b
3 changed files with 35 additions and 6 deletions
  1. +29
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java
  2. +1
    -1
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java
  3. +5
    -5
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java

+ 29
- 0
kqapi/src/main/java/com/ningdatech/kqapi/common/handler/MyBatisPlusConfig.java View File

@@ -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;
}
}

+ 1
- 1
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java View File

@@ -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);
} }
} }

+ 5
- 5
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java View File

@@ -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());
} }
} }

Loading…
Cancel
Save