Skip to content

Commit

Permalink
+ 优化了包名
Browse files Browse the repository at this point in the history
! 修复了一些问题
  • Loading branch information
cruldra committed Dec 30, 2022
1 parent 01ddd1b commit a3d4675
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 18 deletions.
18 changes: 10 additions & 8 deletions src/org/cruldra/pdmviewer/PDMViewerApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
import javax.swing.LayoutStyle;

import kotlin.text.StringsKt;
import org.cruldra.pdmviewer.models.PDM;
import org.cruldra.pdmviewer.models.PDMColumn;
import org.cruldra.pdmviewer.models.PDMTable;
import org.cruldra.pdmviewer.parser.Parser;
import org.cruldra.pdmviewer.utils.*;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

import java.awt.Frame;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import javax.swing.JFileChooser;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
Expand Down Expand Up @@ -175,7 +177,7 @@ private void generateInsertSelectiveBlockMenu(ActionEvent e) {
trim1.addAttribute("suffixOverrides", ",");
pdmt.getColumns().forEach(pdmColumn -> {
Element if1 = trim1.addElement("if");
if1.addAttribute("test", pdmColumn.getCode() + " != null");
if1.addAttribute("test", StrUtilsKt.toCamelCase(pdmColumn.getCode()) + " != null");
if1.addText(pdmColumn.getCode() + ",");
});

Expand All @@ -185,8 +187,8 @@ private void generateInsertSelectiveBlockMenu(ActionEvent e) {
trim2.addAttribute("suffixOverrides", ",");
pdmt.getColumns().forEach(pdmColumn -> {
Element if2 = trim2.addElement("if");
if2.addAttribute("test", pdmColumn.getCode() + " != null");
if2.addText("#{" + pdmColumn.getCode() + ",jdbcType=" + StringsKt.substringBefore(pdmColumn.getDataType(), "(", pdmColumn.getDataType()) + "},");
if2.addAttribute("test", StrUtilsKt.toCamelCase(pdmColumn.getCode()) + " != null");
if2.addText("#{" + StrUtilsKt.toCamelCase(pdmColumn.getCode()) + ",jdbcType=" + PDMColumnExtensionsKt.getIbatisType(pdmColumn) + "},");
});

Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Expand Down Expand Up @@ -214,10 +216,10 @@ private void generateUpdateByPrimaryKeySelectiveBlockMenu(ActionEvent e) {
Element set = root.addElement("set");
pdmt.getColumns().forEach(pdmColumn -> {
Element if1 = set.addElement("if");
if1.addAttribute("test", pdmColumn.getCode() + " != null");
if1.addText(pdmColumn.getCode() + " = #{" + StrUtilsKt.toCamelCase(pdmColumn.getCode()) + ",jdbcType=" + StringsKt.substringBefore(pdmColumn.getDataType(), "(", pdmColumn.getDataType()) + "},");
if1.addAttribute("test", StrUtilsKt.toCamelCase(pdmColumn.getCode()) + " != null");
if1.addText(pdmColumn.getCode() + " = #{" + StrUtilsKt.toCamelCase(pdmColumn.getCode()) + ",jdbcType=" + PDMColumnExtensionsKt.getIbatisType(pdmColumn) + "},");
});
root.addText("\nwhere "+pkColumn.getCode()+" = #{"+pkColumn.getCode()+",jdbcType="+ StringsKt.substringBefore(pkColumn.getDataType() ,"(" ,pkColumn.getDataType() ) +"}");
root.addText("\nwhere " + pkColumn.getCode() + " = #{" + pkColumn.getCode() + ",jdbcType=" + PDMColumnExtensionsKt.getIbatisType(pkColumn) + "}");
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection selection = new StringSelection(formatXML(root));
clipboard.setContents(selection, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

public class PDMColumn {
private String id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

public class PDMReferenceJoin {
private String Id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.models;

import java.util.ArrayList;

Expand Down
6 changes: 6 additions & 0 deletions src/org/cruldra/pdmviewer/parser/PDMParseException.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.cruldra.pdmviewer.parser

class PDMParseException(private val msg: String, override val cause: Throwable? = null) :
Exception(msg, cause) {

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.cruldra.pdmviewer.utils;
package org.cruldra.pdmviewer.parser;

import java.util.ArrayList;
import java.util.List;

import org.cruldra.pdmviewer.models.*;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
Expand Down
14 changes: 14 additions & 0 deletions src/org/cruldra/pdmviewer/utils/PDMColumnExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.cruldra.pdmviewer.utils

import org.cruldra.pdmviewer.models.PDMColumn
import org.cruldra.pdmviewer.parser.PDMParseException
import java.util.*

fun PDMColumn.getIbatisType():String{
return when(val shortName= this.dataType.substringBefore("(")){
"varchar" , "double"-> shortName.uppercase(Locale.getDefault())
"datetime" -> "TIMESTAMP"
"int" -> "INTEGER"
else -> throw PDMParseException("ibatis没有匹配的数据类型 $shortName")
}
}

0 comments on commit a3d4675

Please sign in to comment.