orderItems = buildOrderItem();
+ if (CollUtil.isNotEmpty(orderItems)) {
+ page.addOrder(orderItems);
+ }
+ return page;
+ }
+
+ /**
+ * 构建排序
+ *
+ * 支持的用法如下:
+ * {isAsc:"asc",orderByColumn:"id"} order by id asc
+ * {isAsc:"asc",orderByColumn:"id,createTime"} order by id asc,create_time asc
+ * {isAsc:"desc",orderByColumn:"id,createTime"} order by id desc,create_time desc
+ * {isAsc:"asc,desc",orderByColumn:"id,createTime"} order by id asc,create_time desc
+ */
+ private List buildOrderItem() {
+ if (StringUtils.isBlank(orderByColumn) || StringUtils.isBlank(isAsc)) {
+ return null;
+ }
+ String orderBy = SqlUtil.escapeOrderBySql(orderByColumn);
+ orderBy = StrUtil.toUnderlineCase(orderBy);
+
+ // 兼容前端排序类型
+ isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
+
+ String[] orderByArr = orderBy.split(",");
+ String[] isAscArr = isAsc.split(",");
+ if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
+ throw new ServiceException("排序参数有误");
+ }
+
+ List list = new ArrayList<>();
+ // 每个字段各自排序
+ for (int i = 0; i < orderByArr.length; i++) {
+ String orderByStr = orderByArr[i];
+ String isAscStr = isAscArr.length == 1 ? isAscArr[0] : isAscArr[i];
+ if ("asc".equals(isAscStr)) {
+ list.add(OrderItem.asc(orderByStr));
+ } else if ("desc".equals(isAscStr)) {
+ list.add(OrderItem.desc(orderByStr));
+ } else {
+ throw new ServiceException("排序参数有误");
+ }
+ }
+ return list;
+ }
+
+ @JsonIgnore
+ public Integer getFirstNum() {
+ return (pageNum - 1) * pageSize;
+ }
+
+ public PageQuery(Integer pageSize, Integer pageNum) {
+ this.pageSize = pageSize;
+ this.pageNum = pageNum;
+ }
+
+}
diff --git a/agileboot-common/wol-common-mybatis/src/main/java/com/agileboot/common/mybatis/core/page/TableDataInfo.java b/agileboot-common/wol-common-mybatis/src/main/java/com/agileboot/common/mybatis/core/page/TableDataInfo.java
new file mode 100644
index 0000000..5bd0c12
--- /dev/null
+++ b/agileboot-common/wol-common-mybatis/src/main/java/com/agileboot/common/mybatis/core/page/TableDataInfo.java
@@ -0,0 +1,107 @@
+package com.agileboot.common.mybatis.core.page;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.http.HttpStatus;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 表格分页数据对象
+ *
+ * @author Lion Li
+ */
+@Data
+@NoArgsConstructor
+public class TableDataInfo implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 总记录数
+ */
+ private long total;
+
+ /**
+ * 列表数据
+ */
+ private List rows;
+
+ /**
+ * 消息状态码
+ */
+ private int code;
+
+ /**
+ * 消息内容
+ */
+ private String msg;
+
+ /**
+ * 分页
+ *
+ * @param list 列表数据
+ * @param total 总记录数
+ */
+ public TableDataInfo(List list, long total) {
+ this.rows = list;
+ this.total = total;
+ this.code = HttpStatus.HTTP_OK;
+ this.msg = "查询成功";
+ }
+
+ /**
+ * 根据分页对象构建表格分页数据对象
+ */
+ public static TableDataInfo build(IPage page) {
+ TableDataInfo rspData = new TableDataInfo<>();
+ rspData.setCode(HttpStatus.HTTP_OK);
+ rspData.setMsg("查询成功");
+ rspData.setRows(page.getRecords());
+ rspData.setTotal(page.getTotal());
+ return rspData;
+ }
+
+ /**
+ * 根据数据列表构建表格分页数据对象
+ */
+ public static TableDataInfo build(List list) {
+ TableDataInfo rspData = new TableDataInfo<>();
+ rspData.setCode(HttpStatus.HTTP_OK);
+ rspData.setMsg("查询成功");
+ rspData.setRows(list);
+ rspData.setTotal(list.size());
+ return rspData;
+ }
+
+ /**
+ * 构建表格分页数据对象
+ */
+ public static TableDataInfo build() {
+ TableDataInfo rspData = new TableDataInfo<>();
+ rspData.setCode(HttpStatus.HTTP_OK);
+ rspData.setMsg("查询成功");
+ return rspData;
+ }
+
+ /**
+ * 根据原始数据列表和分页参数,构建表格分页数据对象(用于假分页)
+ *
+ * @param list 原始数据列表(全部数据)
+ * @param page 分页参数对象(包含当前页码、每页大小等)
+ * @return 构造好的分页结果 TableDataInfo
+ */
+ public static TableDataInfo build(List list, IPage page) {
+ if (CollUtil.isEmpty(list)) {
+ return TableDataInfo.build();
+ }
+ List pageList = CollUtil.page((int) page.getCurrent() - 1, (int) page.getSize(), list);
+ return new TableDataInfo<>(pageList, list.size());
+ }
+
+}
diff --git a/agileboot-common/wol-common-mybatis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/agileboot-common/wol-common-mybatis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..b7d43c6
--- /dev/null
+++ b/agileboot-common/wol-common-mybatis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.agileboot.common.mybatis.config.MybatisPlusConfiguration
diff --git a/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml b/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml
new file mode 100644
index 0000000..855d85d
--- /dev/null
+++ b/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml
@@ -0,0 +1,28 @@
+# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖
+# MyBatisPlus配置
+# https://baomidou.com/config/
+mybatis-plus:
+ # 启动时是否检查 MyBatis XML 文件的存在,默认不检查
+ checkConfigLocation: false
+ configuration:
+ # 自动驼峰命名规则(camel case)映射
+ mapUnderscoreToCamelCase: true
+ # MyBatis 自动映射策略
+ # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
+ autoMappingBehavior: FULL
+ # MyBatis 自动映射时未知列或未知属性处理策
+ # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
+ autoMappingUnknownColumnBehavior: NONE
+ # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
+ # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
+ # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
+ logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+ global-config:
+ banner: true # 是否打印 Logo banner
+ dbConfig:
+ idType: ASSIGN_ID # 主键类型: AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
+ logicDeleteValue: 1 # 逻辑已删除值(框架表均使用此值 禁止随意修改)
+ logicNotDeleteValue: 0 # 逻辑未删除值
+ insertStrategy: NOT_NULL
+ updateStrategy: NOT_NULL
+ whereStrategy: NOT_NULL
diff --git a/pom.xml b/pom.xml
index 048a1f2..742dd34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,6 @@
2.6.5
4.1.2
1.6.8
- 3.5.2
@@ -95,9 +94,14 @@
+
+
+
+
+
com.baomidou
- mybatis-plus-boot-starter
+ mybatis-plus-spring-boot3-starter
${mybatis-plus.version}
@@ -293,10 +297,10 @@
org.projectlombok
lombok
-
- com.baomidou
- mybatis-plus-boot-starter
-
+
+
+
+
org.springframework.boot
spring-boot-configuration-processor