Jelajahi Sumber

修改代码生成模版

gaoxiong 2 tahun lalu
induk
melakukan
b7df6180ed

+ 12 - 10
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/controller/GenController.java

@@ -25,7 +25,7 @@ import java.util.Map;
 
 /**
  * 代码生成 操作处理
- * 
+ *
  * @author xunmei
  */
 @RequestMapping("/gen")
@@ -41,18 +41,17 @@ public class GenController extends BaseController
     /**
      * 查询代码生成列表
      */
-/*
     @RequiresPermissions("tool:gen:list")
     @GetMapping("/list")
     public TableDataInfo genList(GenTable genTable)
     {
-        */
-/*startPage();
         List<GenTable> list = genTableService.selectGenTableList(genTable);
-        return getDataTable(list);*//*
+        TableDataInfo info = new TableDataInfo();
+        info.setRows(list);
+        info.setTotal(list.size());
+        return info;
 
     }
-*/
 
     /**
      * 修改代码生成业务
@@ -74,14 +73,17 @@ public class GenController extends BaseController
     /**
      * 查询数据库列表
      */
- /*   @RequiresPermissions("tool:gen:list")
+    @RequiresPermissions("tool:gen:list")
     @GetMapping("/db/list")
     public TableDataInfo dataList(GenTable genTable)
     {
-        startPage();
         List<GenTable> list = genTableService.selectDbTableList(genTable);
-        return getDataTable(list);
-    }*/
+        TableDataInfo info = new TableDataInfo();
+        info.setRows(list);
+        info.setTotal(list.size());
+        info.setCode(200);
+        return info;
+    }
 
     /**
      * 查询数据表字段列表

+ 23 - 21
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/mapper/GenTableMapper.java

@@ -1,84 +1,86 @@
 package com.xunmei.gen.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xunmei.gen.domain.GenTable;
+import com.xunmei.system.api.domain.SysArea;
 
 import java.util.List;
 
 /**
  * 业务 数据层
- * 
+ *
  * @author xunmei
  */
-public interface GenTableMapper
+public interface GenTableMapper extends BaseMapper<GenTable>
 {
     /**
      * 查询业务列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 业务集合
      */
-    public List<GenTable> selectGenTableList(GenTable genTable);
+    List<GenTable> selectGenTableList(GenTable genTable);
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 数据库表集合
      */
-    public List<GenTable> selectDbTableList(GenTable genTable);
+    List<GenTable> selectDbTableList(GenTable genTable);
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param tableNames 表名称组
      * @return 数据库表集合
      */
-    public List<GenTable> selectDbTableListByNames(String[] tableNames);
+    List<GenTable> selectDbTableListByNames(String[] tableNames);
 
     /**
      * 查询所有表信息
-     * 
+     *
      * @return 表信息集合
      */
-    public List<GenTable> selectGenTableAll();
+    List<GenTable> selectGenTableAll();
 
     /**
      * 查询表ID业务信息
-     * 
+     *
      * @param id 业务ID
      * @return 业务信息
      */
-    public GenTable selectGenTableById(Long id);
+    GenTable selectGenTableById(Long id);
 
     /**
      * 查询表名称业务信息
-     * 
+     *
      * @param tableName 表名称
      * @return 业务信息
      */
-    public GenTable selectGenTableByName(String tableName);
+    GenTable selectGenTableByName(String tableName);
 
     /**
      * 新增业务
-     * 
+     *
      * @param genTable 业务信息
      * @return 结果
      */
-    public int insertGenTable(GenTable genTable);
+    int insertGenTable(GenTable genTable);
 
     /**
      * 修改业务
-     * 
+     *
      * @param genTable 业务信息
      * @return 结果
      */
-    public int updateGenTable(GenTable genTable);
+    int updateGenTable(GenTable genTable);
 
     /**
      * 批量删除业务
-     * 
+     *
      * @param ids 需要删除的数据ID
      * @return 结果
      */
-    public int deleteGenTableByIds(Long[] ids);
-}
+    int deleteGenTableByIds(Long[] ids);
+}

+ 21 - 20
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/service/GenTableServiceImpl.java

