管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-08-08 5b2c27902205fbcf32bd996aab9ef65e0165264a
JavaCode/FrmSys.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
@@ -38,7 +36,7 @@
        private void btnReadTab_Click(object sender, EventArgs e)
        {
            string txtTab = this.txtTabPre.Text.Trim();
            string sql = "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 c.relname like '" + txtTab + "%' and attname not like '%pg.dropped%' and obj_description(c.oid) is not null and relnamespace=" + this.txtNS.Text.Trim() + " order by c.relname desc, a.attnum asc";
            string sql = "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 c.relname like '" + txtTab + "%' and attname not like '%pg.dropped%' and obj_description(c.oid) is not null and relnamespace=" + this.txtTabNS.Text.Trim() + " order by c.relname desc, a.attnum asc";
            DataTable dt = _dbHelper.GetDataTable(sql, null);
@@ -96,7 +94,7 @@
        private void GenerateMapperXml(string name, List<TabInfo> tabs)
        {
            string tabName = this.txtTabNS.Text.Trim() + name;
            string tabName = this.txtTabPrefix.Text.Trim() + name;
            name = name.Replace(this.txtTabPre.Text, "");
            string shortName = NameConvert(name, true);
@@ -360,7 +358,7 @@
            int idx = this.dgvTab.CurrentRow.Index;
            TabInfo selectTabInfo = tabs[idx];
            string colType  = GetJavaType(selectTabInfo);
            string colType = GetJavaType(selectTabInfo);
            string colName = NameConvert(selectTabInfo.col, false);
            string queryCol = colType + " " + colName;
            string colBak = selectTabInfo.bak;
@@ -540,6 +538,7 @@
            string entityName = shortName + "Entity";
            string serviceName = shortName + "Service";
            string bak = tabs[0].desc.Replace("表", "");
            string ns = this.txtNS.Text.Trim();
            int idx = this.dgvTab.CurrentRow.Index;
            TabInfo selectTabInfo = tabs[idx];
@@ -564,7 +563,8 @@
                .Replace("{bak}", bak)
                .Replace("{queryCol}", queryCol)
                .Replace("{colName}", colName)
                .Replace("{where}", where);
                .Replace("{ns}", ns)
                .Replace("{where}", where);
            string path = Path.Combine(baseDir, "SysGenerate");
            if (!Directory.Exists(path))
@@ -613,6 +613,7 @@
            string controllerName = shortName + "Controller";
            string bak = tabs[0].desc.Replace("表", "");
            string apiName = NameConvert(name, false);
            string ns = this.txtNS.Text.Trim();
            int idx = this.dgvTab.CurrentRow.Index;
            TabInfo selectTabInfo = tabs[idx];
@@ -639,6 +640,7 @@
                .Replace("{colType}", colType)
                .Replace("{apiTag}", apiTag)
                .Replace("{apiName}", apiName)
                .Replace("{ns}", ns)
                .Replace("{bak}", bak);
            string path = Path.Combine(baseDir, "SysGenerate");
@@ -653,6 +655,15 @@
        #endregion
        #region 生成所有文件
        private void txtNS_TextChanged(object sender, EventArgs e)
        {
            string ns = txtNS.Text.Trim();
            txtMapperNS.Text = "com.lf.server.mapper.sys".Replace("lf", ns);
            txtEntityNS.Text = "com.lf.server.entity.sys".Replace("lf", ns);
            txtServiceNS.Text = "com.lf.server.service.sys".Replace("lf", ns);
            txtControllerNS.Text = "com.lf.server.controller.sys".Replace("lf", ns);
        }
        private void generateAll_Click(object sender, EventArgs e)
        {
            try