正在显示
38 个修改的文件
包含
1158 行增加
和
604 行删除
lh-common/lh-public-dao/src/main/java/com/zhonglai/luhui/dao/mapper/PublicTemplateMapper.java
0 → 100644
| 1 | +package com.zhonglai.luhui.dao.mapper; | ||
| 2 | + | ||
| 3 | +import com.zhonglai.luhui.dao.dto.PublicSQL; | ||
| 4 | +import org.apache.ibatis.annotations.*; | ||
| 5 | +import org.springframework.stereotype.Component; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 公用mapper | ||
| 12 | + */ | ||
| 13 | +@Component | ||
| 14 | +public interface PublicTemplateMapper { | ||
| 15 | + /** | ||
| 16 | + * 添加对象 | ||
| 17 | + */ | ||
| 18 | + @InsertProvider(type = PublicSQL.class, method = "insert") | ||
| 19 | + int insert(Object object); | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 指定表名添加 | ||
| 23 | + */ | ||
| 24 | + @InsertProvider(type = PublicSQL.class, method = "insertToTable") | ||
| 25 | + @Options(useGeneratedKeys = true, keyProperty = "object.id") | ||
| 26 | + int insertToTable(@Param("object") Object object,@Param("tableName") String tableName,@Param("primaryKey") String primaryKey); | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 添加对象集合 | ||
| 30 | + */ | ||
| 31 | + @InsertProvider(type = PublicSQL.class, method = "insertAll") | ||
| 32 | + int insertAll(List<?> list); | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 指定表名添加对象集合 | ||
| 36 | + */ | ||
| 37 | + @InsertProvider(type = PublicSQL.class, method = "insertAllToTable") | ||
| 38 | + int insertAllToTable(@Param("list")List<?> list,@Param("tableName")String tableName); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 更新对象不为空的属性 | ||
| 42 | + * @param object | ||
| 43 | + * @param whereFieldNames | ||
| 44 | + */ | ||
| 45 | + @UpdateProvider(type = PublicSQL.class, method = "updateObject") | ||
| 46 | + int updateObject(@Param("object") Object object, @Param("whereFieldNames") String whereFieldNames); | ||
| 47 | + | ||
| 48 | + @UpdateProvider(type = PublicSQL.class, method = "updateObject") | ||
| 49 | + int updateObjectByTable(@Param("object") Object object, @Param("whereFieldNames") String whereFieldNames, @Param("tablename") String tablename); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 自定义sql更新 | ||
| 53 | + * @param sql | ||
| 54 | + */ | ||
| 55 | + @UpdateProvider(type = PublicSQL.class, method = "updateBySql") | ||
| 56 | + int updateBySql(String sql); | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 查询 通过条件查询 | ||
| 60 | + * @param clas | ||
| 61 | + * @param idName | ||
| 62 | + * @param values | ||
| 63 | + * @return | ||
| 64 | + */ | ||
| 65 | + @SelectProvider(type = PublicSQL.class, method = "getObject") | ||
| 66 | + Map<String,Object> getObject(@Param("class") Class<?> clas, @Param("idName") String idName, @Param("values") String values); | ||
| 67 | + | ||
| 68 | + @SelectProvider(type = PublicSQL.class, method = "selectCountBySql") | ||
| 69 | + Long selectCountBySql(@Param("sql") String sql); | ||
| 70 | + /** | ||
| 71 | + * 查询 通过条件查询 | ||
| 72 | + * @param clas | ||
| 73 | + * @param idName | ||
| 74 | + * @param values | ||
| 75 | + * @return | ||
| 76 | + */ | ||
| 77 | + @SelectProvider(type = PublicSQL.class, method = "getObject") | ||
| 78 | + Map<String,Object> getObjectForTableName(@Param("class") Class<?> clas, @Param("idName") String idName, @Param("values") String values, @Param("tableName") String tableName); | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 查询 通过条件查询单个指定项目 | ||
| 82 | + * @param clas 類型 | ||
| 83 | + * @param select 查詢結果 | ||
| 84 | + * @param idName 主鍵名稱 | ||
| 85 | + * @param values 主鍵值 | ||
| 86 | + * @return | ||
| 87 | + */ | ||
| 88 | + @SelectProvider(type = PublicSQL.class, method = "getObject") | ||
| 89 | + Map<String,Object> getObjectSelectTableName(@Param("class") Class<?> clas, @Param("select") String select, @Param("idName") String idName, @Param("values") String values, @Param("tableName") String tableName); | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 查询list | ||
| 93 | + * @param object | ||
| 94 | + * @param whereMap 如果是时间,whereMap里面对应的字段比较符为time,同时添加一个end_字段名的值 表示是结束时间 | ||
| 95 | + * @param order | ||
| 96 | + * @param pagetSize | ||
| 97 | + * @param pageNo | ||
| 98 | + * @return | ||
| 99 | + */ | ||
| 100 | + @SelectProvider(type = PublicSQL.class, method = "getObjectList") | ||
| 101 | + List<Map<String,Object>> getObjectList(@Param("object") Object object, @Param("selectStr") String selectStr, @Param("whereMap") Map<String, String> whereMap, @Param("order") String order, @Param("pageSize") Integer pagetSize, @Param("pageNo") Integer pageNo); | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * 查詢totle | ||
| 105 | + * @param object | ||
| 106 | + * @param whereMap 如果是时间,whereMap里面对应的字段比较符为time,同时添加一个end_字段名的值 表示是结束时间 | ||
| 107 | + * @return | ||
| 108 | + */ | ||
| 109 | + @SelectProvider(type = PublicSQL.class, method = "getObjectListTotle") | ||
| 110 | + Long getObjectListTotle(@Param("object") Object object, @Param("whereMap") Map<String, String> whereMap); | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * 通过条件删除对象 | ||
| 114 | + * @param oClass | ||
| 115 | + * @param map | ||
| 116 | + */ | ||
| 117 | + @UpdateProvider(type = PublicSQL.class, method = "deleteObjectByContent") | ||
| 118 | + int deleteObjectByContent(@Param("objectCalss") Class<?> oClass, @Param("map") Map<String, String> map); | ||
| 119 | + | ||
| 120 | + /** | ||
| 121 | + * 自定义sql语句查询list | ||
| 122 | + * @param sql | ||
| 123 | + * @return | ||
| 124 | + */ | ||
| 125 | + @SelectProvider(type = PublicSQL.class, method = "getObjectListBySQL") | ||
| 126 | + List<Map<String,Object>> getObjectListBySQL(@Param("sql") String sql); | ||
| 127 | + /** | ||
| 128 | + * 添加或更新对象列表 | ||
| 129 | + * INSERT INTO `test` (`in1`,`str1`)VALUES ('1','2'),('2','2') ON DUPLICATE KEY UPDATE `in1`=VALUES(`in1`),`str1`=VALUES(`str1`); | ||
| 130 | + * @param objectlist 对象列表 | ||
| 131 | + * @return | ||
| 132 | + */ | ||
| 133 | + @UpdateProvider(type = PublicSQL.class, method = "saveOrUpdateObjectList") | ||
| 134 | + int saveOrUpdateObjectList(List<Object> objectlist); | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * 添加或更新对象 | ||
| 138 | + * INSERT INTO test(`in1`,`str1`) VALUES ('1','1'); | ||
| 139 | + * @param object 对象 | ||
| 140 | + * @return | ||
| 141 | + */ | ||
| 142 | + @UpdateProvider(type = PublicSQL.class, method = "saveOrUpdateObject") | ||
| 143 | + int saveOrUpdateObject(Object object); | ||
| 144 | + | ||
| 145 | + /** | ||
| 146 | + * 通过id删除数据 | ||
| 147 | + * @return | ||
| 148 | + */ | ||
| 149 | + @UpdateProvider(type = PublicSQL.class, method = "deleteObjectById") | ||
| 150 | + int deleteObjectById(@Param("objectCalss") Class<?> oClass, @Param("id") String id); | ||
| 151 | + | ||
| 152 | + @Options(useGeneratedKeys = false) | ||
| 153 | + @InsertProvider(type = PublicSQL.class, method = "updateBySql") | ||
| 154 | + int insertIntoBySql(@Param("sql") String sql); | ||
| 155 | + | ||
| 156 | + @SelectProvider(type = PublicSQL.class, method = "selectTList") | ||
| 157 | + List<Map<String,Object>> selectTList(Object t); | ||
| 158 | + | ||
| 159 | +} |
lh-common/lh-public-dao/src/main/java/com/zhonglai/luhui/dao/service/PublicTemplateService.java
0 → 100644
| 1 | +package com.zhonglai.luhui.dao.service; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +public interface PublicTemplateService { | ||
| 6 | + /** | ||
| 7 | + * 查询表 | ||
| 8 | + * | ||
| 9 | + * @return 表 | ||
| 10 | + */ | ||
| 11 | + <T> List<T> selectTList(T t); | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + <T> T getTById(Object id,Class<T> clas); | ||
| 15 | + | ||
| 16 | + int add(Object t); | ||
| 17 | + | ||
| 18 | + int edit(Object t); | ||
| 19 | + | ||
| 20 | + int removeByIds(Class<?> clas,Object... id); | ||
| 21 | +} |
| 1 | +package com.zhonglai.luhui.dao.service.impl; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.zhonglai.luhui.dao.mapper.PublicMapper; | ||
| 5 | +import com.zhonglai.luhui.dao.mapper.PublicTemplateMapper; | ||
| 6 | +import com.zhonglai.luhui.dao.service.PublicTemplateService; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | + | ||
| 10 | +import java.util.ArrayList; | ||
| 11 | +import java.util.List; | ||
| 12 | +import java.util.Map; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 公共模板服务 | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +public class PublicTemplateServiceImpl implements PublicTemplateService { | ||
| 19 | + @Autowired | ||
| 20 | + private PublicTemplateMapper publicMapper; | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public <T> List<T> selectTList(T t) { | ||
| 24 | + List<Map<String,Object>> list = publicMapper.selectTList(t); | ||
| 25 | + | ||
| 26 | + List<T> rList = new ArrayList<>(); | ||
| 27 | + if(null != list && list.size() != 0) | ||
| 28 | + { | ||
| 29 | + rList = new ArrayList<T>(); | ||
| 30 | + for (Map<String,Object> map:list) | ||
| 31 | + { | ||
| 32 | + T at = (T) JSONObject.parseObject(JSONObject.toJSONString(map),t.getClass()); | ||
| 33 | + rList.add(at); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + return rList; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public <T> T getTById(Object id,Class<T> clas) { | ||
| 41 | + Map<String,Object> object = publicMapper.getObject(clas,"id", String.valueOf(id)); | ||
| 42 | + if(null != object) | ||
| 43 | + { | ||
| 44 | + return JSONObject.parseObject(JSONObject.toJSONString(object),clas); | ||
| 45 | + } | ||
| 46 | + return null; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public int add(Object t) { | ||
| 51 | + return publicMapper.insert(t); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public int edit(Object t) { | ||
| 56 | + return publicMapper.updateObject(t,"id"); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public int removeByIds(Class<?> clas, Object... ids) { | ||
| 61 | + int i = 0; | ||
| 62 | + for (Object o:ids) | ||
| 63 | + { | ||
| 64 | + i+=publicMapper.deleteObjectById(clas,o+""); | ||
| 65 | + } | ||
| 66 | + return i; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + | ||
| 70 | +} |
| @@ -11,20 +11,18 @@ | @@ -11,20 +11,18 @@ | ||
| 11 | 11 | ||
| 12 | <artifactId>ruoyi-generator</artifactId> | 12 | <artifactId>ruoyi-generator</artifactId> |
| 13 | 13 | ||
| 14 | + <description> | ||
| 15 | + generator代码生成 | ||
| 16 | + </description> | ||
| 17 | + | ||
| 14 | <dependencies> | 18 | <dependencies> |
| 15 | 19 | ||
| 16 | - <!--velocity代码生成使用模板 --> | 20 | + <!-- velocity代码生成使用模板 --> |
| 17 | <dependency> | 21 | <dependency> |
| 18 | <groupId>org.apache.velocity</groupId> | 22 | <groupId>org.apache.velocity</groupId> |
| 19 | <artifactId>velocity-engine-core</artifactId> | 23 | <artifactId>velocity-engine-core</artifactId> |
| 20 | </dependency> | 24 | </dependency> |
| 21 | 25 | ||
| 22 | - <!-- collections工具类 --> | ||
| 23 | - <dependency> | ||
| 24 | - <groupId>commons-collections</groupId> | ||
| 25 | - <artifactId>commons-collections</artifactId> | ||
| 26 | - </dependency> | ||
| 27 | - | ||
| 28 | <!-- 通用工具--> | 26 | <!-- 通用工具--> |
| 29 | <dependency> | 27 | <dependency> |
| 30 | <groupId>com.zhonglai.luhui</groupId> | 28 | <groupId>com.zhonglai.luhui</groupId> |
| @@ -35,52 +33,17 @@ | @@ -35,52 +33,17 @@ | ||
| 35 | <groupId>com.zhonglai.luhui</groupId> | 33 | <groupId>com.zhonglai.luhui</groupId> |
| 36 | <artifactId>lh-jar-action</artifactId> | 34 | <artifactId>lh-jar-action</artifactId> |
| 37 | </dependency> | 35 | </dependency> |
| 38 | - <!-- 文档 --> | ||
| 39 | - <dependency > | ||
| 40 | - <groupId>io.springfox</groupId> | ||
| 41 | - <artifactId>springfox-swagger2</artifactId> | ||
| 42 | - <version>${swagger.version}</version> | ||
| 43 | - <exclusions> | ||
| 44 | - <exclusion> | ||
| 45 | - <groupId>io.swagger</groupId> | ||
| 46 | - <artifactId>swagger-models</artifactId> | ||
| 47 | - </exclusion> | ||
| 48 | - <exclusion> | ||
| 49 | - <groupId>com.google.guava</groupId> | ||
| 50 | - <artifactId>guava</artifactId> | ||
| 51 | - </exclusion> | ||
| 52 | - </exclusions> | ||
| 53 | - </dependency> | ||
| 54 | - <!--https://mvnrepository.com/artifact/io.swagger/swagger-models--> | ||
| 55 | - <dependency> | ||
| 56 | - <groupId>io.swagger</groupId> | ||
| 57 | - <artifactId>swagger-models</artifactId> | ||
| 58 | - <version>${swagger-models.version}</version> | ||
| 59 | - </dependency> | ||
| 60 | - <dependency> | ||
| 61 | - <groupId>io.springfox</groupId> | ||
| 62 | - <artifactId>springfox-swagger-ui</artifactId> | ||
| 63 | - <version>${swagger.version}</version> | ||
| 64 | - </dependency> | ||
| 65 | - <!--<!– https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui –>--> | ||
| 66 | <dependency> | 36 | <dependency> |
| 67 | - <groupId>com.github.xiaoymin</groupId> | ||
| 68 | - <artifactId>swagger-bootstrap-ui</artifactId> | ||
| 69 | - <version>${swagger-ui.version}</version> | 37 | + <groupId>com.zhonglai.luhui</groupId> |
| 38 | + <artifactId>ruoyi-common-security</artifactId> | ||
| 70 | </dependency> | 39 | </dependency> |
| 71 | 40 | ||
| 41 | + <!-- 阿里数据库连接池 --> | ||
| 72 | <dependency> | 42 | <dependency> |
| 73 | - <groupId>tk.mybatis</groupId> | ||
| 74 | - <artifactId>mapper</artifactId> | ||
| 75 | - <!-- 建议使用最新版本,最新版本请从项目首页查找 --> | ||
| 76 | - </dependency> | ||
| 77 | - <dependency> | ||
| 78 | - <groupId>tk.mybatis</groupId> | ||
| 79 | - <artifactId>mapper-spring-boot-starter</artifactId> | ||
| 80 | - </dependency> | ||
| 81 | - <dependency> | ||
| 82 | - <groupId>com.zhonglai.luhui</groupId> | ||
| 83 | - <artifactId>lh-common-datasource</artifactId> | 43 | + <groupId>com.alibaba</groupId> |
| 44 | + <artifactId>druid-spring-boot-starter</artifactId> | ||
| 84 | </dependency> | 45 | </dependency> |
| 46 | + | ||
| 85 | </dependencies> | 47 | </dependencies> |
| 48 | + | ||
| 86 | </project> | 49 | </project> |
| 1 | package com.ruoyi.generator.controller; | 1 | package com.ruoyi.generator.controller; |
| 2 | 2 | ||
| 3 | import java.io.IOException; | 3 | import java.io.IOException; |
| 4 | +import java.util.ArrayList; | ||
| 4 | import java.util.HashMap; | 5 | import java.util.HashMap; |
| 5 | import java.util.List; | 6 | import java.util.List; |
| 6 | import java.util.Map; | 7 | import java.util.Map; |
| 7 | import javax.servlet.http.HttpServletResponse; | 8 | import javax.servlet.http.HttpServletResponse; |
| 8 | - | ||
| 9 | -import com.ruoyi.common.utils.DateUtils; | ||
| 10 | -import com.zhonglai.luhui.action.BaseController; | ||
| 11 | -import io.swagger.annotations.Api; | ||
| 12 | -import io.swagger.annotations.ApiImplicitParam; | ||
| 13 | -import io.swagger.annotations.ApiOperation; | ||
| 14 | import org.apache.commons.io.IOUtils; | 9 | import org.apache.commons.io.IOUtils; |
| 15 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | -//import org.springframework.security.access.prepost.PreAuthorize; | 11 | +import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | import org.springframework.validation.annotation.Validated; | 12 | import org.springframework.validation.annotation.Validated; |
| 18 | import org.springframework.web.bind.annotation.DeleteMapping; | 13 | import org.springframework.web.bind.annotation.DeleteMapping; |
| 19 | import org.springframework.web.bind.annotation.GetMapping; | 14 | import org.springframework.web.bind.annotation.GetMapping; |
| @@ -23,11 +18,18 @@ import org.springframework.web.bind.annotation.PutMapping; | @@ -23,11 +18,18 @@ import org.springframework.web.bind.annotation.PutMapping; | ||
| 23 | import org.springframework.web.bind.annotation.RequestBody; | 18 | import org.springframework.web.bind.annotation.RequestBody; |
| 24 | import org.springframework.web.bind.annotation.RequestMapping; | 19 | import org.springframework.web.bind.annotation.RequestMapping; |
| 25 | import org.springframework.web.bind.annotation.RestController; | 20 | import org.springframework.web.bind.annotation.RestController; |
| 21 | +import com.alibaba.druid.DbType; | ||
| 22 | +import com.alibaba.druid.sql.SQLUtils; | ||
| 23 | +import com.alibaba.druid.sql.ast.SQLStatement; | ||
| 24 | +import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; | ||
| 26 | import com.ruoyi.common.annotation.Log; | 25 | import com.ruoyi.common.annotation.Log; |
| 26 | +import com.zhonglai.luhui.action.BaseController; | ||
| 27 | import com.ruoyi.common.core.domain.AjaxResult; | 27 | import com.ruoyi.common.core.domain.AjaxResult; |
| 28 | import com.ruoyi.common.core.page.TableDataInfo; | 28 | import com.ruoyi.common.core.page.TableDataInfo; |
| 29 | import com.ruoyi.common.core.text.Convert; | 29 | import com.ruoyi.common.core.text.Convert; |
| 30 | import com.ruoyi.common.enums.BusinessType; | 30 | import com.ruoyi.common.enums.BusinessType; |
| 31 | +import com.zhonglai.luhui.security.utils.SecurityUtils; | ||
| 32 | +import com.ruoyi.common.utils.sql.SqlUtil; | ||
| 31 | import com.ruoyi.generator.domain.GenTable; | 33 | import com.ruoyi.generator.domain.GenTable; |
| 32 | import com.ruoyi.generator.domain.GenTableColumn; | 34 | import com.ruoyi.generator.domain.GenTableColumn; |
| 33 | import com.ruoyi.generator.service.IGenTableColumnService; | 35 | import com.ruoyi.generator.service.IGenTableColumnService; |
| @@ -38,7 +40,6 @@ import com.ruoyi.generator.service.IGenTableService; | @@ -38,7 +40,6 @@ import com.ruoyi.generator.service.IGenTableService; | ||
| 38 | * | 40 | * |
| 39 | * @author ruoyi | 41 | * @author ruoyi |
| 40 | */ | 42 | */ |
| 41 | -@Api(tags = "代码生成 操作处理") | ||
| 42 | @RestController | 43 | @RestController |
| 43 | @RequestMapping("/tool/gen") | 44 | @RequestMapping("/tool/gen") |
| 44 | public class GenController extends BaseController | 45 | public class GenController extends BaseController |
| @@ -52,8 +53,7 @@ public class GenController extends BaseController | @@ -52,8 +53,7 @@ public class GenController extends BaseController | ||
| 52 | /** | 53 | /** |
| 53 | * 查询代码生成列表 | 54 | * 查询代码生成列表 |
| 54 | */ | 55 | */ |
| 55 | - @ApiOperation("查询代码生成列表") | ||
| 56 | -// @PreAuthorize("@ss.hasPermi('tool:gen:list')") | 56 | + @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| 57 | @GetMapping("/list") | 57 | @GetMapping("/list") |
| 58 | public TableDataInfo genList(GenTable genTable) | 58 | public TableDataInfo genList(GenTable genTable) |
| 59 | { | 59 | { |
| @@ -65,8 +65,7 @@ public class GenController extends BaseController | @@ -65,8 +65,7 @@ public class GenController extends BaseController | ||
| 65 | /** | 65 | /** |
| 66 | * 修改代码生成业务 | 66 | * 修改代码生成业务 |
| 67 | */ | 67 | */ |
| 68 | - @ApiOperation("修改代码生成业务") | ||
| 69 | -// @PreAuthorize("@ss.hasPermi('tool:gen:query')") | 68 | + @PreAuthorize("@ss.hasPermi('tool:gen:query')") |
| 70 | @GetMapping(value = "/{tableId}") | 69 | @GetMapping(value = "/{tableId}") |
| 71 | public AjaxResult getInfo(@PathVariable Long tableId) | 70 | public AjaxResult getInfo(@PathVariable Long tableId) |
| 72 | { | 71 | { |
| @@ -77,14 +76,13 @@ public class GenController extends BaseController | @@ -77,14 +76,13 @@ public class GenController extends BaseController | ||
| 77 | map.put("info", table); | 76 | map.put("info", table); |
| 78 | map.put("rows", list); | 77 | map.put("rows", list); |
| 79 | map.put("tables", tables); | 78 | map.put("tables", tables); |
| 80 | - return AjaxResult.success(map); | 79 | + return success(map); |
| 81 | } | 80 | } |
| 82 | 81 | ||
| 83 | /** | 82 | /** |
| 84 | * 查询数据库列表 | 83 | * 查询数据库列表 |
| 85 | */ | 84 | */ |
| 86 | - @ApiOperation("查询数据库列表") | ||
| 87 | -// @PreAuthorize("@ss.hasPermi('tool:gen:list')") | 85 | + @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| 88 | @GetMapping("/db/list") | 86 | @GetMapping("/db/list") |
| 89 | public TableDataInfo dataList(GenTable genTable) | 87 | public TableDataInfo dataList(GenTable genTable) |
| 90 | { | 88 | { |
| @@ -96,8 +94,7 @@ public class GenController extends BaseController | @@ -96,8 +94,7 @@ public class GenController extends BaseController | ||
| 96 | /** | 94 | /** |
| 97 | * 查询数据表字段列表 | 95 | * 查询数据表字段列表 |
| 98 | */ | 96 | */ |
| 99 | - @ApiOperation("查询数据表字段列表") | ||
| 100 | -// @PreAuthorize("@ss.hasPermi('tool:gen:list')") | 97 | + @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| 101 | @GetMapping(value = "/column/{tableId}") | 98 | @GetMapping(value = "/column/{tableId}") |
| 102 | public TableDataInfo columnList(Long tableId) | 99 | public TableDataInfo columnList(Long tableId) |
| 103 | { | 100 | { |
| @@ -111,8 +108,7 @@ public class GenController extends BaseController | @@ -111,8 +108,7 @@ public class GenController extends BaseController | ||
| 111 | /** | 108 | /** |
| 112 | * 导入表结构(保存) | 109 | * 导入表结构(保存) |
| 113 | */ | 110 | */ |
| 114 | - @ApiOperation("导入表结构(保存)") | ||
| 115 | -// @PreAuthorize("@ss.hasPermi('tool:gen:import')") | 111 | + @PreAuthorize("@ss.hasPermi('tool:gen:import')") |
| 116 | @Log(title = "代码生成", businessType = BusinessType.IMPORT) | 112 | @Log(title = "代码生成", businessType = BusinessType.IMPORT) |
| 117 | @PostMapping("/importTable") | 113 | @PostMapping("/importTable") |
| 118 | public AjaxResult importTableSave(String tables) | 114 | public AjaxResult importTableSave(String tables) |
| @@ -120,54 +116,87 @@ public class GenController extends BaseController | @@ -120,54 +116,87 @@ public class GenController extends BaseController | ||
| 120 | String[] tableNames = Convert.toStrArray(tables); | 116 | String[] tableNames = Convert.toStrArray(tables); |
| 121 | // 查询表信息 | 117 | // 查询表信息 |
| 122 | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); | 118 | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); |
| 123 | - genTableService.importGenTable(tableList); | 119 | + genTableService.importGenTable(tableList, SecurityUtils.getUsername()); |
| 120 | + return success(); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * 创建表结构(保存) | ||
| 125 | + */ | ||
| 126 | + @PreAuthorize("@ss.hasRole('admin')") | ||
| 127 | + @Log(title = "创建表", businessType = BusinessType.OTHER) | ||
| 128 | + @PostMapping("/createTable") | ||
| 129 | + public AjaxResult createTableSave(String sql) | ||
| 130 | + { | ||
| 131 | + try | ||
| 132 | + { | ||
| 133 | + SqlUtil.filterKeyword(sql); | ||
| 134 | + List<SQLStatement> sqlStatements = SQLUtils.parseStatements(sql, DbType.mysql); | ||
| 135 | + List<String> tableNames = new ArrayList<>(); | ||
| 136 | + for (SQLStatement sqlStatement : sqlStatements) | ||
| 137 | + { | ||
| 138 | + if (sqlStatement instanceof MySqlCreateTableStatement) | ||
| 139 | + { | ||
| 140 | + MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement) sqlStatement; | ||
| 141 | + if (genTableService.createTable(createTableStatement.toString())) | ||
| 142 | + { | ||
| 143 | + String tableName = createTableStatement.getTableName().replaceAll("`", ""); | ||
| 144 | + tableNames.add(tableName); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames.toArray(new String[tableNames.size()])); | ||
| 149 | + String operName = SecurityUtils.getUsername(); | ||
| 150 | + genTableService.importGenTable(tableList, operName); | ||
| 124 | return AjaxResult.success(); | 151 | return AjaxResult.success(); |
| 125 | } | 152 | } |
| 153 | + catch (Exception e) | ||
| 154 | + { | ||
| 155 | + logger.error(e.getMessage(), e); | ||
| 156 | + return AjaxResult.error("创建表结构异常"); | ||
| 157 | + } | ||
| 158 | + } | ||
| 126 | 159 | ||
| 127 | /** | 160 | /** |
| 128 | * 修改保存代码生成业务 | 161 | * 修改保存代码生成业务 |
| 129 | */ | 162 | */ |
| 130 | - @ApiOperation("修改保存代码生成业务") | ||
| 131 | -// @PreAuthorize("@ss.hasPermi('tool:gen:edit')") | 163 | + @PreAuthorize("@ss.hasPermi('tool:gen:edit')") |
| 132 | @Log(title = "代码生成", businessType = BusinessType.UPDATE) | 164 | @Log(title = "代码生成", businessType = BusinessType.UPDATE) |
| 133 | @PutMapping | 165 | @PutMapping |
| 134 | public AjaxResult editSave(@Validated @RequestBody GenTable genTable) | 166 | public AjaxResult editSave(@Validated @RequestBody GenTable genTable) |
| 135 | { | 167 | { |
| 136 | genTableService.validateEdit(genTable); | 168 | genTableService.validateEdit(genTable); |
| 137 | genTableService.updateGenTable(genTable); | 169 | genTableService.updateGenTable(genTable); |
| 138 | - return AjaxResult.success(); | 170 | + return success(); |
| 139 | } | 171 | } |
| 140 | 172 | ||
| 141 | /** | 173 | /** |
| 142 | * 删除代码生成 | 174 | * 删除代码生成 |
| 143 | */ | 175 | */ |
| 144 | - @ApiOperation("删除代码生成") | ||
| 145 | -// @PreAuthorize("@ss.hasPermi('tool:gen:remove')") | 176 | + @PreAuthorize("@ss.hasPermi('tool:gen:remove')") |
| 146 | @Log(title = "代码生成", businessType = BusinessType.DELETE) | 177 | @Log(title = "代码生成", businessType = BusinessType.DELETE) |
| 147 | @DeleteMapping("/{tableIds}") | 178 | @DeleteMapping("/{tableIds}") |
| 148 | public AjaxResult remove(@PathVariable Long[] tableIds) | 179 | public AjaxResult remove(@PathVariable Long[] tableIds) |
| 149 | { | 180 | { |
| 150 | genTableService.deleteGenTableByIds(tableIds); | 181 | genTableService.deleteGenTableByIds(tableIds); |
| 151 | - return AjaxResult.success(); | 182 | + return success(); |
| 152 | } | 183 | } |
| 153 | 184 | ||
| 154 | /** | 185 | /** |
| 155 | * 预览代码 | 186 | * 预览代码 |
| 156 | */ | 187 | */ |
| 157 | - @ApiOperation("预览代码") | ||
| 158 | -// @PreAuthorize("@ss.hasPermi('tool:gen:preview')") | 188 | + @PreAuthorize("@ss.hasPermi('tool:gen:preview')") |
| 159 | @GetMapping("/preview/{tableId}") | 189 | @GetMapping("/preview/{tableId}") |
| 160 | public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException | 190 | public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException |
| 161 | { | 191 | { |
| 162 | Map<String, String> dataMap = genTableService.previewCode(tableId); | 192 | Map<String, String> dataMap = genTableService.previewCode(tableId); |
| 163 | - return AjaxResult.success(dataMap); | 193 | + return success(dataMap); |
| 164 | } | 194 | } |
| 165 | 195 | ||
| 166 | /** | 196 | /** |
| 167 | * 生成代码(下载方式) | 197 | * 生成代码(下载方式) |
| 168 | */ | 198 | */ |
| 169 | - @ApiOperation("生成代码(下载方式)") | ||
| 170 | -// @PreAuthorize("@ss.hasPermi('tool:gen:code')") | 199 | + @PreAuthorize("@ss.hasPermi('tool:gen:code')") |
| 171 | @Log(title = "代码生成", businessType = BusinessType.GENCODE) | 200 | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| 172 | @GetMapping("/download/{tableName}") | 201 | @GetMapping("/download/{tableName}") |
| 173 | public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException | 202 | public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException |
| @@ -179,34 +208,31 @@ public class GenController extends BaseController | @@ -179,34 +208,31 @@ public class GenController extends BaseController | ||
| 179 | /** | 208 | /** |
| 180 | * 生成代码(自定义路径) | 209 | * 生成代码(自定义路径) |
| 181 | */ | 210 | */ |
| 182 | - @ApiOperation("生成代码(自定义路径)") | ||
| 183 | -// @PreAuthorize("@ss.hasPermi('tool:gen:code')") | 211 | + @PreAuthorize("@ss.hasPermi('tool:gen:code')") |
| 184 | @Log(title = "代码生成", businessType = BusinessType.GENCODE) | 212 | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| 185 | @GetMapping("/genCode/{tableName}") | 213 | @GetMapping("/genCode/{tableName}") |
| 186 | public AjaxResult genCode(@PathVariable("tableName") String tableName) | 214 | public AjaxResult genCode(@PathVariable("tableName") String tableName) |
| 187 | { | 215 | { |
| 188 | genTableService.generatorCode(tableName); | 216 | genTableService.generatorCode(tableName); |
| 189 | - return AjaxResult.success(); | 217 | + return success(); |
| 190 | } | 218 | } |
| 191 | 219 | ||
| 192 | /** | 220 | /** |
| 193 | * 同步数据库 | 221 | * 同步数据库 |
| 194 | */ | 222 | */ |
| 195 | - @ApiOperation("同步数据库") | ||
| 196 | -// @PreAuthorize("@ss.hasPermi('tool:gen:edit')") | ||
| 197 | - @Log(title = "代码生成", businessType = BusinessType.UPDATE) | 223 | + @PreAuthorize("@ss.hasPermi('tool:gen:edit')") |
| 224 | + @Log(title = "同步数据库", businessType = BusinessType.UPDATE) | ||
| 198 | @GetMapping("/synchDb/{tableName}") | 225 | @GetMapping("/synchDb/{tableName}") |
| 199 | public AjaxResult synchDb(@PathVariable("tableName") String tableName) | 226 | public AjaxResult synchDb(@PathVariable("tableName") String tableName) |
| 200 | { | 227 | { |
| 201 | genTableService.synchDb(tableName); | 228 | genTableService.synchDb(tableName); |
| 202 | - return AjaxResult.success(); | 229 | + return success(); |
| 203 | } | 230 | } |
| 204 | 231 | ||
| 205 | /** | 232 | /** |
| 206 | * 批量生成代码 | 233 | * 批量生成代码 |
| 207 | */ | 234 | */ |
| 208 | - @ApiOperation("批量生成代码") | ||
| 209 | -// @PreAuthorize("@ss.hasPermi('tool:gen:code')") | 235 | + @PreAuthorize("@ss.hasPermi('tool:gen:code')") |
| 210 | @Log(title = "代码生成", businessType = BusinessType.GENCODE) | 236 | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| 211 | @GetMapping("/batchGenCode") | 237 | @GetMapping("/batchGenCode") |
| 212 | public void batchGenCode(HttpServletResponse response, String tables) throws IOException | 238 | public void batchGenCode(HttpServletResponse response, String tables) throws IOException |
| @@ -216,14 +242,6 @@ public class GenController extends BaseController | @@ -216,14 +242,6 @@ public class GenController extends BaseController | ||
| 216 | genCode(response, data); | 242 | genCode(response, data); |
| 217 | } | 243 | } |
| 218 | 244 | ||
| 219 | - @ApiOperation("从数据库结构生成代码") | ||
| 220 | - @ApiImplicitParam(value = "表名集合",name = "tableNames") | ||
| 221 | - @GetMapping("/generatorCodeFromDb") | ||
| 222 | - public void generatorCodeFromDb(HttpServletResponse response,String databaseName, String tableNames,String packageName,String dataSource) throws IOException { | ||
| 223 | - byte[] data = genTableService.generatorCodeFromDb(databaseName,tableNames,packageName,dataSource); | ||
| 224 | - genCode(response, data); | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | /** | 245 | /** |
| 228 | * 生成zip文件 | 246 | * 生成zip文件 |
| 229 | */ | 247 | */ |
| @@ -232,7 +250,7 @@ public class GenController extends BaseController | @@ -232,7 +250,7 @@ public class GenController extends BaseController | ||
| 232 | response.reset(); | 250 | response.reset(); |
| 233 | response.addHeader("Access-Control-Allow-Origin", "*"); | 251 | response.addHeader("Access-Control-Allow-Origin", "*"); |
| 234 | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); | 252 | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| 235 | - response.setHeader("Content-Disposition", "attachment; filename=\""+ DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS) +"生成代码.zip\""); | 253 | + response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); |
| 236 | response.addHeader("Content-Length", "" + data.length); | 254 | response.addHeader("Content-Length", "" + data.length); |
| 237 | response.setContentType("application/octet-stream; charset=UTF-8"); | 255 | response.setContentType("application/octet-stream; charset=UTF-8"); |
| 238 | IOUtils.write(data, response.getOutputStream()); | 256 | IOUtils.write(data, response.getOutputStream()); |
| @@ -3,8 +3,6 @@ package com.ruoyi.generator.domain; | @@ -3,8 +3,6 @@ package com.ruoyi.generator.domain; | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import javax.validation.Valid; | 4 | import javax.validation.Valid; |
| 5 | import javax.validation.constraints.NotBlank; | 5 | import javax.validation.constraints.NotBlank; |
| 6 | - | ||
| 7 | -import com.ruoyi.common.annotation.PublicSQLConfig; | ||
| 8 | import org.apache.commons.lang3.ArrayUtils; | 6 | import org.apache.commons.lang3.ArrayUtils; |
| 9 | import com.ruoyi.common.constant.GenConstants; | 7 | import com.ruoyi.common.constant.GenConstants; |
| 10 | import com.ruoyi.common.tool.BaseEntity; | 8 | import com.ruoyi.common.tool.BaseEntity; |
| @@ -17,7 +15,6 @@ import com.ruoyi.common.utils.StringUtils; | @@ -17,7 +15,6 @@ import com.ruoyi.common.utils.StringUtils; | ||
| 17 | */ | 15 | */ |
| 18 | public class GenTable extends BaseEntity | 16 | public class GenTable extends BaseEntity |
| 19 | { | 17 | { |
| 20 | - @PublicSQLConfig(isSelect=false) | ||
| 21 | private static final long serialVersionUID = 1L; | 18 | private static final long serialVersionUID = 1L; |
| 22 | 19 | ||
| 23 | /** 编号 */ | 20 | /** 编号 */ |
| @@ -44,6 +41,9 @@ public class GenTable extends BaseEntity | @@ -44,6 +41,9 @@ public class GenTable extends BaseEntity | ||
| 44 | /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */ | 41 | /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */ |
| 45 | private String tplCategory; | 42 | private String tplCategory; |
| 46 | 43 | ||
| 44 | + /** 前端类型(element-ui模版 element-plus模版) */ | ||
| 45 | + private String tplWebType; | ||
| 46 | + | ||
| 47 | /** 生成包路径 */ | 47 | /** 生成包路径 */ |
| 48 | @NotBlank(message = "生成包路径不能为空") | 48 | @NotBlank(message = "生成包路径不能为空") |
| 49 | private String packageName; | 49 | private String packageName; |
| @@ -98,7 +98,19 @@ public class GenTable extends BaseEntity | @@ -98,7 +98,19 @@ public class GenTable extends BaseEntity | ||
| 98 | /** 上级菜单名称字段 */ | 98 | /** 上级菜单名称字段 */ |
| 99 | private String parentMenuName; | 99 | private String parentMenuName; |
| 100 | 100 | ||
| 101 | - private String dataSource; | 101 | + /** |
| 102 | + * 模块路径 | ||
| 103 | + */ | ||
| 104 | + private String modlePath; | ||
| 105 | + | ||
| 106 | + | ||
| 107 | + public String getModlePath() { | ||
| 108 | + return modlePath; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public void setModlePath(String modlePath) { | ||
| 112 | + this.modlePath = modlePath; | ||
| 113 | + } | ||
| 102 | 114 | ||
| 103 | public Long getTableId() | 115 | public Long getTableId() |
| 104 | { | 116 | { |
| @@ -170,6 +182,16 @@ public class GenTable extends BaseEntity | @@ -170,6 +182,16 @@ public class GenTable extends BaseEntity | ||
| 170 | this.tplCategory = tplCategory; | 182 | this.tplCategory = tplCategory; |
| 171 | } | 183 | } |
| 172 | 184 | ||
| 185 | + public String getTplWebType() | ||
| 186 | + { | ||
| 187 | + return tplWebType; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + public void setTplWebType(String tplWebType) | ||
| 191 | + { | ||
| 192 | + this.tplWebType = tplWebType; | ||
| 193 | + } | ||
| 194 | + | ||
| 173 | public String getPackageName() | 195 | public String getPackageName() |
| 174 | { | 196 | { |
| 175 | return packageName; | 197 | return packageName; |
| @@ -374,12 +396,4 @@ public class GenTable extends BaseEntity | @@ -374,12 +396,4 @@ public class GenTable extends BaseEntity | ||
| 374 | } | 396 | } |
| 375 | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); | 397 | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); |
| 376 | } | 398 | } |
| 377 | - | ||
| 378 | - public String getDataSource() { | ||
| 379 | - return dataSource; | ||
| 380 | - } | ||
| 381 | - | ||
| 382 | - public void setDataSource(String dataSource) { | ||
| 383 | - this.dataSource = dataSource; | ||
| 384 | - } | ||
| 385 | } | 399 | } |
| @@ -3,7 +3,6 @@ package com.ruoyi.generator.domain; | @@ -3,7 +3,6 @@ package com.ruoyi.generator.domain; | ||
| 3 | import javax.validation.constraints.NotBlank; | 3 | import javax.validation.constraints.NotBlank; |
| 4 | import com.ruoyi.common.tool.BaseEntity; | 4 | import com.ruoyi.common.tool.BaseEntity; |
| 5 | import com.ruoyi.common.utils.StringUtils; | 5 | import com.ruoyi.common.utils.StringUtils; |
| 6 | -import com.ruoyi.common.annotation.PublicSQLConfig; | ||
| 7 | 6 | ||
| 8 | /** | 7 | /** |
| 9 | * 代码生成业务字段表 gen_table_column | 8 | * 代码生成业务字段表 gen_table_column |
| @@ -12,7 +11,6 @@ import com.ruoyi.common.annotation.PublicSQLConfig; | @@ -12,7 +11,6 @@ import com.ruoyi.common.annotation.PublicSQLConfig; | ||
| 12 | */ | 11 | */ |
| 13 | public class GenTableColumn extends BaseEntity | 12 | public class GenTableColumn extends BaseEntity |
| 14 | { | 13 | { |
| 15 | - @PublicSQLConfig(isSelect=false) | ||
| 16 | private static final long serialVersionUID = 1L; | 14 | private static final long serialVersionUID = 1L; |
| 17 | 15 | ||
| 18 | /** 编号 */ | 16 | /** 编号 */ |
| @@ -2,7 +2,6 @@ package com.ruoyi.generator.mapper; | @@ -2,7 +2,6 @@ package com.ruoyi.generator.mapper; | ||
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import com.ruoyi.generator.domain.GenTableColumn; | 4 | import com.ruoyi.generator.domain.GenTableColumn; |
| 5 | -import org.apache.ibatis.annotations.Mapper; | ||
| 6 | 5 | ||
| 7 | /** | 6 | /** |
| 8 | * 业务字段 数据层 | 7 | * 业务字段 数据层 |
| @@ -2,7 +2,6 @@ package com.ruoyi.generator.mapper; | @@ -2,7 +2,6 @@ package com.ruoyi.generator.mapper; | ||
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import com.ruoyi.generator.domain.GenTable; | 4 | import com.ruoyi.generator.domain.GenTable; |
| 5 | -import org.apache.ibatis.annotations.Mapper; | ||
| 6 | 5 | ||
| 7 | /** | 6 | /** |
| 8 | * 业务 数据层 | 7 | * 业务 数据层 |
| @@ -81,4 +80,12 @@ public interface GenTableMapper | @@ -81,4 +80,12 @@ public interface GenTableMapper | ||
| 81 | * @return 结果 | 80 | * @return 结果 |
| 82 | */ | 81 | */ |
| 83 | public int deleteGenTableByIds(Long[] ids); | 82 | public int deleteGenTableByIds(Long[] ids); |
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * 创建表 | ||
| 86 | + * | ||
| 87 | + * @param sql 表结构 | ||
| 88 | + * @return 结果 | ||
| 89 | + */ | ||
| 90 | + public int createTable(String sql); | ||
| 84 | } | 91 | } |
| 1 | package com.ruoyi.generator.service; | 1 | package com.ruoyi.generator.service; |
| 2 | 2 | ||
| 3 | +import java.io.ByteArrayOutputStream; | ||
| 3 | import java.util.List; | 4 | import java.util.List; |
| 5 | +import java.util.zip.ZipOutputStream; | ||
| 6 | + | ||
| 7 | +import com.ruoyi.generator.domain.GenTable; | ||
| 8 | +import org.apache.commons.io.IOUtils; | ||
| 4 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 5 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 6 | import com.ruoyi.common.core.text.Convert; | 11 | import com.ruoyi.common.core.text.Convert; |
| @@ -65,4 +70,5 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService | @@ -65,4 +70,5 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService | ||
| 65 | { | 70 | { |
| 66 | return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); | 71 | return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); |
| 67 | } | 72 | } |
| 73 | + | ||
| 68 | } | 74 | } |
| @@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream; | @@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream; | ||
| 4 | import java.io.File; | 4 | import java.io.File; |
| 5 | import java.io.IOException; | 5 | import java.io.IOException; |
| 6 | import java.io.StringWriter; | 6 | import java.io.StringWriter; |
| 7 | -import java.util.ArrayList; | ||
| 8 | import java.util.LinkedHashMap; | 7 | import java.util.LinkedHashMap; |
| 9 | import java.util.List; | 8 | import java.util.List; |
| 10 | import java.util.Map; | 9 | import java.util.Map; |
| @@ -13,10 +12,9 @@ import java.util.stream.Collectors; | @@ -13,10 +12,9 @@ import java.util.stream.Collectors; | ||
| 13 | import java.util.zip.ZipEntry; | 12 | import java.util.zip.ZipEntry; |
| 14 | import java.util.zip.ZipOutputStream; | 13 | import java.util.zip.ZipOutputStream; |
| 15 | 14 | ||
| 16 | -import com.ruoyi.generator.domain.TableVules; | ||
| 17 | -import com.ruoyi.generator.mapper.GenTableMapMapper; | ||
| 18 | -import com.zhonglai.luhui.datasource.enums.DataSource; | ||
| 19 | -import com.zhonglai.luhui.datasource.enums.DataSourceType; | 15 | +import com.alibaba.fastjson.JSON; |
| 16 | +import com.alibaba.fastjson.JSONObject; | ||
| 17 | +import com.ruoyi.common.utils.GsonConstructor; | ||
| 20 | import org.apache.commons.io.FileUtils; | 18 | import org.apache.commons.io.FileUtils; |
| 21 | import org.apache.commons.io.IOUtils; | 19 | import org.apache.commons.io.IOUtils; |
| 22 | import org.apache.velocity.Template; | 20 | import org.apache.velocity.Template; |
| @@ -27,8 +25,6 @@ import org.slf4j.LoggerFactory; | @@ -27,8 +25,6 @@ import org.slf4j.LoggerFactory; | ||
| 27 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| 28 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
| 29 | import org.springframework.transaction.annotation.Transactional; | 27 | import org.springframework.transaction.annotation.Transactional; |
| 30 | -import com.alibaba.fastjson.JSON; | ||
| 31 | -import com.alibaba.fastjson.JSONObject; | ||
| 32 | import com.ruoyi.common.constant.Constants; | 28 | import com.ruoyi.common.constant.Constants; |
| 33 | import com.ruoyi.common.constant.GenConstants; | 29 | import com.ruoyi.common.constant.GenConstants; |
| 34 | import com.ruoyi.common.core.text.CharsetKit; | 30 | import com.ruoyi.common.core.text.CharsetKit; |
| @@ -58,9 +54,6 @@ public class GenTableServiceImpl implements IGenTableService | @@ -58,9 +54,6 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 58 | @Autowired | 54 | @Autowired |
| 59 | private GenTableColumnMapper genTableColumnMapper; | 55 | private GenTableColumnMapper genTableColumnMapper; |
| 60 | 56 | ||
| 61 | - @Autowired | ||
| 62 | - private GenTableMapMapper mapMapper; | ||
| 63 | - | ||
| 64 | /** | 57 | /** |
| 65 | * 查询业务信息 | 58 | * 查询业务信息 |
| 66 | * | 59 | * |
| @@ -159,38 +152,49 @@ public class GenTableServiceImpl implements IGenTableService | @@ -159,38 +152,49 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 159 | } | 152 | } |
| 160 | 153 | ||
| 161 | /** | 154 | /** |
| 155 | + * 创建表 | ||
| 156 | + * | ||
| 157 | + * @param sql 创建表语句 | ||
| 158 | + * @return 结果 | ||
| 159 | + */ | ||
| 160 | + @Override | ||
| 161 | + public boolean createTable(String sql) | ||
| 162 | + { | ||
| 163 | + return genTableMapper.createTable(sql) == 0; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + /** | ||
| 162 | * 导入表结构 | 167 | * 导入表结构 |
| 163 | * | 168 | * |
| 164 | * @param tableList 导入表列表 | 169 | * @param tableList 导入表列表 |
| 165 | */ | 170 | */ |
| 166 | @Override | 171 | @Override |
| 167 | @Transactional | 172 | @Transactional |
| 168 | - public void importGenTable(List<GenTable> tableList) | ||
| 169 | - { | ||
| 170 | -// String operName = SecurityUtils.getUsername(); | ||
| 171 | -// try | ||
| 172 | -// { | ||
| 173 | -// for (GenTable table : tableList) | ||
| 174 | -// { | ||
| 175 | -// String tableName = table.getTableName(); | ||
| 176 | -// GenUtils.initTable(table, operName); | ||
| 177 | -// int row = genTableMapper.insertGenTable(table); | ||
| 178 | -// if (row > 0) | ||
| 179 | -// { | ||
| 180 | -// // 保存列信息 | ||
| 181 | -// List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); | ||
| 182 | -// for (GenTableColumn column : genTableColumns) | ||
| 183 | -// { | ||
| 184 | -// GenUtils.initColumnField(column, table); | ||
| 185 | -// genTableColumnMapper.insertGenTableColumn(column); | ||
| 186 | -// } | ||
| 187 | -// } | ||
| 188 | -// } | ||
| 189 | -// } | ||
| 190 | -// catch (Exception e) | ||
| 191 | -// { | ||
| 192 | -// throw new ServiceException("导入失败:" + e.getMessage()); | ||
| 193 | -// } | 173 | + public void importGenTable(List<GenTable> tableList, String operName) |
| 174 | + { | ||
| 175 | + try | ||
| 176 | + { | ||
| 177 | + for (GenTable table : tableList) | ||
| 178 | + { | ||
| 179 | + String tableName = table.getTableName(); | ||
| 180 | + GenUtils.initTable(table, operName); | ||
| 181 | + int row = genTableMapper.insertGenTable(table); | ||
| 182 | + if (row > 0) | ||
| 183 | + { | ||
| 184 | + // 保存列信息 | ||
| 185 | + List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); | ||
| 186 | + for (GenTableColumn column : genTableColumns) | ||
| 187 | + { | ||
| 188 | + GenUtils.initColumnField(column, table); | ||
| 189 | + genTableColumnMapper.insertGenTableColumn(column); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + catch (Exception e) | ||
| 195 | + { | ||
| 196 | + throw new ServiceException("导入失败:" + e.getMessage()); | ||
| 197 | + } | ||
| 194 | } | 198 | } |
| 195 | 199 | ||
| 196 | /** | 200 | /** |
| @@ -214,7 +218,7 @@ public class GenTableServiceImpl implements IGenTableService | @@ -214,7 +218,7 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 214 | VelocityContext context = VelocityUtils.prepareContext(table); | 218 | VelocityContext context = VelocityUtils.prepareContext(table); |
| 215 | 219 | ||
| 216 | // 获取模板列表 | 220 | // 获取模板列表 |
| 217 | - List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); | 221 | + List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); |
| 218 | for (String template : templates) | 222 | for (String template : templates) |
| 219 | { | 223 | { |
| 220 | // 渲染模板 | 224 | // 渲染模板 |
| @@ -252,36 +256,6 @@ public class GenTableServiceImpl implements IGenTableService | @@ -252,36 +256,6 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 252 | { | 256 | { |
| 253 | // 查询表信息 | 257 | // 查询表信息 |
| 254 | GenTable table = genTableMapper.selectGenTableByName(tableName); | 258 | GenTable table = genTableMapper.selectGenTableByName(tableName); |
| 255 | - generatorCode(table); | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | - /** | ||
| 259 | - * 从数据库结构生成代码 | ||
| 260 | - * | ||
| 261 | - * @param tableNames 表名称 | ||
| 262 | - */ | ||
| 263 | - @DataSource(value = DataSourceType.SLAVE) | ||
| 264 | - @Override | ||
| 265 | - public byte[] generatorCodeFromDb(String databaseName,String tableNames,String packageName,String dataSource) | ||
| 266 | - { | ||
| 267 | - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
| 268 | - ZipOutputStream zip = new ZipOutputStream(outputStream); | ||
| 269 | - | ||
| 270 | - for (String tableName:tableNames.split(",")) | ||
| 271 | - { | ||
| 272 | - // 查询表信息 | ||
| 273 | - GenTable table = generatorFromTablename(databaseName,tableName,packageName,dataSource); | ||
| 274 | - generatorCode(table, zip); | ||
| 275 | - } | ||
| 276 | - IOUtils.closeQuietly(zip); | ||
| 277 | - return outputStream.toByteArray(); | ||
| 278 | - | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - | ||
| 282 | - | ||
| 283 | - private void generatorCode(GenTable table) | ||
| 284 | - { | ||
| 285 | // 设置主子表信息 | 259 | // 设置主子表信息 |
| 286 | setSubTable(table); | 260 | setSubTable(table); |
| 287 | // 设置主键列信息 | 261 | // 设置主键列信息 |
| @@ -292,7 +266,7 @@ public class GenTableServiceImpl implements IGenTableService | @@ -292,7 +266,7 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 292 | VelocityContext context = VelocityUtils.prepareContext(table); | 266 | VelocityContext context = VelocityUtils.prepareContext(table); |
| 293 | 267 | ||
| 294 | // 获取模板列表 | 268 | // 获取模板列表 |
| 295 | - List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); | 269 | + List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); |
| 296 | for (String template : templates) | 270 | for (String template : templates) |
| 297 | { | 271 | { |
| 298 | if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) | 272 | if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) |
| @@ -314,97 +288,6 @@ public class GenTableServiceImpl implements IGenTableService | @@ -314,97 +288,6 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 314 | } | 288 | } |
| 315 | } | 289 | } |
| 316 | 290 | ||
| 317 | - public GenTable generatorFromTablename(String databaseName,String tableName,String packageName,String dataSource) | ||
| 318 | - { | ||
| 319 | - List<Map<String,Object>> list = mapMapper.getObjectListBySQL("SELECT COLUMN_NAME,ORDINAL_POSITION,COLUMN_DEFAULT,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,CHARACTER_OCTET_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE,DATETIME_PRECISION,CHARACTER_SET_NAME,COLLATION_NAME,COLUMN_TYPE,COLUMN_KEY,EXTRA,COLUMN_COMMENT FROM information_schema.columns WHERE table_schema = '"+databaseName+"' AND table_name = '"+tableName+"'"); | ||
| 320 | - Map<String,Object> map = mapMapper.getObjectListBySQL("SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name='"+tableName+"' AND table_schema='"+databaseName+"'").get(0); | ||
| 321 | - | ||
| 322 | - String[] tbs = tableName.split("_"); | ||
| 323 | - GenTable genTable = new GenTable(); | ||
| 324 | - genTable.setTableName(tableName); | ||
| 325 | - genTable.setTableComment(map.get("TABLE_COMMENT")+""); | ||
| 326 | - genTable.setClassName(GenUtils.convertClassName(tableName)); | ||
| 327 | - genTable.setTplCategory("crud"); | ||
| 328 | - genTable.setPackageName(packageName); | ||
| 329 | - genTable.setModuleName(tbs[0]); | ||
| 330 | - genTable.setBusinessName(genTable.getClassName()); | ||
| 331 | - genTable.setFunctionName(genTable.getTableComment()); | ||
| 332 | - genTable.setFunctionAuthor("钟来"); | ||
| 333 | - genTable.setGenType("1"); | ||
| 334 | - genTable.setGenPath("/"); | ||
| 335 | - if(StringUtils.isNotEmpty(dataSource)) | ||
| 336 | - { | ||
| 337 | - genTable.setDataSource("DataSourceType."+dataSource); | ||
| 338 | - } | ||
| 339 | - List<GenTableColumn> columns = new ArrayList<>(); | ||
| 340 | - for(Map<String,Object> table:list) | ||
| 341 | - { | ||
| 342 | - TableVules tableVules = JSONObject.parseObject(JSONObject.toJSONString(table), TableVules.class); | ||
| 343 | - GenTableColumn genTableColumn = new GenTableColumn(); | ||
| 344 | - genTableColumn.setColumnName(tableVules.getColumnName()); | ||
| 345 | - genTableColumn.setColumnComment(tableVules.getColumnComment()); | ||
| 346 | - genTableColumn.setColumnType(tableVules.getColumnType()); | ||
| 347 | - genTableColumn.setJavaType(GenUtils.toSqlToJava(tableVules.getDataType())); | ||
| 348 | - genTableColumn.setJavaField(tableVules.getColumnName()); | ||
| 349 | - genTableColumn.setIsQuery(GenConstants.REQUIRE); | ||
| 350 | - if("PRI".equals(tableVules.getColumnKey())) //主键 | ||
| 351 | - { | ||
| 352 | - genTableColumn.setIsPk("1"); | ||
| 353 | - genTable.setPkColumn(genTableColumn); | ||
| 354 | - } | ||
| 355 | - if("auto_increment".equals(tableVules.getExtra())) | ||
| 356 | - { | ||
| 357 | - genTableColumn.setIsIncrement("1"); | ||
| 358 | - }else { | ||
| 359 | - genTableColumn.setIsIncrement("0"); | ||
| 360 | - } | ||
| 361 | - if("NO".equals(tableVules.getIsNullable())) | ||
| 362 | - { | ||
| 363 | - genTableColumn.setIsRequired("1"); | ||
| 364 | - }else { | ||
| 365 | - genTableColumn.setIsRequired("0"); | ||
| 366 | - } | ||
| 367 | - switch (tableVules.getDataType()) | ||
| 368 | - { | ||
| 369 | - case "int": | ||
| 370 | - if(genTableColumn.getColumnName().indexOf("_time")>=0 ) | ||
| 371 | - { | ||
| 372 | - genTableColumn.setQueryType("BETWEEN"); | ||
| 373 | - }else{ | ||
| 374 | - genTableColumn.setQueryType("EQ"); | ||
| 375 | - } | ||
| 376 | - break; | ||
| 377 | - case "varchar": | ||
| 378 | - genTableColumn.setQueryType("LIKE"); | ||
| 379 | - break; | ||
| 380 | - case "bigint": | ||
| 381 | - genTableColumn.setQueryType("EQ"); | ||
| 382 | - break; | ||
| 383 | - case "boolean": | ||
| 384 | - genTableColumn.setQueryType("EQ"); | ||
| 385 | - break; | ||
| 386 | - case "char": | ||
| 387 | - genTableColumn.setQueryType("EQ"); | ||
| 388 | - break; | ||
| 389 | - case "date": | ||
| 390 | - genTableColumn.setQueryType("BETWEEN"); | ||
| 391 | - break; | ||
| 392 | - case "datetime": | ||
| 393 | - genTableColumn.setQueryType("BETWEEN"); | ||
| 394 | - break; | ||
| 395 | - case "enum": | ||
| 396 | - genTableColumn.setQueryType("EQ"); | ||
| 397 | - break; | ||
| 398 | - } | ||
| 399 | - | ||
| 400 | - columns.add(genTableColumn); | ||
| 401 | - } | ||
| 402 | - | ||
| 403 | - | ||
| 404 | - genTable.setColumns(columns); | ||
| 405 | - return genTable; | ||
| 406 | - } | ||
| 407 | - | ||
| 408 | /** | 291 | /** |
| 409 | * 同步数据库 | 292 | * 同步数据库 |
| 410 | * | 293 | * |
| @@ -482,48 +365,13 @@ public class GenTableServiceImpl implements IGenTableService | @@ -482,48 +365,13 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 482 | /** | 365 | /** |
| 483 | * 查询表信息并生成代码 | 366 | * 查询表信息并生成代码 |
| 484 | */ | 367 | */ |
| 485 | - private void generatorCode(String tableName, ZipOutputStream zip) | 368 | + public void generatorCode(String tableName, ZipOutputStream zip) |
| 486 | { | 369 | { |
| 487 | // 查询表信息 | 370 | // 查询表信息 |
| 488 | GenTable table = genTableMapper.selectGenTableByName(tableName); | 371 | GenTable table = genTableMapper.selectGenTableByName(tableName); |
| 489 | generatorCode(table,zip); | 372 | generatorCode(table,zip); |
| 490 | } | 373 | } |
| 491 | 374 | ||
| 492 | - private void generatorCode(GenTable table, ZipOutputStream zip) | ||
| 493 | - { | ||
| 494 | - // 设置主子表信息 | ||
| 495 | - setSubTable(table); | ||
| 496 | - // 设置主键列信息 | ||
| 497 | - setPkColumn(table); | ||
| 498 | - | ||
| 499 | - VelocityInitializer.initVelocity(); | ||
| 500 | - | ||
| 501 | - VelocityContext context = VelocityUtils.prepareContext(table); | ||
| 502 | - | ||
| 503 | - // 获取模板列表 | ||
| 504 | - List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); | ||
| 505 | - for (String template : templates) | ||
| 506 | - { | ||
| 507 | - // 渲染模板 | ||
| 508 | - StringWriter sw = new StringWriter(); | ||
| 509 | - Template tpl = Velocity.getTemplate(template, Constants.UTF8); | ||
| 510 | - tpl.merge(context, sw); | ||
| 511 | - try | ||
| 512 | - { | ||
| 513 | - // 添加到zip | ||
| 514 | - zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); | ||
| 515 | - IOUtils.write(sw.toString(), zip, Constants.UTF8); | ||
| 516 | - IOUtils.closeQuietly(sw); | ||
| 517 | - zip.flush(); | ||
| 518 | - zip.closeEntry(); | ||
| 519 | - } | ||
| 520 | - catch (IOException e) | ||
| 521 | - { | ||
| 522 | - log.error("渲染模板失败,表名:" + table.getTableName(), e); | ||
| 523 | - } | ||
| 524 | - } | ||
| 525 | - } | ||
| 526 | - | ||
| 527 | /** | 375 | /** |
| 528 | * 修改保存参数校验 | 376 | * 修改保存参数校验 |
| 529 | * | 377 | * |
| @@ -534,8 +382,8 @@ public class GenTableServiceImpl implements IGenTableService | @@ -534,8 +382,8 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 534 | { | 382 | { |
| 535 | if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) | 383 | if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) |
| 536 | { | 384 | { |
| 537 | - String options = JSON.toJSONString(genTable.getParams()); | ||
| 538 | - JSONObject paramsObj = JSONObject.parseObject(options); | 385 | + String options = GsonConstructor.get().toJson(genTable.getParams()); |
| 386 | + JSONObject paramsObj = JSON.parseObject(options); | ||
| 539 | if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) | 387 | if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) |
| 540 | { | 388 | { |
| 541 | throw new ServiceException("树编码字段不能为空"); | 389 | throw new ServiceException("树编码字段不能为空"); |
| @@ -619,7 +467,7 @@ public class GenTableServiceImpl implements IGenTableService | @@ -619,7 +467,7 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 619 | */ | 467 | */ |
| 620 | public void setTableFromOptions(GenTable genTable) | 468 | public void setTableFromOptions(GenTable genTable) |
| 621 | { | 469 | { |
| 622 | - JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); | 470 | + JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); |
| 623 | if (StringUtils.isNotNull(paramsObj)) | 471 | if (StringUtils.isNotNull(paramsObj)) |
| 624 | { | 472 | { |
| 625 | String treeCode = paramsObj.getString(GenConstants.TREE_CODE); | 473 | String treeCode = paramsObj.getString(GenConstants.TREE_CODE); |
| @@ -652,4 +500,39 @@ public class GenTableServiceImpl implements IGenTableService | @@ -652,4 +500,39 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 652 | } | 500 | } |
| 653 | return genPath + File.separator + VelocityUtils.getFileName(template, table); | 501 | return genPath + File.separator + VelocityUtils.getFileName(template, table); |
| 654 | } | 502 | } |
| 503 | + | ||
| 504 | + public void generatorCode(GenTable table, ZipOutputStream zip) | ||
| 505 | + { | ||
| 506 | + // 设置主子表信息 | ||
| 507 | + setSubTable(table); | ||
| 508 | + // 设置主键列信息 | ||
| 509 | + setPkColumn(table); | ||
| 510 | + | ||
| 511 | + VelocityInitializer.initVelocity(); | ||
| 512 | + | ||
| 513 | + VelocityContext context = VelocityUtils.prepareContext(table); | ||
| 514 | + | ||
| 515 | + // 获取模板列表 | ||
| 516 | + List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); | ||
| 517 | + for (String template : templates) | ||
| 518 | + { | ||
| 519 | + // 渲染模板 | ||
| 520 | + StringWriter sw = new StringWriter(); | ||
| 521 | + Template tpl = Velocity.getTemplate(template, Constants.UTF8); | ||
| 522 | + tpl.merge(context, sw); | ||
| 523 | + try | ||
| 524 | + { | ||
| 525 | + // 添加到zip | ||
| 526 | + zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); | ||
| 527 | + IOUtils.write(sw.toString(), zip, Constants.UTF8); | ||
| 528 | + IOUtils.closeQuietly(sw); | ||
| 529 | + zip.flush(); | ||
| 530 | + zip.closeEntry(); | ||
| 531 | + } | ||
| 532 | + catch (IOException e) | ||
| 533 | + { | ||
| 534 | + log.error("渲染模板失败,表名:" + table.getTableName(), e); | ||
| 535 | + } | ||
| 536 | + } | ||
| 537 | + } | ||
| 655 | } | 538 | } |
| @@ -67,11 +67,20 @@ public interface IGenTableService | @@ -67,11 +67,20 @@ public interface IGenTableService | ||
| 67 | public void deleteGenTableByIds(Long[] tableIds); | 67 | public void deleteGenTableByIds(Long[] tableIds); |
| 68 | 68 | ||
| 69 | /** | 69 | /** |
| 70 | + * 创建表 | ||
| 71 | + * | ||
| 72 | + * @param sql 创建表语句 | ||
| 73 | + * @return 结果 | ||
| 74 | + */ | ||
| 75 | + public boolean createTable(String sql); | ||
| 76 | + | ||
| 77 | + /** | ||
| 70 | * 导入表结构 | 78 | * 导入表结构 |
| 71 | * | 79 | * |
| 72 | * @param tableList 导入表列表 | 80 | * @param tableList 导入表列表 |
| 81 | + * @param operName 操作人员 | ||
| 73 | */ | 82 | */ |
| 74 | - public void importGenTable(List<GenTable> tableList); | 83 | + public void importGenTable(List<GenTable> tableList, String operName); |
| 75 | 84 | ||
| 76 | /** | 85 | /** |
| 77 | * 预览代码 | 86 | * 预览代码 |
| @@ -118,11 +127,4 @@ public interface IGenTableService | @@ -118,11 +127,4 @@ public interface IGenTableService | ||
| 118 | * @param genTable 业务信息 | 127 | * @param genTable 业务信息 |
| 119 | */ | 128 | */ |
| 120 | public void validateEdit(GenTable genTable); | 129 | public void validateEdit(GenTable genTable); |
| 121 | - | ||
| 122 | - /** | ||
| 123 | - * 从数据库结构生成代码 | ||
| 124 | - * | ||
| 125 | - * @param tableName 表名称 | ||
| 126 | - */ | ||
| 127 | - public byte[] generatorCodeFromDb(String databaseName,String tableName,String packageName,String dataSource); | ||
| 128 | } | 130 | } |
| @@ -22,7 +22,7 @@ public class GenUtils | @@ -22,7 +22,7 @@ public class GenUtils | ||
| 22 | { | 22 | { |
| 23 | genTable.setClassName(convertClassName(genTable.getTableName())); | 23 | genTable.setClassName(convertClassName(genTable.getTableName())); |
| 24 | genTable.setPackageName(GenConfig.getPackageName()); | 24 | genTable.setPackageName(GenConfig.getPackageName()); |
| 25 | - genTable.setModuleName(getModuleName(GenConfig.getPackageName())); | 25 | + genTable.setModuleName(getModuleName(genTable.getTableName())); |
| 26 | genTable.setBusinessName(getBusinessName(genTable.getTableName())); | 26 | genTable.setBusinessName(getBusinessName(genTable.getTableName())); |
| 27 | genTable.setFunctionName(replaceText(genTable.getTableComment())); | 27 | genTable.setFunctionName(replaceText(genTable.getTableComment())); |
| 28 | genTable.setFunctionAuthor(GenConfig.getAuthor()); | 28 | genTable.setFunctionAuthor(GenConfig.getAuthor()); |
| @@ -70,6 +70,9 @@ public class GenUtils | @@ -70,6 +70,9 @@ public class GenUtils | ||
| 70 | else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) | 70 | else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) |
| 71 | { | 71 | { |
| 72 | column.setJavaType(GenConstants.TYPE_INTEGER); | 72 | column.setJavaType(GenConstants.TYPE_INTEGER); |
| 73 | + }else if(column.getColumnType().equals("int")) | ||
| 74 | + { | ||
| 75 | + column.setJavaType(GenConstants.TYPE_INTEGER); | ||
| 73 | } | 76 | } |
| 74 | // 长整形 | 77 | // 长整形 |
| 75 | else | 78 | else |
| @@ -150,9 +153,7 @@ public class GenUtils | @@ -150,9 +153,7 @@ public class GenUtils | ||
| 150 | */ | 153 | */ |
| 151 | public static String getModuleName(String packageName) | 154 | public static String getModuleName(String packageName) |
| 152 | { | 155 | { |
| 153 | - int lastIndex = packageName.lastIndexOf("."); | ||
| 154 | - int nameLength = packageName.length(); | ||
| 155 | - return StringUtils.substring(packageName, lastIndex + 1, nameLength); | 156 | + return packageName.split("_")[0]; |
| 156 | } | 157 | } |
| 157 | 158 | ||
| 158 | /** | 159 | /** |
| @@ -163,9 +164,7 @@ public class GenUtils | @@ -163,9 +164,7 @@ public class GenUtils | ||
| 163 | */ | 164 | */ |
| 164 | public static String getBusinessName(String tableName) | 165 | public static String getBusinessName(String tableName) |
| 165 | { | 166 | { |
| 166 | - int lastIndex = tableName.lastIndexOf("_"); | ||
| 167 | - int nameLength = tableName.length(); | ||
| 168 | - return StringUtils.substring(tableName, lastIndex + 1, nameLength); | 167 | + return tableName.substring(tableName.indexOf("_")+1); |
| 169 | } | 168 | } |
| 170 | 169 | ||
| 171 | /** | 170 | /** |
| @@ -275,7 +274,7 @@ public class GenUtils | @@ -275,7 +274,7 @@ public class GenUtils | ||
| 275 | case "smallint":return "Integer"; | 274 | case "smallint":return "Integer"; |
| 276 | case "mediumint":return "Integer"; | 275 | case "mediumint":return "Integer"; |
| 277 | case "bit":return "Boolean"; | 276 | case "bit":return "Boolean"; |
| 278 | - case "bigint":return "java.math.BigInteger"; | 277 | + case "bigint":return "java.math.Long"; |
| 279 | case "float":return "Float"; | 278 | case "float":return "Float"; |
| 280 | case "double":return "Double"; | 279 | case "double":return "Double"; |
| 281 | case "decimal":return "java.math.BigDecimal"; | 280 | case "decimal":return "java.math.BigDecimal"; |
| @@ -295,6 +294,7 @@ public class GenUtils | @@ -295,6 +294,7 @@ public class GenUtils | ||
| 295 | case "longblob":return "String"; | 294 | case "longblob":return "String"; |
| 296 | case "mediumtext":return "String"; | 295 | case "mediumtext":return "String"; |
| 297 | case "enum":return "Enum"; | 296 | case "enum":return "Enum"; |
| 297 | + case "json":return "com.alibaba.fastjson2.JSONObject"; | ||
| 298 | default: | 298 | default: |
| 299 | System.out.println("-----------------》转化失败:未发现的类型"+sqlType); | 299 | System.out.println("-----------------》转化失败:未发现的类型"+sqlType); |
| 300 | break; | 300 | break; |
| @@ -4,8 +4,10 @@ import java.util.ArrayList; | @@ -4,8 +4,10 @@ import java.util.ArrayList; | ||
| 4 | import java.util.HashSet; | 4 | import java.util.HashSet; |
| 5 | import java.util.List; | 5 | import java.util.List; |
| 6 | import java.util.Set; | 6 | import java.util.Set; |
| 7 | -import org.apache.velocity.VelocityContext; | 7 | + |
| 8 | +import com.alibaba.fastjson.JSON; | ||
| 8 | import com.alibaba.fastjson.JSONObject; | 9 | import com.alibaba.fastjson.JSONObject; |
| 10 | +import org.apache.velocity.VelocityContext; | ||
| 9 | import com.ruoyi.common.constant.GenConstants; | 11 | import com.ruoyi.common.constant.GenConstants; |
| 10 | import com.ruoyi.common.utils.DateUtils; | 12 | import com.ruoyi.common.utils.DateUtils; |
| 11 | import com.ruoyi.common.utils.StringUtils; | 13 | import com.ruoyi.common.utils.StringUtils; |
| @@ -40,6 +42,7 @@ public class VelocityUtils | @@ -40,6 +42,7 @@ public class VelocityUtils | ||
| 40 | String packageName = genTable.getPackageName(); | 42 | String packageName = genTable.getPackageName(); |
| 41 | String tplCategory = genTable.getTplCategory(); | 43 | String tplCategory = genTable.getTplCategory(); |
| 42 | String functionName = genTable.getFunctionName(); | 44 | String functionName = genTable.getFunctionName(); |
| 45 | + String modlePath = genTable.getModlePath(); | ||
| 43 | 46 | ||
| 44 | VelocityContext velocityContext = new VelocityContext(); | 47 | VelocityContext velocityContext = new VelocityContext(); |
| 45 | velocityContext.put("tplCategory", genTable.getTplCategory()); | 48 | velocityContext.put("tplCategory", genTable.getTplCategory()); |
| @@ -56,11 +59,11 @@ public class VelocityUtils | @@ -56,11 +59,11 @@ public class VelocityUtils | ||
| 56 | velocityContext.put("datetime", DateUtils.getDate()); | 59 | velocityContext.put("datetime", DateUtils.getDate()); |
| 57 | velocityContext.put("pkColumn", genTable.getPkColumn()); | 60 | velocityContext.put("pkColumn", genTable.getPkColumn()); |
| 58 | velocityContext.put("importList", getImportList(genTable)); | 61 | velocityContext.put("importList", getImportList(genTable)); |
| 59 | - velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); | 62 | + velocityContext.put("permissionPrefix", getPermissionPrefix(modlePath,moduleName, businessName)); |
| 60 | velocityContext.put("columns", genTable.getColumns()); | 63 | velocityContext.put("columns", genTable.getColumns()); |
| 61 | velocityContext.put("table", genTable); | 64 | velocityContext.put("table", genTable); |
| 62 | velocityContext.put("dicts", getDicts(genTable)); | 65 | velocityContext.put("dicts", getDicts(genTable)); |
| 63 | - velocityContext.put("dataSource", genTable.getDataSource()); | 66 | + velocityContext.put("modlePath", modlePath); |
| 64 | setMenuVelocityContext(velocityContext, genTable); | 67 | setMenuVelocityContext(velocityContext, genTable); |
| 65 | if (GenConstants.TPL_TREE.equals(tplCategory)) | 68 | if (GenConstants.TPL_TREE.equals(tplCategory)) |
| 66 | { | 69 | { |
| @@ -76,7 +79,7 @@ public class VelocityUtils | @@ -76,7 +79,7 @@ public class VelocityUtils | ||
| 76 | public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) | 79 | public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) |
| 77 | { | 80 | { |
| 78 | String options = genTable.getOptions(); | 81 | String options = genTable.getOptions(); |
| 79 | - JSONObject paramsObj = JSONObject.parseObject(options); | 82 | + JSONObject paramsObj = JSON.parseObject(options); |
| 80 | String parentMenuId = getParentMenuId(paramsObj); | 83 | String parentMenuId = getParentMenuId(paramsObj); |
| 81 | context.put("parentMenuId", parentMenuId); | 84 | context.put("parentMenuId", parentMenuId); |
| 82 | } | 85 | } |
| @@ -84,7 +87,7 @@ public class VelocityUtils | @@ -84,7 +87,7 @@ public class VelocityUtils | ||
| 84 | public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) | 87 | public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) |
| 85 | { | 88 | { |
| 86 | String options = genTable.getOptions(); | 89 | String options = genTable.getOptions(); |
| 87 | - JSONObject paramsObj = JSONObject.parseObject(options); | 90 | + JSONObject paramsObj = JSON.parseObject(options); |
| 88 | String treeCode = getTreecode(paramsObj); | 91 | String treeCode = getTreecode(paramsObj); |
| 89 | String treeParentCode = getTreeParentCode(paramsObj); | 92 | String treeParentCode = getTreeParentCode(paramsObj); |
| 90 | String treeName = getTreeName(paramsObj); | 93 | String treeName = getTreeName(paramsObj); |
| @@ -123,31 +126,37 @@ public class VelocityUtils | @@ -123,31 +126,37 @@ public class VelocityUtils | ||
| 123 | 126 | ||
| 124 | /** | 127 | /** |
| 125 | * 获取模板信息 | 128 | * 获取模板信息 |
| 126 | - * | 129 | + * @param tplCategory 生成的模板 |
| 130 | + * @param tplWebType 前端类型 | ||
| 127 | * @return 模板列表 | 131 | * @return 模板列表 |
| 128 | */ | 132 | */ |
| 129 | - public static List<String> getTemplateList(String tplCategory) | 133 | + public static List<String> getTemplateList(String tplCategory, String tplWebType) |
| 130 | { | 134 | { |
| 135 | + String useWebType = "vm/vue"; | ||
| 136 | + if ("element-plus".equals(tplWebType)) | ||
| 137 | + { | ||
| 138 | + useWebType = "vm/vue/v3"; | ||
| 139 | + } | ||
| 131 | List<String> templates = new ArrayList<String>(); | 140 | List<String> templates = new ArrayList<String>(); |
| 132 | templates.add("vm/java/domain.java.vm"); | 141 | templates.add("vm/java/domain.java.vm"); |
| 133 | - templates.add("vm/java/mapper.java.vm"); | ||
| 134 | - templates.add("vm/java/service.java.vm"); | ||
| 135 | - templates.add("vm/java/serviceImpl.java.vm"); | 142 | +// templates.add("vm/java/mapper.java.vm"); |
| 143 | +// templates.add("vm/java/service.java.vm"); | ||
| 144 | +// templates.add("vm/java/serviceImpl.java.vm"); | ||
| 136 | templates.add("vm/java/controller.java.vm"); | 145 | templates.add("vm/java/controller.java.vm"); |
| 137 | - templates.add("vm/xml/mapper.xml.vm"); | 146 | +// templates.add("vm/xml/mapper.xml.vm"); |
| 138 | templates.add("vm/sql/sql.vm"); | 147 | templates.add("vm/sql/sql.vm"); |
| 139 | templates.add("vm/js/api.js.vm"); | 148 | templates.add("vm/js/api.js.vm"); |
| 140 | if (GenConstants.TPL_CRUD.equals(tplCategory)) | 149 | if (GenConstants.TPL_CRUD.equals(tplCategory)) |
| 141 | { | 150 | { |
| 142 | - templates.add("vm/vue/index.vue.vm"); | 151 | + templates.add(useWebType + "/index.vue.vm"); |
| 143 | } | 152 | } |
| 144 | else if (GenConstants.TPL_TREE.equals(tplCategory)) | 153 | else if (GenConstants.TPL_TREE.equals(tplCategory)) |
| 145 | { | 154 | { |
| 146 | - templates.add("vm/vue/index-tree.vue.vm"); | 155 | + templates.add(useWebType + "/index-tree.vue.vm"); |
| 147 | } | 156 | } |
| 148 | else if (GenConstants.TPL_SUB.equals(tplCategory)) | 157 | else if (GenConstants.TPL_SUB.equals(tplCategory)) |
| 149 | { | 158 | { |
| 150 | - templates.add("vm/vue/index.vue.vm"); | 159 | + templates.add(useWebType + "/index.vue.vm"); |
| 151 | templates.add("vm/java/sub-domain.java.vm"); | 160 | templates.add("vm/java/sub-domain.java.vm"); |
| 152 | } | 161 | } |
| 153 | return templates; | 162 | return templates; |
| @@ -169,17 +178,20 @@ public class VelocityUtils | @@ -169,17 +178,20 @@ public class VelocityUtils | ||
| 169 | // 业务名称 | 178 | // 业务名称 |
| 170 | String businessName = genTable.getBusinessName(); | 179 | String businessName = genTable.getBusinessName(); |
| 171 | 180 | ||
| 181 | + //业务项目的路径 | ||
| 182 | + String modlePath = genTable.getModlePath(); | ||
| 183 | + | ||
| 172 | String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); | 184 | String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); |
| 173 | String mybatisPath = MYBATIS_PATH + "/" + moduleName; | 185 | String mybatisPath = MYBATIS_PATH + "/" + moduleName; |
| 174 | String vuePath = "vue"; | 186 | String vuePath = "vue"; |
| 175 | 187 | ||
| 176 | if (template.contains("domain.java.vm")) | 188 | if (template.contains("domain.java.vm")) |
| 177 | { | 189 | { |
| 178 | - fileName = StringUtils.format("{}/domain/{}.java", javaPath, className); | 190 | + fileName = StringUtils.format("{}/domain/{}/{}.java", javaPath,moduleName, className); |
| 179 | } | 191 | } |
| 180 | if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) | 192 | if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) |
| 181 | { | 193 | { |
| 182 | - fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); | 194 | + fileName = StringUtils.format("{}/domain/{}/{}.java", javaPath, moduleName,genTable.getSubTable().getClassName()); |
| 183 | } | 195 | } |
| 184 | else if (template.contains("mapper.java.vm")) | 196 | else if (template.contains("mapper.java.vm")) |
| 185 | { | 197 | { |
| @@ -195,7 +207,7 @@ public class VelocityUtils | @@ -195,7 +207,7 @@ public class VelocityUtils | ||
| 195 | } | 207 | } |
| 196 | else if (template.contains("controller.java.vm")) | 208 | else if (template.contains("controller.java.vm")) |
| 197 | { | 209 | { |
| 198 | - fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); | 210 | + fileName = StringUtils.format("{}/{}/controller/{}/{}Controller.java", javaPath,modlePath,moduleName, className); |
| 199 | } | 211 | } |
| 200 | else if (template.contains("mapper.xml.vm")) | 212 | else if (template.contains("mapper.xml.vm")) |
| 201 | { | 213 | { |
| @@ -307,9 +319,9 @@ public class VelocityUtils | @@ -307,9 +319,9 @@ public class VelocityUtils | ||
| 307 | * @param businessName 业务名称 | 319 | * @param businessName 业务名称 |
| 308 | * @return 返回权限前缀 | 320 | * @return 返回权限前缀 |
| 309 | */ | 321 | */ |
| 310 | - public static String getPermissionPrefix(String moduleName, String businessName) | 322 | + public static String getPermissionPrefix(String modlePath,String moduleName, String businessName) |
| 311 | { | 323 | { |
| 312 | - return StringUtils.format("{}:{}", moduleName, businessName); | 324 | + return StringUtils.format("{}:{}:{}",modlePath, moduleName, businessName); |
| 313 | } | 325 | } |
| 314 | 326 | ||
| 315 | /** | 327 | /** |
| @@ -382,7 +394,7 @@ public class VelocityUtils | @@ -382,7 +394,7 @@ public class VelocityUtils | ||
| 382 | public static int getExpandColumn(GenTable genTable) | 394 | public static int getExpandColumn(GenTable genTable) |
| 383 | { | 395 | { |
| 384 | String options = genTable.getOptions(); | 396 | String options = genTable.getOptions(); |
| 385 | - JSONObject paramsObj = JSONObject.parseObject(options); | 397 | + JSONObject paramsObj = JSON.parseObject(options); |
| 386 | String treeName = paramsObj.getString(GenConstants.TREE_NAME); | 398 | String treeName = paramsObj.getString(GenConstants.TREE_NAME); |
| 387 | int num = 0; | 399 | int num = 0; |
| 388 | for (GenTableColumn column : genTable.getColumns()) | 400 | for (GenTableColumn column : genTable.getColumns()) |
| 1 | # 代码生成 | 1 | # 代码生成 |
| 2 | gen: | 2 | gen: |
| 3 | # 作者 | 3 | # 作者 |
| 4 | - author: ruoyi | 4 | + author: zhonglai |
| 5 | # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool | 5 | # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool |
| 6 | - packageName: com.ruoyi.system | 6 | + packageName: com.zhonglai.luhui |
| 7 | # 自动去除表前缀,默认是false | 7 | # 自动去除表前缀,默认是false |
| 8 | autoRemovePre: false | 8 | autoRemovePre: false |
| 9 | -# # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) | 9 | + # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) |
| 10 | tablePrefix: sys_ | 10 | tablePrefix: sys_ |
| @@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 40 | </select> | 40 | </select> |
| 41 | 41 | ||
| 42 | <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> | 42 | <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> |
| 43 | - select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type | 43 | + select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type |
| 44 | from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) | 44 | from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) |
| 45 | order by ordinal_position | 45 | order by ordinal_position |
| 46 | </select> | 46 | </select> |
| @@ -92,19 +92,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -92,19 +92,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 92 | <update id="updateGenTableColumn" parameterType="GenTableColumn"> | 92 | <update id="updateGenTableColumn" parameterType="GenTableColumn"> |
| 93 | update gen_table_column | 93 | update gen_table_column |
| 94 | <set> | 94 | <set> |
| 95 | - column_comment = #{columnComment}, | ||
| 96 | - java_type = #{javaType}, | ||
| 97 | - java_field = #{javaField}, | ||
| 98 | - is_insert = #{isInsert}, | ||
| 99 | - is_edit = #{isEdit}, | ||
| 100 | - is_list = #{isList}, | ||
| 101 | - is_query = #{isQuery}, | ||
| 102 | - is_required = #{isRequired}, | ||
| 103 | - query_type = #{queryType}, | ||
| 104 | - html_type = #{htmlType}, | ||
| 105 | - dict_type = #{dictType}, | ||
| 106 | - sort = #{sort}, | ||
| 107 | - update_by = #{updateBy}, | 95 | + <if test="columnComment != null">column_comment = #{columnComment},</if> |
| 96 | + <if test="javaType != null">java_type = #{javaType},</if> | ||
| 97 | + <if test="javaField != null">java_field = #{javaField},</if> | ||
| 98 | + <if test="isInsert != null">is_insert = #{isInsert},</if> | ||
| 99 | + <if test="isEdit != null">is_edit = #{isEdit},</if> | ||
| 100 | + <if test="isList != null">is_list = #{isList},</if> | ||
| 101 | + <if test="isQuery != null">is_query = #{isQuery},</if> | ||
| 102 | + <if test="isRequired != null">is_required = #{isRequired},</if> | ||
| 103 | + <if test="queryType != null">query_type = #{queryType},</if> | ||
| 104 | + <if test="htmlType != null">html_type = #{htmlType},</if> | ||
| 105 | + <if test="dictType != null">dict_type = #{dictType},</if> | ||
| 106 | + <if test="sort != null">sort = #{sort},</if> | ||
| 107 | + <if test="updateBy != null">update_by = #{updateBy},</if> | ||
| 108 | update_time = sysdate() | 108 | update_time = sysdate() |
| 109 | </set> | 109 | </set> |
| 110 | where column_id = #{columnId} | 110 | where column_id = #{columnId} |
| @@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 12 | <result property="subTableFkName" column="sub_table_fk_name" /> | 12 | <result property="subTableFkName" column="sub_table_fk_name" /> |
| 13 | <result property="className" column="class_name" /> | 13 | <result property="className" column="class_name" /> |
| 14 | <result property="tplCategory" column="tpl_category" /> | 14 | <result property="tplCategory" column="tpl_category" /> |
| 15 | + <result property="tplWebType" column="tpl_web_type" /> | ||
| 15 | <result property="packageName" column="package_name" /> | 16 | <result property="packageName" column="package_name" /> |
| 16 | <result property="moduleName" column="module_name" /> | 17 | <result property="moduleName" column="module_name" /> |
| 17 | <result property="businessName" column="business_name" /> | 18 | <result property="businessName" column="business_name" /> |
| @@ -54,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -54,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 54 | </resultMap> | 55 | </resultMap> |
| 55 | 56 | ||
| 56 | <sql id="selectGenTableVo"> | 57 | <sql id="selectGenTableVo"> |
| 57 | - select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table | 58 | + select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table |
| 58 | </sql> | 59 | </sql> |
| 59 | 60 | ||
| 60 | <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> | 61 | <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> |
| @@ -111,7 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -111,7 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 111 | </select> | 112 | </select> |
| 112 | 113 | ||
| 113 | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> | 114 | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> |
| 114 | - SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, | 115 | + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| 115 | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort | 116 | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| 116 | FROM gen_table t | 117 | FROM gen_table t |
| 117 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id | 118 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| @@ -119,7 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -119,7 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 119 | </select> | 120 | </select> |
| 120 | 121 | ||
| 121 | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> | 122 | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> |
| 122 | - SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, | 123 | + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| 123 | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort | 124 | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| 124 | FROM gen_table t | 125 | FROM gen_table t |
| 125 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id | 126 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| @@ -127,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -127,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 127 | </select> | 128 | </select> |
| 128 | 129 | ||
| 129 | <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> | 130 | <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> |
| 130 | - SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, | 131 | + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, |
| 131 | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort | 132 | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| 132 | FROM gen_table t | 133 | FROM gen_table t |
| 133 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id | 134 | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| @@ -140,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -140,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 140 | <if test="tableComment != null and tableComment != ''">table_comment,</if> | 141 | <if test="tableComment != null and tableComment != ''">table_comment,</if> |
| 141 | <if test="className != null and className != ''">class_name,</if> | 142 | <if test="className != null and className != ''">class_name,</if> |
| 142 | <if test="tplCategory != null and tplCategory != ''">tpl_category,</if> | 143 | <if test="tplCategory != null and tplCategory != ''">tpl_category,</if> |
| 144 | + <if test="tplWebType != null and tplWebType != ''">tpl_web_type,</if> | ||
| 143 | <if test="packageName != null and packageName != ''">package_name,</if> | 145 | <if test="packageName != null and packageName != ''">package_name,</if> |
| 144 | <if test="moduleName != null and moduleName != ''">module_name,</if> | 146 | <if test="moduleName != null and moduleName != ''">module_name,</if> |
| 145 | <if test="businessName != null and businessName != ''">business_name,</if> | 147 | <if test="businessName != null and businessName != ''">business_name,</if> |
| @@ -155,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -155,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 155 | <if test="tableComment != null and tableComment != ''">#{tableComment},</if> | 157 | <if test="tableComment != null and tableComment != ''">#{tableComment},</if> |
| 156 | <if test="className != null and className != ''">#{className},</if> | 158 | <if test="className != null and className != ''">#{className},</if> |
| 157 | <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if> | 159 | <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if> |
| 160 | + <if test="tplWebType != null and tplWebType != ''">#{tplWebType},</if> | ||
| 158 | <if test="packageName != null and packageName != ''">#{packageName},</if> | 161 | <if test="packageName != null and packageName != ''">#{packageName},</if> |
| 159 | <if test="moduleName != null and moduleName != ''">#{moduleName},</if> | 162 | <if test="moduleName != null and moduleName != ''">#{moduleName},</if> |
| 160 | <if test="businessName != null and businessName != ''">#{businessName},</if> | 163 | <if test="businessName != null and businessName != ''">#{businessName},</if> |
| @@ -168,6 +171,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -168,6 +171,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 168 | ) | 171 | ) |
| 169 | </insert> | 172 | </insert> |
| 170 | 173 | ||
| 174 | + <update id="createTable"> | ||
| 175 | + ${sql} | ||
| 176 | + </update> | ||
| 177 | + | ||
| 171 | <update id="updateGenTable" parameterType="GenTable"> | 178 | <update id="updateGenTable" parameterType="GenTable"> |
| 172 | update gen_table | 179 | update gen_table |
| 173 | <set> | 180 | <set> |
| @@ -180,6 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -180,6 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 180 | <if test="genType != null and genType != ''">gen_type = #{genType},</if> | 187 | <if test="genType != null and genType != ''">gen_type = #{genType},</if> |
| 181 | <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if> | 188 | <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if> |
| 182 | <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> | 189 | <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> |
| 190 | + <if test="tplWebType != null and tplWebType != ''">tpl_web_type = #{tplWebType},</if> | ||
| 183 | <if test="packageName != null and packageName != ''">package_name = #{packageName},</if> | 191 | <if test="packageName != null and packageName != ''">package_name = #{packageName},</if> |
| 184 | <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if> | 192 | <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if> |
| 185 | <if test="businessName != null and businessName != ''">business_name = #{businessName},</if> | 193 | <if test="businessName != null and businessName != ''">business_name = #{businessName},</if> |
| 1 | -package ${packageName}.controller; | 1 | +package ${packageName}.${modlePath}.controller.${moduleName}; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | +import com.ruoyi.common.annotation.DataSource; | ||
| 5 | +import com.ruoyi.common.enums.DataSourceType; | ||
| 4 | import javax.servlet.http.HttpServletResponse; | 6 | import javax.servlet.http.HttpServletResponse; |
| 5 | - | ||
| 6 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| 7 | import io.swagger.annotations.ApiOperation; | 8 | import io.swagger.annotations.ApiOperation; |
| 8 | -##import org.springframework.security.access.prepost.PreAuthorize; | 9 | +import org.springframework.security.access.prepost.PreAuthorize; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.web.bind.annotation.GetMapping; | 11 | import org.springframework.web.bind.annotation.GetMapping; |
| 11 | import org.springframework.web.bind.annotation.PostMapping; | 12 | import org.springframework.web.bind.annotation.PostMapping; |
| @@ -19,9 +20,10 @@ import com.ruoyi.common.annotation.Log; | @@ -19,9 +20,10 @@ import com.ruoyi.common.annotation.Log; | ||
| 19 | import com.zhonglai.luhui.action.BaseController; | 20 | import com.zhonglai.luhui.action.BaseController; |
| 20 | import com.ruoyi.common.core.domain.AjaxResult; | 21 | import com.ruoyi.common.core.domain.AjaxResult; |
| 21 | import com.ruoyi.common.enums.BusinessType; | 22 | import com.ruoyi.common.enums.BusinessType; |
| 22 | -import ${packageName}.domain.${ClassName}; | ||
| 23 | -import ${packageName}.service.I${ClassName}Service; | ||
| 24 | -##import com.zhonglai.luhui.sys.utils.ExcelUtil; | 23 | +import com.zhonglai.luhui.dao.service.PublicTemplateService; |
| 24 | +import ${packageName}.domain.${moduleName}.${ClassName}; | ||
| 25 | +import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 26 | + | ||
| 25 | #if($table.crud || $table.sub) | 27 | #if($table.crud || $table.sub) |
| 26 | import com.ruoyi.common.core.page.TableDataInfo; | 28 | import com.ruoyi.common.core.page.TableDataInfo; |
| 27 | #elseif($table.tree) | 29 | #elseif($table.tree) |
| @@ -35,91 +37,89 @@ import com.ruoyi.common.core.page.TableDataInfo; | @@ -35,91 +37,89 @@ import com.ruoyi.common.core.page.TableDataInfo; | ||
| 35 | */ | 37 | */ |
| 36 | @Api(tags = "${functionName}") | 38 | @Api(tags = "${functionName}") |
| 37 | @RestController | 39 | @RestController |
| 38 | -@RequestMapping("/${moduleName}/${businessName}") | 40 | +@RequestMapping("/${modlePath}/${moduleName}/${businessName}") |
| 39 | public class ${ClassName}Controller extends BaseController | 41 | public class ${ClassName}Controller extends BaseController |
| 40 | { | 42 | { |
| 41 | @Autowired | 43 | @Autowired |
| 42 | - private I${ClassName}Service ${className}Service; | 44 | + private PublicTemplateService publicTemplateService; |
| 43 | 45 | ||
| 44 | - /** | ||
| 45 | - * 查询${functionName}列表 | ||
| 46 | - */ | ||
| 47 | - @ApiOperation("查询${functionName}列表") | ||
| 48 | -## @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") | 46 | + @ApiOperation(value ="查询${functionName}列表",notes="\n" + |
| 47 | + "公共参数描述:\n" + | ||
| 48 | + "条件参数:\n" + | ||
| 49 | + "timeMap; //时间条件(如:{\"create_time\":[开始时间,结束时间]})\n" + | ||
| 50 | + "keyValue; //模糊匹配的关键字(如:[\"value\",\"name,no\"])\n" + | ||
| 51 | + "queryParams; //字段对应的比较符号(如:{\"id\":\"EQ\"})\n" + | ||
| 52 | + "orderBy; //排序(如:\"id desc,name asc\")\n" + | ||
| 53 | + "\n" + | ||
| 54 | + "分页参数:\n" + | ||
| 55 | + "pageNum; //当前记录起始索引,从1开始\n" + | ||
| 56 | + "pageSize; //每页显示记录数") | ||
| 57 | + @DataSource(DataSourceType.SLAVE) | ||
| 58 | + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") | ||
| 49 | @GetMapping("/list") | 59 | @GetMapping("/list") |
| 50 | #if($table.crud || $table.sub) | 60 | #if($table.crud || $table.sub) |
| 51 | public TableDataInfo list(${ClassName} ${className}) | 61 | public TableDataInfo list(${ClassName} ${className}) |
| 52 | { | 62 | { |
| 53 | startPage(); | 63 | startPage(); |
| 54 | - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); | 64 | + List<${ClassName}> list = publicTemplateService.selectTList(${className}); |
| 55 | return getDataTable(list); | 65 | return getDataTable(list); |
| 56 | } | 66 | } |
| 57 | #elseif($table.tree) | 67 | #elseif($table.tree) |
| 58 | public AjaxResult list(${ClassName} ${className}) | 68 | public AjaxResult list(${ClassName} ${className}) |
| 59 | { | 69 | { |
| 60 | - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); | ||
| 61 | - return AjaxResult.success(list); | 70 | + List<${ClassName}> list = publicTemplateService.selectTList(${className}); |
| 71 | + return success(list); | ||
| 62 | } | 72 | } |
| 63 | #end | 73 | #end |
| 64 | 74 | ||
| 65 | -## /** | ||
| 66 | -## * 导出${functionName}列表 | ||
| 67 | -## */ | ||
| 68 | -## @ApiOperation("导出${functionName}列表") | ||
| 69 | -#### @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") | ||
| 70 | -## @Log(title = "${functionName}", businessType = BusinessType.EXPORT) | ||
| 71 | -## @PostMapping("/export") | ||
| 72 | -## public void export(HttpServletResponse response, ${ClassName} ${className}) | ||
| 73 | -## { | ||
| 74 | -## List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); | ||
| 75 | -## ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); | ||
| 76 | -## util.exportExcel(response, list, "${functionName}数据"); | ||
| 77 | -## } | 75 | + @ApiOperation("导出${functionName}列表") |
| 76 | + @DataSource(DataSourceType.SLAVE) | ||
| 77 | + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") | ||
| 78 | + @Log(title = "${functionName}", businessType = BusinessType.EXPORT) | ||
| 79 | + @PostMapping("/export") | ||
| 80 | + public void export(HttpServletResponse response, ${ClassName} ${className}) | ||
| 81 | + { | ||
| 82 | + List<${ClassName}> list = publicTemplateService.selectTList(${className}); | ||
| 83 | + ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); | ||
| 84 | + util.exportExcel(response, list, "${functionName}数据"); | ||
| 85 | + } | ||
| 78 | 86 | ||
| 79 | - /** | ||
| 80 | - * 获取${functionName}详细信息 | ||
| 81 | - */ | ||
| 82 | @ApiOperation("获取${functionName}详细信息") | 87 | @ApiOperation("获取${functionName}详细信息") |
| 83 | -## @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") | 88 | + @DataSource(DataSourceType.SLAVE) |
| 89 | + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") | ||
| 84 | @GetMapping(value = "/{${pkColumn.javaField}}") | 90 | @GetMapping(value = "/{${pkColumn.javaField}}") |
| 85 | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) | 91 | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) |
| 86 | { | 92 | { |
| 87 | - return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); | 93 | + return success(publicTemplateService.getTById(${pkColumn.javaField}, ${ClassName}.class)); |
| 88 | } | 94 | } |
| 89 | 95 | ||
| 90 | - /** | ||
| 91 | - * 新增${functionName} | ||
| 92 | - */ | ||
| 93 | @ApiOperation("新增${functionName}") | 96 | @ApiOperation("新增${functionName}") |
| 94 | -## @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") | 97 | + @DataSource(DataSourceType.SLAVE) |
| 98 | + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") | ||
| 95 | @Log(title = "${functionName}", businessType = BusinessType.INSERT) | 99 | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| 96 | @PostMapping | 100 | @PostMapping |
| 97 | public AjaxResult add(@RequestBody ${ClassName} ${className}) | 101 | public AjaxResult add(@RequestBody ${ClassName} ${className}) |
| 98 | { | 102 | { |
| 99 | - return toAjax(${className}Service.insert${ClassName}(${className})); | 103 | + return toAjax(publicTemplateService.add(${className})); |
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | - /** | ||
| 103 | - * 修改${functionName} | ||
| 104 | - */ | ||
| 105 | @ApiOperation("修改${functionName}") | 106 | @ApiOperation("修改${functionName}") |
| 106 | -## @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") | 107 | + @DataSource(DataSourceType.SLAVE) |
| 108 | + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") | ||
| 107 | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) | 109 | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| 108 | @PutMapping | 110 | @PutMapping |
| 109 | public AjaxResult edit(@RequestBody ${ClassName} ${className}) | 111 | public AjaxResult edit(@RequestBody ${ClassName} ${className}) |
| 110 | { | 112 | { |
| 111 | - return toAjax(${className}Service.update${ClassName}(${className})); | 113 | + return toAjax(publicTemplateService.edit((${className}))); |
| 112 | } | 114 | } |
| 113 | 115 | ||
| 114 | - /** | ||
| 115 | - * 删除${functionName} | ||
| 116 | - */ | ||
| 117 | @ApiOperation("删除${functionName}") | 116 | @ApiOperation("删除${functionName}") |
| 118 | -## @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") | 117 | + @DataSource(DataSourceType.SLAVE) |
| 118 | + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") | ||
| 119 | @Log(title = "${functionName}", businessType = BusinessType.DELETE) | 119 | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| 120 | @DeleteMapping("/{${pkColumn.javaField}s}") | 120 | @DeleteMapping("/{${pkColumn.javaField}s}") |
| 121 | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) | 121 | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) |
| 122 | { | 122 | { |
| 123 | - return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); | 123 | + return toAjax(publicTemplateService.removeByIds(${ClassName}.class,${pkColumn.javaField}s)); |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 1 | -package ${packageName}.domain; | 1 | +package ${packageName}.domain.${moduleName}; |
| 2 | 2 | ||
| 3 | #foreach ($import in $importList) | 3 | #foreach ($import in $importList) |
| 4 | import ${import}; | 4 | import ${import}; |
| 5 | #end | 5 | #end |
| 6 | -import com.ruoyi.common.annotation.Excel; | ||
| 7 | -#if($table.crud || $table.sub) | ||
| 8 | -#elseif($table.tree) | ||
| 9 | -#end | 6 | +import org.apache.commons.lang3.builder.ToStringBuilder; |
| 7 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 8 | +import com.zhonglai.luhui.common.util.annotation.Excel; | ||
| 10 | import io.swagger.annotations.ApiModel; | 9 | import io.swagger.annotations.ApiModel; |
| 11 | import io.swagger.annotations.ApiModelProperty; | 10 | import io.swagger.annotations.ApiModelProperty; |
| 12 | -import com.ruoyi.common.annotation.PublicSQLConfig; | 11 | +#if($table.crud || $table.sub) |
| 13 | import com.ruoyi.common.tool.BaseEntity; | 12 | import com.ruoyi.common.tool.BaseEntity; |
| 14 | -import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 15 | -import org.apache.commons.lang3.builder.ToStringStyle; | 13 | +#elseif($table.tree) |
| 14 | +#end | ||
| 16 | 15 | ||
| 17 | /** | 16 | /** |
| 18 | * ${functionName}对象 ${tableName} | 17 | * ${functionName}对象 ${tableName} |
| @@ -28,32 +27,33 @@ import org.apache.commons.lang3.builder.ToStringStyle; | @@ -28,32 +27,33 @@ import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 28 | #end | 27 | #end |
| 29 | public class ${ClassName} extends ${Entity} | 28 | public class ${ClassName} extends ${Entity} |
| 30 | { | 29 | { |
| 31 | - @PublicSQLConfig(isSelect=false) | ||
| 32 | private static final long serialVersionUID = 1L; | 30 | private static final long serialVersionUID = 1L; |
| 33 | 31 | ||
| 34 | #foreach ($column in $columns) | 32 | #foreach ($column in $columns) |
| 35 | -#if(!$table.isSuperColumn($column.javaField)) | 33 | + #if(!$table.isSuperColumn($column.javaField)) |
| 36 | /** $column.columnComment */ | 34 | /** $column.columnComment */ |
| 37 | - @ApiModelProperty("${column.columnComment}") | ||
| 38 | -#if($column.list) | ||
| 39 | -#set($parentheseIndex=$column.columnComment.indexOf("(")) | ||
| 40 | -#if($parentheseIndex != -1) | ||
| 41 | -#set($comment=$column.columnComment.substring(0, $parentheseIndex)) | ||
| 42 | -#else | ||
| 43 | -#set($comment=$column.columnComment) | ||
| 44 | -#end | ||
| 45 | -#if($parentheseIndex != -1) | 35 | + #if($column.list) |
| 36 | + #set($parentheseIndex=$column.columnComment.indexOf("(")) | ||
| 37 | + #if($parentheseIndex != -1) | ||
| 38 | + #set($comment=$column.columnComment.substring(0, $parentheseIndex)) | ||
| 39 | + #else | ||
| 40 | + #set($comment=$column.columnComment) | ||
| 41 | + #end | ||
| 42 | + #if($parentheseIndex != -1) | ||
| 43 | + @ApiModelProperty(value="${comment}",allowableValues="$column.readConverterExp()") | ||
| 46 | @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") | 44 | @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") |
| 47 | -#elseif($column.javaType == 'Date') | 45 | + #elseif($column.javaType == 'Date') |
| 48 | @JsonFormat(pattern = "yyyy-MM-dd") | 46 | @JsonFormat(pattern = "yyyy-MM-dd") |
| 47 | + @ApiModelProperty(value="${comment}") | ||
| 49 | @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") | 48 | @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") |
| 50 | -#else | 49 | + #else |
| 50 | + @ApiModelProperty(value="${comment}") | ||
| 51 | @Excel(name = "${comment}") | 51 | @Excel(name = "${comment}") |
| 52 | -#end | ||
| 53 | -#end | 52 | + #end |
| 53 | + #end | ||
| 54 | private $column.javaType $column.javaField; | 54 | private $column.javaType $column.javaField; |
| 55 | 55 | ||
| 56 | -#end | 56 | + #end |
| 57 | #end | 57 | #end |
| 58 | #if($table.sub) | 58 | #if($table.sub) |
| 59 | /** $table.subTable.functionName信息 */ | 59 | /** $table.subTable.functionName信息 */ |
| @@ -7,11 +7,6 @@ import com.ruoyi.common.utils.DateUtils; | @@ -7,11 +7,6 @@ import com.ruoyi.common.utils.DateUtils; | ||
| 7 | #break | 7 | #break |
| 8 | #end | 8 | #end |
| 9 | #end | 9 | #end |
| 10 | - | ||
| 11 | -#if($dataSource) | ||
| 12 | -import com.zhonglai.luhui.datasource.enums.DataSource; | ||
| 13 | -import com.zhonglai.luhui.datasource.enums.DataSourceType; | ||
| 14 | -#end | ||
| 15 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 17 | #if($table.sub) | 12 | #if($table.sub) |
| @@ -42,9 +37,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -42,9 +37,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 42 | * @param ${pkColumn.javaField} ${functionName}主键 | 37 | * @param ${pkColumn.javaField} ${functionName}主键 |
| 43 | * @return ${functionName} | 38 | * @return ${functionName} |
| 44 | */ | 39 | */ |
| 45 | -#if($dataSource) | ||
| 46 | - @DataSource(${dataSource}) | ||
| 47 | -#end | ||
| 48 | @Override | 40 | @Override |
| 49 | public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) | 41 | public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) |
| 50 | { | 42 | { |
| @@ -57,9 +49,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -57,9 +49,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 57 | * @param ${className} ${functionName} | 49 | * @param ${className} ${functionName} |
| 58 | * @return ${functionName} | 50 | * @return ${functionName} |
| 59 | */ | 51 | */ |
| 60 | -#if($dataSource) | ||
| 61 | - @DataSource(${dataSource}) | ||
| 62 | -#end | ||
| 63 | @Override | 52 | @Override |
| 64 | public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) | 53 | public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) |
| 65 | { | 54 | { |
| @@ -72,9 +61,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -72,9 +61,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 72 | * @param ${className} ${functionName} | 61 | * @param ${className} ${functionName} |
| 73 | * @return 结果 | 62 | * @return 结果 |
| 74 | */ | 63 | */ |
| 75 | -#if($dataSource) | ||
| 76 | - @DataSource(${dataSource}) | ||
| 77 | -#end | ||
| 78 | #if($table.sub) | 64 | #if($table.sub) |
| 79 | @Transactional | 65 | @Transactional |
| 80 | #end | 66 | #end |
| @@ -101,9 +87,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -101,9 +87,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 101 | * @param ${className} ${functionName} | 87 | * @param ${className} ${functionName} |
| 102 | * @return 结果 | 88 | * @return 结果 |
| 103 | */ | 89 | */ |
| 104 | -#if($dataSource) | ||
| 105 | - @DataSource(${dataSource}) | ||
| 106 | -#end | ||
| 107 | #if($table.sub) | 90 | #if($table.sub) |
| 108 | @Transactional | 91 | @Transactional |
| 109 | #end | 92 | #end |
| @@ -128,9 +111,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -128,9 +111,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 128 | * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 | 111 | * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 |
| 129 | * @return 结果 | 112 | * @return 结果 |
| 130 | */ | 113 | */ |
| 131 | -#if($dataSource) | ||
| 132 | - @DataSource(${dataSource}) | ||
| 133 | -#end | ||
| 134 | #if($table.sub) | 114 | #if($table.sub) |
| 135 | @Transactional | 115 | @Transactional |
| 136 | #end | 116 | #end |
| @@ -149,9 +129,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -149,9 +129,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 149 | * @param ${pkColumn.javaField} ${functionName}主键 | 129 | * @param ${pkColumn.javaField} ${functionName}主键 |
| 150 | * @return 结果 | 130 | * @return 结果 |
| 151 | */ | 131 | */ |
| 152 | -#if($dataSource) | ||
| 153 | - @DataSource(${dataSource}) | ||
| 154 | -#end | ||
| 155 | #if($table.sub) | 132 | #if($table.sub) |
| 156 | @Transactional | 133 | @Transactional |
| 157 | #end | 134 | #end |
| @@ -170,9 +147,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | @@ -170,9 +147,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service | ||
| 170 | * | 147 | * |
| 171 | * @param ${className} ${functionName}对象 | 148 | * @param ${className} ${functionName}对象 |
| 172 | */ | 149 | */ |
| 173 | - #if($dataSource) | ||
| 174 | - @DataSource(${dataSource}) | ||
| 175 | - #end | ||
| 176 | public void insert${subClassName}(${ClassName} ${className}) | 150 | public void insert${subClassName}(${ClassName} ${className}) |
| 177 | { | 151 | { |
| 178 | List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); | 152 | List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); |
| @@ -3,8 +3,10 @@ package ${packageName}.domain; | @@ -3,8 +3,10 @@ package ${packageName}.domain; | ||
| 3 | #foreach ($import in $subImportList) | 3 | #foreach ($import in $subImportList) |
| 4 | import ${import}; | 4 | import ${import}; |
| 5 | #end | 5 | #end |
| 6 | -import com.ruoyi.common.annotation.Excel; | ||
| 7 | -import com.ruoyi.common.annotation.PublicSQLConfig; | 6 | +import org.apache.commons.lang3.builder.ToStringBuilder; |
| 7 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 8 | +import com.zhonglai.luhui.common.util.annotation.Excel; | ||
| 9 | +import com.ruoyi.common.tool.BaseEntity; | ||
| 8 | 10 | ||
| 9 | /** | 11 | /** |
| 10 | * ${subTable.functionName}对象 ${subTableName} | 12 | * ${subTable.functionName}对象 ${subTableName} |
| @@ -14,7 +16,6 @@ import com.ruoyi.common.annotation.PublicSQLConfig; | @@ -14,7 +16,6 @@ import com.ruoyi.common.annotation.PublicSQLConfig; | ||
| 14 | */ | 16 | */ |
| 15 | public class ${subClassName} extends BaseEntity | 17 | public class ${subClassName} extends BaseEntity |
| 16 | { | 18 | { |
| 17 | - @PublicSQLConfig(isSelect=false) | ||
| 18 | private static final long serialVersionUID = 1L; | 19 | private static final long serialVersionUID = 1L; |
| 19 | 20 | ||
| 20 | #foreach ($column in $subTable.columns) | 21 | #foreach ($column in $subTable.columns) |
| @@ -3,7 +3,7 @@ import request from '@/utils/request' | @@ -3,7 +3,7 @@ import request from '@/utils/request' | ||
| 3 | // 查询${functionName}列表 | 3 | // 查询${functionName}列表 |
| 4 | export function list${BusinessName}(query) { | 4 | export function list${BusinessName}(query) { |
| 5 | return request({ | 5 | return request({ |
| 6 | - url: '/${moduleName}/${businessName}/list', | 6 | + url: '/${modlePath}/${moduleName}/${businessName}/list', |
| 7 | method: 'get', | 7 | method: 'get', |
| 8 | params: query | 8 | params: query |
| 9 | }) | 9 | }) |
| @@ -12,7 +12,7 @@ export function list${BusinessName}(query) { | @@ -12,7 +12,7 @@ export function list${BusinessName}(query) { | ||
| 12 | // 查询${functionName}详细 | 12 | // 查询${functionName}详细 |
| 13 | export function get${BusinessName}(${pkColumn.javaField}) { | 13 | export function get${BusinessName}(${pkColumn.javaField}) { |
| 14 | return request({ | 14 | return request({ |
| 15 | - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, | 15 | + url: '/${modlePath}/${moduleName}/${businessName}/' + ${pkColumn.javaField}, |
| 16 | method: 'get' | 16 | method: 'get' |
| 17 | }) | 17 | }) |
| 18 | } | 18 | } |
| @@ -20,7 +20,7 @@ export function get${BusinessName}(${pkColumn.javaField}) { | @@ -20,7 +20,7 @@ export function get${BusinessName}(${pkColumn.javaField}) { | ||
| 20 | // 新增${functionName} | 20 | // 新增${functionName} |
| 21 | export function add${BusinessName}(data) { | 21 | export function add${BusinessName}(data) { |
| 22 | return request({ | 22 | return request({ |
| 23 | - url: '/${moduleName}/${businessName}', | 23 | + url: '/${modlePath}/${moduleName}/${businessName}', |
| 24 | method: 'post', | 24 | method: 'post', |
| 25 | data: data | 25 | data: data |
| 26 | }) | 26 | }) |
| @@ -29,7 +29,7 @@ export function add${BusinessName}(data) { | @@ -29,7 +29,7 @@ export function add${BusinessName}(data) { | ||
| 29 | // 修改${functionName} | 29 | // 修改${functionName} |
| 30 | export function update${BusinessName}(data) { | 30 | export function update${BusinessName}(data) { |
| 31 | return request({ | 31 | return request({ |
| 32 | - url: '/${moduleName}/${businessName}', | 32 | + url: '/${modlePath}/${moduleName}/${businessName}', |
| 33 | method: 'put', | 33 | method: 'put', |
| 34 | data: data | 34 | data: data |
| 35 | }) | 35 | }) |
| @@ -38,7 +38,7 @@ export function update${BusinessName}(data) { | @@ -38,7 +38,7 @@ export function update${BusinessName}(data) { | ||
| 38 | // 删除${functionName} | 38 | // 删除${functionName} |
| 39 | export function del${BusinessName}(${pkColumn.javaField}) { | 39 | export function del${BusinessName}(${pkColumn.javaField}) { |
| 40 | return request({ | 40 | return request({ |
| 41 | - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, | 41 | + url: '/${modlePath}/${moduleName}/${businessName}/' + ${pkColumn.javaField}, |
| 42 | method: 'delete' | 42 | method: 'delete' |
| 43 | }) | 43 | }) |
| 44 | } | 44 | } |
| 1 | -- 菜单 SQL | 1 | -- 菜单 SQL |
| 2 | insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) | 2 | insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) |
| 3 | -values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); | 3 | +values('${functionName}', 2006, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); |
| 4 | 4 | ||
| 5 | -- 按钮父菜单ID | 5 | -- 按钮父菜单ID |
| 6 | SELECT @parentId := LAST_INSERT_ID(); | 6 | SELECT @parentId := LAST_INSERT_ID(); |
| @@ -75,7 +75,7 @@ | @@ -75,7 +75,7 @@ | ||
| 75 | icon="el-icon-plus" | 75 | icon="el-icon-plus" |
| 76 | size="mini" | 76 | size="mini" |
| 77 | @click="handleAdd" | 77 | @click="handleAdd" |
| 78 | - v-hasPermi="['${moduleName}:${businessName}:add']" | 78 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:add']" |
| 79 | >新增</el-button> | 79 | >新增</el-button> |
| 80 | </el-col> | 80 | </el-col> |
| 81 | <el-col :span="1.5"> | 81 | <el-col :span="1.5"> |
| @@ -144,21 +144,21 @@ | @@ -144,21 +144,21 @@ | ||
| 144 | type="text" | 144 | type="text" |
| 145 | icon="el-icon-edit" | 145 | icon="el-icon-edit" |
| 146 | @click="handleUpdate(scope.row)" | 146 | @click="handleUpdate(scope.row)" |
| 147 | - v-hasPermi="['${moduleName}:${businessName}:edit']" | 147 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:edit']" |
| 148 | >修改</el-button> | 148 | >修改</el-button> |
| 149 | <el-button | 149 | <el-button |
| 150 | size="mini" | 150 | size="mini" |
| 151 | type="text" | 151 | type="text" |
| 152 | icon="el-icon-plus" | 152 | icon="el-icon-plus" |
| 153 | @click="handleAdd(scope.row)" | 153 | @click="handleAdd(scope.row)" |
| 154 | - v-hasPermi="['${moduleName}:${businessName}:add']" | 154 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:add']" |
| 155 | >新增</el-button> | 155 | >新增</el-button> |
| 156 | <el-button | 156 | <el-button |
| 157 | size="mini" | 157 | size="mini" |
| 158 | type="text" | 158 | type="text" |
| 159 | icon="el-icon-delete" | 159 | icon="el-icon-delete" |
| 160 | @click="handleDelete(scope.row)" | 160 | @click="handleDelete(scope.row)" |
| 161 | - v-hasPermi="['${moduleName}:${businessName}:remove']" | 161 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:remove']" |
| 162 | >删除</el-button> | 162 | >删除</el-button> |
| 163 | </template> | 163 | </template> |
| 164 | </el-table-column> | 164 | </el-table-column> |
| @@ -187,11 +187,11 @@ | @@ -187,11 +187,11 @@ | ||
| 187 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> | 187 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| 188 | </el-form-item> | 188 | </el-form-item> |
| 189 | #elseif($column.htmlType == "imageUpload") | 189 | #elseif($column.htmlType == "imageUpload") |
| 190 | - <el-form-item label="${comment}"> | 190 | + <el-form-item label="${comment}" prop="${field}"> |
| 191 | <image-upload v-model="form.${field}"/> | 191 | <image-upload v-model="form.${field}"/> |
| 192 | </el-form-item> | 192 | </el-form-item> |
| 193 | #elseif($column.htmlType == "fileUpload") | 193 | #elseif($column.htmlType == "fileUpload") |
| 194 | - <el-form-item label="${comment}"> | 194 | + <el-form-item label="${comment}" prop="${field}"> |
| 195 | <file-upload v-model="form.${field}"/> | 195 | <file-upload v-model="form.${field}"/> |
| 196 | </el-form-item> | 196 | </el-form-item> |
| 197 | #elseif($column.htmlType == "editor") | 197 | #elseif($column.htmlType == "editor") |
| @@ -205,8 +205,11 @@ | @@ -205,8 +205,11 @@ | ||
| 205 | v-for="dict in dict.type.${dictType}" | 205 | v-for="dict in dict.type.${dictType}" |
| 206 | :key="dict.value" | 206 | :key="dict.value" |
| 207 | :label="dict.label" | 207 | :label="dict.label" |
| 208 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end | ||
| 209 | - | 208 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 209 | + :value="parseInt(dict.value)" | ||
| 210 | +#else | ||
| 211 | + :value="dict.value" | ||
| 212 | +#end | ||
| 210 | ></el-option> | 213 | ></el-option> |
| 211 | </el-select> | 214 | </el-select> |
| 212 | </el-form-item> | 215 | </el-form-item> |
| @@ -217,7 +220,7 @@ | @@ -217,7 +220,7 @@ | ||
| 217 | </el-select> | 220 | </el-select> |
| 218 | </el-form-item> | 221 | </el-form-item> |
| 219 | #elseif($column.htmlType == "checkbox" && "" != $dictType) | 222 | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| 220 | - <el-form-item label="${comment}"> | 223 | + <el-form-item label="${comment}" prop="${field}"> |
| 221 | <el-checkbox-group v-model="form.${field}"> | 224 | <el-checkbox-group v-model="form.${field}"> |
| 222 | <el-checkbox | 225 | <el-checkbox |
| 223 | v-for="dict in dict.type.${dictType}" | 226 | v-for="dict in dict.type.${dictType}" |
| @@ -228,24 +231,27 @@ | @@ -228,24 +231,27 @@ | ||
| 228 | </el-checkbox-group> | 231 | </el-checkbox-group> |
| 229 | </el-form-item> | 232 | </el-form-item> |
| 230 | #elseif($column.htmlType == "checkbox" && $dictType) | 233 | #elseif($column.htmlType == "checkbox" && $dictType) |
| 231 | - <el-form-item label="${comment}"> | 234 | + <el-form-item label="${comment}" prop="${field}"> |
| 232 | <el-checkbox-group v-model="form.${field}"> | 235 | <el-checkbox-group v-model="form.${field}"> |
| 233 | <el-checkbox>请选择字典生成</el-checkbox> | 236 | <el-checkbox>请选择字典生成</el-checkbox> |
| 234 | </el-checkbox-group> | 237 | </el-checkbox-group> |
| 235 | </el-form-item> | 238 | </el-form-item> |
| 236 | #elseif($column.htmlType == "radio" && "" != $dictType) | 239 | #elseif($column.htmlType == "radio" && "" != $dictType) |
| 237 | - <el-form-item label="${comment}"> | 240 | + <el-form-item label="${comment}" prop="${field}"> |
| 238 | <el-radio-group v-model="form.${field}"> | 241 | <el-radio-group v-model="form.${field}"> |
| 239 | <el-radio | 242 | <el-radio |
| 240 | v-for="dict in dict.type.${dictType}" | 243 | v-for="dict in dict.type.${dictType}" |
| 241 | :key="dict.value" | 244 | :key="dict.value" |
| 242 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end | ||
| 243 | - | 245 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 246 | + :label="parseInt(dict.value)" | ||
| 247 | +#else | ||
| 248 | + :label="dict.value" | ||
| 249 | +#end | ||
| 244 | >{{dict.label}}</el-radio> | 250 | >{{dict.label}}</el-radio> |
| 245 | </el-radio-group> | 251 | </el-radio-group> |
| 246 | </el-form-item> | 252 | </el-form-item> |
| 247 | #elseif($column.htmlType == "radio" && $dictType) | 253 | #elseif($column.htmlType == "radio" && $dictType) |
| 248 | - <el-form-item label="${comment}"> | 254 | + <el-form-item label="${comment}" prop="${field}"> |
| 249 | <el-radio-group v-model="form.${field}"> | 255 | <el-radio-group v-model="form.${field}"> |
| 250 | <el-radio label="1">请选择字典生成</el-radio> | 256 | <el-radio label="1">请选择字典生成</el-radio> |
| 251 | </el-radio-group> | 257 | </el-radio-group> |
| @@ -335,7 +341,7 @@ export default { | @@ -335,7 +341,7 @@ export default { | ||
| 335 | #set($comment=$column.columnComment) | 341 | #set($comment=$column.columnComment) |
| 336 | #end | 342 | #end |
| 337 | $column.javaField: [ | 343 | $column.javaField: [ |
| 338 | - { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } | 344 | + { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| 339 | ]#if($foreach.count != $columns.size()),#end | 345 | ]#if($foreach.count != $columns.size()),#end |
| 340 | #end | 346 | #end |
| 341 | #end | 347 | #end |
| @@ -398,10 +404,7 @@ export default { | @@ -398,10 +404,7 @@ export default { | ||
| 398 | reset() { | 404 | reset() { |
| 399 | this.form = { | 405 | this.form = { |
| 400 | #foreach ($column in $columns) | 406 | #foreach ($column in $columns) |
| 401 | -#if($column.htmlType == "radio") | ||
| 402 | - $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end | ||
| 403 | - | ||
| 404 | -#elseif($column.htmlType == "checkbox") | 407 | +#if($column.htmlType == "checkbox") |
| 405 | $column.javaField: []#if($foreach.count != $columns.size()),#end | 408 | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| 406 | #else | 409 | #else |
| 407 | $column.javaField: null#if($foreach.count != $columns.size()),#end | 410 | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| @@ -450,7 +453,7 @@ export default { | @@ -450,7 +453,7 @@ export default { | ||
| 450 | this.reset(); | 453 | this.reset(); |
| 451 | this.getTreeselect(); | 454 | this.getTreeselect(); |
| 452 | if (row != null) { | 455 | if (row != null) { |
| 453 | - this.form.${treeParentCode} = row.${treeCode}; | 456 | + this.form.${treeParentCode} = row.${treeParentCode}; |
| 454 | } | 457 | } |
| 455 | get${BusinessName}(row.${pkColumn.javaField}).then(response => { | 458 | get${BusinessName}(row.${pkColumn.javaField}).then(response => { |
| 456 | this.form = response.data; | 459 | this.form = response.data; |
| @@ -75,7 +75,7 @@ | @@ -75,7 +75,7 @@ | ||
| 75 | icon="el-icon-plus" | 75 | icon="el-icon-plus" |
| 76 | size="mini" | 76 | size="mini" |
| 77 | @click="handleAdd" | 77 | @click="handleAdd" |
| 78 | - v-hasPermi="['${moduleName}:${businessName}:add']" | 78 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:add']" |
| 79 | >新增</el-button> | 79 | >新增</el-button> |
| 80 | </el-col> | 80 | </el-col> |
| 81 | <el-col :span="1.5"> | 81 | <el-col :span="1.5"> |
| @@ -86,7 +86,7 @@ | @@ -86,7 +86,7 @@ | ||
| 86 | size="mini" | 86 | size="mini" |
| 87 | :disabled="single" | 87 | :disabled="single" |
| 88 | @click="handleUpdate" | 88 | @click="handleUpdate" |
| 89 | - v-hasPermi="['${moduleName}:${businessName}:edit']" | 89 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:edit']" |
| 90 | >修改</el-button> | 90 | >修改</el-button> |
| 91 | </el-col> | 91 | </el-col> |
| 92 | <el-col :span="1.5"> | 92 | <el-col :span="1.5"> |
| @@ -97,7 +97,7 @@ | @@ -97,7 +97,7 @@ | ||
| 97 | size="mini" | 97 | size="mini" |
| 98 | :disabled="multiple" | 98 | :disabled="multiple" |
| 99 | @click="handleDelete" | 99 | @click="handleDelete" |
| 100 | - v-hasPermi="['${moduleName}:${businessName}:remove']" | 100 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:remove']" |
| 101 | >删除</el-button> | 101 | >删除</el-button> |
| 102 | </el-col> | 102 | </el-col> |
| 103 | <el-col :span="1.5"> | 103 | <el-col :span="1.5"> |
| @@ -107,7 +107,7 @@ | @@ -107,7 +107,7 @@ | ||
| 107 | icon="el-icon-download" | 107 | icon="el-icon-download" |
| 108 | size="mini" | 108 | size="mini" |
| 109 | @click="handleExport" | 109 | @click="handleExport" |
| 110 | - v-hasPermi="['${moduleName}:${businessName}:export']" | 110 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:export']" |
| 111 | >导出</el-button> | 111 | >导出</el-button> |
| 112 | </el-col> | 112 | </el-col> |
| 113 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | 113 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| @@ -158,14 +158,14 @@ | @@ -158,14 +158,14 @@ | ||
| 158 | type="text" | 158 | type="text" |
| 159 | icon="el-icon-edit" | 159 | icon="el-icon-edit" |
| 160 | @click="handleUpdate(scope.row)" | 160 | @click="handleUpdate(scope.row)" |
| 161 | - v-hasPermi="['${moduleName}:${businessName}:edit']" | 161 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:edit']" |
| 162 | >修改</el-button> | 162 | >修改</el-button> |
| 163 | <el-button | 163 | <el-button |
| 164 | size="mini" | 164 | size="mini" |
| 165 | type="text" | 165 | type="text" |
| 166 | icon="el-icon-delete" | 166 | icon="el-icon-delete" |
| 167 | @click="handleDelete(scope.row)" | 167 | @click="handleDelete(scope.row)" |
| 168 | - v-hasPermi="['${moduleName}:${businessName}:remove']" | 168 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:remove']" |
| 169 | >删除</el-button> | 169 | >删除</el-button> |
| 170 | </template> | 170 | </template> |
| 171 | </el-table-column> | 171 | </el-table-column> |
| @@ -198,11 +198,11 @@ | @@ -198,11 +198,11 @@ | ||
| 198 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> | 198 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| 199 | </el-form-item> | 199 | </el-form-item> |
| 200 | #elseif($column.htmlType == "imageUpload") | 200 | #elseif($column.htmlType == "imageUpload") |
| 201 | - <el-form-item label="${comment}"> | 201 | + <el-form-item label="${comment}" prop="${field}"> |
| 202 | <image-upload v-model="form.${field}"/> | 202 | <image-upload v-model="form.${field}"/> |
| 203 | </el-form-item> | 203 | </el-form-item> |
| 204 | #elseif($column.htmlType == "fileUpload") | 204 | #elseif($column.htmlType == "fileUpload") |
| 205 | - <el-form-item label="${comment}"> | 205 | + <el-form-item label="${comment}" prop="${field}"> |
| 206 | <file-upload v-model="form.${field}"/> | 206 | <file-upload v-model="form.${field}"/> |
| 207 | </el-form-item> | 207 | </el-form-item> |
| 208 | #elseif($column.htmlType == "editor") | 208 | #elseif($column.htmlType == "editor") |
| @@ -216,8 +216,11 @@ | @@ -216,8 +216,11 @@ | ||
| 216 | v-for="dict in dict.type.${dictType}" | 216 | v-for="dict in dict.type.${dictType}" |
| 217 | :key="dict.value" | 217 | :key="dict.value" |
| 218 | :label="dict.label" | 218 | :label="dict.label" |
| 219 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end | ||
| 220 | - | 219 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 220 | + :value="parseInt(dict.value)" | ||
| 221 | +#else | ||
| 222 | + :value="dict.value" | ||
| 223 | +#end | ||
| 221 | ></el-option> | 224 | ></el-option> |
| 222 | </el-select> | 225 | </el-select> |
| 223 | </el-form-item> | 226 | </el-form-item> |
| @@ -228,7 +231,7 @@ | @@ -228,7 +231,7 @@ | ||
| 228 | </el-select> | 231 | </el-select> |
| 229 | </el-form-item> | 232 | </el-form-item> |
| 230 | #elseif($column.htmlType == "checkbox" && "" != $dictType) | 233 | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| 231 | - <el-form-item label="${comment}"> | 234 | + <el-form-item label="${comment}" prop="${field}"> |
| 232 | <el-checkbox-group v-model="form.${field}"> | 235 | <el-checkbox-group v-model="form.${field}"> |
| 233 | <el-checkbox | 236 | <el-checkbox |
| 234 | v-for="dict in dict.type.${dictType}" | 237 | v-for="dict in dict.type.${dictType}" |
| @@ -239,24 +242,27 @@ | @@ -239,24 +242,27 @@ | ||
| 239 | </el-checkbox-group> | 242 | </el-checkbox-group> |
| 240 | </el-form-item> | 243 | </el-form-item> |
| 241 | #elseif($column.htmlType == "checkbox" && $dictType) | 244 | #elseif($column.htmlType == "checkbox" && $dictType) |
| 242 | - <el-form-item label="${comment}"> | 245 | + <el-form-item label="${comment}" prop="${field}"> |
| 243 | <el-checkbox-group v-model="form.${field}"> | 246 | <el-checkbox-group v-model="form.${field}"> |
| 244 | <el-checkbox>请选择字典生成</el-checkbox> | 247 | <el-checkbox>请选择字典生成</el-checkbox> |
| 245 | </el-checkbox-group> | 248 | </el-checkbox-group> |
| 246 | </el-form-item> | 249 | </el-form-item> |
| 247 | #elseif($column.htmlType == "radio" && "" != $dictType) | 250 | #elseif($column.htmlType == "radio" && "" != $dictType) |
| 248 | - <el-form-item label="${comment}"> | 251 | + <el-form-item label="${comment}" prop="${field}"> |
| 249 | <el-radio-group v-model="form.${field}"> | 252 | <el-radio-group v-model="form.${field}"> |
| 250 | <el-radio | 253 | <el-radio |
| 251 | v-for="dict in dict.type.${dictType}" | 254 | v-for="dict in dict.type.${dictType}" |
| 252 | :key="dict.value" | 255 | :key="dict.value" |
| 253 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end | ||
| 254 | - | 256 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 257 | + :label="parseInt(dict.value)" | ||
| 258 | +#else | ||
| 259 | + :label="dict.value" | ||
| 260 | +#end | ||
| 255 | >{{dict.label}}</el-radio> | 261 | >{{dict.label}}</el-radio> |
| 256 | </el-radio-group> | 262 | </el-radio-group> |
| 257 | </el-form-item> | 263 | </el-form-item> |
| 258 | #elseif($column.htmlType == "radio" && $dictType) | 264 | #elseif($column.htmlType == "radio" && $dictType) |
| 259 | - <el-form-item label="${comment}"> | 265 | + <el-form-item label="${comment}" prop="${field}"> |
| 260 | <el-radio-group v-model="form.${field}"> | 266 | <el-radio-group v-model="form.${field}"> |
| 261 | <el-radio label="1">请选择字典生成</el-radio> | 267 | <el-radio label="1">请选择字典生成</el-radio> |
| 262 | </el-radio-group> | 268 | </el-radio-group> |
| @@ -412,7 +418,7 @@ export default { | @@ -412,7 +418,7 @@ export default { | ||
| 412 | #set($comment=$column.columnComment) | 418 | #set($comment=$column.columnComment) |
| 413 | #end | 419 | #end |
| 414 | $column.javaField: [ | 420 | $column.javaField: [ |
| 415 | - { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } | 421 | + { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| 416 | ]#if($foreach.count != $columns.size()),#end | 422 | ]#if($foreach.count != $columns.size()),#end |
| 417 | #end | 423 | #end |
| 418 | #end | 424 | #end |
| @@ -456,9 +462,7 @@ export default { | @@ -456,9 +462,7 @@ export default { | ||
| 456 | reset() { | 462 | reset() { |
| 457 | this.form = { | 463 | this.form = { |
| 458 | #foreach ($column in $columns) | 464 | #foreach ($column in $columns) |
| 459 | -#if($column.htmlType == "radio") | ||
| 460 | - $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end | ||
| 461 | -#elseif($column.htmlType == "checkbox") | 465 | +#if($column.htmlType == "checkbox") |
| 462 | $column.javaField: []#if($foreach.count != $columns.size()),#end | 466 | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| 463 | #else | 467 | #else |
| 464 | $column.javaField: null#if($foreach.count != $columns.size()),#end | 468 | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| @@ -589,7 +593,7 @@ export default { | @@ -589,7 +593,7 @@ export default { | ||
| 589 | #end | 593 | #end |
| 590 | /** 导出按钮操作 */ | 594 | /** 导出按钮操作 */ |
| 591 | handleExport() { | 595 | handleExport() { |
| 592 | - this.download('${moduleName}/${businessName}/export', { | 596 | + this.download('${modlePath}/${moduleName}/${businessName}/export', { |
| 593 | ...this.queryParams | 597 | ...this.queryParams |
| 594 | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) | 598 | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) |
| 595 | } | 599 | } |
| @@ -73,7 +73,7 @@ | @@ -73,7 +73,7 @@ | ||
| 73 | plain | 73 | plain |
| 74 | icon="Plus" | 74 | icon="Plus" |
| 75 | @click="handleAdd" | 75 | @click="handleAdd" |
| 76 | - v-hasPermi="['${moduleName}:${businessName}:add']" | 76 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:add']" |
| 77 | >新增</el-button> | 77 | >新增</el-button> |
| 78 | </el-col> | 78 | </el-col> |
| 79 | <el-col :span="1.5"> | 79 | <el-col :span="1.5"> |
| @@ -136,24 +136,9 @@ | @@ -136,24 +136,9 @@ | ||
| 136 | #end | 136 | #end |
| 137 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 137 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 138 | <template #default="scope"> | 138 | <template #default="scope"> |
| 139 | - <el-button | ||
| 140 | - type="text" | ||
| 141 | - icon="Edit" | ||
| 142 | - @click="handleUpdate(scope.row)" | ||
| 143 | - v-hasPermi="['${moduleName}:${businessName}:edit']" | ||
| 144 | - >修改</el-button> | ||
| 145 | - <el-button | ||
| 146 | - type="text" | ||
| 147 | - icon="Plus" | ||
| 148 | - @click="handleAdd(scope.row)" | ||
| 149 | - v-hasPermi="['${moduleName}:${businessName}:add']" | ||
| 150 | - >新增</el-button> | ||
| 151 | - <el-button | ||
| 152 | - type="text" | ||
| 153 | - icon="Delete" | ||
| 154 | - @click="handleDelete(scope.row)" | ||
| 155 | - v-hasPermi="['${moduleName}:${businessName}:remove']" | ||
| 156 | - >删除</el-button> | 139 | + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${modlePath}:${moduleName}:${businessName}:edit']">修改</el-button> |
| 140 | + <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${modlePath}:${moduleName}:${businessName}:add']">新增</el-button> | ||
| 141 | + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${modlePath}:${moduleName}:${businessName}:remove']">删除</el-button> | ||
| 157 | </template> | 142 | </template> |
| 158 | </el-table-column> | 143 | </el-table-column> |
| 159 | </el-table> | 144 | </el-table> |
| @@ -174,11 +159,13 @@ | @@ -174,11 +159,13 @@ | ||
| 174 | #set($dictType=$column.dictType) | 159 | #set($dictType=$column.dictType) |
| 175 | #if("" != $treeParentCode && $column.javaField == $treeParentCode) | 160 | #if("" != $treeParentCode && $column.javaField == $treeParentCode) |
| 176 | <el-form-item label="${comment}" prop="${treeParentCode}"> | 161 | <el-form-item label="${comment}" prop="${treeParentCode}"> |
| 177 | - <tree-select | ||
| 178 | - v-model:value="form.${treeParentCode}" | ||
| 179 | - :options="${businessName}Options" | ||
| 180 | - :objMap="{ value: '${treeCode}', label: '${treeName}', children: 'children' }" | 162 | + <el-tree-select |
| 163 | + v-model="form.${treeParentCode}" | ||
| 164 | + :data="${businessName}Options" | ||
| 165 | + :props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }" | ||
| 166 | + value-key="${treeCode}" | ||
| 181 | placeholder="请选择${comment}" | 167 | placeholder="请选择${comment}" |
| 168 | + check-strictly | ||
| 182 | /> | 169 | /> |
| 183 | </el-form-item> | 170 | </el-form-item> |
| 184 | #elseif($column.htmlType == "input") | 171 | #elseif($column.htmlType == "input") |
| @@ -186,11 +173,11 @@ | @@ -186,11 +173,11 @@ | ||
| 186 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> | 173 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| 187 | </el-form-item> | 174 | </el-form-item> |
| 188 | #elseif($column.htmlType == "imageUpload") | 175 | #elseif($column.htmlType == "imageUpload") |
| 189 | - <el-form-item label="${comment}"> | 176 | + <el-form-item label="${comment}" prop="${field}"> |
| 190 | <image-upload v-model="form.${field}"/> | 177 | <image-upload v-model="form.${field}"/> |
| 191 | </el-form-item> | 178 | </el-form-item> |
| 192 | #elseif($column.htmlType == "fileUpload") | 179 | #elseif($column.htmlType == "fileUpload") |
| 193 | - <el-form-item label="${comment}"> | 180 | + <el-form-item label="${comment}" prop="${field}"> |
| 194 | <file-upload v-model="form.${field}"/> | 181 | <file-upload v-model="form.${field}"/> |
| 195 | </el-form-item> | 182 | </el-form-item> |
| 196 | #elseif($column.htmlType == "editor") | 183 | #elseif($column.htmlType == "editor") |
| @@ -204,8 +191,11 @@ | @@ -204,8 +191,11 @@ | ||
| 204 | v-for="dict in ${dictType}" | 191 | v-for="dict in ${dictType}" |
| 205 | :key="dict.value" | 192 | :key="dict.value" |
| 206 | :label="dict.label" | 193 | :label="dict.label" |
| 207 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end | ||
| 208 | - | 194 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 195 | + :value="parseInt(dict.value)" | ||
| 196 | +#else | ||
| 197 | + :value="dict.value" | ||
| 198 | +#end | ||
| 209 | ></el-option> | 199 | ></el-option> |
| 210 | </el-select> | 200 | </el-select> |
| 211 | </el-form-item> | 201 | </el-form-item> |
| @@ -216,7 +206,7 @@ | @@ -216,7 +206,7 @@ | ||
| 216 | </el-select> | 206 | </el-select> |
| 217 | </el-form-item> | 207 | </el-form-item> |
| 218 | #elseif($column.htmlType == "checkbox" && "" != $dictType) | 208 | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| 219 | - <el-form-item label="${comment}"> | 209 | + <el-form-item label="${comment}" prop="${field}"> |
| 220 | <el-checkbox-group v-model="form.${field}"> | 210 | <el-checkbox-group v-model="form.${field}"> |
| 221 | <el-checkbox | 211 | <el-checkbox |
| 222 | v-for="dict in ${dictType}" | 212 | v-for="dict in ${dictType}" |
| @@ -227,24 +217,27 @@ | @@ -227,24 +217,27 @@ | ||
| 227 | </el-checkbox-group> | 217 | </el-checkbox-group> |
| 228 | </el-form-item> | 218 | </el-form-item> |
| 229 | #elseif($column.htmlType == "checkbox" && $dictType) | 219 | #elseif($column.htmlType == "checkbox" && $dictType) |
| 230 | - <el-form-item label="${comment}"> | 220 | + <el-form-item label="${comment}" prop="${field}"> |
| 231 | <el-checkbox-group v-model="form.${field}"> | 221 | <el-checkbox-group v-model="form.${field}"> |
| 232 | <el-checkbox>请选择字典生成</el-checkbox> | 222 | <el-checkbox>请选择字典生成</el-checkbox> |
| 233 | </el-checkbox-group> | 223 | </el-checkbox-group> |
| 234 | </el-form-item> | 224 | </el-form-item> |
| 235 | #elseif($column.htmlType == "radio" && "" != $dictType) | 225 | #elseif($column.htmlType == "radio" && "" != $dictType) |
| 236 | - <el-form-item label="${comment}"> | 226 | + <el-form-item label="${comment}" prop="${field}"> |
| 237 | <el-radio-group v-model="form.${field}"> | 227 | <el-radio-group v-model="form.${field}"> |
| 238 | <el-radio | 228 | <el-radio |
| 239 | v-for="dict in ${dictType}" | 229 | v-for="dict in ${dictType}" |
| 240 | :key="dict.value" | 230 | :key="dict.value" |
| 241 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end | ||
| 242 | - | 231 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 232 | + :label="parseInt(dict.value)" | ||
| 233 | +#else | ||
| 234 | + :label="dict.value" | ||
| 235 | +#end | ||
| 243 | >{{dict.label}}</el-radio> | 236 | >{{dict.label}}</el-radio> |
| 244 | </el-radio-group> | 237 | </el-radio-group> |
| 245 | </el-form-item> | 238 | </el-form-item> |
| 246 | #elseif($column.htmlType == "radio" && $dictType) | 239 | #elseif($column.htmlType == "radio" && $dictType) |
| 247 | - <el-form-item label="${comment}"> | 240 | + <el-form-item label="${comment}" prop="${field}"> |
| 248 | <el-radio-group v-model="form.${field}"> | 241 | <el-radio-group v-model="form.${field}"> |
| 249 | <el-radio label="1">请选择字典生成</el-radio> | 242 | <el-radio label="1">请选择字典生成</el-radio> |
| 250 | </el-radio-group> | 243 | </el-radio-group> |
| @@ -320,7 +313,7 @@ const data = reactive({ | @@ -320,7 +313,7 @@ const data = reactive({ | ||
| 320 | #set($comment=$column.columnComment) | 313 | #set($comment=$column.columnComment) |
| 321 | #end | 314 | #end |
| 322 | $column.javaField: [ | 315 | $column.javaField: [ |
| 323 | - { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } | 316 | + { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| 324 | ]#if($foreach.count != $columns.size()),#end | 317 | ]#if($foreach.count != $columns.size()),#end |
| 325 | #end | 318 | #end |
| 326 | #end | 319 | #end |
| @@ -354,8 +347,8 @@ function getList() { | @@ -354,8 +347,8 @@ function getList() { | ||
| 354 | } | 347 | } |
| 355 | 348 | ||
| 356 | /** 查询${functionName}下拉树结构 */ | 349 | /** 查询${functionName}下拉树结构 */ |
| 357 | -async function getTreeselect() { | ||
| 358 | - await list${BusinessName}().then(response => { | 350 | +function getTreeselect() { |
| 351 | + list${BusinessName}().then(response => { | ||
| 359 | ${businessName}Options.value = []; | 352 | ${businessName}Options.value = []; |
| 360 | const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] }; | 353 | const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] }; |
| 361 | data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}"); | 354 | data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}"); |
| @@ -373,10 +366,7 @@ function cancel() { | @@ -373,10 +366,7 @@ function cancel() { | ||
| 373 | function reset() { | 366 | function reset() { |
| 374 | form.value = { | 367 | form.value = { |
| 375 | #foreach ($column in $columns) | 368 | #foreach ($column in $columns) |
| 376 | -#if($column.htmlType == "radio") | ||
| 377 | - $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end | ||
| 378 | - | ||
| 379 | -#elseif($column.htmlType == "checkbox") | 369 | +#if($column.htmlType == "checkbox") |
| 380 | $column.javaField: []#if($foreach.count != $columns.size()),#end | 370 | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| 381 | #else | 371 | #else |
| 382 | $column.javaField: null#if($foreach.count != $columns.size()),#end | 372 | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| @@ -404,9 +394,9 @@ function resetQuery() { | @@ -404,9 +394,9 @@ function resetQuery() { | ||
| 404 | } | 394 | } |
| 405 | 395 | ||
| 406 | /** 新增按钮操作 */ | 396 | /** 新增按钮操作 */ |
| 407 | -async function handleAdd(row) { | 397 | +function handleAdd(row) { |
| 408 | reset(); | 398 | reset(); |
| 409 | - await getTreeselect(); | 399 | + getTreeselect(); |
| 410 | if (row != null && row.${treeCode}) { | 400 | if (row != null && row.${treeCode}) { |
| 411 | form.value.${treeParentCode} = row.${treeCode}; | 401 | form.value.${treeParentCode} = row.${treeCode}; |
| 412 | } else { | 402 | } else { |
| @@ -430,7 +420,7 @@ async function handleUpdate(row) { | @@ -430,7 +420,7 @@ async function handleUpdate(row) { | ||
| 430 | reset(); | 420 | reset(); |
| 431 | await getTreeselect(); | 421 | await getTreeselect(); |
| 432 | if (row != null) { | 422 | if (row != null) { |
| 433 | - form.value.${treeParentCode} = row.${treeCode}; | 423 | + form.value.${treeParentCode} = row.${treeParentCode}; |
| 434 | } | 424 | } |
| 435 | get${BusinessName}(row.${pkColumn.javaField}).then(response => { | 425 | get${BusinessName}(row.${pkColumn.javaField}).then(response => { |
| 436 | form.value = response.data; | 426 | form.value = response.data; |
| @@ -73,7 +73,7 @@ | @@ -73,7 +73,7 @@ | ||
| 73 | plain | 73 | plain |
| 74 | icon="Plus" | 74 | icon="Plus" |
| 75 | @click="handleAdd" | 75 | @click="handleAdd" |
| 76 | - v-hasPermi="['${moduleName}:${businessName}:add']" | 76 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:add']" |
| 77 | >新增</el-button> | 77 | >新增</el-button> |
| 78 | </el-col> | 78 | </el-col> |
| 79 | <el-col :span="1.5"> | 79 | <el-col :span="1.5"> |
| @@ -83,7 +83,7 @@ | @@ -83,7 +83,7 @@ | ||
| 83 | icon="Edit" | 83 | icon="Edit" |
| 84 | :disabled="single" | 84 | :disabled="single" |
| 85 | @click="handleUpdate" | 85 | @click="handleUpdate" |
| 86 | - v-hasPermi="['${moduleName}:${businessName}:edit']" | 86 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:edit']" |
| 87 | >修改</el-button> | 87 | >修改</el-button> |
| 88 | </el-col> | 88 | </el-col> |
| 89 | <el-col :span="1.5"> | 89 | <el-col :span="1.5"> |
| @@ -93,7 +93,7 @@ | @@ -93,7 +93,7 @@ | ||
| 93 | icon="Delete" | 93 | icon="Delete" |
| 94 | :disabled="multiple" | 94 | :disabled="multiple" |
| 95 | @click="handleDelete" | 95 | @click="handleDelete" |
| 96 | - v-hasPermi="['${moduleName}:${businessName}:remove']" | 96 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:remove']" |
| 97 | >删除</el-button> | 97 | >删除</el-button> |
| 98 | </el-col> | 98 | </el-col> |
| 99 | <el-col :span="1.5"> | 99 | <el-col :span="1.5"> |
| @@ -102,7 +102,7 @@ | @@ -102,7 +102,7 @@ | ||
| 102 | plain | 102 | plain |
| 103 | icon="Download" | 103 | icon="Download" |
| 104 | @click="handleExport" | 104 | @click="handleExport" |
| 105 | - v-hasPermi="['${moduleName}:${businessName}:export']" | 105 | + v-hasPermi="['${modlePath}:${moduleName}:${businessName}:export']" |
| 106 | >导出</el-button> | 106 | >导出</el-button> |
| 107 | </el-col> | 107 | </el-col> |
| 108 | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | 108 | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| @@ -148,18 +148,8 @@ | @@ -148,18 +148,8 @@ | ||
| 148 | #end | 148 | #end |
| 149 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 149 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 150 | <template #default="scope"> | 150 | <template #default="scope"> |
| 151 | - <el-button | ||
| 152 | - type="text" | ||
| 153 | - icon="Edit" | ||
| 154 | - @click="handleUpdate(scope.row)" | ||
| 155 | - v-hasPermi="['${moduleName}:${businessName}:edit']" | ||
| 156 | - >修改</el-button> | ||
| 157 | - <el-button | ||
| 158 | - type="text" | ||
| 159 | - icon="Delete" | ||
| 160 | - @click="handleDelete(scope.row)" | ||
| 161 | - v-hasPermi="['${moduleName}:${businessName}:remove']" | ||
| 162 | - >删除</el-button> | 151 | + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${modlePath}:${moduleName}:${businessName}:edit']">修改</el-button> |
| 152 | + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${modlePath}:${moduleName}:${businessName}:remove']">删除</el-button> | ||
| 163 | </template> | 153 | </template> |
| 164 | </el-table-column> | 154 | </el-table-column> |
| 165 | </el-table> | 155 | </el-table> |
| @@ -191,11 +181,11 @@ | @@ -191,11 +181,11 @@ | ||
| 191 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> | 181 | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| 192 | </el-form-item> | 182 | </el-form-item> |
| 193 | #elseif($column.htmlType == "imageUpload") | 183 | #elseif($column.htmlType == "imageUpload") |
| 194 | - <el-form-item label="${comment}"> | 184 | + <el-form-item label="${comment}" prop="${field}"> |
| 195 | <image-upload v-model="form.${field}"/> | 185 | <image-upload v-model="form.${field}"/> |
| 196 | </el-form-item> | 186 | </el-form-item> |
| 197 | #elseif($column.htmlType == "fileUpload") | 187 | #elseif($column.htmlType == "fileUpload") |
| 198 | - <el-form-item label="${comment}"> | 188 | + <el-form-item label="${comment}" prop="${field}"> |
| 199 | <file-upload v-model="form.${field}"/> | 189 | <file-upload v-model="form.${field}"/> |
| 200 | </el-form-item> | 190 | </el-form-item> |
| 201 | #elseif($column.htmlType == "editor") | 191 | #elseif($column.htmlType == "editor") |
| @@ -209,8 +199,11 @@ | @@ -209,8 +199,11 @@ | ||
| 209 | v-for="dict in ${dictType}" | 199 | v-for="dict in ${dictType}" |
| 210 | :key="dict.value" | 200 | :key="dict.value" |
| 211 | :label="dict.label" | 201 | :label="dict.label" |
| 212 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end | ||
| 213 | - | 202 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 203 | + :value="parseInt(dict.value)" | ||
| 204 | +#else | ||
| 205 | + :value="dict.value" | ||
| 206 | +#end | ||
| 214 | ></el-option> | 207 | ></el-option> |
| 215 | </el-select> | 208 | </el-select> |
| 216 | </el-form-item> | 209 | </el-form-item> |
| @@ -221,7 +214,7 @@ | @@ -221,7 +214,7 @@ | ||
| 221 | </el-select> | 214 | </el-select> |
| 222 | </el-form-item> | 215 | </el-form-item> |
| 223 | #elseif($column.htmlType == "checkbox" && "" != $dictType) | 216 | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| 224 | - <el-form-item label="${comment}"> | 217 | + <el-form-item label="${comment}" prop="${field}"> |
| 225 | <el-checkbox-group v-model="form.${field}"> | 218 | <el-checkbox-group v-model="form.${field}"> |
| 226 | <el-checkbox | 219 | <el-checkbox |
| 227 | v-for="dict in ${dictType}" | 220 | v-for="dict in ${dictType}" |
| @@ -232,24 +225,27 @@ | @@ -232,24 +225,27 @@ | ||
| 232 | </el-checkbox-group> | 225 | </el-checkbox-group> |
| 233 | </el-form-item> | 226 | </el-form-item> |
| 234 | #elseif($column.htmlType == "checkbox" && $dictType) | 227 | #elseif($column.htmlType == "checkbox" && $dictType) |
| 235 | - <el-form-item label="${comment}"> | 228 | + <el-form-item label="${comment}" prop="${field}"> |
| 236 | <el-checkbox-group v-model="form.${field}"> | 229 | <el-checkbox-group v-model="form.${field}"> |
| 237 | <el-checkbox>请选择字典生成</el-checkbox> | 230 | <el-checkbox>请选择字典生成</el-checkbox> |
| 238 | </el-checkbox-group> | 231 | </el-checkbox-group> |
| 239 | </el-form-item> | 232 | </el-form-item> |
| 240 | #elseif($column.htmlType == "radio" && "" != $dictType) | 233 | #elseif($column.htmlType == "radio" && "" != $dictType) |
| 241 | - <el-form-item label="${comment}"> | 234 | + <el-form-item label="${comment}" prop="${field}"> |
| 242 | <el-radio-group v-model="form.${field}"> | 235 | <el-radio-group v-model="form.${field}"> |
| 243 | <el-radio | 236 | <el-radio |
| 244 | v-for="dict in ${dictType}" | 237 | v-for="dict in ${dictType}" |
| 245 | :key="dict.value" | 238 | :key="dict.value" |
| 246 | - #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end | ||
| 247 | - | 239 | +#if($column.javaType == "Integer" || $column.javaType == "Long") |
| 240 | + :label="parseInt(dict.value)" | ||
| 241 | +#else | ||
| 242 | + :label="dict.value" | ||
| 243 | +#end | ||
| 248 | >{{dict.label}}</el-radio> | 244 | >{{dict.label}}</el-radio> |
| 249 | </el-radio-group> | 245 | </el-radio-group> |
| 250 | </el-form-item> | 246 | </el-form-item> |
| 251 | #elseif($column.htmlType == "radio" && $dictType) | 247 | #elseif($column.htmlType == "radio" && $dictType) |
| 252 | - <el-form-item label="${comment}"> | 248 | + <el-form-item label="${comment}" prop="${field}"> |
| 253 | <el-radio-group v-model="form.${field}"> | 249 | <el-radio-group v-model="form.${field}"> |
| 254 | <el-radio label="1">请选择字典生成</el-radio> | 250 | <el-radio label="1">请选择字典生成</el-radio> |
| 255 | </el-radio-group> | 251 | </el-radio-group> |
| @@ -398,7 +394,7 @@ const data = reactive({ | @@ -398,7 +394,7 @@ const data = reactive({ | ||
| 398 | #set($comment=$column.columnComment) | 394 | #set($comment=$column.columnComment) |
| 399 | #end | 395 | #end |
| 400 | $column.javaField: [ | 396 | $column.javaField: [ |
| 401 | - { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } | 397 | + { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| 402 | ]#if($foreach.count != $columns.size()),#end | 398 | ]#if($foreach.count != $columns.size()),#end |
| 403 | #end | 399 | #end |
| 404 | #end | 400 | #end |
| @@ -442,9 +438,7 @@ function cancel() { | @@ -442,9 +438,7 @@ function cancel() { | ||
| 442 | function reset() { | 438 | function reset() { |
| 443 | form.value = { | 439 | form.value = { |
| 444 | #foreach ($column in $columns) | 440 | #foreach ($column in $columns) |
| 445 | -#if($column.htmlType == "radio") | ||
| 446 | - $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end | ||
| 447 | -#elseif($column.htmlType == "checkbox") | 441 | +#if($column.htmlType == "checkbox") |
| 448 | $column.javaField: []#if($foreach.count != $columns.size()),#end | 442 | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| 449 | #else | 443 | #else |
| 450 | $column.javaField: null#if($foreach.count != $columns.size()),#end | 444 | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| @@ -492,8 +486,8 @@ function handleAdd() { | @@ -492,8 +486,8 @@ function handleAdd() { | ||
| 492 | /** 修改按钮操作 */ | 486 | /** 修改按钮操作 */ |
| 493 | function handleUpdate(row) { | 487 | function handleUpdate(row) { |
| 494 | reset(); | 488 | reset(); |
| 495 | - const ${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value | ||
| 496 | - get${BusinessName}(${pkColumn.javaField}).then(response => { | 489 | + const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value |
| 490 | + get${BusinessName}(_${pkColumn.javaField}).then(response => { | ||
| 497 | form.value = response.data; | 491 | form.value = response.data; |
| 498 | #foreach ($column in $columns) | 492 | #foreach ($column in $columns) |
| 499 | #if($column.htmlType == "checkbox") | 493 | #if($column.htmlType == "checkbox") |
| @@ -539,9 +533,9 @@ function submitForm() { | @@ -539,9 +533,9 @@ function submitForm() { | ||
| 539 | 533 | ||
| 540 | /** 删除按钮操作 */ | 534 | /** 删除按钮操作 */ |
| 541 | function handleDelete(row) { | 535 | function handleDelete(row) { |
| 542 | - const ${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value; | ||
| 543 | - proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() { | ||
| 544 | - return del${BusinessName}(${pkColumn.javaField}s); | 536 | + const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value; |
| 537 | + proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() { | ||
| 538 | + return del${BusinessName}(_${pkColumn.javaField}s); | ||
| 545 | }).then(() => { | 539 | }).then(() => { |
| 546 | getList(); | 540 | getList(); |
| 547 | proxy.#[[$modal]]#.msgSuccess("删除成功"); | 541 | proxy.#[[$modal]]#.msgSuccess("删除成功"); |
| @@ -587,7 +581,7 @@ function handle${subClassName}SelectionChange(selection) { | @@ -587,7 +581,7 @@ function handle${subClassName}SelectionChange(selection) { | ||
| 587 | #end | 581 | #end |
| 588 | /** 导出按钮操作 */ | 582 | /** 导出按钮操作 */ |
| 589 | function handleExport() { | 583 | function handleExport() { |
| 590 | - proxy.download('${moduleName}/${businessName}/export', { | 584 | + proxy.download('${modlePath}/${moduleName}/${businessName}/export', { |
| 591 | ...queryParams.value | 585 | ...queryParams.value |
| 592 | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) | 586 | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) |
| 593 | } | 587 | } |
| @@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 23 | #end | 23 | #end |
| 24 | 24 | ||
| 25 | <sql id="select${ClassName}Vo"> | 25 | <sql id="select${ClassName}Vo"> |
| 26 | - select#foreach($column in $columns) `$column.columnName`#if($foreach.count != $columns.size()),#end#end from ${tableName} | 26 | + select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName} |
| 27 | </sql> | 27 | </sql> |
| 28 | 28 | ||
| 29 | <select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result"> | 29 | <select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result"> |
| @@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 77 | <trim prefix="(" suffix=")" suffixOverrides=","> | 77 | <trim prefix="(" suffix=")" suffixOverrides=","> |
| 78 | #foreach($column in $columns) | 78 | #foreach($column in $columns) |
| 79 | #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) | 79 | #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) |
| 80 | - <if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">`$column.columnName`,</if> | 80 | + <if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if> |
| 81 | #end | 81 | #end |
| 82 | #end | 82 | #end |
| 83 | </trim> | 83 | </trim> |
| @@ -95,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -95,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 95 | <trim prefix="SET" suffixOverrides=","> | 95 | <trim prefix="SET" suffixOverrides=","> |
| 96 | #foreach($column in $columns) | 96 | #foreach($column in $columns) |
| 97 | #if($column.columnName != $pkColumn.columnName) | 97 | #if($column.columnName != $pkColumn.columnName) |
| 98 | - <if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">`$column.columnName` = #{$column.javaField},</if> | 98 | + <if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if> |
| 99 | #end | 99 | #end |
| 100 | #end | 100 | #end |
| 101 | </trim> | 101 | </trim> |
| @@ -146,7 +146,7 @@ public class BaseController | @@ -146,7 +146,7 @@ public class BaseController | ||
| 146 | /** | 146 | /** |
| 147 | * 返回成功消息 | 147 | * 返回成功消息 |
| 148 | */ | 148 | */ |
| 149 | - public AjaxResult success(String message) | 149 | + public AjaxResult success(Object message) |
| 150 | { | 150 | { |
| 151 | return AjaxResult.success(message); | 151 | return AjaxResult.success(message); |
| 152 | } | 152 | } |
| @@ -59,7 +59,6 @@ public class IotProduct implements Serializable | @@ -59,7 +59,6 @@ public class IotProduct implements Serializable | ||
| 59 | @ApiModelProperty("产品名称") | 59 | @ApiModelProperty("产品名称") |
| 60 | private String product_name; | 60 | private String product_name; |
| 61 | 61 | ||
| 62 | - | ||
| 63 | @ApiModelProperty("是否需要同步数据库(0否,1是)") | 62 | @ApiModelProperty("是否需要同步数据库(0否,1是)") |
| 64 | private Integer is_sync_db; | 63 | private Integer is_sync_db; |
| 65 | 64 | ||
| @@ -72,6 +71,17 @@ public class IotProduct implements Serializable | @@ -72,6 +71,17 @@ public class IotProduct implements Serializable | ||
| 72 | @ApiModelProperty("清洗服务") | 71 | @ApiModelProperty("清洗服务") |
| 73 | private Integer purification_clas; // varchar(100) DEFAULT 'com.zhonglai.luhui.device.protocol.factory.purification.DefaultProtocolPurificationFactoryImpl' COMMENT '清洗服务', | 72 | private Integer purification_clas; // varchar(100) DEFAULT 'com.zhonglai.luhui.device.protocol.factory.purification.DefaultProtocolPurificationFactoryImpl' COMMENT '清洗服务', |
| 74 | 73 | ||
| 74 | + @ApiModelProperty("订阅服务器id") | ||
| 75 | + private Integer subscribe_service_ip; | ||
| 76 | + | ||
| 77 | + public Integer getSubscribe_service_ip() { | ||
| 78 | + return subscribe_service_ip; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setSubscribe_service_ip(Integer subscribe_service_ip) { | ||
| 82 | + this.subscribe_service_ip = subscribe_service_ip; | ||
| 83 | + } | ||
| 84 | + | ||
| 75 | public Integer getPurification_clas() { | 85 | public Integer getPurification_clas() { |
| 76 | return purification_clas; | 86 | return purification_clas; |
| 77 | } | 87 | } |
lh-jar/lh-jar-device-service/src/main/java/com/zhonglai/luhui/device/domain/IotProductType.java
0 → 100644
| 1 | +package com.zhonglai.luhui.device.domain; | ||
| 2 | + | ||
| 3 | +import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 4 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import com.ruoyi.common.tool.BaseEntity; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 产品类型对象 iot_product_type | ||
| 11 | + * | ||
| 12 | + * @author zhonglai | ||
| 13 | + * @date 2024-06-26 | ||
| 14 | + */ | ||
| 15 | +@ApiModel("产品类型") | ||
| 16 | +public class IotProductType extends BaseEntity | ||
| 17 | +{ | ||
| 18 | + private static final long serialVersionUID = 1L; | ||
| 19 | + | ||
| 20 | + /** 主键 */ | ||
| 21 | + private Integer id; | ||
| 22 | + | ||
| 23 | + /** 类型名称 */ | ||
| 24 | + @ApiModelProperty(value="类型名称") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 27 | + /** 关联的产品id */ | ||
| 28 | + @ApiModelProperty(value="关联的产品id") | ||
| 29 | + private Integer productId; | ||
| 30 | + | ||
| 31 | + public void setId(Integer id) | ||
| 32 | + { | ||
| 33 | + this.id = id; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public Integer getId() | ||
| 37 | + { | ||
| 38 | + return id; | ||
| 39 | + } | ||
| 40 | + public void setName(String name) | ||
| 41 | + { | ||
| 42 | + this.name = name; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public String getName() | ||
| 46 | + { | ||
| 47 | + return name; | ||
| 48 | + } | ||
| 49 | + public void setProductId(Integer productId) | ||
| 50 | + { | ||
| 51 | + this.productId = productId; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public Integer getProductId() | ||
| 55 | + { | ||
| 56 | + return productId; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public String toString() { | ||
| 61 | + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 62 | + .append("id", getId()) | ||
| 63 | + .append("name", getName()) | ||
| 64 | + .append("productId", getProductId()) | ||
| 65 | + .append("createTime", getCreateTime()) | ||
| 66 | + .toString(); | ||
| 67 | + } | ||
| 68 | +} |
| @@ -44,6 +44,30 @@ public class IotProtocolClass extends BaseEntity | @@ -44,6 +44,30 @@ public class IotProtocolClass extends BaseEntity | ||
| 44 | @ApiModelProperty("创建时间") | 44 | @ApiModelProperty("创建时间") |
| 45 | private String create_time; | 45 | private String create_time; |
| 46 | 46 | ||
| 47 | + /** 类名 */ | ||
| 48 | + @ApiModelProperty("订阅的topic") | ||
| 49 | + private String sub_topics; | ||
| 50 | + | ||
| 51 | + /** 类名 */ | ||
| 52 | + @ApiModelProperty("协议地址") | ||
| 53 | + private String protocol_url; | ||
| 54 | + | ||
| 55 | + public String getSub_topics() { | ||
| 56 | + return sub_topics; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setSub_topics(String sub_topics) { | ||
| 60 | + this.sub_topics = sub_topics; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public String getProtocol_url() { | ||
| 64 | + return protocol_url; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setProtocol_url(String protocol_url) { | ||
| 68 | + this.protocol_url = protocol_url; | ||
| 69 | + } | ||
| 70 | + | ||
| 47 | public void setId(Integer id) | 71 | public void setId(Integer id) |
| 48 | { | 72 | { |
| 49 | this.id = id; | 73 | this.id = id; |
| @@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 20 | <result property="sync_db" column="sync_db" /> | 20 | <result property="sync_db" column="sync_db" /> |
| 21 | <result property="analysis_clas" column="analysis_clas" /> | 21 | <result property="analysis_clas" column="analysis_clas" /> |
| 22 | <result property="purification_clas" column="purification_clas" /> | 22 | <result property="purification_clas" column="purification_clas" /> |
| 23 | + <result property="subscribe_service_ip" column="subscribe_service_ip" /> | ||
| 23 | </resultMap> | 24 | </resultMap> |
| 24 | 25 | ||
| 25 | <sql id="selectIotProductVo"> | 26 | <sql id="selectIotProductVo"> |
| 26 | - select `id`,`mqtt_username`,`mqtt_password`,`product_name`,`mqtt_salt`,`create_time`,`encryption_type`,`open_encryption`,`used`,`role_id`,`is_sync_db`,`sync_db`,`analysis_clas`,`purification_clas` from iot_product | 27 | + select `id`,`mqtt_username`,`mqtt_password`,`product_name`,`mqtt_salt`,`create_time`,`encryption_type`,`open_encryption`,`used`,`role_id`,`is_sync_db`,`sync_db`,`analysis_clas`,`purification_clas`,`subscribe_service_ip` from iot_product |
| 27 | </sql> | 28 | </sql> |
| 28 | 29 | ||
| 29 | <select id="selectIotProductList" parameterType="IotProduct" resultMap="IotProductResult"> | 30 | <select id="selectIotProductList" parameterType="IotProduct" resultMap="IotProductResult"> |
| @@ -38,6 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -38,6 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 38 | <if test="mqtt_username != null and mqtt_username != ''"> | 39 | <if test="mqtt_username != null and mqtt_username != ''"> |
| 39 | AND `mqtt_username` like concat('%', #{mqtt_username}, '%') | 40 | AND `mqtt_username` like concat('%', #{mqtt_username}, '%') |
| 40 | </if> | 41 | </if> |
| 42 | + <if test="subscribe_service_ip != null and subscribe_service_ip != ''"> | ||
| 43 | + AND `subscribe_service_ip` like concat('%', #{subscribe_service_ip}, '%') | ||
| 44 | + </if> | ||
| 41 | </where> | 45 | </where> |
| 42 | </select> | 46 | </select> |
| 43 | 47 |
| @@ -11,10 +11,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -11,10 +11,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 11 | <result property="case_model" column="case_model" /> | 11 | <result property="case_model" column="case_model" /> |
| 12 | <result property="classname" column="classname" /> | 12 | <result property="classname" column="classname" /> |
| 13 | <result property="create_time" column="create_time" /> | 13 | <result property="create_time" column="create_time" /> |
| 14 | + <result property="sub_topics" column="sub_topics" /> | ||
| 15 | + <result property="protocol_url" column="protocol_url" /> | ||
| 14 | </resultMap> | 16 | </resultMap> |
| 15 | 17 | ||
| 16 | <sql id="selectIotProtocolClassVo"> | 18 | <sql id="selectIotProtocolClassVo"> |
| 17 | - select `id`, `type`, `name`, `case_model`, `classname`, `create_time` from iot_protocol_class | 19 | + select `id`, `type`, `name`, `case_model`, `classname`, `create_time`,`sub_topics`,`protocol_url` from iot_protocol_class |
| 18 | </sql> | 20 | </sql> |
| 19 | 21 | ||
| 20 | <select id="selectIotProtocolClassList" parameterType="IotProtocolClass" resultMap="IotProtocolClassResult"> | 22 | <select id="selectIotProtocolClassList" parameterType="IotProtocolClass" resultMap="IotProtocolClassResult"> |
| @@ -40,6 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -40,6 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 40 | <if test="case_model != null">`case_model`,</if> | 42 | <if test="case_model != null">`case_model`,</if> |
| 41 | <if test="classname != null">`classname`,</if> | 43 | <if test="classname != null">`classname`,</if> |
| 42 | <if test="create_time != null">`create_time`,</if> | 44 | <if test="create_time != null">`create_time`,</if> |
| 45 | + <if test="sub_topics != null">`sub_topics`,</if> | ||
| 46 | + <if test="protocol_url != null">`protocol_url`,</if> | ||
| 43 | </trim> | 47 | </trim> |
| 44 | <trim prefix="values (" suffix=")" suffixOverrides=","> | 48 | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| 45 | <if test="type != null">#{type},</if> | 49 | <if test="type != null">#{type},</if> |
| @@ -47,6 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -47,6 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 47 | <if test="case_model != null">#{case_model},</if> | 51 | <if test="case_model != null">#{case_model},</if> |
| 48 | <if test="classname != null">#{classname},</if> | 52 | <if test="classname != null">#{classname},</if> |
| 49 | <if test="create_time != null">#{create_time},</if> | 53 | <if test="create_time != null">#{create_time},</if> |
| 54 | + <if test="sub_topics != null">#{sub_topics},</if> | ||
| 55 | + <if test="protocol_url != null">#{protocol_url},</if> | ||
| 50 | </trim> | 56 | </trim> |
| 51 | </insert> | 57 | </insert> |
| 52 | 58 | ||
| @@ -58,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -58,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 58 | <if test="case_model != null">`case_model` = #{case_model},</if> | 64 | <if test="case_model != null">`case_model` = #{case_model},</if> |
| 59 | <if test="classname != null">`classname` = #{classname},</if> | 65 | <if test="classname != null">`classname` = #{classname},</if> |
| 60 | <if test="create_time != null">`create_time` = #{create_time},</if> | 66 | <if test="create_time != null">`create_time` = #{create_time},</if> |
| 67 | + <if test="sub_topics != null">`sub_topics` = #{sub_topics},</if> | ||
| 68 | + <if test="protocol_url != null">`protocol_url` = #{protocol_url},</if> | ||
| 61 | </trim> | 69 | </trim> |
| 62 | where id = #{id} | 70 | where id = #{id} |
| 63 | </update> | 71 | </update> |
| 1 | +package com.zhonglai.luhui.admin.controller.iot; | ||
| 2 | + | ||
| 3 | +import javax.servlet.http.HttpServletResponse; | ||
| 4 | + | ||
| 5 | +import com.zhonglai.luhui.sys.utils.ExcelUtil; | ||
| 6 | +import io.swagger.annotations.Api; | ||
| 7 | +import io.swagger.annotations.ApiOperation; | ||
| 8 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 12 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 15 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 17 | +import org.springframework.web.bind.annotation.RestController; | ||
| 18 | +import com.ruoyi.common.annotation.Log; | ||
| 19 | +import com.zhonglai.luhui.action.BaseController; | ||
| 20 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 21 | +import com.ruoyi.common.enums.BusinessType; | ||
| 22 | +import com.zhonglai.luhui.dao.service.PublicTemplateService; | ||
| 23 | + | ||
| 24 | +import com.zhonglai.luhui.device.domain.IotProductType; | ||
| 25 | + | ||
| 26 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 27 | + | ||
| 28 | +import java.util.List; | ||
| 29 | + | ||
| 30 | +/** | ||
| 31 | + * 产品类型Controller | ||
| 32 | + * | ||
| 33 | + * @author zhonglai | ||
| 34 | + * @date 2024-06-26 | ||
| 35 | + */ | ||
| 36 | +@Api(tags = "产品类型") | ||
| 37 | +@RestController | ||
| 38 | +@RequestMapping("/com.zhonglai.luhui.admin/iot/product_type") | ||
| 39 | +public class IotProductTypeController extends BaseController | ||
| 40 | +{ | ||
| 41 | + @Autowired | ||
| 42 | + private PublicTemplateService publicTemplateService; | ||
| 43 | + | ||
| 44 | + @ApiOperation(value ="查询产品类型列表",notes="\n" + | ||
| 45 | + "公共参数描述:\n" + | ||
| 46 | + "条件参数:\n" + | ||
| 47 | + "timeMap; //时间条件(如:{\"create_time\":[开始时间,结束时间]})\n" + | ||
| 48 | + "keyValue; //模糊匹配的关键字(如:[\"value\",\"name,no\"])\n" + | ||
| 49 | + "queryParams; //字段对应的比较符号(如:{\"id\":\"EQ\"})\n" + | ||
| 50 | + "orderBy; //排序(如:\"id desc,name asc\")\n" + | ||
| 51 | + "\n" + | ||
| 52 | + "分页参数:\n" + | ||
| 53 | + "pageNum; //当前记录起始索引,从1开始\n" + | ||
| 54 | + "pageSize; //每页显示记录数") | ||
| 55 | + @PreAuthorize("@ss.hasPermi('com.zhonglai.luhui.admin:iot:product_type:list')") | ||
| 56 | + @GetMapping("/list") | ||
| 57 | + public TableDataInfo list(IotProductType iotProductType) | ||
| 58 | + { | ||
| 59 | + startPage(); | ||
| 60 | + List<IotProductType> list = publicTemplateService.selectTList(iotProductType); | ||
| 61 | + return getDataTable(list); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @ApiOperation("导出产品类型列表") | ||
| 65 | + @PreAuthorize("@ss.hasPermi('com.zhonglai.luhui.admin:iot:product_type:export')") | ||
| 66 | + @Log(title = "产品类型", businessType = BusinessType.EXPORT) | ||
| 67 | + @PostMapping("/export") | ||
| 68 | + public void export(HttpServletResponse response, IotProductType iotProductType) | ||
| 69 | + { | ||
| 70 | + List<IotProductType> list = publicTemplateService.selectTList(iotProductType); | ||
| 71 | + ExcelUtil<IotProductType> util = new ExcelUtil<IotProductType>(IotProductType.class); | ||
| 72 | + util.exportExcel(response, list, "产品类型数据"); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @ApiOperation("获取产品类型详细信息") | ||
| 76 | + @PreAuthorize("@ss.hasPermi('com.zhonglai.luhui.admin:iot:product_type:query')") | ||
| 77 | + @GetMapping(value = "/{id}") | ||
| 78 | + public AjaxResult getInfo(@PathVariable("id") Integer id) | ||
| 79 | + { | ||
| 80 | + return success(publicTemplateService.getTById(id, IotProductType.class)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @ApiOperation("新增产品类型") | ||
| 84 | + @PreAuthorize("@ss.hasPermi('com.zhonglai.luhui.admin:iot:product_type:add')") | ||
| 85 | + @Log(title = "产品类型", businessType = BusinessType.INSERT) | ||
| 86 | + @PostMapping | ||
| 87 | + public AjaxResult add(@RequestBody IotProductType iotProductType) | ||
| 88 | + { | ||
| 89 | + return toAjax(publicTemplateService.add(iotProductType)); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @ApiOperation("修改产品类型") | ||
| 93 | + @PreAuthorize("@ss.hasPermi('com.zhonglai.luhui.admin:iot:product_type:edit')") | ||
| 94 | + @Log(title = "产品类型", businessType = BusinessType.UPDATE) | ||
| 95 | + @PutMapping | ||
| 96 | + public AjaxResult edit(@RequestBody IotProductType iotProductType) | ||
| 97 | + { | ||
| 98 | + return toAjax(publicTemplateService.edit((iotProductType))); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @ApiOperation("删除产品类型") | ||
| 102 | + @PreAuthorize("@ss.hasPermi('com.zhonglai.luhui.admin:iot:product_type:remove')") | ||
| 103 | + @Log(title = "产品类型", businessType = BusinessType.DELETE) | ||
| 104 | + @DeleteMapping("/{ids}") | ||
| 105 | + public AjaxResult remove(@PathVariable Integer[] ids) | ||
| 106 | + { | ||
| 107 | + return toAjax(publicTemplateService.removeByIds(IotProductType.class,ids)); | ||
| 108 | + } | ||
| 109 | +} |
| @@ -189,6 +189,7 @@ public class IotThingsModelController extends BaseController | @@ -189,6 +189,7 @@ public class IotThingsModelController extends BaseController | ||
| 189 | iotThingsModel.setMqtt_username(iotProduct.getMqtt_username()); | 189 | iotThingsModel.setMqtt_username(iotProduct.getMqtt_username()); |
| 190 | terminalDataThingsModeService.saveIotThingsModel(JSON.parseObject(JSONObject.toJSONString(iotThingsModel),IotThingsModel.class)); | 190 | terminalDataThingsModeService.saveIotThingsModel(JSON.parseObject(JSONObject.toJSONString(iotThingsModel),IotThingsModel.class)); |
| 191 | 191 | ||
| 192 | + | ||
| 192 | return toAjax(ri); | 193 | return toAjax(ri); |
| 193 | } | 194 | } |
| 194 | 195 |
lh-modules/lh-admin/src/main/java/com/zhonglai/luhui/admin/controller/system/LuhuiGenController.java
0 → 100644
| 1 | +package com.zhonglai.luhui.admin.controller.system; | ||
| 2 | + | ||
| 3 | +import com.zhonglai.luhui.admin.service.LuhuiGenService; | ||
| 4 | +import io.swagger.annotations.Api; | ||
| 5 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 6 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 7 | +import io.swagger.annotations.ApiOperation; | ||
| 8 | +import org.apache.commons.io.IOUtils; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.RestController; | ||
| 14 | + | ||
| 15 | +import javax.servlet.http.HttpServletResponse; | ||
| 16 | +import java.io.IOException; | ||
| 17 | + | ||
| 18 | +@Api(tags = "禄辉代码生成管理") | ||
| 19 | +@RestController | ||
| 20 | +@RequestMapping("/admin/luhuiGen") | ||
| 21 | +public class LuhuiGenController { | ||
| 22 | + | ||
| 23 | + @Autowired | ||
| 24 | + private LuhuiGenService luhuiGenService; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 批量生成代码 | ||
| 28 | + */ | ||
| 29 | + @ApiOperation( "代码生成") | ||
| 30 | + @ApiImplicitParams({ | ||
| 31 | + @ApiImplicitParam(name = "databaseName", value = "数据库名称",required = true), | ||
| 32 | + @ApiImplicitParam(name = "tableNmaes", value = "表名集合") | ||
| 33 | + }) | ||
| 34 | + @GetMapping("/batchGenCode/{databaseName}") | ||
| 35 | + public void generatorCodeFromDatabase(HttpServletResponse response, @PathVariable("databaseName") String databaseName,String modlePath,String tableNmaes) throws IOException | ||
| 36 | + { | ||
| 37 | + byte[] data = luhuiGenService.generatorCodeFromDb(databaseName,modlePath,tableNmaes); | ||
| 38 | + genCode(response, data); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 生成zip文件 | ||
| 43 | + */ | ||
| 44 | + private void genCode(HttpServletResponse response, byte[] data) throws IOException | ||
| 45 | + { | ||
| 46 | + response.reset(); | ||
| 47 | + response.addHeader("Access-Control-Allow-Origin", "*"); | ||
| 48 | + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); | ||
| 49 | + response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); | ||
| 50 | + response.addHeader("Content-Length", "" + data.length); | ||
| 51 | + response.setContentType("application/octet-stream; charset=UTF-8"); | ||
| 52 | + IOUtils.write(data, response.getOutputStream()); | ||
| 53 | + } | ||
| 54 | +} |
| 1 | +package com.zhonglai.luhui.admin.service; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.ruoyi.common.utils.StringUtils; | ||
| 5 | +import com.ruoyi.generator.domain.GenTable; | ||
| 6 | +import com.ruoyi.generator.domain.GenTableColumn; | ||
| 7 | +import com.ruoyi.generator.service.GenTableServiceImpl; | ||
| 8 | +import com.ruoyi.generator.util.GenUtils; | ||
| 9 | +import com.zhonglai.luhui.dao.service.PublicService; | ||
| 10 | +import org.apache.commons.io.IOUtils; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | + | ||
| 14 | +import java.io.ByteArrayOutputStream; | ||
| 15 | +import java.io.File; | ||
| 16 | +import java.io.IOException; | ||
| 17 | +import java.net.URL; | ||
| 18 | +import java.util.ArrayList; | ||
| 19 | +import java.util.Enumeration; | ||
| 20 | +import java.util.List; | ||
| 21 | +import java.util.Map; | ||
| 22 | +import java.util.zip.ZipOutputStream; | ||
| 23 | + | ||
| 24 | +@Service | ||
| 25 | +public class LuhuiGenService { | ||
| 26 | + | ||
| 27 | + @Autowired | ||
| 28 | + private PublicService publicService; | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 31 | + private GenTableServiceImpl genTableService; | ||
| 32 | + | ||
| 33 | + public byte[] generatorCodeFromDb(String databaseName,String modlePath,String tableNmaes) | ||
| 34 | + { | ||
| 35 | + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
| 36 | + ZipOutputStream zip = new ZipOutputStream(outputStream); | ||
| 37 | + | ||
| 38 | + // 查询表信息 | ||
| 39 | + List<GenTable> tables = fromDBNameToGenTables(databaseName,modlePath,tableNmaes); | ||
| 40 | + for (GenTable table:tables) | ||
| 41 | + { | ||
| 42 | + genTableService.generatorCode(table, zip); | ||
| 43 | + } | ||
| 44 | + IOUtils.closeQuietly(zip); | ||
| 45 | + return outputStream.toByteArray(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + private static List<String> findClassesInPackage(String packageName) throws ClassNotFoundException, IOException { | ||
| 49 | + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | ||
| 50 | + String path = packageName.replace('.', '/'); | ||
| 51 | + Enumeration<URL> resources = classLoader.getResources(path); | ||
| 52 | + List<String> classNames = new ArrayList<>(); | ||
| 53 | + while (resources.hasMoreElements()) { | ||
| 54 | + URL resource = resources.nextElement(); | ||
| 55 | + classNames.addAll(findClasses(new File(resource.getFile()), packageName)); | ||
| 56 | + } | ||
| 57 | + return classNames; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + private static List<String> findClasses(File directory, String packageName) throws ClassNotFoundException, IOException { | ||
| 61 | + List<String> classNames = new ArrayList<>(); | ||
| 62 | + if (!directory.exists()) { | ||
| 63 | + return classNames; | ||
| 64 | + } | ||
| 65 | + File[] files = directory.listFiles(); | ||
| 66 | + if (files != null) { | ||
| 67 | + for (File file : files) { | ||
| 68 | + if (file.isDirectory()) { | ||
| 69 | + // 如果是目录,递归调用findClasses方法 | ||
| 70 | + classNames.addAll(findClasses(file, packageName + "." + file.getName())); | ||
| 71 | + } else if (file.getName().endsWith(".class")) { | ||
| 72 | + // 如果是.class文件,提取类名 | ||
| 73 | + String className = packageName + '.' + file.getName().substring(0, file.getName().length() - 6); | ||
| 74 | + try { | ||
| 75 | + Class.forName(className); | ||
| 76 | + classNames.add(className.substring(className.lastIndexOf(".")+1)); | ||
| 77 | + } catch (ClassNotFoundException e) { | ||
| 78 | + // 忽略找不到的类,可能是一个编译后的.class文件而没有对应的源代码 | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + return classNames; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + private List<GenTable> fromDBNameToGenTables(String dbName,String modlePath,String tableNmaes) { | ||
| 87 | + String tableWhere = ""; | ||
| 88 | + if (StringUtils.isNotEmpty(tableNmaes)) { | ||
| 89 | + tableWhere = " and TABLE_NAME in ('" + tableNmaes.replace(",", "','") + "')"; | ||
| 90 | + } | ||
| 91 | + List<Map<String, Object>> list = publicService.getObjectListBySQL("SELECT TABLE_NAME, TABLE_COMMENT, CREATE_TIME, UPDATE_TIME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" + dbName + "'" + tableWhere); | ||
| 92 | + if (null != list && list.size() != 0) { | ||
| 93 | + List<String> classNames = new ArrayList<>(); | ||
| 94 | + try { | ||
| 95 | + classNames = findClassesInPackage("com.zhonglai.luhui.domain"); | ||
| 96 | + } catch (ClassNotFoundException e) { | ||
| 97 | + throw new RuntimeException(e); | ||
| 98 | + } catch (IOException e) { | ||
| 99 | + throw new RuntimeException(e); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + List<GenTable> listGenTable = new ArrayList<>(); | ||
| 103 | + for (Map<String, Object> map : list) { | ||
| 104 | + GenTable table = JSONObject.parseObject(JSONObject.toJSONString(map), GenTable.class); | ||
| 105 | + String tableName = table.getTableName(); | ||
| 106 | + | ||
| 107 | + String className = GenUtils.convertClassName(tableName); | ||
| 108 | +// if (StringUtils.isEmpty(tableNmaes) && classNames.contains(className)) { | ||
| 109 | +// continue; | ||
| 110 | +// } | ||
| 111 | + | ||
| 112 | + GenUtils.initTable(table, "钟来"); | ||
| 113 | + table.setModlePath(modlePath); | ||
| 114 | + | ||
| 115 | + String moduleName = tableName.split("_")[0]; | ||
| 116 | + table.setPackageName("com.zhonglai.luhui"); | ||
| 117 | + table.setModuleName(moduleName); | ||
| 118 | + table.setTplCategory("crud"); | ||
| 119 | + table.setGenPath("/"); | ||
| 120 | + table.setGenType("0"); | ||
| 121 | + | ||
| 122 | + List<Map<String, Object>> columnlist = publicService.getObjectListBySQL("SELECT column_name, (CASE WHEN (is_nullable = 'no' && column_key != 'PRI') THEN '1' ELSE '0' END) AS is_required, (CASE WHEN column_key = 'PRI' THEN '1' ELSE '0' END) AS is_pk, ordinal_position AS sort, column_comment, (CASE WHEN extra = 'auto_increment' THEN '1' ELSE '0' END) AS is_increment, column_type\n" + | ||
| 123 | + "\t\tFROM information_schema.columns WHERE table_schema = '" + dbName + "' AND table_name = '" + tableName + "'\n" + | ||
| 124 | + "\t\tORDER BY ordinal_position"); | ||
| 125 | + | ||
| 126 | + List<GenTableColumn> columns = new ArrayList<>(); | ||
| 127 | + for (Map<String, Object> columnMap : columnlist) { | ||
| 128 | + GenTableColumn column = JSONObject.parseObject(JSONObject.toJSONString(columnMap), GenTableColumn.class); | ||
| 129 | + GenUtils.initColumnField(column, table); | ||
| 130 | + if (StringUtils.isEmpty(column.getDictType())) { | ||
| 131 | + column.setDictType(""); | ||
| 132 | + | ||
| 133 | + if (StringUtils.isEmpty(column.getQueryType())) { | ||
| 134 | + column.setQueryType("EQ"); | ||
| 135 | + } | ||
| 136 | + columns.add(column); | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + table.setColumns(columns); | ||
| 140 | + | ||
| 141 | + } | ||
| 142 | + listGenTable.add(table); | ||
| 143 | + | ||
| 144 | + | ||
| 145 | + } | ||
| 146 | + return listGenTable; | ||
| 147 | + } | ||
| 148 | + return null; | ||
| 149 | + } | ||
| 150 | +} |
-
请 注册 或 登录 后发表评论