Browse Source

fix:修复执行新增修改不返回结果,拖拽表格、表单,table模版接口的bug修复、新增table时sql条件错误问题

韩帛霖 1 year ago
parent
commit
f0e292044f

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/CommonController.java

@@ -59,7 +59,7 @@ public class CommonController extends BaseController {
     /**
      * 共通修改sql
      */
-    @PutMapping("/edit")
+    @PutMapping("/batchEdit")
     public AjaxResult edit(@RequestBody CommonEntity commonEntity) {
         return toAjax(commonService.edit(commonEntity));
     }

+ 21 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SqlInterceptor.java

@@ -4,6 +4,7 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.reflect.ReflectUtils;
 import org.apache.ibatis.executor.statement.StatementHandler;
 import org.apache.ibatis.plugin.*;
+import org.aspectj.lang.annotation.Before;
 
 import java.sql.Connection;
 import java.util.Properties;
@@ -23,9 +24,11 @@ public class SqlInterceptor implements Interceptor {
         StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
         String sql = statementHandler.getBoundSql().getSql();
         // 修改SQL语句
-        String modifiedSql = modifySql(sql);
+        String modifiedSql = BeforeSQL(sql);
         // 将修改后的SQL语句设置回StatementHandler
         ReflectUtils.setFieldValue(statementHandler.getBoundSql(), "sql", modifiedSql);
+        invocation.proceed();
+        ReflectUtils.setFieldValue(statementHandler.getBoundSql(), "sql", sql);
         return invocation.proceed();
     }
 
@@ -45,6 +48,23 @@ public class SqlInterceptor implements Interceptor {
         return sql;
     }
 
+    // 根据类型设置不同的选择数据源格式
+    private String BeforeSQL(String sql) {
+        try {
+            SecurityUtils.getDatabaseType();
+        } catch (Exception e) {
+            return "";
+        }
+        if (SecurityUtils.getDatabaseType().equals("sqlserver"))
+            return "USE `" + SecurityUtils.getDatabaseName() + "`; ";
+        if (SecurityUtils.getDatabaseType().equals("dm"))
+            return "set schema " + SecurityUtils.getDatabaseName() + "; ";
+        if (SecurityUtils.getDatabaseType().equals("mysql"))
+            return "USE `" + SecurityUtils.getDatabaseName() + "`; ";
+        return sql;
+    }
+
+
     @Override
     public Object plugin(Object target) {
         return Plugin.wrap(target, this);

+ 146 - 96
ruoyi-system/src/main/java/com/ruoyi/system/entity/DragTable.java

@@ -7,144 +7,187 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * 动态格对象 drag_table
- * 
+ *
  * @author ruoyi
  * @date 2023-07-31
  */
-public class DragTable extends BaseEntity
-{
+public class DragTable extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 表格主键 */
+    /**
+     * 表格主键
+     */
     private Long tId;
 
-    /** 表格名称 */
+    /**
+     * 表格名称
+     */
     @Excel(name = "表格名称")
     private String dtName;
 
-    /** 表格别名 */
+    /**
+     * 表格别名
+     */
     @Excel(name = "表格别名")
     private String dtNickname;
 
-    /** table编号 */
+    /**
+     * table编号
+     */
     @Excel(name = "table编号")
     private String tableKey;
 
-    /** sql编号 */
+    /**
+     * sql编号
+     */
     @Excel(name = "sql编号")
     private String sqlKey;
 
-    /** 绑定表名称 */
+    /**
+     * 绑定表名称
+     */
     @Excel(name = "绑定表名称")
     private String dtTableName;
 
-    /** 表格描述 */
+    /**
+     * 表格描述
+     */
     @Excel(name = "表格描述")
     private String dtNotes;
 
-    /** 列字段标题名称 */
+    /**
+     * 列字段标题名称
+     */
     @Excel(name = "列字段标题名称")
     private String dtColumnName;
 
-    /** 时间格式 */
+    /**
+     * 时间格式
+     */
     @Excel(name = "时间格式")
     private String timeFormat;
 
-    /** 备用列 */
+    /**
+     * 备用列
+     */
     @Excel(name = "备用列")
     private String spare;
 
-    /** 备用列 */
+    /**
+     * 备用列
+     */
     @Excel(name = "备用列")
     private String spare1;
 
-    /** 逻辑删除 */
+    /**
+     * 逻辑删除
+     */
     private String delFlag;
 
-    /** 是否显示列表复选框(0:显示;1;不显示) */
+    /**
+     * 是否显示列表复选框(0:显示;1;不显示)
+     */
     private String isSelection;
 
-    /** 回显数据(前端修改回显数据使用) */
+    /**
+     * 回显数据(前端修改回显数据使用)
+     */
     private String echoData;
 
-    /** 菜单编号 */
+    /**
+     * 菜单编号
+     */
     private Long menuId;
 
-    public void settId(Long tId) 
-    {
-        this.tId = tId;
+    /**
+     * 当前表单的唯一标识,修改删除使用
+     */
+    private String primaryKey;
+
+    @Override
+    public String toString() {
+        return "DragTable{" +
+                "tId=" + tId +
+                ", dtName='" + dtName + '\'' +
+                ", dtNickname='" + dtNickname + '\'' +
+                ", tableKey='" + tableKey + '\'' +
+                ", sqlKey='" + sqlKey + '\'' +
+                ", dtTableName='" + dtTableName + '\'' +
+                ", dtNotes='" + dtNotes + '\'' +
+                ", dtColumnName='" + dtColumnName + '\'' +
+                ", timeFormat='" + timeFormat + '\'' +
+                ", spare='" + spare + '\'' +
+                ", spare1='" + spare1 + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                ", isSelection='" + isSelection + '\'' +
+                ", echoData='" + echoData + '\'' +
+                ", menuId=" + menuId +
+                ", primaryKey='" + primaryKey + '\'' +
+                '}';
     }
 
-    public Long gettId() 
-    {
+    public Long gettId() {
         return tId;
     }
-    public void setDtName(String dtName) 
-    {
-        this.dtName = dtName;
+
+    public void settId(Long tId) {
+        this.tId = tId;
     }
 
-    public String getDtName() 
-    {
+    public String getDtName() {
         return dtName;
     }
-    public void setDtNickname(String dtNickname) 
-    {
-        this.dtNickname = dtNickname;
+
+    public void setDtName(String dtName) {
+        this.dtName = dtName;
     }
 
-    public String getDtNickname() 
-    {
+    public String getDtNickname() {
         return dtNickname;
     }
-    public void setTableKey(String tableKey) 
-    {
-        this.tableKey = tableKey;
+
+    public void setDtNickname(String dtNickname) {
+        this.dtNickname = dtNickname;
     }
 
-    public String getTableKey() 
-    {
+    public String getTableKey() {
         return tableKey;
     }
-    public void setSqlKey(String sqlKey) 
-    {
-        this.sqlKey = sqlKey;
+
+    public void setTableKey(String tableKey) {
+        this.tableKey = tableKey;
     }
 
-    public String getSqlKey() 
-    {
+    public String getSqlKey() {
         return sqlKey;
     }
-    public void setDtTableName(String dtTableName) 
-    {
-        this.dtTableName = dtTableName;
+
+    public void setSqlKey(String sqlKey) {
+        this.sqlKey = sqlKey;
     }
 
-    public String getDtTableName() 
-    {
+    public String getDtTableName() {
         return dtTableName;
     }
-    public void setDtNotes(String dtNotes) 
-    {
-        this.dtNotes = dtNotes;
+
+    public void setDtTableName(String dtTableName) {
+        this.dtTableName = dtTableName;
     }
 
-    public String getDtNotes() 
-    {
+    public String getDtNotes() {
         return dtNotes;
     }
-    public void setDtColumnName(String dtColumnName) 
-    {
-        this.dtColumnName = dtColumnName;
+
+    public void setDtNotes(String dtNotes) {
+        this.dtNotes = dtNotes;
     }
 
-    public String getDtColumnName() 
-    {
+    public String getDtColumnName() {
         return dtColumnName;
     }
-    public void setSpare(String spare) 
-    {
-        this.spare = spare;
+
+    public void setDtColumnName(String dtColumnName) {
+        this.dtColumnName = dtColumnName;
     }
 
     public String getTimeFormat() {
@@ -155,29 +198,30 @@ public class DragTable extends BaseEntity
         this.timeFormat = timeFormat;
     }
 
-    public String getSpare()
-    {
+    public String getSpare() {
         return spare;
     }
-    public void setSpare1(String spare1) 
-    {
-        this.spare1 = spare1;
+
+    public void setSpare(String spare) {
+        this.spare = spare;
     }
 
-    public String getSpare1() 
-    {
+    public String getSpare1() {
         return spare1;
     }
-    public void setDelFlag(String delFlag) 
-    {
-        this.delFlag = delFlag;
+
+    public void setSpare1(String spare1) {
+        this.spare1 = spare1;
     }
 
-    public String getDelFlag() 
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
     public String getIsSelection() {
         return isSelection;
     }
@@ -202,28 +246,34 @@ public class DragTable extends BaseEntity
         this.menuId = menuId;
     }
 
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("tId", gettId())
-            .append("dtName", getDtName())
-            .append("dtNickname", getDtNickname())
-            .append("tableKey", getTableKey())
-            .append("sqlKey", getSqlKey())
-            .append("dtTableName", getDtTableName())
-            .append("dtNotes", getDtNotes())
-            .append("dtColumnName", getDtColumnName())
-            .append("timeFormat",getTimeFormat())
-            .append("spare", getSpare())
-            .append("spare1", getSpare1())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("isSelection", getIsSelection())
-            .append("echoData",getEchoData())
-            .append("menuId",getMenuId())
-            .toString();
+    public String getPrimaryKey() {
+        return primaryKey;
+    }
+
+    public void setPrimaryKey(String primaryKey) {
+        this.primaryKey = primaryKey;
+    }
+
+    public DragTable() {
+
+    }
+
+    public DragTable(Long tId, String dtName, String dtNickname, String tableKey, String sqlKey, String dtTableName, String dtNotes, String dtColumnName, String timeFormat, String spare, String spare1, String delFlag, String isSelection, String echoData, Long menuId, String primaryKey) {
+        this.tId = tId;
+        this.dtName = dtName;
+        this.dtNickname = dtNickname;
+        this.tableKey = tableKey;
+        this.sqlKey = sqlKey;
+        this.dtTableName = dtTableName;
+        this.dtNotes = dtNotes;
+        this.dtColumnName = dtColumnName;
+        this.timeFormat = timeFormat;
+        this.spare = spare;
+        this.spare1 = spare1;
+        this.delFlag = delFlag;
+        this.isSelection = isSelection;
+        this.echoData = echoData;
+        this.menuId = menuId;
+        this.primaryKey = primaryKey;
     }
 }

+ 104 - 58
ruoyi-system/src/main/java/com/ruoyi/system/entity/TableSql.java

@@ -7,94 +7,117 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * table 联合查询sql存储对象 table_sql
- * 
+ *
  * @author ruoyi
  * @date 2023-07-19
  */
-public class TableSql extends BaseEntity
-{
+public class TableSql extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** $column.columnComment */
+    /**
+     * $column.columnComment
+     */
     private Long tId;
 
-    /** 表查询语句
- */
+    /**
+     * 表查询语句
+     */
     @Excel(name = "表查询语句")
     private String tableSql;
 
-    /** 表查询条件 */
+    /**
+     * 表查询条件
+     */
     @Excel(name = "表查询条件")
     private String tableCondition;
 
-    /** 表别名 */
+    /**
+     * 表别名
+     */
     @Excel(name = "表别名")
     private String tableAlias;
 
-    /** sql编号,绑定tableList */
+    /**
+     * sql编号,绑定tableList
+     */
     @Excel(name = "sql编号,绑定tableList")
     private String sqlKey;
 
-    /** 导出的字段名以及列名 */
+    /**
+     * 导出的字段名以及列名
+     */
     @Excel(name = "导出的字段名以及列名")
     private String tableExportField;
 
-    /** 逻辑删除 */
+    /**
+     * 逻辑删除
+     */
     private String delFlag;
 
-    public void settId(Long tId) 
-    {
-        this.tId = tId;
+
+    /**
+     * 根据某一列进行排序
+     */
+    private String orderByColumn;
+
+    /**
+     * 排序方式  boolean: desc(降序)? asc(升序)
+     */
+    private String sortOrder;
+
+    @Override
+    public String toString() {
+        return "TableSql{" +
+                "tId=" + tId +
+                ", tableSql='" + tableSql + '\'' +
+                ", tableCondition='" + tableCondition + '\'' +
+                ", tableAlias='" + tableAlias + '\'' +
+                ", sqlKey='" + sqlKey + '\'' +
+                ", tableExportField='" + tableExportField + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                ", orderByColumn='" + orderByColumn + '\'' +
+                ", sortOrder='" + sortOrder + '\'' +
+                '}';
     }
 
-    public Long gettId() 
-    {
+    public Long gettId() {
         return tId;
     }
-    public void setTableSql(String tableSql) 
-    {
-        this.tableSql = tableSql;
+
+    public void settId(Long tId) {
+        this.tId = tId;
     }
 
-    public String getTableSql() 
-    {
+    public String getTableSql() {
         return tableSql;
     }
-    public void setTableCondition(String tableCondition) 
-    {
-        this.tableCondition = tableCondition;
+
+    public void setTableSql(String tableSql) {
+        this.tableSql = tableSql;
     }
 
-    public String getTableCondition() 
-    {
+    public String getTableCondition() {
         return tableCondition;
     }
-    public void setTableAlias(String tableAlias) 
-    {
-        this.tableAlias = tableAlias;
+
+    public void setTableCondition(String tableCondition) {
+        this.tableCondition = tableCondition;
     }
 
-    public String getTableAlias() 
-    {
+    public String getTableAlias() {
         return tableAlias;
     }
-    public void setSqlKey(String sqlKey) 
-    {
-        this.sqlKey = sqlKey;
+
+    public void setTableAlias(String tableAlias) {
+        this.tableAlias = tableAlias;
     }
 
-    public String getSqlKey() 
-    {
+    public String getSqlKey() {
         return sqlKey;
     }
-    public void setDelFlag(String delFlag) 
-    {
-        this.delFlag = delFlag;
-    }
 
-    public String getDelFlag() 
-    {
-        return delFlag;
+    public void setSqlKey(String sqlKey) {
+        this.sqlKey = sqlKey;
     }
 
     public String getTableExportField() {
@@ -105,20 +128,43 @@ public class TableSql extends BaseEntity
         this.tableExportField = tableExportField;
     }
 
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("tId", gettId())
-            .append("tableSql", getTableSql())
-            .append("tableCondition", getTableCondition())
-            .append("tableAlias", getTableAlias())
-            .append("sqlKey", getSqlKey())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("delFlag", getDelFlag())
-            .append("tableExportField",getTableExportField())
-            .toString();
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public String getOrderByColumn() {
+        return orderByColumn;
+    }
+
+    public void setOrderByColumn(String orderByColumn) {
+        this.orderByColumn = orderByColumn;
+    }
+
+    public String getSortOrder() {
+        return sortOrder;
+    }
+
+    public void setSortOrder(String sortOrder) {
+        this.sortOrder = sortOrder;
+    }
+
+    public TableSql() {
+
+    }
+
+    public TableSql(Long tId, String tableSql, String tableCondition, String tableAlias, String sqlKey, String tableExportField, String delFlag, String orderByColumn, String sortOrder) {
+        this.tId = tId;
+        this.tableSql = tableSql;
+        this.tableCondition = tableCondition;
+        this.tableAlias = tableAlias;
+        this.sqlKey = sqlKey;
+        this.tableExportField = tableExportField;
+        this.delFlag = delFlag;
+        this.orderByColumn = orderByColumn;
+        this.sortOrder = sortOrder;
     }
 }

+ 128 - 35
ruoyi-system/src/main/java/com/ruoyi/system/entity/vo/DragTableVo.java

@@ -10,53 +10,118 @@ import java.util.Map;
 
 /**
  * 动态格对象 drag_table
- * 
+ *
  * @author ruoyi
  * @date 2023-07-31
  */
-public class DragTableVo
-{
-    /** 表格主键 */
+public class DragTableVo {
+    /**
+     * 表格主键
+     */
     private Long tId;
 
-    /** 菜单名称 */
+    /**
+     * 菜单名称
+     */
     private String dtName;
 
-    /** 表格别名 */
+    /**
+     * 表格别名
+     */
     private String dtNickname;
 
-    /** 路由信息 */
+    /**
+     * 路由信息
+     */
     private String tableKey;
 
-    /** sql编号 */
+    /**
+     * sql编号
+     */
     private String sqlKey;
 
-    /** 绑定表名称 */
+    /**
+     * 绑定表名称
+     */
     private String dtTableName;
 
-    /** 列字段标题名称(存储显示字段信息JSON) */
+    /**
+     * 列字段标题名称(存储显示字段信息JSON)
+     */
     private Object dtColumnName;
 
-    /** 时间格式 */
+    /**
+     * 时间格式
+     */
     private String timeFormat;
 
-    /** 是否显示列表复选框(0:显示;1;不显示) */
+    /**
+     * 是否显示列表复选框(0:显示;1;不显示)
+     */
     private String isSelection;
 
-    /** 搜索字段数组 */
+    /**
+     * 搜索字段数组
+     */
     private List<String> searchFieldList;
 
-    /** 表查询语句 */
+    /**
+     * 表查询语句
+     */
     private String tableSql;
 
-    /** 导出字段名以及列名JSON */
+    /**
+     * 导出字段名以及列名JSON
+     */
     private Object tableExportField;
 
-    /** 回显数据(前端修改回显数据使用) */
+    /**
+     * 回显数据(前端修改回显数据使用)
+     */
     private String echoData;
 
-    /** 菜单编号 */
+    /**
+     * 菜单编号
+     */
     private Long menuId;
+    /**
+     * 当前表单的唯一标识,修改删除使用
+     */
+
+    private String primaryKey;
+
+    /**
+     * 根据某一列进行排序
+     */
+    private String orderByColumn;
+
+    /**
+     * 排序方式  boolean: desc(降序)? asc(升序)
+     */
+    private String sortOrder;
+
+    @Override
+    public String toString() {
+        return "DragTableVo{" +
+                "tId=" + tId +
+                ", dtName='" + dtName + '\'' +
+                ", dtNickname='" + dtNickname + '\'' +
+                ", tableKey='" + tableKey + '\'' +
+                ", sqlKey='" + sqlKey + '\'' +
+                ", dtTableName='" + dtTableName + '\'' +
+                ", dtColumnName=" + dtColumnName +
+                ", timeFormat='" + timeFormat + '\'' +
+                ", isSelection='" + isSelection + '\'' +
+                ", searchFieldList=" + searchFieldList +
+                ", tableSql='" + tableSql + '\'' +
+                ", tableExportField=" + tableExportField +
+                ", echoData='" + echoData + '\'' +
+                ", menuId=" + menuId +
+                ", primaryKey='" + primaryKey + '\'' +
+                ", orderByColumn='" + orderByColumn + '\'' +
+                ", sortOrder='" + sortOrder + '\'' +
+                '}';
+    }
 
     public Long gettId() {
         return tId;
@@ -170,23 +235,51 @@ public class DragTableVo
         this.menuId = menuId;
     }
 
-    @Override
-    public String toString() {
-        return "DragTableVo{" +
-                "tId=" + tId +
-                ", dtName='" + dtName + '\'' +
-                ", dtNickname='" + dtNickname + '\'' +
-                ", tableKey='" + tableKey + '\'' +
-                ", sqlKey='" + sqlKey + '\'' +
-                ", dtTableName='" + dtTableName + '\'' +
-                ", dtColumnName=" + dtColumnName +
-                ", timeFormat='" + timeFormat + '\'' +
-                ", isSelection='" + isSelection + '\'' +
-                ", searchFieldList=" + searchFieldList +
-                ", tableSql='" + tableSql + '\'' +
-                ", tableExportField=" + tableExportField +
-                ", echoData='" + echoData + '\'' +
-                ", menuId=" + menuId +
-                '}';
+    public String getPrimaryKey() {
+        return primaryKey;
+    }
+
+    public void setPrimaryKey(String primaryKey) {
+        this.primaryKey = primaryKey;
+    }
+
+    public String getOrderByColumn() {
+        return orderByColumn;
+    }
+
+    public void setOrderByColumn(String orderByColumn) {
+        this.orderByColumn = orderByColumn;
+    }
+
+    public String getSortOrder() {
+        return sortOrder;
+    }
+
+    public void setSortOrder(String sortOrder) {
+        this.sortOrder = sortOrder;
+    }
+
+    public DragTableVo() {
+
+    }
+
+    public DragTableVo(Long tId, String dtName, String dtNickname, String tableKey, String sqlKey, String dtTableName, Object dtColumnName, String timeFormat, String isSelection, List<String> searchFieldList, String tableSql, Object tableExportField, String echoData, Long menuId, String primaryKey, String orderByColumn, String sortOrder) {
+        this.tId = tId;
+        this.dtName = dtName;
+        this.dtNickname = dtNickname;
+        this.tableKey = tableKey;
+        this.sqlKey = sqlKey;
+        this.dtTableName = dtTableName;
+        this.dtColumnName = dtColumnName;
+        this.timeFormat = timeFormat;
+        this.isSelection = isSelection;
+        this.searchFieldList = searchFieldList;
+        this.tableSql = tableSql;
+        this.tableExportField = tableExportField;
+        this.echoData = echoData;
+        this.menuId = menuId;
+        this.primaryKey = primaryKey;
+        this.orderByColumn = orderByColumn;
+        this.sortOrder = sortOrder;
     }
 }

+ 1 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragFormServiceImpl.java

@@ -103,8 +103,7 @@ public class DragFormServiceImpl implements IDragFormService {
         // 修改的时候删除表单源文件后重新创建
         delFileForm(dragForm.getfId());
         dragForm.setUpdateTime(DateUtils.getNowDate());
-        dragFormMapper.updateDragForm(dragForm);
-        return 1;
+        return dragFormMapper.updateDragForm(dragForm);
     }
 
     /**

+ 27 - 20
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableServiceImpl.java

@@ -144,20 +144,21 @@ public class DragTableServiceImpl implements IDragTableService {
     }
 
     // SQL 条件的开始
-    public String SQL_START = "CONCAT(";
+    public static final String SQL_START = "CONCAT(";
 
     // SQL 超级查询常量
-    public String SQL_MIDDLE = "IFNULL( #{VAL}, '' )";
+    public static final String SQL_MIDDLE = "IFNULL( #{VAL}, '' )";
 
     // sqlserver 数据类型的超级查询常量
-    public String SQLSERVER_MIDDLE = "COALESCE( #{VAL}, '' )";
+    public static final String SQLSERVER_MIDDLE = "COALESCE( #{VAL}, '' )";
 
     // SQL 条件的结束
-    public String SQL_END = "LIKE '%#{val}%'";
+    public static final String SQL_END = "LIKE '%#{val}%'";
 
     @Transactional
     @Override
     public void addDragTable(DragTableVo dragTableVo) {
+        String SQL = "";
         //生成dtNickname表格别名
         String dtNickname = IdUtils.fastSimpleUUID();
         //生成sqlKey唯一标识
@@ -167,6 +168,7 @@ public class DragTableServiceImpl implements IDragTableService {
         BeanUtils.copyProperties(dragTableVo, dragTable);
         //dragTable.setDtTableName(dtNickname);
         dragTable.setDtColumnName(JSON.toJSONString(dragTableVo.getDtColumnName()));
+        dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
         //add table_sql
         TableSql tableSql = new TableSql();
         tableSql.setTableSql(dragTableVo.getTableSql());
@@ -176,28 +178,30 @@ public class DragTableServiceImpl implements IDragTableService {
             case "MYSQL":
             case "DM":
                 for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
-                    SQL_START += SQL_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
-                    SQL_START += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
+                    SQL += SQL_START + SQL_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
+                    SQL += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
                 }
                 break;
             case "SQLSERVER":
                 for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
-                    SQL_START += SQLSERVER_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
-                    SQL_START += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
+                    SQL += SQL_START + SQLSERVER_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
+                    SQL += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
                 }
                 break;
             case "ORACLE":
-                SQL_START = "";
+//                SQL_START = "";
                 for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
-                    SQL_START += dragTableVo.getSearchFieldList().get(i);
-                    SQL_START += dragTableVo.getSearchFieldList().size() - 1 == i ? " " : "||";
+                    SQL += dragTableVo.getSearchFieldList().get(i);
+                    SQL += (dragTableVo.getSearchFieldList().size() - 1 == i ? " " : "||");
                 }
                 break;
         }
-        tableSql.setTableCondition(SQL_START + SQL_END);
+        tableSql.setTableCondition(SQL + SQL_END);
         tableSql.setTableAlias(dragTableVo.getDtTableName());
         tableSql.setTableExportField(JSON.toJSONString(dragTableVo.getTableExportField()));
         tableSql.setSqlKey(dragTableVo.getSqlKey());
+        tableSql.setOrderByColumn(dragTableVo.getOrderByColumn());
+        tableSql.setSortOrder(dragTableVo.getSortOrder());
         tableSqlMapper.insertTableSql(tableSql);
         //add drag_table_condition
         if (dragTableVo.getSearchFieldList().size() > 0) {
@@ -219,6 +223,7 @@ public class DragTableServiceImpl implements IDragTableService {
     @Transactional
     @Override
     public void updateDragTable(DragTableVo dragTableVo) {
+        String SQL = "";
         //update drag_table
         DragTable dragTable = new DragTable();
         BeanUtils.copyProperties(dragTableVo, dragTable);
@@ -234,28 +239,30 @@ public class DragTableServiceImpl implements IDragTableService {
             case "MYSQL":
             case "DM":
                 for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
-                    SQL_START += SQL_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
-                    SQL_START += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
+                    SQL += SQL_START + SQL_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
+                    SQL += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
                 }
                 break;
             case "SQLSERVER":
                 for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
-                    SQL_START += SQLSERVER_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
-                    SQL_START += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
+                    SQL += SQL_START + SQLSERVER_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
+                    SQL += dragTableVo.getSearchFieldList().size() - 1 == i ? ")" : ",\n";
                 }
                 break;
             case "ORACLE":
-                SQL_START = "";
+//                SQL_START = "";
                 for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
-                    SQL_START += dragTableVo.getSearchFieldList().get(i);
-                    SQL_START += dragTableVo.getSearchFieldList().size() - 1 == i ? " " : "||";
+                    SQL += dragTableVo.getSearchFieldList().get(i);
+                    SQL += (dragTableVo.getSearchFieldList().size() - 1 == i ? " " : "||");
                 }
                 break;
         }
-        tableSql.setTableCondition(SQL_START + SQL_END);
+        tableSql.setTableCondition(SQL + SQL_END);
         tableSql.setTableAlias(dragTableVo.getDtTableName());
         tableSql.setSqlKey(dragTableVo.getSqlKey());
         tableSql.setTableExportField(JSON.toJSONString(dragTableVo.getTableExportField()));
+        tableSql.setOrderByColumn(dragTableVo.getOrderByColumn());
+        tableSql.setSortOrder(dragTableVo.getSortOrder());
         tableSqlMapper.updateTableSqlBySqlKey(tableSql);
         //update drag_table_condition
         if (dragTableVo.getSearchFieldList().size() > 0) {

+ 8 - 12
ruoyi-system/src/main/java/com/ruoyi/system/test/ljj.java

@@ -22,20 +22,16 @@ public class ljj {
 
 
     public static void main(String[] args) {
+//        for (int i = 0; i < 10; i++) {
+//
+//            System.out.println(SQL_MIDDLE + "1");
+//        }
 
 
-
-        // 获取当前日期
-        LocalDate today = LocalDate.now();
-
-        // 获取当前星期几
-        int dayOfWeekNumber = today.getDayOfWeek().getValue();
-
-        // 根据星期几的数字值获取对应的星期几的枚举值
-        DayOfWeek dayOfWeek = DayOfWeek.of(dayOfWeekNumber);
-
-        // 输出当前日期和对应的星期几的枚举值
-        System.out.println("Today's date is " + today + " which is " + dayOfWeek);
+//        String a = "\u200B冀J1T697";
+//
+//        System.out.println(a.length());
+//        System.out.println("\u200B冀J1T697".equals("冀J1T697"));
 
 
 //        if (true) {

+ 51 - 27
ruoyi-system/src/main/resources/mapper/common/TableSqlMapper.xml

@@ -1,37 +1,52 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.TableSqlMapper">
-    
+
     <resultMap type="com.ruoyi.system.entity.TableSql" id="TableSqlResult">
-        <result property="tId"    column="t_id"    />
-        <result property="tableSql"    column="table_sql"    />
-        <result property="tableCondition"    column="table_condition"    />
-        <result property="tableAlias"    column="table_alias"    />
-        <result property="sqlKey"    column="sql_key"    />
+        <result property="tId" column="t_id"/>
+        <result property="tableSql" column="table_sql"/>
+        <result property="tableCondition" column="table_condition"/>
+        <result property="tableAlias" column="table_alias"/>
+        <result property="sqlKey" column="sql_key"/>
         <result property="tableExportField" column="table_export_field"/>
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="orderByColumn" column="order_by_column"/>
+        <result property="sortOrder" column="is_asc"/>
     </resultMap>
 
     <sql id="selectTableSqlVo">
-        select t_id, table_sql, table_condition, table_alias, sql_key, table_export_field, create_by, create_time, update_by, update_time, del_flag from table_sql
+        select t_id,
+               table_sql,
+               table_condition,
+               table_alias,
+               sql_key,
+               table_export_field,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               del_flag,
+               order_by_column,
+               is_asc
+        from table_sql
     </sql>
 
     <select id="selectTableSqlList" parameterType="com.ruoyi.system.entity.TableSql" resultMap="TableSqlResult">
         <include refid="selectTableSqlVo"/>
-        <where>  
-            <if test="tableSql != null  and tableSql != ''"> and table_sql = #{tableSql}</if>
-            <if test="tableCondition != null  and tableCondition != ''"> and table_condition = #{tableCondition}</if>
-            <if test="tableAlias != null  and tableAlias != ''"> and table_alias = #{tableAlias}</if>
-            <if test="sqlKey != null  and sqlKey != ''"> and sql_key = #{sqlKey}</if>
+        <where>
+            <if test="tableSql != null  and tableSql != ''">and table_sql = #{tableSql}</if>
+            <if test="tableCondition != null  and tableCondition != ''">and table_condition = #{tableCondition}</if>
+            <if test="tableAlias != null  and tableAlias != ''">and table_alias = #{tableAlias}</if>
+            <if test="sqlKey != null  and sqlKey != ''">and sql_key = #{sqlKey}</if>
         </where>
     </select>
-    
+
     <select id="selectTableSqlByTId" parameterType="Long" resultMap="TableSqlResult">
         <include refid="selectTableSqlVo"/>
         where t_id = #{tId}
@@ -43,9 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-
-
-    <insert id="insertTableSql" parameterType="com.ruoyi.system.entity.TableSql" useGeneratedKeys="true" keyProperty="tId">
+    <insert id="insertTableSql" parameterType="com.ruoyi.system.entity.TableSql" useGeneratedKeys="true"
+            keyProperty="tId">
         insert into table_sql
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="tableSql != null">table_sql,</if>
@@ -58,7 +72,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="delFlag != null">del_flag,</if>
-         </trim>
+            <if test="orderByColumn != null">order_by_column,</if>
+            <if test="sortOrder != null">is_asc,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="tableSql != null">#{tableSql},</if>
             <if test="tableCondition != null">#{tableCondition},</if>
@@ -70,7 +86,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="delFlag != null">#{delFlag},</if>
-         </trim>
+            <if test="orderByColumn != null">#{orderByColumn},</if>
+            <if test="sortOrder != null">#{sortOrder},</if>
+        </trim>
     </insert>
 
     <update id="updateTableSql" parameterType="com.ruoyi.system.entity.TableSql">
@@ -86,16 +104,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="orderByColumn != null">order_by_column = #{orderByColumn},</if>
+            <if test="sortOrder != null">is_asc = #{sortOrder},</if>
         </trim>
         where t_id = #{tId}
     </update>
 
     <delete id="deleteTableSqlByTId" parameterType="Long">
-        delete from table_sql where t_id = #{tId}
+        delete
+        from table_sql
+        where t_id = #{tId}
     </delete>
 
     <delete id="deleteTableSqlByTIds" parameterType="String">
-        delete from table_sql where t_id in 
+        delete from table_sql where t_id in
         <foreach item="tId" collection="array" open="(" separator="," close=")">
             #{tId}
         </foreach>
@@ -113,6 +135,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="orderByColumn != null">order_by_column = #{orderByColumn},</if>
+            <if test="sortOrder != null">is_asc = #{sortOrder},</if>
         </trim>
         where sql_key = #{sqlKey}
     </update>

+ 6 - 1
ruoyi-system/src/main/resources/mapper/dragmapper/DragTableMapper.xml

@@ -24,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isSelection"   column="is_selection"/>
         <result property="echoData"      column="echo_data"/>
         <result property="menuId" column="menu_id"/>
+        <result property="primaryKey" column="primary_key"/>
     </resultMap>
 
     <resultMap type="com.ruoyi.system.entity.vo.DragTableVo" id="DragTableVoResult">
@@ -40,10 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="tableExportField" column="table_export_field"/>
         <result property="echoData"      column="echo_data"/>
         <result property="menuId" column="menu_id"/>
+        <result property="primaryKey" column="primary_key"/>
     </resultMap>
 
     <sql id="selectDragTableVo">
-        select t_id, dt_name, dt_nickname, table_key, sql_key, dt_table_name,time_format, dt_notes, dt_column_name, spare, spare1, del_flag, create_by, create_time, update_by, update_time, is_selection,echo_data,menu_id from drag_table
+        select t_id, dt_name, dt_nickname, table_key, sql_key, dt_table_name,time_format, dt_notes, dt_column_name, spare, spare1, del_flag, create_by, create_time, update_by, update_time, is_selection,echo_data,menu_id,primary_key from drag_table
     </sql>
 
     <select id="selectDragTableList" parameterType="com.ruoyi.system.entity.DragTable" resultMap="DragTableResult">
@@ -84,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSelection != null">is_selection,</if>
             <if test="echoData != null">echo_data,</if>
             <if test="menuId != null">menu_id,</if>
+            <if test="primaryKey != null">primary_key,</if>
             create_time
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -102,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSelection != null">#{isSelection},</if>
             <if test="echoData != null">#{echoData},</if>
             <if test="menuId != null">#{menuId},</if>
+            <if test="primaryKey != null">#{primaryKey},</if>
             now()
          </trim>
     </insert>
@@ -127,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSelection != null">is_selection = #{isSelection},</if>
             <if test="echoData != null">echo_data = #{echoData},</if>
             <if test="menuId != null">menu_id = #{menuId},</if>
+            <if test="primaryKey != null">primary_key = #{primaryKey},</if>
         </trim>
         where t_id = #{tId}
     </update>