|
@@ -1,27 +1,26 @@
|
|
|
package com.persagy.fm.common.model.dto;
|
|
|
|
|
|
+import com.persagy.fm.common.constant.PageQueryConstants;
|
|
|
+import io.swagger.annotations.ApiModel;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
import lombok.Data;
|
|
|
import net.minidev.json.annotate.JsonIgnore;
|
|
|
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
- * @description: 分页条件
|
|
|
- * @author: lixing
|
|
|
- * @company: Persagy Technology Co.,Ltd
|
|
|
- * @since: 2020/10/13 3:23 下午
|
|
|
- * @version: V1.0
|
|
|
- **/
|
|
|
+ * 分页条件
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/4/29 2:57 下午
|
|
|
+ */
|
|
|
@Data
|
|
|
+@ApiModel
|
|
|
public class PageDTO {
|
|
|
- @ApiModelProperty(value = "当前页数", required = true)
|
|
|
- @NotNull(message = "当前页数不能为空")
|
|
|
+ @ApiModelProperty(value = "当前页数")
|
|
|
private Integer page;
|
|
|
|
|
|
- @ApiModelProperty(value = "每页条数", required = true)
|
|
|
- @NotNull(message = "每页条数不能为空")
|
|
|
+ @ApiModelProperty(value = "每页条数")
|
|
|
private Integer size;
|
|
|
@ApiModelProperty(value = "排序方式")
|
|
|
private List<Sort> orders;
|
|
@@ -31,10 +30,21 @@ public class PageDTO {
|
|
|
private Integer startIndex;
|
|
|
|
|
|
public Integer getStartIndex() {
|
|
|
- if (page == null || size == null) {
|
|
|
- return 0;
|
|
|
+ return (getPage() - 1) * getSize();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getPage() {
|
|
|
+ if (this.page == null) {
|
|
|
+ return PageQueryConstants.DEFAULT_PAGE;
|
|
|
+ }
|
|
|
+ return this.page;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getSize() {
|
|
|
+ if (this.size == null) {
|
|
|
+ return PageQueryConstants.DEFAULT_SIZE;
|
|
|
}
|
|
|
- return (page -1) * size;
|
|
|
+ return this.size;
|
|
|
}
|
|
|
}
|
|
|
|