tanghc 3 jaren geleden
bovenliggende
commit
dd52a5f406

+ 7 - 0
changelog.md

@@ -1,5 +1,12 @@
 # changelog
 
+## 1.4.2
+
+- 修复oracle下同一库不同用户无法显示表问题
+- 修复模板名称重复问题
+- 数据源下拉框显示用户名
+- 修复${table.hasBigDecimalField}不生效问题
+
 ## 1.4.1
 
 - 修复数据库字段单个单词全部大写的情况下,实体字段会全部大写

+ 5 - 2
front/src/views/generate/GenerateConfig/index.vue

@@ -10,10 +10,10 @@
           <el-option
             v-for="item in datasourceConfigList"
             :key="item.id"
-            :label="`${item.dbName}(${item.host})`"
+            :label="getDatasourceLabel(item)"
             :value="item.id"
           >
-            <span style="float: left">{{ `${item.dbName}(${item.host})` }} </span>
+            <span style="float: left">{{ getDatasourceLabel(item) }}</span>
             <span style="float: right; color: #8492a6; font-size: 13px">
               <el-tooltip placement="top" content="Duplicate">
                 <el-link type="primary" icon="el-icon-document-copy" style="margin-right: 20px;" @click.stop="onDataSourceDuplicate(item)"></el-link>
@@ -298,6 +298,9 @@ export default {
       row.hidden = true
       return 'hidden-row';
     },
