Эх сурвалжийг харах

增加查询分页,以及排序等

韩帛霖 1 жил өмнө
parent
commit
cdb80307f6

+ 15 - 0
ruoyi-admin/pom.xml

@@ -54,6 +54,21 @@
             <artifactId>lombok</artifactId>
         </dependency>
 
+        <!-- sqlserver 驱动 -->
+        <dependency>
+            <groupId>com.microsoft.sqlserver</groupId>
+            <artifactId>mssql-jdbc</artifactId>
+            <version>10.2.3.jre8</version>
+        </dependency>
+
+        <!-- 达梦驱动 -->
+        <dependency>
+            <groupId>com.dm</groupId>
+            <artifactId>DmJdbcDriver18</artifactId>
+            <version>1.8</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/DmJdbcDriver18.jar</systemPath>
+        </dependency>
 
     </dependencies>
 

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

@@ -3,6 +3,8 @@ package com.ruoyi.web.controller.dragForm;
 import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.system.entity.CommonEntity;
 import com.ruoyi.system.service.ICommonService;
 import org.springframework.web.bind.annotation.*;
 
@@ -20,16 +22,17 @@ public class CommonController extends BaseController {
     /**
      * 查询
      */
-    @PostMapping("/selectList")
-    public AjaxResult selectList(@RequestBody Map<String,Object> map){
-        return AjaxResult.success(commonService.selectList(map));
+    @GetMapping("/selectList")
+    public TableDataInfo selectList( CommonEntity commonEntity) {
+        startPage();
+        return getDataTable(commonService.selectList(commonEntity.getFormMap()));
     }
 
     /**
      * 批量新增
      */
     @PostMapping("/batchInsert")
-    public AjaxResult batchInsert(@RequestBody Map<String,Object> map){
+    public AjaxResult batchInsert(@RequestBody Map<String, Object> map) {
         return toAjax(commonService.batchInsert(map));
     }
 
@@ -37,7 +40,7 @@ public class CommonController extends BaseController {
      * 修改
      */
     @PutMapping("/edit")
-    public AjaxResult edit(@RequestBody Map<String,Object> map){
+    public AjaxResult edit(@RequestBody Map<String, Object> map) {
         return toAjax(commonService.edit(map));
     }
 
@@ -45,8 +48,14 @@ public class CommonController extends BaseController {
      * 批量删除
      */
     @DeleteMapping("/batchDelete")
-    public AjaxResult batchDelete(@RequestBody Map<String,Object> map){
+    public AjaxResult batchDelete(@RequestBody Map<String, Object> map) {
         return toAjax(commonService.batchDelete(map));
     }
 
+    @GetMapping("/getTableList")
+    public AjaxResult queryTableList(String sqlkey) {
+
+        return AjaxResult.success();
+    }
+
 }

+ 107 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/TableSqlController.java

@@ -0,0 +1,107 @@
+package com.ruoyi.web.controller.dragForm;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.entity.TableSql;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+
+import com.ruoyi.system.service.ITableSqlService;
+
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * table 联合查询sql存储Controller
+ * 
+ * @author ruoyi
+ * @date 2023-07-19
+ */
+@RestController
+@RequestMapping("/system/sql")
+public class TableSqlController extends BaseController
+{
+    @Autowired
+    private ITableSqlService tableSqlService;
+
+    /**
+     * 查询table 联合查询sql存储列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:sql:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TableSql tableSql)
+    {
+        startPage();
+        List<TableSql> list = tableSqlService.selectTableSqlList(tableSql);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出table 联合查询sql存储列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:sql:export')")
+    @Log(title = "table 联合查询sql存储", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TableSql tableSql)
+    {
+        List<TableSql> list = tableSqlService.selectTableSqlList(tableSql);
+        ExcelUtil<TableSql> util = new ExcelUtil<TableSql>(TableSql.class);
+        util.exportExcel(response, list, "table 联合查询sql存储数据");
+    }
+
+    /**
+     * 获取table 联合查询sql存储详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:sql:query')")
+    @GetMapping(value = "/{tId}")
+    public AjaxResult getInfo(@PathVariable("tId") Long tId)
+    {
+        return success(tableSqlService.selectTableSqlByTId(tId));
+    }
+
+    /**
+     * 新增table 联合查询sql存储
+     */
+    @PreAuthorize("@ss.hasPermi('system:sql:add')")
+    @Log(title = "table 联合查询sql存储", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TableSql tableSql)
+    {
+        return toAjax(tableSqlService.insertTableSql(tableSql));
+    }
+
+    /**
+     * 修改table 联合查询sql存储
+     */
+    @PreAuthorize("@ss.hasPermi('system:sql:edit')")
+    @Log(title = "table 联合查询sql存储", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TableSql tableSql)
+    {
+        return toAjax(tableSqlService.updateTableSql(tableSql));
+    }
+
+    /**
+     * 删除table 联合查询sql存储
+     */
+    @PreAuthorize("@ss.hasPermi('system:sql:remove')")
+    @Log(title = "table 联合查询sql存储", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{tIds}")
+    public AjaxResult remove(@PathVariable Long[] tIds)
+    {
+        return toAjax(tableSqlService.deleteTableSqlByTIds(tIds));
+    }
+}

BIN
ruoyi-admin/src/main/resources/lib/DmJdbcDriver18.jar


+ 40 - 0
ruoyi-system/src/main/java/com/ruoyi/system/entity/CommonEntity.java

@@ -0,0 +1,40 @@
+package com.ruoyi.system.entity;
+
+import com.ruoyi.common.core.domain.BaseEntity;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author hanzihang
+ * @date 2023/7/19 4:05 PM
+ */
+public class CommonEntity extends BaseEntity {
+
+    /**
+     * map
+     */
+    private Map<String, Object> formMap;
+
+    public CommonEntity() {
+    }
+
+    @Override
+    public String toString() {
+        return "CommonEntity{" +
+                "formMap=" + formMap +
+                '}';
+    }
+
+    public Map<String, Object> getFormMap() {
+        return formMap;
+    }
+
+    public void setFormMap(Map<String, Object> formMap) {
+        this.formMap = formMap;
+    }
+
+    public CommonEntity(Map<String, Object> formMap) {
+        this.formMap = formMap;
+    }
+}

+ 111 - 0
ruoyi-system/src/main/java/com/ruoyi/system/entity/TableSql.java

@@ -0,0 +1,111 @@
+package com.ruoyi.system.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * table 联合查询sql存储对象 table_sql
+ * 
+ * @author ruoyi
+ * @date 2023-07-19
+ */
+public class TableSql extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long tId;
+
+    /** 表查询语句
+ */
+    @Excel(name = "表查询语句")
+    private String tableSql;
+
+    /** 表查询条件 */
+    @Excel(name = "表查询条件")
+    private String tableCondition;
+
+    /** 表别名 */
+    @Excel(name = "表别名")
+    private String tableAlias;
+
+    /** sql编号,绑定tableList */
+    @Excel(name = "sql编号,绑定tableList")
+    private String sqlKey;
+
+    /** 逻辑删除 */
+    private String delFlag;
+
+    public void settId(Long tId) 
+    {
+        this.tId = tId;
+    }
+
+    public Long gettId() 
+    {
+        return tId;
+    }
+    public void setTableSql(String tableSql) 
+    {
+        this.tableSql = tableSql;
+    }
+
+    public String getTableSql() 
+    {
+        return tableSql;
+    }
+    public void setTableCondition(String tableCondition) 
+    {
+        this.tableCondition = tableCondition;
+    }
+
+    public String getTableCondition() 
+    {
+        return tableCondition;
+    }
+    public void setTableAlias(String tableAlias) 
+    {
+        this.tableAlias = tableAlias;
+    }
+
+    public String getTableAlias() 
+    {
+        return tableAlias;
+    }
+    public void setSqlKey(String sqlKey) 
+    {
+        this.sqlKey = sqlKey;
+    }
+
+    public String getSqlKey() 
+    {
+        return sqlKey;
+    }
+    public void setDelFlag(String delFlag) 
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag() 
+    {
+        return delFlag;
+    }
+
+    @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())
+            .toString();
+    }
+}

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CommonMapper.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.mapper;
 
+import com.ruoyi.system.entity.CommonEntity;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -13,7 +14,7 @@ public interface CommonMapper {
     /**
      * 查询列表
      */
-    List<Map<String,Object>> selectList(@Param("tableName") String tableName, @Param("conditions")Map<String,Object> conditions);
+    List<CommonEntity> selectList(@Param("tableName") String tableName, @Param("conditions")Map<String,Object> conditions);
 
     /**
      * 批量新增

+ 70 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TableSqlMapper.java

@@ -0,0 +1,70 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.entity.TableSql;
+
+import java.util.List;
+
+
+/**
+ * table 联合查询sql存储Mapper接口
+ *
+ * @author ruoyi
+ * @date 2023-07-19
+ */
+public interface TableSqlMapper {
+    /**
+     * 查询table 联合查询sql存储
+     *
+     * @param tId table 联合查询sql存储主键
+     * @return table 联合查询sql存储
+     */
+    public TableSql selectTableSqlByTId(Long tId);
+
+    /**
+     * 查询table 联合查询sql存储
+     *
+     * @param SQLKEY 绑定table唯一标识
+     * @return table 联合查询sql存储
+     */
+    public TableSql selectTableSqlByTSqlKey(String SQLKEY);
+
+    /**
+     * 查询table 联合查询sql存储列表
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return table 联合查询sql存储集合
+     */
+    public List<TableSql> selectTableSqlList(TableSql tableSql);
+
+    /**
+     * 新增table 联合查询sql存储
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return 结果
+     */
+    public int insertTableSql(TableSql tableSql);
+
+    /**
+     * 修改table 联合查询sql存储
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return 结果
+     */
+    public int updateTableSql(TableSql tableSql);
+
+    /**
+     * 删除table 联合查询sql存储
+     *
+     * @param tId table 联合查询sql存储主键
+     * @return 结果
+     */
+    public int deleteTableSqlByTId(Long tId);
+
+    /**
+     * 批量删除table 联合查询sql存储
+     *
+     * @param tIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTableSqlByTIds(Long[] tIds);
+}

+ 11 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/ICommonService.java

@@ -1,6 +1,6 @@
 package com.ruoyi.system.service;
 
-import org.apache.ibatis.annotations.Param;
+import com.ruoyi.system.entity.CommonEntity;
 
 import java.util.List;
 import java.util.Map;
@@ -11,20 +11,26 @@ public interface ICommonService {
     /**
      * 单表查询列表
      */
-    List<Map<String,Object>> selectList(Map<String,Object> map);
+    List<CommonEntity> selectList(Map<String, Object> map);
 
     /**
      * 批量新增
      */
-    int batchInsert(Map<String,Object> map);
+    int batchInsert(Map<String, Object> map);
 
     /**
      * 修改
      */
-    int edit(Map<String,Object> map);
+    int edit(Map<String, Object> map);
 
     /**
      * 批量删除
      */
-    int batchDelete(Map<String,Object> map);
+    int batchDelete(Map<String, Object> map);
+
+    /**
+     * 根据sqlkey 执行sql并返回结果
+     */
+    List<Map<String, Object>> queryTableList(Map<String, Object> map);
+
 }

+ 70 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ITableSqlService.java

@@ -0,0 +1,70 @@
+package com.ruoyi.system.service;
+
+
+import com.ruoyi.system.entity.TableSql;
+
+import java.util.List;
+
+/**
+ * table 联合查询sql存储Service接口
+ *
+ * @author ruoyi
+ * @date 2023-07-19
+ */
+public interface ITableSqlService {
+    /**
+     * 查询table 联合查询sql存储
+     *
+     * @param tId table 联合查询sql存储主键
+     * @return table 联合查询sql存储
+     */
+    public TableSql selectTableSqlByTId(Long tId);
+
+    /**
+     * 查询table 联合查询sql存储
+     *
+     * @param SQLKEY 绑定table唯一标识
+     * @return table 联合查询sql存储
+     */
+    public TableSql selectTableSqlByTSqlKey(String SQLKEY);
+
+    /**
+     * 查询table 联合查询sql存储列表
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return table 联合查询sql存储集合
+     */
+    public List<TableSql> selectTableSqlList(TableSql tableSql);
+
+    /**
+     * 新增table 联合查询sql存储
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return 结果
+     */
+    public int insertTableSql(TableSql tableSql);
+
+    /**
+     * 修改table 联合查询sql存储
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return 结果
+     */
+    public int updateTableSql(TableSql tableSql);
+
+    /**
+     * 批量删除table 联合查询sql存储
+     *
+     * @param tIds 需要删除的table 联合查询sql存储主键集合
+     * @return 结果
+     */
+    public int deleteTableSqlByTIds(Long[] tIds);
+
+    /**
+     * 删除table 联合查询sql存储信息
+     *
+     * @param tId table 联合查询sql存储主键
+     * @return 结果
+     */
+    public int deleteTableSqlByTId(Long tId);
+}

+ 38 - 16
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommonServiceImpl.java

@@ -3,8 +3,12 @@ package com.ruoyi.system.service.impl;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.utils.CollectionUtil;
+import com.ruoyi.system.entity.CommonEntity;
+import com.ruoyi.system.entity.TableSql;
 import com.ruoyi.system.mapper.CommonMapper;
 import com.ruoyi.system.service.ICommonService;
+import com.ruoyi.system.service.ITableSqlService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -17,44 +21,62 @@ public class CommonServiceImpl implements ICommonService {
 
     @Resource
     private CommonMapper commonMapper;
+    @Resource
+    private ITableSqlService iTableSqlService;
 
     @Override
-    public List<Map<String, Object>> selectList(Map<String,Object> map) {
-        String tableName = (String)map.get("tableName");
-        Map<String,Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
-        return commonMapper.selectList(tableName,conditions);
+    public List<CommonEntity> selectList(Map<String, Object> map) {
+        String tableName = (String) map.get("tableName");
+        Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
+        return commonMapper.selectList(tableName, conditions);
     }
 
     @Override
     public int batchInsert(Map<String, Object> map) {
-        String tableName = (String)map.get("tableName");
+        String tableName = (String) map.get("tableName");
         List<Object> list = (List<Object>) map.get("field");
         List<Map<String, Object>> mapList = new ArrayList<>();
         for (Object obj : list) {
-            Map<String,Object> map1 = JSONObject.parseObject(JSON.toJSONString(obj));
+            Map<String, Object> map1 = JSONObject.parseObject(JSON.toJSONString(obj));
             mapList.add(map1);
         }
         Set<String> fieldNames = new LinkedHashSet<>();
-        mapList.stream().forEach(map1 ->{
-            map1.forEach((key,value)->{
+        mapList.stream().forEach(map1 -> {
+            map1.forEach((key, value) -> {
                 fieldNames.add(key);
             });
         });
-        return commonMapper.batchInsert(fieldNames,tableName,mapList);
+        return commonMapper.batchInsert(fieldNames, tableName, mapList);
     }
 
     @Override
     public int edit(Map<String, Object> map) {
-        String tableName = (String)map.get("tableName");
-        Map<String,Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
-        Map<String,Object> fields = JSONObject.parseObject(JSON.toJSONString(map.get("field")));
-        return commonMapper.edit(fields,tableName,conditions);
+        String tableName = (String) map.get("tableName");
+        Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
+        Map<String, Object> fields = JSONObject.parseObject(JSON.toJSONString(map.get("field")));
+        return commonMapper.edit(fields, tableName, conditions);
     }
 
     @Override
     public int batchDelete(Map<String, Object> map) {
-        String tableName = (String)map.get("tableName");
-        Map<String,Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
-        return commonMapper.batchDelete(tableName,conditions);
+        String tableName = (String) map.get("tableName");
+        Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
+        return commonMapper.batchDelete(tableName, conditions);
+    }
+
+    @Override
+    public List<Map<String, Object>> queryTableList(Map<String, Object> map) {
+        // 根据sqlkey查询得到当前表单对应的sql
+        TableSql tableSql = iTableSqlService.selectTableSqlByTSqlKey(map.get("SQLKEY").toString());
+        Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(map.get("condition")));
+
+
+        StringBuilder endSQL = new StringBuilder();
+        endSQL.append("" + tableSql.getTableSql() + "where 1=1");
+
+        conditions.forEach((key, val) -> {
+            endSQL.append(" and " + tableSql.getTableAlias() + " " + key + " = " + val);
+        });
+        return null;
     }
 }

+ 95 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TableSqlServiceImpl.java

@@ -0,0 +1,95 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.entity.TableSql;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.TableSqlMapper;
+import com.ruoyi.system.service.ITableSqlService;
+
+/**
+ * table 联合查询sql存储Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-07-19
+ */
+@Service
+public class TableSqlServiceImpl implements ITableSqlService {
+    @Autowired
+    private TableSqlMapper tableSqlMapper;
+
+    /**
+     * 查询table 联合查询sql存储
+     *
+     * @param tId table 联合查询sql存储主键
+     * @return table 联合查询sql存储
+     */
+    @Override
+    public TableSql selectTableSqlByTId(Long tId) {
+        return tableSqlMapper.selectTableSqlByTId(tId);
+    }
+
+    @Override
+    public TableSql selectTableSqlByTSqlKey(String SQLKEY) {
+        return selectTableSqlByTSqlKey(SQLKEY);
+    }
+
+    /**
+     * 查询table 联合查询sql存储列表
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return table 联合查询sql存储
+     */
+    @Override
+    public List<TableSql> selectTableSqlList(TableSql tableSql) {
+        return tableSqlMapper.selectTableSqlList(tableSql);
+    }
+
+    /**
+     * 新增table 联合查询sql存储
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return 结果
+     */
+    @Override
+    public int insertTableSql(TableSql tableSql) {
+        tableSql.setCreateTime(DateUtils.getNowDate());
+        return tableSqlMapper.insertTableSql(tableSql);
+    }
+
+    /**
+     * 修改table 联合查询sql存储
+     *
+     * @param tableSql table 联合查询sql存储
+     * @return 结果
+     */
+    @Override
+    public int updateTableSql(TableSql tableSql) {
+        tableSql.setUpdateTime(DateUtils.getNowDate());
+        return tableSqlMapper.updateTableSql(tableSql);
+    }
+
+    /**
+     * 批量删除table 联合查询sql存储
+     *
+     * @param tIds 需要删除的table 联合查询sql存储主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTableSqlByTIds(Long[] tIds) {
+        return tableSqlMapper.deleteTableSqlByTIds(tIds);
+    }
+
+    /**
+     * 删除table 联合查询sql存储信息
+     *
+     * @param tId table 联合查询sql存储主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTableSqlByTId(Long tId) {
+        return tableSqlMapper.deleteTableSqlByTId(tId);
+    }
+}

+ 14 - 8
ruoyi-system/src/main/resources/mapper/common/CommonMapper.xml

@@ -4,7 +4,13 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.CommonMapper">
 
-    <select id="selectList" resultType="map">
+
+    <resultMap id="testMap" type="map" autoMapping="true">
+        <collection property="formMap" ofType="com.ruoyi.system.entity.CommonEntity" autoMapping="true" javaType="map">
+        </collection>
+    </resultMap>
+
+    <select id="selectList" resultMap="testMap">
         select * from ${tableName}
         <where>
             <if test="conditions != null">
@@ -17,9 +23,9 @@
 
     <insert id="batchInsert">
         insert into ${tableName}
-         <foreach collection="fieldNames" item="fieldName" open="(" close=")" separator=",">
-             ${fieldName}
-         </foreach>
+        <foreach collection="fieldNames" item="fieldName" open="(" close=")" separator=",">
+            ${fieldName}
+        </foreach>
         values
         <foreach collection="fieldValues" item="map" separator=",">
             <foreach collection="map" item="value" index="key" separator="," open="(" close=")">
@@ -33,11 +39,11 @@
         <where>
             <if test="conditions != null">
                 <foreach collection="conditions" item="value" index="key" separator="and">
-                ${key} in
-                <foreach collection="value" item="v" open="(" close=")" separator=",">
-                    #{v}
+                    ${key} in
+                    <foreach collection="value" item="v" open="(" close=")" separator=",">
+                        #{v}
+                    </foreach>
                 </foreach>
-            </foreach>
             </if>
         </where>
     </delete>

+ 99 - 0
ruoyi-system/src/main/resources/mapper/common/TableSqlMapper.xml

@@ -0,0 +1,99 @@
+<?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">
+<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="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"    />
+    </resultMap>
+
+    <sql id="selectTableSqlVo">
+        select t_id, table_sql, table_condition, table_alias, sql_key, create_by, create_time, update_by, update_time, del_flag 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>
+    </select>
+    
+    <select id="selectTableSqlByTId" parameterType="Long" resultMap="TableSqlResult">
+        <include refid="selectTableSqlVo"/>
+        where t_id = #{tId}
+    </select>
+
+    <select id="selectTableSqlByTSqlKey" parameterType="String" resultMap="TableSqlResult">
+        <include refid="selectTableSqlVo"/>
+        where sql_key = #{SQLKEY}
+    </select>
+
+
+
+
+    <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>
+            <if test="tableCondition != null">table_condition,</if>
+            <if test="tableAlias != null">table_alias,</if>
+            <if test="sqlKey != null">sql_key,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="delFlag != null">del_flag,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="tableSql != null">#{tableSql},</if>
+            <if test="tableCondition != null">#{tableCondition},</if>
+            <if test="tableAlias != null">#{tableAlias},</if>
+            <if test="sqlKey != null">#{sqlKey},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTableSql" parameterType="com.ruoyi.system.entity.TableSql">
+        update table_sql
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="tableSql != null">table_sql = #{tableSql},</if>
+            <if test="tableCondition != null">table_condition = #{tableCondition},</if>
+            <if test="tableAlias != null">table_alias = #{tableAlias},</if>
+            <if test="sqlKey != null">sql_key = #{sqlKey},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+        </trim>
+        where t_id = #{tId}
+    </update>
+
+    <delete id="deleteTableSqlByTId" parameterType="Long">
+        delete from table_sql where t_id = #{tId}
+    </delete>
+
+    <delete id="deleteTableSqlByTIds" parameterType="String">
+        delete from table_sql where t_id in 
+        <foreach item="tId" collection="array" open="(" separator="," close=")">
+            #{tId}
+        </foreach>
+    </delete>
+</mapper>