@@ -2,6 +2,7 @@ package com.xunmei.gen.service;
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.constant.GenConstants;
 import com.xunmei.common.core.exception.ServiceException;
@@ -40,11 +41,11 @@ import java.util.zip.ZipOutputStream;
 
 /**
  * 业务 服务层实现
- * 
+ *
  * @author xunmei
  */
 @Service
-public class GenTableServiceImpl implements IGenTableService
+public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> implements IGenTableService
 {
     private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
 
@@ -56,7 +57,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询业务信息
-     * 
+     *
      * @param id 业务ID
      * @return 业务信息
      */
@@ -70,7 +71,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询业务列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 业务集合
      */
@@ -82,7 +83,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 数据库表集合
      */
@@ -94,7 +95,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param tableNames 表名称组
      * @return 数据库表集合
      */
@@ -106,7 +107,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询所有表信息
-     * 
+     *
      * @return 表信息集合
      */
     @Override
@@ -117,7 +118,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 修改业务
-     * 
+     *
      * @param genTable 业务信息
      * @return 结果
      */
@@ -139,7 +140,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 删除业务对象
-     * 
+     *
      * @param tableIds 需要删除的数据ID
      * @return 结果
      */
@@ -153,7 +154,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 导入表结构
-     * 
+     *
      * @param tableList 导入表列表
      */
     @Override
@@ -188,7 +189,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 预览代码
-     * 
+     *
      * @param tableId 表编号
      * @return 预览数据列表
      */
@@ -221,7 +222,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 生成代码(下载方式)
-     * 
+     *
      * @param tableName 表名称
      * @return 数据
      */
@@ -237,7 +238,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 生成代码(自定义路径)
-     * 
+     *
      * @param tableName 表名称
      */
     @Override
@@ -279,7 +280,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 同步数据库
-     * 
+     *
      * @param tableName 表名称
      */
     @Override
@@ -334,7 +335,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 批量生成代码(下载方式)
-     * 
+     *
      * @param tableNames 表数组
      * @return 数据
      */
@@ -393,7 +394,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 修改保存参数校验
-     * 
+     *
      * @param genTable 业务信息
      */
     @Override
@@ -431,7 +432,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 设置主键列信息
-     * 
+     *
      * @param table 业务表信息
      */
     public void setPkColumn(GenTable table)
@@ -467,7 +468,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 设置主子表信息
-     * 
+     *
      * @param table 业务表信息
      */
     public void setSubTable(GenTable table)
@@ -481,7 +482,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 设置代码生成其他选项值
-     * 
+     *
      * @param genTable 设置后的生成对象
      */
     public void setTableFromOptions(GenTable genTable)
@@ -505,7 +506,7 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 获取代码生成地址
-     * 
+     *
      * @param table 业务表信息
      * @param template 模板文件路径
      * @return 生成地址

+ 32 - 30
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/service/IGenTableService.java

@@ -1,122 +1,124 @@
 package com.xunmei.gen.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.gen.domain.GenTable;
+import com.xunmei.system.api.domain.SysArea;
 
 import java.util.List;
 import java.util.Map;
 
 /**
  * 业务 服务层
- * 
+ *
  * @author xunmei
  */
-public interface IGenTableService
+public interface IGenTableService extends IService<GenTable>
 {
     /**
      * 查询业务列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 业务集合
      */
-    public List<GenTable> selectGenTableList(GenTable genTable);
+    List<GenTable> selectGenTableList(GenTable genTable);
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 数据库表集合
      */
-    public List<GenTable> selectDbTableList(GenTable genTable);
+    List<GenTable> selectDbTableList(GenTable genTable);
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param tableNames 表名称组
      * @return 数据库表集合
      */
-    public List<GenTable> selectDbTableListByNames(String[] tableNames);
+    List<GenTable> selectDbTableListByNames(String[] tableNames);
 
     /**
      * 查询所有表信息
-     * 
+     *
      * @return 表信息集合
      */
-    public List<GenTable> selectGenTableAll();
+    List<GenTable> selectGenTableAll();
 
     /**
      * 查询业务信息
-     * 
+     *
      * @param id 业务ID
      * @return 业务信息
      */
-    public GenTable selectGenTableById(Long id);
+    GenTable selectGenTableById(Long id);
 
     /**
      * 修改业务
-     * 
+     *
      * @param genTable 业务信息
      * @return 结果
      */
-    public void updateGenTable(GenTable genTable);
+    void updateGenTable(GenTable genTable);
 
     /**
      * 删除业务信息
-     * 
+     *
      * @param tableIds 需要删除的表数据ID
      * @return 结果
      */
-    public void deleteGenTableByIds(Long[] tableIds);
+    void deleteGenTableByIds(Long[] tableIds);
 
     /**
      * 导入表结构
-     * 
+     *
      * @param tableList 导入表列表
      */
-    public void importGenTable(List<GenTable> tableList);
+    void importGenTable(List<GenTable> tableList);
 
     /**
      * 预览代码
-     * 
+     *
      * @param tableId 表编号
      * @return 预览数据列表
      */
-    public Map<String, String> previewCode(Long tableId);
+    Map<String, String> previewCode(Long tableId);
 
     /**
      * 生成代码(下载方式)
-     * 
+     *
      * @param tableName 表名称
      * @return 数据
      */
-    public byte[] downloadCode(String tableName);
+    byte[] downloadCode(String tableName);
 
     /**
      * 生成代码(自定义路径)
-     * 
+     *
      * @param tableName 表名称
      * @return 数据
      */
-    public void generatorCode(String tableName);
+    void generatorCode(String tableName);
 
     /**
      * 同步数据库
-     * 
+     *
      * @param tableName 表名称
      */
-    public void synchDb(String tableName);
+    void synchDb(String tableName);
 
     /**
      * 批量生成代码(下载方式)
-     * 
+     *
      * @param tableNames 表数组
      * @return 数据
      */
-    public byte[] downloadCode(String[] tableNames);
+    byte[] downloadCode(String[] tableNames);
 
     /**
      * 修改保存参数校验
-     * 
+     *
      * @param genTable 业务信息
      */
-    public void validateEdit(GenTable genTable);
+    void validateEdit(GenTable genTable);
 }

+ 1 - 12
soc-modules/soc-modules-gen/src/main/resources/vm/java/controller.java.vm

@@ -60,18 +60,7 @@ public class ${ClassName}Controller extends BaseController {
         }
     #end
 
-    ##    /**
-    ##     * 导出${functionName}列表
-    ##     */
-    ##    @RequiresPermissions("${permissionPrefix}:export")
-    ##    @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
-    ##    @PostMapping("/export")
-    ##    public void export(HttpServletResponse response, ${ClassName} ${className})
-    ##    {
-    ##        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-    ##        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
-    ##        util.exportExcel(response, list, "${functionName}数据");
-    ##    }
+
 
     /**
      * 获取${functionName}详细信息

+ 2 - 2
soc-modules/soc-modules-gen/src/main/resources/vm/js/api.js.vm

@@ -1,6 +1,6 @@
 import request from '@/utils/request'
 
-// 查询${functionName}列表
+// 查询列表${functionName}
 export function list${BusinessName}(query) {
   return request({
     url: '/${moduleName}/${businessName}/list',
@@ -9,7 +9,7 @@ export function list${BusinessName}(query) {
   })
 }
 
-// 查询${functionName}详细
+// 查询详细${functionName}
 export function get${BusinessName}(${pkColumn.javaField}) {
   return request({
     url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},

+ 1 - 1
soc-modules/soc-modules-gen/src/main/resources/vm/vue/v3/readme.txt

@@ -1 +1 @@
-如果使用的是RuoYi-Cloud-Vue3前端,那么需要覆盖一下此目录的模板index.vue.vm、index-tree.vue.vm文件到上级vue目录。
+锟斤拷锟绞癸拷玫锟斤拷锟絰unmei-Cloud-Vue3前锟剿o拷锟斤拷么锟斤拷要锟斤拷锟斤拷一锟铰达拷目录锟斤拷模锟斤拷index.vue.vm锟斤拷index-tree.vue.vm锟侥硷拷锟斤拷锟较硷拷vue目录锟斤拷