🔨 数据清理时添加条数限制.

This commit is contained in:
lijiahang
2024-08-26 17:10:40 +08:00
parent 6c60756e54
commit a0adb415fa
41 changed files with 295 additions and 51 deletions

View File

@@ -4,7 +4,9 @@ import com.orion.lang.define.wrapper.IPageRequest;
import com.orion.visor.framework.common.validator.group.Page;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
/**
* 公共页码请求
@@ -17,11 +19,13 @@ import org.hibernate.validator.constraints.Range;
@Schema(description = "公共页码请求")
public class PageRequest implements IPageRequest {
@Range(min = 1, max = 10000, groups = Page.class)
@Min(value = 1, groups = Page.class)
@Max(value = 10000, groups = Page.class)
@Schema(description = "页码")
private int page;
@Range(min = 1, max = 200, groups = Page.class)
@Min(value = 1, groups = Page.class)
@Max(value = 200, groups = Page.class)
@Schema(description = "大小")
private int limit;

View File

@@ -0,0 +1,38 @@
package com.orion.visor.framework.common.utils;
import com.orion.visor.framework.common.constant.Const;
/**
* sql 工具类
*
* @author Jiahang Li
* @version 1.0.0
* @since 2024/8/26 16:03
*/
public class SqlUtils {
private SqlUtils() {
}
/**
* limit n
*
* @param limit limit
* @return limit
*/
public static String limit(Integer limit) {
return Const.LIMIT + Const.SPACE + limit;
}
/**
* limit offset limit
*
* @param offset offset
* @param limit limit
* @return limit
*/
public static String limit(int offset, Integer limit) {
return Const.LIMIT + Const.SPACE + offset + Const.COMMA + limit;
}
}

View File

@@ -1,7 +1,5 @@
package com.orion.visor.framework.common.validator.group;
import javax.validation.groups.Default;
/**
* 批量验证分组
*
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Batch extends Default {
public interface Batch {
}

View File

@@ -0,0 +1,11 @@
package com.orion.visor.framework.common.validator.group;
/**
* 清理验证分组
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Clear {
}

View File

@@ -0,0 +1,11 @@
package com.orion.visor.framework.common.validator.group;
/**
* 导出验证分组
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Export {
}

View File

@@ -1,7 +1,5 @@
package com.orion.visor.framework.common.validator.group;
import javax.validation.groups.Default;
/**
* 分页验证分组
*
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Id extends Default {
public interface Id {
}

View File

@@ -0,0 +1,11 @@
package com.orion.visor.framework.common.validator.group;
/**
* 导出验证分组
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Import {
}

View File

@@ -1,7 +1,5 @@
package com.orion.visor.framework.common.validator.group;
import javax.validation.groups.Default;
/**
* 分页验证分组
*
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Page extends Default {
public interface Page {
}

View File

@@ -16,6 +16,7 @@ import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.reflect.Classes;
import com.orion.spring.SpringHolder;
import com.orion.visor.framework.common.constant.Const;
import com.orion.visor.framework.common.utils.SqlUtils;
import com.orion.visor.framework.mybatis.core.domain.BaseDO;
import java.io.Serializable;
@@ -111,11 +112,11 @@ public class DataQuery<T> {
}
public DataQuery<T> limit(int limit) {
return this.last(Const.LIMIT + Const.SPACE + limit);
return this.last(SqlUtils.limit(limit));
}
public DataQuery<T> limit(int offset, int limit) {
return this.last(Const.LIMIT + Const.SPACE + offset + Const.COMMA + limit);
return this.last(SqlUtils.limit(offset, limit));
}
public DataQuery<T> only() {