| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> implements IGenTableService { |
| | | public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTable> implements IGenTableService { |
| | | |
| | | @Autowired |
| | | private GenTableColumnMapper genTableColumnMapper; |
| | |
| | | // 获取模板列表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) { |
| | | if (!StrUtil.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { |
| | | if (!StrUtil.containsAny("sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm", template)) { |
| | | // 渲染模板 |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | |
| | | * @param genTable 设置后的生成对象 |
| | | */ |
| | | public void setTableFromOptions(GenTable genTable) { |
| | | Map<String, String> paramsObj = JsonUtils.parseMap(genTable.getOptions()); |
| | | Map<String, Object> paramsObj = JsonUtils.parseMap(genTable.getOptions()); |
| | | if (Validator.isNotNull(paramsObj)) { |
| | | String treeCode = paramsObj.get(GenConstants.TREE_CODE); |
| | | String treeParentCode = paramsObj.get(GenConstants.TREE_PARENT_CODE); |
| | | String treeName = paramsObj.get(GenConstants.TREE_NAME); |
| | | String parentMenuId = paramsObj.get(GenConstants.PARENT_MENU_ID); |
| | | String parentMenuName = paramsObj.get(GenConstants.PARENT_MENU_NAME); |
| | | String treeCode = Convert.toStr(paramsObj.get(GenConstants.TREE_CODE)); |
| | | String treeParentCode = Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE)); |
| | | String treeName = Convert.toStr(paramsObj.get(GenConstants.TREE_NAME)); |
| | | String parentMenuId = Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)); |
| | | String parentMenuName = Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_NAME)); |
| | | |
| | | genTable.setTreeCode(treeCode); |
| | | genTable.setTreeParentCode(treeParentCode); |
| | |
| | | /** |
| | | * 获取代码生成地址 |
| | | * |
| | | * @param table 业务表信息 |
| | | * @param table 业务表信息 |
| | | * @param template 模板文件路径 |
| | | * @return 生成地址 |
| | | */ |