| | |
| | | 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 |
| | |
| | | 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 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); |
| | | |
| | |
| | | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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]; |
| | |
| | | .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)) |
| | |
| | | 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]; |
| | |
| | | .Replace("{colType}", colType) |
| | | .Replace("{apiTag}", apiTag) |
| | | .Replace("{apiName}", apiName) |
| | | .Replace("{ns}", ns) |
| | | .Replace("{bak}", bak); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | |
| | | #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 |