合并代码
This commit is contained in:
parent
abca1acabd
commit
18b184bdac
|
|
@ -0,0 +1,27 @@
|
||||||
|
package net.xnzn.constant;
|
||||||
|
|
||||||
|
public interface LeConstants {
|
||||||
|
String ID_TEMPORARY_PRE = "xnznkjxnznkj";
|
||||||
|
String NUM_PRE = "0";
|
||||||
|
Long DATA_DEFAULT_LONG = -1L;
|
||||||
|
Integer DATA_DEFAULT_INTEGER = -1;
|
||||||
|
Integer COMMON_YES = 1;
|
||||||
|
Integer COMMON_NO = 2;
|
||||||
|
Integer MAX_CARD_NUM = 100000;
|
||||||
|
Integer MAX_CUST_LIMIT_ID = 65535;
|
||||||
|
Integer MIN_DATA_NUM = 1;
|
||||||
|
Integer MAX_CUST_PSN_TYPE = 100;
|
||||||
|
String DEFAULT_GRADE_NAME = "普通会员";
|
||||||
|
String DEFAULT_PSN_TYPE_NAME = "类别";
|
||||||
|
String MAPPING_OBJECT = "object";
|
||||||
|
String MAPPING_PAGE = "page";
|
||||||
|
String MERCHANT_ID = "MERCHANT-ID";
|
||||||
|
String MERCHANT_ID_LOW = "merchant-id";
|
||||||
|
String OPENID = "openid";
|
||||||
|
String SOURCE_TYPE = "source-type";
|
||||||
|
String FACE_VER = "face-ver";
|
||||||
|
String MACHINE_SN = "machine-sn";
|
||||||
|
String MACHINE_NUM = "machine-num";
|
||||||
|
String MERCHANT_DEFAULT = "(默认)";
|
||||||
|
String DEFAULT_ORG_NUM = "0";
|
||||||
|
}
|
||||||
|
|
@ -123,6 +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>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-extension</artifactId>
|
||||||
|
<version>3.5.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,174 @@
|
||||||
|
package net.xnzn.core.common.page;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.github.pagehelper.page.PageMethod;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import net.xnzn.constant.LeConstants;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class PageDTO {
|
||||||
|
@ApiModelProperty("当前页(默认1)")
|
||||||
|
private Long current;
|
||||||
|
@ApiModelProperty("每页显示条数(默认10) -1查询全部")
|
||||||
|
private Long size;
|
||||||
|
@ApiModelProperty("是否包含count查询 1是 2否 默认是")
|
||||||
|
private Integer ifCount;
|
||||||
|
@ApiModelProperty("size空(-1)时是否查询全部 1是 2否 默认是")
|
||||||
|
private Integer ifPageSizeZero;
|
||||||
|
@ApiModelProperty("排序,支持多个(仅支持PageHelper)")
|
||||||
|
private List<OrderItem> orders;
|
||||||
|
|
||||||
|
public Long getCurrent() {
|
||||||
|
return !ObjectUtil.isNull(this.current) && this.current > 0L ? this.current : 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSize() {
|
||||||
|
return !ObjectUtil.isNull(this.size) && this.size != 0L ? this.size : 10L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderItem> getOrders() {
|
||||||
|
return ObjectUtil.isNull(this.orders) ? Collections.emptyList() : this.orders;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "分页条件",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
public String getOrderString() {
|
||||||
|
return (String)this.getOrders().stream().map(OrderItem::orderString).collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "PageHelper使用字段:pageNum",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
public int getPageNum() {
|
||||||
|
return this.getCurrent().intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "PageHelper使用字段:pageSize",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
public int getPageSize() {
|
||||||
|
int sizeValue = this.getSize().intValue();
|
||||||
|
return sizeValue == -1 ? 0 : sizeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "PageHelper使用字段:orderBy",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
public String getOrderBy() {
|
||||||
|
return this.getOrderString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "PageHelper使用字段:countSql(是否包含count查询)",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
public Boolean getCountSql() {
|
||||||
|
return LeConstants.COMMON_YES.equals(this.ifCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "PageHelper使用字段:pageSizeZero(size 0是否查询全部)",
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
public Boolean getPageSizeZero() {
|
||||||
|
return LeConstants.COMMON_YES.equals(this.ifPageSizeZero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startPage() {
|
||||||
|
PageMethod.startPage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PageDTO of(Long current, Long size) {
|
||||||
|
PageDTO pageDTO = new PageDTO();
|
||||||
|
pageDTO.setCurrent(current);
|
||||||
|
pageDTO.setSize(size);
|
||||||
|
return pageDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PageDTO countOnly() {
|
||||||
|
PageDTO pageDTO = new PageDTO();
|
||||||
|
pageDTO.setCurrent(1L);
|
||||||
|
pageDTO.setSize(-1L);
|
||||||
|
pageDTO.setIfCount(LeConstants.COMMON_YES);
|
||||||
|
pageDTO.setIfPageSizeZero(LeConstants.COMMON_NO);
|
||||||
|
return pageDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startPage(PageDTO page) {
|
||||||
|
if (!Objects.isNull(page)) {
|
||||||
|
page.startPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageDTO() {
|
||||||
|
this.ifCount = LeConstants.COMMON_YES;
|
||||||
|
this.ifPageSizeZero = LeConstants.COMMON_YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIfCount() {
|
||||||
|
return this.ifCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIfPageSizeZero() {
|
||||||
|
return this.ifPageSizeZero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrent(final Long current) {
|
||||||
|
this.current = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(final Long size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIfCount(final Integer ifCount) {
|
||||||
|
this.ifCount = ifCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIfPageSizeZero(final Integer ifPageSizeZero) {
|
||||||
|
this.ifPageSizeZero = ifPageSizeZero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrders(final List<OrderItem> orders) {
|
||||||
|
this.orders = orders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OrderItem {
|
||||||
|
@ApiModelProperty("字段名")
|
||||||
|
private String column;
|
||||||
|
@ApiModelProperty("true增序 false降序")
|
||||||
|
private Boolean asc = true;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String orderString() {
|
||||||
|
String var10000 = StrUtil.toUnderlineCase(this.column);
|
||||||
|
return var10000 + " " + (this.asc ? "ASC" : "DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColumn() {
|
||||||
|
return this.column;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAsc() {
|
||||||
|
return this.asc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColumn(final String column) {
|
||||||
|
this.column = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAsc(final Boolean asc) {
|
||||||
|
this.asc = asc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,197 @@
|
||||||
|
package net.xnzn.core.common.page;
|
||||||
|
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PageVO<T> {
|
||||||
|
protected List<T> records;
|
||||||
|
protected long total;
|
||||||
|
protected long size;
|
||||||
|
protected long current;
|
||||||
|
protected boolean searchCount;
|
||||||
|
private String orderBy;
|
||||||
|
|
||||||
|
public PageVO() {
|
||||||
|
this.records = Collections.emptyList();
|
||||||
|
this.total = 0L;
|
||||||
|
this.size = 10L;
|
||||||
|
this.current = 1L;
|
||||||
|
this.searchCount = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO(long current, long size) {
|
||||||
|
this(current, size, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO(long current, long size, long total) {
|
||||||
|
this(current, size, total, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO(long current, long size, boolean searchCount) {
|
||||||
|
this(current, size, 0L, searchCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO(long current, long size, long total, boolean searchCount) {
|
||||||
|
this.records = Collections.emptyList();
|
||||||
|
this.total = 0L;
|
||||||
|
this.size = 10L;
|
||||||
|
this.current = 1L;
|
||||||
|
this.searchCount = true;
|
||||||
|
if (current > 1L) {
|
||||||
|
this.current = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.size = size;
|
||||||
|
this.total = total;
|
||||||
|
this.searchCount = searchCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> PageVO<T> empty() {
|
||||||
|
return new PageVO();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> PageVO<T> of(long current, long size, long total, boolean searchCount) {
|
||||||
|
return new PageVO(current, size, total, searchCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> PageVO<T> of(long current, long size) {
|
||||||
|
return of(current, size, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> PageVO<T> of(long current, long size, long total) {
|
||||||
|
return of(current, size, total, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> PageVO<T> of(long current, long size, boolean searchCount) {
|
||||||
|
return of(current, size, 0L, searchCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static <T> PageVO<T> of(List<?> page, List<T> records) {
|
||||||
|
// if (page instanceof Page) {
|
||||||
|
// PageVO<T> vo = of((long)((Page)page).getPageNum(), (long)((Page)page).getPageSize(), ((Page)page).getTotal(), ((Page)page).isCount());
|
||||||
|
// vo.setOrderBy(((Page)page).getOrderBy());
|
||||||
|
// vo.setRecords(records);
|
||||||
|
// 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 {
|
||||||
|
PageVO<T> vo = of(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
|
||||||
|
vo.setRecords(page.getRecords());
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return this.current > 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return this.current < this.getPages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> getRecords() {
|
||||||
|
return this.records;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO<T> setRecords(List<T> records) {
|
||||||
|
this.records = records;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotal() {
|
||||||
|
return this.total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO<T> setTotal(long total) {
|
||||||
|
this.total = total;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO<T> setSize(long size) {
|
||||||
|
this.size = size;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCurrent() {
|
||||||
|
return this.current;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO<T> setCurrent(long current) {
|
||||||
|
this.current = current;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO<T> setSearchCount(boolean searchCount) {
|
||||||
|
this.searchCount = searchCount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrderBy() {
|
||||||
|
return this.orderBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageVO<T> setOrderBy(String orderBy) {
|
||||||
|
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