Initial project
This commit is contained in:
51
src/main/java/com/imyeyu/spring/bean/CaptchaData.java
Normal file
51
src/main/java/com/imyeyu/spring/bean/CaptchaData.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.imyeyu.spring.bean;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 含验证码数据实体
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2021-03-01 17:10
|
||||
*/
|
||||
public class CaptchaData<T> {
|
||||
|
||||
/** 来源 */
|
||||
@NotBlank(message = "timijava.code.request_bad")
|
||||
protected String from;
|
||||
|
||||
/** 验证码 */
|
||||
@NotBlank(message = "captcha.miss")
|
||||
protected String captcha;
|
||||
|
||||
/** 数据体 */
|
||||
@Valid
|
||||
@NotNull
|
||||
protected T data;
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getCaptcha() {
|
||||
return captcha;
|
||||
}
|
||||
|
||||
public void setCaptcha(String captcha) {
|
||||
this.captcha = captcha;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
83
src/main/java/com/imyeyu/spring/bean/Page.java
Normal file
83
src/main/java/com/imyeyu/spring/bean/Page.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.imyeyu.spring.bean;
|
||||
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* 抽象页面查询参数
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2023-06-02 14:47
|
||||
*/
|
||||
public class Page {
|
||||
|
||||
/** 下标 */
|
||||
@Min(value = 0, message = "page.min_index")
|
||||
protected int index = 0;
|
||||
|
||||
/** 数据量 */
|
||||
@Max(value = 64, message = "page.max_size")
|
||||
protected int size = 16;
|
||||
|
||||
/** 关键字 */
|
||||
protected String keyword;
|
||||
|
||||
protected LinkedHashMap<String, BaseMapper.OrderType> orderMap;
|
||||
|
||||
public Page() {
|
||||
}
|
||||
|
||||
public Page(int index, int size) {
|
||||
this.index = index;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public long getOffset() {
|
||||
return (long) index * size;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, BaseMapper.OrderType> getOrderMap() {
|
||||
return orderMap;
|
||||
}
|
||||
|
||||
public void setOrderMap(LinkedHashMap<String, BaseMapper.OrderType> orderMap) {
|
||||
this.orderMap = orderMap;
|
||||
}
|
||||
|
||||
public static <T, P extends Page, R extends PageResult<T>> R toResult(BaseMapper<T, ?> pageMapper, P page, R result) {
|
||||
result.setList(pageMapper.list(page.getOffset(), page.getLimit()));
|
||||
result.setTotal(pageMapper.count());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
59
src/main/java/com/imyeyu/spring/bean/PageResult.java
Normal file
59
src/main/java/com/imyeyu/spring/bean/PageResult.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.imyeyu.spring.bean;
|
||||
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.utils.Calc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 抽象页面查询结果
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2023-06-02 14:47
|
||||
*/
|
||||
public class PageResult<T> {
|
||||
|
||||
/** 总数据量 */
|
||||
protected long total;
|
||||
|
||||
/** 总页数 */
|
||||
protected int pages;
|
||||
|
||||
protected List<T> list;
|
||||
|
||||
/**
|
||||
* 获取总数据量
|
||||
*
|
||||
* @return 总数据量
|
||||
*/
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置总数据量
|
||||
*
|
||||
* @param total 总数据量
|
||||
*/
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
if (TimiJava.isNotEmpty(list)) {
|
||||
pages = Calc.ceil(1D * total / list.size());
|
||||
}
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<T> list) {
|
||||
this.list = list;
|
||||
if (TimiJava.isNotEmpty(list)) {
|
||||
pages = Calc.ceil(1D * total / list.size());
|
||||
}
|
||||
}
|
||||
|
||||
public int getPages() {
|
||||
return pages;
|
||||
}
|
||||
}
|
||||
157
src/main/java/com/imyeyu/spring/bean/RedisConfigParams.java
Normal file
157
src/main/java/com/imyeyu/spring/bean/RedisConfigParams.java
Normal file
@@ -0,0 +1,157 @@
|
||||
package com.imyeyu.spring.bean;
|
||||
|
||||
/**
|
||||
* RedisConfig 配置参数
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2021-11-21 10:02
|
||||
*/
|
||||
public class RedisConfigParams {
|
||||
|
||||
/** 地址 */
|
||||
private String host;
|
||||
|
||||
/** 端口 */
|
||||
private int port;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 超时(毫秒) */
|
||||
private int timeout;
|
||||
|
||||
/** 最大活跃连接 */
|
||||
private int maxActive;
|
||||
|
||||
/** 最小空闲连接 */
|
||||
private int minIdle;
|
||||
|
||||
/** 最大空闲连接 */
|
||||
private int maxIdle;
|
||||
|
||||
/**
|
||||
* 获取地址
|
||||
*
|
||||
* @return 地址
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地址
|
||||
*
|
||||
* @param host 地址
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取端口
|
||||
*
|
||||
* @return 端口
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置端口
|
||||
*
|
||||
* @param port 端口
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取密码
|
||||
*
|
||||
* @return 密码
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置密码
|
||||
*
|
||||
* @param password 密码
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取超时(毫秒)
|
||||
*
|
||||
* @return 超时(毫秒)
|
||||
*/
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置超时(毫秒)
|
||||
*
|
||||
* @param timeout 超时(毫秒)
|
||||
*/
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大活跃连接
|
||||
*
|
||||
* @return 最大活跃连接
|
||||
*/
|
||||
public int getMaxActive() {
|
||||
return maxActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大活跃连接
|
||||
*
|
||||
* @param maxActive 最大活跃连接
|
||||
*/
|
||||
public void setMaxActive(int maxActive) {
|
||||
this.maxActive = maxActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最小空闲连接
|
||||
*
|
||||
* @return 最小空闲连接
|
||||
*/
|
||||
public int getMinIdle() {
|
||||
return minIdle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最小空闲连接
|
||||
*
|
||||
* @param minIdle 最小空闲连接
|
||||
*/
|
||||
public void setMinIdle(int minIdle) {
|
||||
this.minIdle = minIdle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大空闲连接
|
||||
*
|
||||
* @return 最大空闲连接
|
||||
*/
|
||||
public int getMaxIdle() {
|
||||
return maxIdle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大空闲连接
|
||||
*
|
||||
* @param maxIdle 最大空闲连接
|
||||
*/
|
||||
public void setMaxIdle(int maxIdle) {
|
||||
this.maxIdle = maxIdle;
|
||||
}
|
||||
}
|
||||
2
src/main/java/com/imyeyu/spring/bean/package-info.java
Normal file
2
src/main/java/com/imyeyu/spring/bean/package-info.java
Normal file
@@ -0,0 +1,2 @@
|
||||
/** 配置对象 */
|
||||
package com.imyeyu.spring.bean;
|
||||
Reference in New Issue
Block a user