custauth
This commit is contained in:
parent
803ec86332
commit
bd3314db1c
|
|
@ -1,52 +1,52 @@
|
||||||
package net.xnzn.framework.config.response;
|
//package net.xnzn.framework.config.response;
|
||||||
|
//
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
//import io.swagger.annotations.ApiModelProperty;
|
||||||
|
//
|
||||||
import java.io.Serializable;
|
//import java.io.Serializable;
|
||||||
|
//
|
||||||
public class ResponseWrapper<T> implements Serializable {
|
//public class ResponseWrapper<T> implements Serializable {
|
||||||
@ApiModelProperty("状态码")
|
// @ApiModelProperty("状态码")
|
||||||
protected Integer code = 10000;
|
// protected Integer code = 10000;
|
||||||
@ApiModelProperty("返回信息")
|
// @ApiModelProperty("返回信息")
|
||||||
protected String msg = "成功";
|
// protected String msg = "成功";
|
||||||
@ApiModelProperty("返回数据")
|
// @ApiModelProperty("返回数据")
|
||||||
protected T data;
|
// protected T data;
|
||||||
|
//
|
||||||
public ResponseWrapper(T data) {
|
// public ResponseWrapper(T data) {
|
||||||
this.data = data;
|
// this.data = data;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static ResponseWrapper<Object> fails(Integer code, String errorMsg) {
|
// public static ResponseWrapper<Object> fails(Integer code, String errorMsg) {
|
||||||
ResponseWrapper<Object> apiResult = new ResponseWrapper();
|
// ResponseWrapper<Object> apiResult = new ResponseWrapper();
|
||||||
apiResult.setCode(code == null ? '鱄' : code);
|
// apiResult.setCode(code == null ? '鱄' : code);
|
||||||
apiResult.setMsg(errorMsg);
|
// apiResult.setMsg(errorMsg);
|
||||||
return apiResult;
|
// return apiResult;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Integer getCode() {
|
// public Integer getCode() {
|
||||||
return this.code;
|
// return this.code;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getMsg() {
|
// public String getMsg() {
|
||||||
return this.msg;
|
// return this.msg;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public T getData() {
|
// public T getData() {
|
||||||
return this.data;
|
// return this.data;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setCode(final Integer code) {
|
// public void setCode(final Integer code) {
|
||||||
this.code = code;
|
// this.code = code;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setMsg(final String msg) {
|
// public void setMsg(final String msg) {
|
||||||
this.msg = msg;
|
// this.msg = msg;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setData(final T data) {
|
// public void setData(final T data) {
|
||||||
this.data = data;
|
// this.data = data;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public ResponseWrapper() {
|
// public ResponseWrapper() {
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,16 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!--加密依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>${jasypt-spring-boot-starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
|
@ -46,28 +56,37 @@
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- bonus Common Security-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.bonus</groupId>
|
|
||||||
<artifactId>bonus-common-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--加密依赖包-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.ulisesbocchio</groupId>
|
|
||||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
|
||||||
<version>${jasypt-spring-boot-starter.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.bonus</groupId>
|
|
||||||
<artifactId>bonus-common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- Swagger UI -->
|
<!-- Swagger UI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${swagger.fox.version}</version>
|
<version>${swagger.fox.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- bonus Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bonus</groupId>
|
||||||
|
<artifactId>bonus-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- bonus Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bonus</groupId>
|
||||||
|
<artifactId>bonus-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- bonus Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bonus</groupId>
|
||||||
|
<artifactId>bonus-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- bonus Common Swagger -->
|
<!-- bonus Common Swagger -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bonus</groupId>
|
<groupId>com.bonus</groupId>
|
||||||
|
|
@ -80,28 +99,17 @@
|
||||||
<version>portable-1.7.8</version>
|
<version>portable-1.7.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>30.0-jre</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.bonus</groupId>
|
|
||||||
<artifactId>bonus-common-config</artifactId>
|
|
||||||
<version>24.12.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
<version>2.5</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>druid</artifactId>
|
|
||||||
<version>1.2.23</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bonus</groupId>
|
<groupId>com.bonus</groupId>
|
||||||
<artifactId>bonus-common-biz</artifactId>
|
<artifactId>bonus-common-biz</artifactId>
|
||||||
|
|
@ -109,12 +117,30 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>33.0.0-jre</version>
|
<scope>test</scope>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Apache POI dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 支付宝支付-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
<version>4.34.0.ALL</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
|
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
|
||||||
|
<!-- <version>3.5.6</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,21 @@
|
||||||
package com.bonus.auth;
|
package com.bonus.auth;
|
||||||
|
|
||||||
|
import com.bonus.common.security.annotation.EnableCustomConfig;
|
||||||
import com.bonus.common.swagger.annotation.EnableCustomSwagger2;
|
import com.bonus.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import com.bonus.common.security.annotation.EnableRyFeignClients;
|
import com.bonus.common.security.annotation.EnableRyFeignClients;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证授权中心
|
* 认证授权中心
|
||||||
*
|
*
|
||||||
* @author bonus
|
* @author bonus
|
||||||
*/
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
|
@EnableScheduling
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||||
public class BonusCustAuthApplication
|
public class BonusCustAuthApplication
|
||||||
|
|
@ -19,6 +23,6 @@ public class BonusCustAuthApplication
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
SpringApplication.run(BonusCustAuthApplication.class, args);
|
SpringApplication.run(BonusCustAuthApplication.class, args);
|
||||||
System.out.println("认证授权中心启动成功");
|
System.out.println("客户认证授权中心启动成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import com.bonus.system.api.RemoteUserService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.xnzn.service.TokenService;
|
import net.xnzn.service.TokenService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
@ -50,23 +51,12 @@ public class TokenController {
|
||||||
private SystemConfig config;
|
private SystemConfig config;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Lazy
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysLoginService sysLoginService;
|
private SysLoginService sysLoginService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LoginStrategyFactory loginStrategyFactory;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RemoteUserService remoteUserService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPasswordService passwordService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PasswordValidatorService passwordValidatorService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRecordLogService logService;
|
private SysRecordLogService logService;
|
||||||
|
|
||||||
|
|
@ -76,10 +66,10 @@ public class TokenController {
|
||||||
@Resource
|
@Resource
|
||||||
private RemoteConfigService configService;
|
private RemoteConfigService configService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private CustInfoMapper custInfoMapper;
|
private CustInfoMapper custInfoMapper;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private CustCasualMapper custCasualMapper;
|
private CustCasualMapper custCasualMapper;
|
||||||
|
|
||||||
private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
||||||
|
|
|
||||||
|
|
@ -123,11 +123,11 @@
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
<version>4.34.0.ALL</version>
|
<version>4.34.0.ALL</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.baomidou</groupId>
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
<artifactId>mybatis-plus-extension</artifactId>
|
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
|
||||||
<version>3.5.6</version>
|
<!-- <version>3.5.6</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,174 +1,174 @@
|
||||||
package net.xnzn.core.common.page;
|
//package net.xnzn.core.common.page;
|
||||||
|
//
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
//import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
//import cn.hutool.core.util.StrUtil;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
//import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.github.pagehelper.page.PageMethod;
|
//import com.github.pagehelper.page.PageMethod;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
//import io.swagger.annotations.ApiModelProperty;
|
||||||
import net.xnzn.constant.LeConstants;
|
//import net.xnzn.constant.LeConstants;
|
||||||
import java.util.Collections;
|
//import java.util.Collections;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Objects;
|
//import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
public class PageDTO {
|
//public class PageDTO {
|
||||||
@ApiModelProperty("当前页(默认1)")
|
// @ApiModelProperty("当前页(默认1)")
|
||||||
private Long current;
|
// private Long current;
|
||||||
@ApiModelProperty("每页显示条数(默认10) -1查询全部")
|
// @ApiModelProperty("每页显示条数(默认10) -1查询全部")
|
||||||
private Long size;
|
// private Long size;
|
||||||
@ApiModelProperty("是否包含count查询 1是 2否 默认是")
|
// @ApiModelProperty("是否包含count查询 1是 2否 默认是")
|
||||||
private Integer ifCount;
|
// private Integer ifCount;
|
||||||
@ApiModelProperty("size空(-1)时是否查询全部 1是 2否 默认是")
|
// @ApiModelProperty("size空(-1)时是否查询全部 1是 2否 默认是")
|
||||||
private Integer ifPageSizeZero;
|
// private Integer ifPageSizeZero;
|
||||||
@ApiModelProperty("排序,支持多个(仅支持PageHelper)")
|
// @ApiModelProperty("排序,支持多个(仅支持PageHelper)")
|
||||||
private List<OrderItem> orders;
|
// private List<OrderItem> orders;
|
||||||
|
//
|
||||||
public Long getCurrent() {
|
// public Long getCurrent() {
|
||||||
return !ObjectUtil.isNull(this.current) && this.current > 0L ? this.current : 1L;
|
// return !ObjectUtil.isNull(this.current) && this.current > 0L ? this.current : 1L;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Long getSize() {
|
// public Long getSize() {
|
||||||
return !ObjectUtil.isNull(this.size) && this.size != 0L ? this.size : 10L;
|
// return !ObjectUtil.isNull(this.size) && this.size != 0L ? this.size : 10L;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public List<OrderItem> getOrders() {
|
// public List<OrderItem> getOrders() {
|
||||||
return ObjectUtil.isNull(this.orders) ? Collections.emptyList() : this.orders;
|
// return ObjectUtil.isNull(this.orders) ? Collections.emptyList() : this.orders;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(
|
// @ApiModelProperty(
|
||||||
value = "分页条件",
|
// value = "分页条件",
|
||||||
hidden = true
|
// hidden = true
|
||||||
)
|
// )
|
||||||
public String getOrderString() {
|
// public String getOrderString() {
|
||||||
return (String)this.getOrders().stream().map(OrderItem::orderString).collect(Collectors.joining(","));
|
// return (String)this.getOrders().stream().map(OrderItem::orderString).collect(Collectors.joining(","));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(
|
// @ApiModelProperty(
|
||||||
value = "PageHelper使用字段:pageNum",
|
// value = "PageHelper使用字段:pageNum",
|
||||||
hidden = true
|
// hidden = true
|
||||||
)
|
// )
|
||||||
public int getPageNum() {
|
// public int getPageNum() {
|
||||||
return this.getCurrent().intValue();
|
// return this.getCurrent().intValue();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(
|
// @ApiModelProperty(
|
||||||
value = "PageHelper使用字段:pageSize",
|
// value = "PageHelper使用字段:pageSize",
|
||||||
hidden = true
|
// hidden = true
|
||||||
)
|
// )
|
||||||
public int getPageSize() {
|
// public int getPageSize() {
|
||||||
int sizeValue = this.getSize().intValue();
|
// int sizeValue = this.getSize().intValue();
|
||||||
return sizeValue == -1 ? 0 : sizeValue;
|
// return sizeValue == -1 ? 0 : sizeValue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(
|
// @ApiModelProperty(
|
||||||
value = "PageHelper使用字段:orderBy",
|
// value = "PageHelper使用字段:orderBy",
|
||||||
hidden = true
|
// hidden = true
|
||||||
)
|
// )
|
||||||
public String getOrderBy() {
|
// public String getOrderBy() {
|
||||||
return this.getOrderString();
|
// return this.getOrderString();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(
|
// @ApiModelProperty(
|
||||||
value = "PageHelper使用字段:countSql(是否包含count查询)",
|
// value = "PageHelper使用字段:countSql(是否包含count查询)",
|
||||||
hidden = true
|
// hidden = true
|
||||||
)
|
// )
|
||||||
public Boolean getCountSql() {
|
// public Boolean getCountSql() {
|
||||||
return LeConstants.COMMON_YES.equals(this.ifCount);
|
// return LeConstants.COMMON_YES.equals(this.ifCount);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@ApiModelProperty(
|
// @ApiModelProperty(
|
||||||
value = "PageHelper使用字段:pageSizeZero(size 0是否查询全部)",
|
// value = "PageHelper使用字段:pageSizeZero(size 0是否查询全部)",
|
||||||
hidden = true
|
// hidden = true
|
||||||
)
|
// )
|
||||||
public Boolean getPageSizeZero() {
|
// public Boolean getPageSizeZero() {
|
||||||
return LeConstants.COMMON_YES.equals(this.ifPageSizeZero);
|
// return LeConstants.COMMON_YES.equals(this.ifPageSizeZero);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void startPage() {
|
// public void startPage() {
|
||||||
PageMethod.startPage(this);
|
// PageMethod.startPage(this);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static PageDTO of(Long current, Long size) {
|
// public static PageDTO of(Long current, Long size) {
|
||||||
PageDTO pageDTO = new PageDTO();
|
// PageDTO pageDTO = new PageDTO();
|
||||||
pageDTO.setCurrent(current);
|
// pageDTO.setCurrent(current);
|
||||||
pageDTO.setSize(size);
|
// pageDTO.setSize(size);
|
||||||
return pageDTO;
|
// return pageDTO;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static PageDTO countOnly() {
|
// public static PageDTO countOnly() {
|
||||||
PageDTO pageDTO = new PageDTO();
|
// PageDTO pageDTO = new PageDTO();
|
||||||
pageDTO.setCurrent(1L);
|
// pageDTO.setCurrent(1L);
|
||||||
pageDTO.setSize(-1L);
|
// pageDTO.setSize(-1L);
|
||||||
pageDTO.setIfCount(LeConstants.COMMON_YES);
|
// pageDTO.setIfCount(LeConstants.COMMON_YES);
|
||||||
pageDTO.setIfPageSizeZero(LeConstants.COMMON_NO);
|
// pageDTO.setIfPageSizeZero(LeConstants.COMMON_NO);
|
||||||
return pageDTO;
|
// return pageDTO;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void startPage(PageDTO page) {
|
// public static void startPage(PageDTO page) {
|
||||||
if (!Objects.isNull(page)) {
|
// if (!Objects.isNull(page)) {
|
||||||
page.startPage();
|
// page.startPage();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageDTO() {
|
// public PageDTO() {
|
||||||
this.ifCount = LeConstants.COMMON_YES;
|
// this.ifCount = LeConstants.COMMON_YES;
|
||||||
this.ifPageSizeZero = LeConstants.COMMON_YES;
|
// this.ifPageSizeZero = LeConstants.COMMON_YES;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Integer getIfCount() {
|
// public Integer getIfCount() {
|
||||||
return this.ifCount;
|
// return this.ifCount;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Integer getIfPageSizeZero() {
|
// public Integer getIfPageSizeZero() {
|
||||||
return this.ifPageSizeZero;
|
// return this.ifPageSizeZero;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setCurrent(final Long current) {
|
// public void setCurrent(final Long current) {
|
||||||
this.current = current;
|
// this.current = current;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setSize(final Long size) {
|
// public void setSize(final Long size) {
|
||||||
this.size = size;
|
// this.size = size;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setIfCount(final Integer ifCount) {
|
// public void setIfCount(final Integer ifCount) {
|
||||||
this.ifCount = ifCount;
|
// this.ifCount = ifCount;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setIfPageSizeZero(final Integer ifPageSizeZero) {
|
// public void setIfPageSizeZero(final Integer ifPageSizeZero) {
|
||||||
this.ifPageSizeZero = ifPageSizeZero;
|
// this.ifPageSizeZero = ifPageSizeZero;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setOrders(final List<OrderItem> orders) {
|
// public void setOrders(final List<OrderItem> orders) {
|
||||||
this.orders = orders;
|
// this.orders = orders;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static class OrderItem {
|
// public static class OrderItem {
|
||||||
@ApiModelProperty("字段名")
|
// @ApiModelProperty("字段名")
|
||||||
private String column;
|
// private String column;
|
||||||
@ApiModelProperty("true增序 false降序")
|
// @ApiModelProperty("true增序 false降序")
|
||||||
private Boolean asc = true;
|
// private Boolean asc = true;
|
||||||
|
//
|
||||||
@JsonIgnore
|
// @JsonIgnore
|
||||||
public String orderString() {
|
// public String orderString() {
|
||||||
String var10000 = StrUtil.toUnderlineCase(this.column);
|
// String var10000 = StrUtil.toUnderlineCase(this.column);
|
||||||
return var10000 + " " + (this.asc ? "ASC" : "DESC");
|
// return var10000 + " " + (this.asc ? "ASC" : "DESC");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getColumn() {
|
// public String getColumn() {
|
||||||
return this.column;
|
// return this.column;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public Boolean getAsc() {
|
// public Boolean getAsc() {
|
||||||
return this.asc;
|
// return this.asc;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setColumn(final String column) {
|
// public void setColumn(final String column) {
|
||||||
this.column = column;
|
// this.column = column;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setAsc(final Boolean asc) {
|
// public void setAsc(final Boolean asc) {
|
||||||
this.asc = asc;
|
// this.asc = asc;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,197 +1,197 @@
|
||||||
package net.xnzn.core.common.page;
|
//package net.xnzn.core.common.page;
|
||||||
|
//
|
||||||
import com.github.pagehelper.Page;
|
//import com.github.pagehelper.Page;
|
||||||
import java.util.Collections;
|
//import java.util.Collections;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
public class PageVO<T> {
|
//public class PageVO<T> {
|
||||||
protected List<T> records;
|
// protected List<T> records;
|
||||||
protected long total;
|
// protected long total;
|
||||||
protected long size;
|
// protected long size;
|
||||||
protected long current;
|
// protected long current;
|
||||||
protected boolean searchCount;
|
// protected boolean searchCount;
|
||||||
private String orderBy;
|
// private String orderBy;
|
||||||
|
//
|
||||||
public PageVO() {
|
// public PageVO() {
|
||||||
this.records = Collections.emptyList();
|
// this.records = Collections.emptyList();
|
||||||
this.total = 0L;
|
// this.total = 0L;
|
||||||
this.size = 10L;
|
// this.size = 10L;
|
||||||
this.current = 1L;
|
// this.current = 1L;
|
||||||
this.searchCount = true;
|
// this.searchCount = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageVO(long current, long size) {
|
// public PageVO(long current, long size) {
|
||||||
this(current, size, 0L);
|
// this(current, size, 0L);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageVO(long current, long size, long total) {
|
// public PageVO(long current, long size, long total) {
|
||||||
this(current, size, total, true);
|
// this(current, size, total, true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageVO(long current, long size, boolean searchCount) {
|
// public PageVO(long current, long size, boolean searchCount) {
|
||||||
this(current, size, 0L, searchCount);
|
// this(current, size, 0L, searchCount);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageVO(long current, long size, long total, boolean searchCount) {
|
// public PageVO(long current, long size, long total, boolean searchCount) {
|
||||||
this.records = Collections.emptyList();
|
// this.records = Collections.emptyList();
|
||||||
this.total = 0L;
|
// this.total = 0L;
|
||||||
this.size = 10L;
|
// this.size = 10L;
|
||||||
this.current = 1L;
|
// this.current = 1L;
|
||||||
this.searchCount = true;
|
// this.searchCount = true;
|
||||||
if (current > 1L) {
|
// if (current > 1L) {
|
||||||
this.current = current;
|
// this.current = current;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
this.size = size;
|
// this.size = size;
|
||||||
this.total = total;
|
// this.total = total;
|
||||||
this.searchCount = searchCount;
|
// this.searchCount = searchCount;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static <T> PageVO<T> empty() {
|
// public static <T> PageVO<T> empty() {
|
||||||
return new PageVO();
|
// return new PageVO();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static <T> PageVO<T> of(long current, long size, long total, boolean searchCount) {
|
// public static <T> PageVO<T> of(long current, long size, long total, boolean searchCount) {
|
||||||
return new PageVO(current, size, total, searchCount);
|
// return new PageVO(current, size, total, searchCount);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static <T> PageVO<T> of(long current, long size) {
|
// public static <T> PageVO<T> of(long current, long size) {
|
||||||
return of(current, size, 0L);
|
// return of(current, size, 0L);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static <T> PageVO<T> of(long current, long size, long total) {
|
// public static <T> PageVO<T> of(long current, long size, long total) {
|
||||||
return of(current, size, total, true);
|
// return of(current, size, total, true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static <T> PageVO<T> of(long current, long size, boolean searchCount) {
|
// public static <T> PageVO<T> of(long current, long size, boolean searchCount) {
|
||||||
return of(current, size, 0L, searchCount);
|
// return of(current, size, 0L, searchCount);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// public static <T> PageVO<T> of(List<?> page, List<T> records) {
|
//// public static <T> PageVO<T> of(List<?> page, List<T> records) {
|
||||||
// if (page instanceof Page) {
|
//// if (page instanceof Page) {
|
||||||
// PageVO<T> vo = of((long)((Page)page).getPageNum(), (long)((Page)page).getPageSize(), ((Page)page).getTotal(), ((Page)page).isCount());
|
//// PageVO<T> vo = of((long)((Page)page).getPageNum(), (long)((Page)page).getPageSize(), ((Page)page).getTotal(), ((Page)page).isCount());
|
||||||
// vo.setOrderBy(((Page)page).getOrderBy());
|
//// vo.setOrderBy(((Page)page).getOrderBy());
|
||||||
// vo.setRecords(records);
|
//// vo.setRecords(records);
|
||||||
// return vo;
|
//// return vo;
|
||||||
|
//// } else {
|
||||||
|
//// return of(records);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//// public static <T> PageVO<T> of(List<T> records) {
|
||||||
|
//// PageVO<T> vo = new PageVO();
|
||||||
|
//// vo.setRecords(records);
|
||||||
|
//// if (records instanceof Page<T> ghRecords) {
|
||||||
|
//// vo.setCurrent((long)ghRecords.getPageNum()).setSize((long)ghRecords.getPageSize()).setTotal(ghRecords.getTotal()).setSearchCount(ghRecords.isCount()).setOrderBy(vo.getOrderBy());
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return vo;
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//// public static <T> PageVO<T> of(PageDTO pageDTO, List<T> records) {
|
||||||
|
//// PageVO<T> vo = new PageVO();
|
||||||
|
//// vo.setRecords(records);
|
||||||
|
//// if (records instanceof Page<T> ghRecords) {
|
||||||
|
//// vo.setCurrent((long)ghRecords.getPageNum()).setSize((long)ghRecords.getPageSize()).setTotal(ghRecords.getTotal()).setSearchCount(ghRecords.isCount()).setOrderBy(vo.getOrderBy());
|
||||||
|
//// } else if (records != null) {
|
||||||
|
//// vo.setCurrent(pageDTO.getCurrent()).setSize(pageDTO.getSize()).setTotal((long)records.size()).setOrderBy(pageDTO.getOrderBy());
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return vo;
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// public static <T> PageVO<T> of(com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> page) {
|
||||||
|
// if (page == null) {
|
||||||
|
// return new PageVO();
|
||||||
// } else {
|
// } else {
|
||||||
// return of(records);
|
// PageVO<T> vo = of(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
|
||||||
// }
|
// vo.setRecords(page.getRecords());
|
||||||
// }
|
|
||||||
|
|
||||||
// public static <T> PageVO<T> of(List<T> records) {
|
|
||||||
// PageVO<T> vo = new PageVO();
|
|
||||||
// vo.setRecords(records);
|
|
||||||
// if (records instanceof Page<T> ghRecords) {
|
|
||||||
// vo.setCurrent((long)ghRecords.getPageNum()).setSize((long)ghRecords.getPageSize()).setTotal(ghRecords.getTotal()).setSearchCount(ghRecords.isCount()).setOrderBy(vo.getOrderBy());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return vo;
|
// return vo;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public static <T> PageVO<T> of(PageDTO pageDTO, List<T> records) {
|
|
||||||
// PageVO<T> vo = new PageVO();
|
|
||||||
// vo.setRecords(records);
|
|
||||||
// if (records instanceof Page<T> ghRecords) {
|
|
||||||
// vo.setCurrent((long)ghRecords.getPageNum()).setSize((long)ghRecords.getPageSize()).setTotal(ghRecords.getTotal()).setSearchCount(ghRecords.isCount()).setOrderBy(vo.getOrderBy());
|
|
||||||
// } else if (records != null) {
|
|
||||||
// vo.setCurrent(pageDTO.getCurrent()).setSize(pageDTO.getSize()).setTotal((long)records.size()).setOrderBy(pageDTO.getOrderBy());
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
// public static <T> PageVO<T> of(com.baomidou.mybatisplus.extension.plugins.pagination.Page<?> page, List<T> records) {
|
||||||
|
// if (page == null) {
|
||||||
|
// return new PageVO();
|
||||||
|
// } else {
|
||||||
|
// PageVO<T> vo = of(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
|
||||||
|
// vo.setRecords(records);
|
||||||
// return vo;
|
// return vo;
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
public static <T> PageVO<T> of(com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> page) {
|
//
|
||||||
if (page == null) {
|
// public boolean hasPrevious() {
|
||||||
return new PageVO();
|
// return this.current > 1L;
|
||||||
} else {
|
// }
|
||||||
PageVO<T> vo = of(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
|
//
|
||||||
vo.setRecords(page.getRecords());
|
// public boolean hasNext() {
|
||||||
return vo;
|
// return this.current < this.getPages();
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// public List<T> getRecords() {
|
||||||
public static <T> PageVO<T> of(com.baomidou.mybatisplus.extension.plugins.pagination.Page<?> page, List<T> records) {
|
// return this.records;
|
||||||
if (page == null) {
|
// }
|
||||||
return new PageVO();
|
//
|
||||||
} else {
|
// public PageVO<T> setRecords(List<T> records) {
|
||||||
PageVO<T> vo = of(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
|
// this.records = records;
|
||||||
vo.setRecords(records);
|
// return this;
|
||||||
return vo;
|
// }
|
||||||
}
|
//
|
||||||
}
|
// public long getTotal() {
|
||||||
|
// return this.total;
|
||||||
public boolean hasPrevious() {
|
// }
|
||||||
return this.current > 1L;
|
//
|
||||||
}
|
// public PageVO<T> setTotal(long total) {
|
||||||
|
// this.total = total;
|
||||||
public boolean hasNext() {
|
// return this;
|
||||||
return this.current < this.getPages();
|
// }
|
||||||
}
|
//
|
||||||
|
// public long getSize() {
|
||||||
public List<T> getRecords() {
|
// return this.size;
|
||||||
return this.records;
|
// }
|
||||||
}
|
//
|
||||||
|
// public PageVO<T> setSize(long size) {
|
||||||
public PageVO<T> setRecords(List<T> records) {
|
// this.size = size;
|
||||||
this.records = records;
|
// return this;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// public long getCurrent() {
|
||||||
public long getTotal() {
|
// return this.current;
|
||||||
return this.total;
|
// }
|
||||||
}
|
//
|
||||||
|
// public PageVO<T> setCurrent(long current) {
|
||||||
public PageVO<T> setTotal(long total) {
|
// this.current = current;
|
||||||
this.total = total;
|
// return this;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// public PageVO<T> setSearchCount(boolean searchCount) {
|
||||||
public long getSize() {
|
// this.searchCount = searchCount;
|
||||||
return this.size;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageVO<T> setSize(long size) {
|
// public String getOrderBy() {
|
||||||
this.size = size;
|
// return this.orderBy;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// public PageVO<T> setOrderBy(String orderBy) {
|
||||||
public long getCurrent() {
|
// this.orderBy = orderBy;
|
||||||
return this.current;
|
// return this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public PageVO<T> setCurrent(long current) {
|
// public long getPages() {
|
||||||
this.current = current;
|
// if (this.getSize() == 0L) {
|
||||||
return this;
|
// return 0L;
|
||||||
}
|
// } else {
|
||||||
|
// long pages = this.getTotal() / this.getSize();
|
||||||
public PageVO<T> setSearchCount(boolean searchCount) {
|
// if (this.getTotal() % this.getSize() != 0L) {
|
||||||
this.searchCount = searchCount;
|
// ++pages;
|
||||||
return this;
|
// }
|
||||||
}
|
//
|
||||||
|
// return pages;
|
||||||
public String getOrderBy() {
|
// }
|
||||||
return this.orderBy;
|
// }
|
||||||
}
|
//
|
||||||
|
// public boolean searchCount() {
|
||||||
public PageVO<T> setOrderBy(String orderBy) {
|
// return this.total < 0L ? false : this.searchCount;
|
||||||
this.orderBy = orderBy;
|
// }
|
||||||
return this;
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
public long getPages() {
|
|
||||||
if (this.getSize() == 0L) {
|
|
||||||
return 0L;
|
|
||||||
} else {
|
|
||||||
long pages = this.getTotal() / this.getSize();
|
|
||||||
if (this.getTotal() % this.getSize() != 0L) {
|
|
||||||
++pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pages;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean searchCount() {
|
|
||||||
return this.total < 0L ? false : this.searchCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Reference in New Issue