+    getDatasourceLabel(item) {
+      return `${item.dbName} (${item.host}) - ${item.username}`
+    },
     loadGroups() {
       this.post(`/group/list/`, {}, function(resp) {
         this.groupData = resp.data

+ 2 - 1
front/src/views/group/index.vue

@@ -31,12 +31,13 @@
         :rules="formRules"
         size="mini"
         label-width="120px"
+        @submit.native.prevent
       >
         <el-form-item prop="name" label="模板组名称">
           <el-input v-model="formData.groupName" show-word-limit maxlength="100" />
         </el-form-item>
         <el-form-item>
-          <el-button type="primary" @click="onSave">保 存</el-button>
+          <el-button type="primary" native-type="submit" @click="onSave">保 存</el-button>
         </el-form-item>
       </el-form>
     </el-dialog>

+ 1 - 2
gen/src/main/java/com/gitee/gen/controller/TemplateGroupController.java

@@ -68,8 +68,7 @@ public class TemplateGroupController {
      */
     @RequestMapping("update")
     public Result update(@RequestBody TemplateGroup templateGroup) {
-//        templateGroupService.updateIgnoreNull(templateGroup);
-        templateGroupService.updateGroup(templateGroup);
+        templateGroupService.updateIgnoreNull(templateGroup);
         return Action.ok();
     }
 

+ 1 - 1
gen/src/main/java/com/gitee/gen/gen/converter/JavaColumnTypeConverter.java

@@ -21,7 +21,7 @@ public class JavaColumnTypeConverter implements ColumnTypeConverter {
         TYPE_MAP.put(TypeEnum.BIGINT.getType(), "long");
         TYPE_MAP.put(TypeEnum.FLOAT.getType(), "float");
         TYPE_MAP.put(TypeEnum.DOUBLE.getType(), "double");
-        TYPE_MAP.put(TypeEnum.DECIMAL.getType(), "decimal");
+        TYPE_MAP.put(TypeEnum.DECIMAL.getType(), "BigDecimal");
         TYPE_MAP.put(TypeEnum.VARCHAR.getType(), "string");
         TYPE_MAP.put(TypeEnum.DATETIME.getType(), "Date");
         TYPE_MAP.put(TypeEnum.BLOB.getType(), "byte[]");

+ 0 - 23
gen/src/main/java/com/gitee/gen/gen/oracle/OracleColumnSelector.java

@@ -41,29 +41,6 @@ public class OracleColumnSelector extends ColumnSelector {
 		super(generatorConfig);
 	}
 
-	/**
-	 * 查询 字段名 类型 编码 是否为空 是否主键 默认值 权限 注释
-	 * select
-	 * utc.column_name as 字段名,utc.data_type 数据类型,utc.data_length 最大长度,
-	 * CASE utc.nullable WHEN 'N' THEN '否' ELSE '是' END 可空,
-	 * utc.data_default 默认值,ucc.comments 注释,UTC.table_name 表名,
-	 * CASE UTC.COLUMN_NAME
-	 * WHEN (select
-	 * col.column_name
-	 * from
-	 * user_constraints con,user_cons_columns col
-	 * where
-	 * con.constraint_name=col.constraint_name and con.constraint_type='P'
-	 * and col.table_name='DEMO')   THEN '是' ELSE '否' END AS 主键
-	 * from
-	 * user_tab_columns utc,user_col_comments ucc
-	 * where
-	 * utc.table_name = ucc.table_name
-	 * and utc.column_name = ucc.column_name
-	 * and utc.table_name = 'DEMO'
-	 * order by
-	 * column_id;
-	 */
 	@Override
 	protected String getColumnInfoSQL(String tableName) {
 		return String.format(COLUMN_SQL, tableName, tableName);

+ 1 - 1
gen/src/main/java/com/gitee/gen/mapper/TemplateConfigMapper.java

@@ -9,7 +9,7 @@ import java.util.List;
 @Mapper
 public interface TemplateConfigMapper {
 
-    TemplateConfig getByName(String name);
+    TemplateConfig getByName(@Param("name") String name, @Param("groupId") Integer groupId);
 
     /**
      * 查询所有记录

+ 8 - 6
gen/src/main/java/com/gitee/gen/service/TemplateConfigService.java

@@ -35,18 +35,20 @@ public class TemplateConfigService {
     }
 
     public void insert(TemplateConfig templateConfig) {
-//        TemplateConfig existObj = templateConfigMapper.getByName(templateConfig.getName());
-//        if (existObj != null) {
-//            throw new RuntimeException("模板名称已存在");
-//        }
+        String name = templateConfig.getName();
+        TemplateConfig existObj = templateConfigMapper.getByName(name, templateConfig.getGroupId());
+        if (existObj != null) {
+            throw new RuntimeException("模板名称 "+ name +" 已存在");
+        }
         templateConfig.setIsDeleted(0);
         templateConfigMapper.insert(templateConfig);
     }
 
     public void update(TemplateConfig templateConfig) {
-        TemplateConfig existObj = templateConfigMapper.getByName(templateConfig.getName());
+        String name = templateConfig.getName();
+        TemplateConfig existObj = templateConfigMapper.getByName(name, templateConfig.getGroupId());
         if (existObj != null && !Objects.equals(templateConfig.getId(), existObj.getId())) {
-            throw new RuntimeException("模板名称已存在");
+            throw new RuntimeException("模板名称 "+ name +" 已存在");
         }
         templateConfigMapper.updateIgnoreNull(templateConfig);
     }

+ 4 - 6
gen/src/main/java/com/gitee/gen/service/TemplateGroupService.java

@@ -93,13 +93,11 @@ public class TemplateGroupService {
         return templateGroupMapper.delete(templateGroup);
     }
 
-    public int updateGroup(TemplateGroup templateGroup) {
-        int count = updateIgnoreNull(templateGroup);
-        templateConfigMapper.updateGroupNameByGroupId(templateGroup.getId(), templateGroup.getGroupName());
-        return count;
-    }
-
     public int deleteGroup(TemplateGroup templateGroup) {
+        List<TemplateGroup> templateGroups = this.listAll();
+        if (templateGroups.size() == 1) {
+            throw new RuntimeException("无法删除,必须要有一个模板组");
+        }
         int delete = templateGroupMapper.delete(templateGroup);
         templateConfigMapper.deleteByGroupId(templateGroup.getId());
         return delete;

+ 2 - 1
gen/src/main/resources/mybatis/TemplateConfigMapper.xml

@@ -34,7 +34,8 @@
         SELECT
         <include refid="baseColumns"/>
         FROM template_config t
-        WHERE name = #{name}
+        WHERE name = #{name} AND group_id=#{groupId}
+        LIMIT 1
     </select>
 
     <!-- 根据主键获取单条记录 -->

File diff suppressed because it is too large
+ 1 - 1
gen/src/main/resources/public/index.html


File diff suppressed because it is too large
+ 1 - 0
gen/src/main/resources/public/static/js/chunk-0bb63457.3ae296fd.js


File diff suppressed because it is too large
+ 0 - 1
gen/src/main/resources/public/static/js/chunk-0bb63457.44392e8b.js


File diff suppressed because it is too large
+ 1 - 0
gen/src/main/resources/public/static/js/chunk-74aeca77.82f8150c.js


File diff suppressed because it is too large
+ 0 - 1
gen/src/main/resources/public/static/js/chunk-74aeca77.ffdf8285.js