feat: 题目模块开发

This commit is contained in:
2024-02-16 19:17:52 +08:00
parent 37fb0ea196
commit 7028b350bd
59 changed files with 3135 additions and 27 deletions

View File

@@ -0,0 +1,37 @@
package com.landaiqing.subject.common.entity;
import lombok.Data;
import java.io.Serializable;
/**
* @Classname PageInfo
* @BelongsProject: jc-club
* @BelongsPackage: com.landaiqing.subject.common.entity
* @Author: landaiqing
* @CreateTime: 2024-02-16 11:52
* @Description: 分页请求实体
* @Version: 1.0
*/
@Data
public class PageInfo implements Serializable {
private Integer pageNo = 1;
private Integer pageSize = 20;
public Integer getPageNo() {
if (pageNo == null || pageNo <= 1) {
return 1;
}
return pageNo;
}
public Integer getPageSize() {
if (pageSize == null || pageSize < 1 || pageSize > Integer.MAX_VALUE) {
return 20;
}
return pageSize;
}
}

View File

@@ -0,0 +1,57 @@
package com.landaiqing.subject.common.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
/**
* @Classname PageResult
* @BelongsProject: jc-club
* @BelongsPackage: com.landaiqing.subject.common.entity
* @Author: landaiqing
* @CreateTime: 2024-02-16 11:56
* @Description: 分页返回的实体
* @Version: 1.0
*/
@Data
public class PageResult<T> implements Serializable {
private Integer pageNo = 1;
private Integer pageSize = 20;
private Integer total = 0;
private Integer totalPages = 0;
private List<T> result = Collections.emptyList();
private Integer start = 1;
private Integer end = 0;
public void setRecords(List<T> result) {
this.result = result;
if (result != null && result.size() > 0) {
setTotal(result.size());
}
}
public void setTotal(Integer total) {
this.total = total;
if (pageSize > 0) {
this.totalPages = (total / this.pageSize) + (total % this.pageSize == 0 ? 0 : 1);
} else {
this.totalPages = 0;
}
this.start = (this.pageSize > 0 ? (this.pageNo - 1) * this.pageSize : 0) + 1;
this.end = (this.start - 1 + this.pageSize * (this.pageNo > 0 ? 1 : 0));
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
}