From 5b2c27902205fbcf32bd996aab9ef65e0165264a Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 08 八月 2023 10:12:15 +0800
Subject: [PATCH] 2023-08-08

---
 JavaCode/FrmMyBatisPlus.cs |   80 +++++++++++++++++++++++++--------------
 1 files changed, 51 insertions(+), 29 deletions(-)

diff --git a/JavaCode/FrmMyBatisPlus.cs b/JavaCode/FrmMyBatisPlus.cs
index 6191c6b..f588e3e 100644
--- a/JavaCode/FrmMyBatisPlus.cs
+++ b/JavaCode/FrmMyBatisPlus.cs
@@ -4,12 +4,10 @@
 using System.ComponentModel;
 using System.Data;
 using System.Diagnostics;
-using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace JavaCode
@@ -44,7 +42,7 @@
                 string tabName = this.txtTabPre.Text.Trim();
                 string tabFilter = string.IsNullOrEmpty(tabName) ? "" : string.Format("and c.relname like '{0}%'", tabName);
 
-                string sql = string.Format("select c.relname \"tab\", cast(obj_description(c.oid) as varchar) \"desc\", a.attnum \"num\", a.attname \"col\", t.typname \"type\", d.description \"bak\" from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and relnamespace in ({0}) {1} and position('pg.dropped' in a.attname) = 0 order by c.relname desc, a.attnum asc", this.txtNS.Text.Trim(), tabFilter);
+                string sql = string.Format("select c.relname \"tab\", cast(obj_description(c.oid) as varchar) \"desc\", a.attnum \"num\", a.attname \"col\", t.typname \"type\", d.description \"bak\" from pg_attribute a left join pg_description d on d.objoid = a.attrelid and d.objsubid = a.attnum left join pg_class c on a.attrelid = c.oid left join pg_type t on a.atttypid = t.oid where a.attnum >= 0 and reltype>0 and relnamespace in ({0}) {1} and position('pg.dropped' in a.attname) = 0 order by c.relname desc, a.attnum asc", this.txtTabNS.Text.Trim(), tabFilter);
 
                 DataTable dt = _dbHelper.GetDataTable(sql, null);
                 _list = ModelHandler.FillModel<TabInfo>(dt);
@@ -151,30 +149,6 @@
                 MessageBox.Show(ex.Message);
             }
         }
-
-        private void btnGeneAll_Click(object sender, EventArgs e)
-        {
-            try
-            {
-                string mapperPath = Path.Combine(baseDir, "BsGenerate\\Mapper");
-                string entityPath = Path.Combine(baseDir, "BsGenerate\\Entity");
-
-                List<string> names = GetTabList();
-                foreach (string name in names)
-                {
-                    List<TabInfo> tabs = GetTabInfo(name);
-                    GenerateMapper(mapperPath, name, tabs);
-                    GenerateEntity(entityPath, name, tabs);
-                }
-
-                string path = Path.Combine(baseDir, "BsGenerate");
-                OpenFolder(path);
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show(ex.Message);
-            }
-        }
         #endregion
 
         #region 鐢熸垚 Mapper
@@ -182,7 +156,7 @@
         {
             if (!Directory.Exists(path)) Directory.CreateDirectory(path);
 
-            string tabName = this.txtTabNS.Text.Trim() + name;
+            string tabName = this.txtTabPrefix.Text.Trim() + name;
             //string shortName = NameConvert(name, true);
             string shortName = GetEntityName(name, true);
 
@@ -192,6 +166,7 @@
             string entityNS = this.txtEntityNS.Text.Trim();
             string entityName = shortName + "Entity";
 
+            string ns = this.txtNS.Text.Trim();
             string bak = string.IsNullOrWhiteSpace(tabs[0].desc) ? shortName : tabs[0].desc.Replace("琛�", "");
 
             //if (this.HasGeom(tabs)) return;
@@ -202,6 +177,7 @@
                 .Replace("{mapperName}", mapperName)
                 .Replace("{entityNS}", entityNS)
                 .Replace("{entityName}", entityName)
+                .Replace("{ns}", ns)
                 .Replace("{bak}", bak);
 
             string fileName = shortName + "Mapper.java";
@@ -214,13 +190,14 @@
         {
             if (!Directory.Exists(path)) Directory.CreateDirectory(path);
 
-            string tabName = this.txtTabNS.Text.Trim() + name;
+            string tabName = this.txtTabPrefix.Text.Trim() + name;
             //string shortName = NameConvert(name, true);
             string shortName = GetEntityName(name, true);
 
             string entityNS = this.txtEntityNS.Text.Trim();
             string entityName = shortName + "Entity";
 
+            string ns = this.txtNS.Text.Trim();
             string bak = string.IsNullOrWhiteSpace(tabs[0].desc) ? shortName : tabs[0].desc.Replace("琛�", "");
             long uid = (long)Math.Floor((new Random()).NextDouble() * 1000000000000000000D);
 
@@ -232,6 +209,7 @@
                 .Replace("{entityName}", entityName)
                 .Replace("{bak}", bak)
                 .Replace("{tabName}", tabName)
+                .Replace("{ns}", ns)
                 .Replace("{uid}", uid.ToString());
 
             StringBuilder sb = new StringBuilder();
@@ -277,6 +255,50 @@
         }
         #endregion
 
+        #region 鐢熸垚鎵�鏈�
+        private void btnGeneAll_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                string mapperPath = Path.Combine(baseDir, "BsGenerate\\Mapper");
+                string entityPath = Path.Combine(baseDir, "BsGenerate\\Entity");
+
+                List<string> names = GetTabList();
+                foreach (string name in names)
+                {
+                    List<TabInfo> tabs = GetTabInfo(name);
+                    GenerateMapper(mapperPath, name, tabs);
+                    GenerateEntity(entityPath, name, tabs);
+                }
+
+                string path = Path.Combine(baseDir, "BsGenerate");
+                OpenFolder(path);
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+        }
+
+        private void txtTabPrefix_TextChanged(object sender, EventArgs e)
+        {
+            txtChanged(sender, e);
+        }
+
+        private void txtNS_TextChanged(object sender, EventArgs e)
+        {
+            txtChanged(sender, e);
+        }
+
+        private void txtChanged(object sender, EventArgs e)
+        {
+            string pre = txtTabPrefix.Text.Replace(".", "").Trim();
+            string ns = txtNS.Text.Trim();
+            txtMapperNS.Text = "com.lf.server.mapper.bd".Replace("lf", ns).Replace("bd", pre);
+            txtEntityNS.Text = "com.lf.server.entity.bd".Replace("lf", ns).Replace("bd", pre);
+        }
+        #endregion
+
         #region 鍏叡鏂规硶
         private List<string> GetTabList()
         {

--
Gitblit v1.9.3