| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.lf.server.entity.all.BaseEntity; |
| | | import com.{ns}.server.entity.all.BaseEntity; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.lf.server.entity.all.BaseGeoEntity; |
| | | import com.{ns}.server.entity.all.BaseGeoEntity; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | package {mapperNS}; |
| | | |
| | | import {entityNS}.{entityName}; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.{ns}.server.mapper.all.GeomBaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | |
| | | package {mapperNS}; |
| | | |
| | | import {entityNS}.{entityName}; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.{ns}.server.mapper.all.BasicMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.txtNS = new System.Windows.Forms.TextBox(); |
| | | this.txtTabNS = new System.Windows.Forms.TextBox(); |
| | | this.txtTabPre = new System.Windows.Forms.TextBox(); |
| | | this.btnReadTab = new System.Windows.Forms.Button(); |
| | | this.tabList = new System.Windows.Forms.ListBox(); |
| | |
| | | this.btnNone = new System.Windows.Forms.Button(); |
| | | this.btnGeneEntity = new System.Windows.Forms.Button(); |
| | | this.btnGeneMapper = new System.Windows.Forms.Button(); |
| | | this.txtTabNS = new System.Windows.Forms.TextBox(); |
| | | this.txtTabPrefix = new System.Windows.Forms.TextBox(); |
| | | this.label1 = new System.Windows.Forms.Label(); |
| | | this.txtNS = new System.Windows.Forms.TextBox(); |
| | | this.label9 = new System.Windows.Forms.Label(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); |
| | | this.SuspendLayout(); |
| | | // |
| | | // txtNS |
| | | // txtTabNS |
| | | // |
| | | this.txtNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtNS.Location = new System.Drawing.Point(12, 13); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(104, 26); |
| | | this.txtNS.TabIndex = 25; |
| | | this.txtNS.Text = "163875"; |
| | | this.txtTabNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabNS.Location = new System.Drawing.Point(12, 13); |
| | | this.txtTabNS.Name = "txtTabNS"; |
| | | this.txtTabNS.Size = new System.Drawing.Size(104, 26); |
| | | this.txtTabNS.TabIndex = 25; |
| | | this.txtTabNS.Text = "163875"; |
| | | // |
| | | // txtTabPre |
| | | // |
| | |
| | | // txtEntityNS |
| | | // |
| | | this.txtEntityNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtEntityNS.Location = new System.Drawing.Point(525, 89); |
| | | this.txtEntityNS.Location = new System.Drawing.Point(524, 89); |
| | | this.txtEntityNS.Name = "txtEntityNS"; |
| | | this.txtEntityNS.Size = new System.Drawing.Size(312, 26); |
| | | this.txtEntityNS.TabIndex = 30; |
| | |
| | | this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label3.Location = new System.Drawing.Point(385, 94); |
| | | this.label3.Name = "label3"; |
| | | this.label3.Size = new System.Drawing.Size(136, 16); |
| | | this.label3.Size = new System.Drawing.Size(135, 16); |
| | | this.label3.TabIndex = 29; |
| | | this.label3.Text = "Entity名称空间:"; |
| | | // |
| | | // txtMapperNS |
| | | // |
| | | this.txtMapperNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtMapperNS.Location = new System.Drawing.Point(525, 53); |
| | | this.txtMapperNS.Location = new System.Drawing.Point(524, 53); |
| | | this.txtMapperNS.Name = "txtMapperNS"; |
| | | this.txtMapperNS.Size = new System.Drawing.Size(312, 26); |
| | | this.txtMapperNS.TabIndex = 32; |
| | |
| | | this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label2.Location = new System.Drawing.Point(385, 58); |
| | | this.label2.Name = "label2"; |
| | | this.label2.Size = new System.Drawing.Size(136, 16); |
| | | this.label2.Size = new System.Drawing.Size(135, 16); |
| | | this.label2.TabIndex = 31; |
| | | this.label2.Text = "Mapper名称空间:"; |
| | | // |
| | | // btnGeneAll |
| | | // |
| | | this.btnGeneAll.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnGeneAll.Location = new System.Drawing.Point(525, 208); |
| | | this.btnGeneAll.Location = new System.Drawing.Point(524, 208); |
| | | this.btnGeneAll.Name = "btnGeneAll"; |
| | | this.btnGeneAll.Size = new System.Drawing.Size(312, 25); |
| | | this.btnGeneAll.TabIndex = 33; |
| | |
| | | // btnGeneEntity |
| | | // |
| | | this.btnGeneEntity.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnGeneEntity.Location = new System.Drawing.Point(525, 169); |
| | | this.btnGeneEntity.Location = new System.Drawing.Point(524, 169); |
| | | this.btnGeneEntity.Name = "btnGeneEntity"; |
| | | this.btnGeneEntity.Size = new System.Drawing.Size(312, 25); |
| | | this.btnGeneEntity.TabIndex = 38; |
| | |
| | | // btnGeneMapper |
| | | // |
| | | this.btnGeneMapper.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnGeneMapper.Location = new System.Drawing.Point(525, 128); |
| | | this.btnGeneMapper.Location = new System.Drawing.Point(524, 128); |
| | | this.btnGeneMapper.Name = "btnGeneMapper"; |
| | | this.btnGeneMapper.Size = new System.Drawing.Size(312, 25); |
| | | this.btnGeneMapper.TabIndex = 37; |
| | |
| | | this.btnGeneMapper.UseVisualStyleBackColor = true; |
| | | this.btnGeneMapper.Click += new System.EventHandler(this.btnGeneMapper_Click); |
| | | // |
| | | // txtTabNS |
| | | // txtTabPrefix |
| | | // |
| | | this.txtTabNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabNS.Location = new System.Drawing.Point(525, 15); |
| | | this.txtTabNS.Name = "txtTabNS"; |
| | | this.txtTabNS.Size = new System.Drawing.Size(312, 26); |
| | | this.txtTabNS.TabIndex = 40; |
| | | this.txtTabNS.Text = "bd."; |
| | | this.txtTabPrefix.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabPrefix.Location = new System.Drawing.Point(524, 15); |
| | | this.txtTabPrefix.Name = "txtTabPrefix"; |
| | | this.txtTabPrefix.Size = new System.Drawing.Size(110, 26); |
| | | this.txtTabPrefix.TabIndex = 40; |
| | | this.txtTabPrefix.Text = "bd."; |
| | | this.txtTabPrefix.TextChanged += new System.EventHandler(this.txtTabPrefix_TextChanged); |
| | | // |
| | | // label1 |
| | | // |
| | |
| | | this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label1.Location = new System.Drawing.Point(433, 20); |
| | | this.label1.Name = "label1"; |
| | | this.label1.Size = new System.Drawing.Size(88, 16); |
| | | this.label1.Size = new System.Drawing.Size(87, 16); |
| | | this.label1.TabIndex = 39; |
| | | this.label1.Text = "表名前缀:"; |
| | | // |
| | | // txtNS |
| | | // |
| | | this.txtNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtNS.Location = new System.Drawing.Point(725, 15); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(111, 26); |
| | | this.txtNS.TabIndex = 42; |
| | | this.txtNS.Text = "lf"; |
| | | this.txtNS.TextChanged += new System.EventHandler(this.txtNS_TextChanged); |
| | | // |
| | | // label9 |
| | | // |
| | | this.label9.AutoSize = true; |
| | | this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label9.Location = new System.Drawing.Point(636, 20); |
| | | this.label9.Name = "label9"; |
| | | this.label9.Size = new System.Drawing.Size(87, 16); |
| | | this.label9.TabIndex = 41; |
| | | this.label9.Text = "名称空间:"; |
| | | // |
| | | // FrmMyBatisPlus |
| | | // |
| | | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); |
| | | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
| | | this.ClientSize = new System.Drawing.Size(852, 628); |
| | | this.Controls.Add(this.txtTabNS); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.label9); |
| | | this.Controls.Add(this.txtTabPrefix); |
| | | this.Controls.Add(this.label1); |
| | | this.Controls.Add(this.btnGeneEntity); |
| | | this.Controls.Add(this.btnGeneMapper); |
| | |
| | | this.Controls.Add(this.txtEntityNS); |
| | | this.Controls.Add(this.label3); |
| | | this.Controls.Add(this.dgvTab); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.txtTabNS); |
| | | this.Controls.Add(this.txtTabPre); |
| | | this.Controls.Add(this.btnReadTab); |
| | | this.Controls.Add(this.tabList); |
| | |
| | | |
| | | #endregion |
| | | |
| | | private System.Windows.Forms.TextBox txtNS; |
| | | private System.Windows.Forms.TextBox txtTabNS; |
| | | private System.Windows.Forms.TextBox txtTabPre; |
| | | private System.Windows.Forms.Button btnReadTab; |
| | | private System.Windows.Forms.ListBox tabList; |
| | |
| | | private System.Windows.Forms.Button btnNone; |
| | | private System.Windows.Forms.Button btnGeneEntity; |
| | | private System.Windows.Forms.Button btnGeneMapper; |
| | | private System.Windows.Forms.TextBox txtTabNS; |
| | | private System.Windows.Forms.TextBox txtTabPrefix; |
| | | private System.Windows.Forms.Label label1; |
| | | private System.Windows.Forms.TextBox txtNS; |
| | | private System.Windows.Forms.Label label9; |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | 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 |
| | |
| | | { |
| | | 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("表", ""); |
| | | |
| | | //if (this.HasGeom(tabs)) return; |
| | |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{ns}", ns) |
| | | .Replace("{bak}", bak); |
| | | |
| | | string fileName = shortName + "Mapper.java"; |
| | |
| | | { |
| | | 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); |
| | | |
| | |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{tabName}", tabName) |
| | | .Replace("{ns}", ns) |
| | | .Replace("{uid}", uid.ToString()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | } |
| | | #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() |
| | | { |
| | |
| | | this.button5 = new System.Windows.Forms.Button(); |
| | | this.button6 = new System.Windows.Forms.Button(); |
| | | this.button1 = new System.Windows.Forms.Button(); |
| | | this.txtNS = new System.Windows.Forms.TextBox(); |
| | | this.txtTabNS = new System.Windows.Forms.TextBox(); |
| | | this.button2 = new System.Windows.Forms.Button(); |
| | | this.button3 = new System.Windows.Forms.Button(); |
| | | this.txtServiceNS = new System.Windows.Forms.TextBox(); |
| | |
| | | this.txtApiTag = new System.Windows.Forms.TextBox(); |
| | | this.label8 = new System.Windows.Forms.Label(); |
| | | this.label1 = new System.Windows.Forms.Label(); |
| | | this.txtTabNS = new System.Windows.Forms.TextBox(); |
| | | this.txtTabPrefix = new System.Windows.Forms.TextBox(); |
| | | this.txtNS = new System.Windows.Forms.TextBox(); |
| | | this.label9 = new System.Windows.Forms.Label(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); |
| | | this.SuspendLayout(); |
| | | // |
| | |
| | | this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label2.Location = new System.Drawing.Point(389, 56); |
| | | this.label2.Name = "label2"; |
| | | this.label2.Size = new System.Drawing.Size(136, 16); |
| | | this.label2.Size = new System.Drawing.Size(135, 16); |
| | | this.label2.TabIndex = 8; |
| | | this.label2.Text = "Mapper名称空间:"; |
| | | // |
| | |
| | | this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label3.Location = new System.Drawing.Point(389, 93); |
| | | this.label3.Name = "label3"; |
| | | this.label3.Size = new System.Drawing.Size(136, 16); |
| | | this.label3.Size = new System.Drawing.Size(135, 16); |
| | | this.label3.TabIndex = 10; |
| | | this.label3.Text = "Entity名称空间:"; |
| | | // |
| | |
| | | this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label4.Location = new System.Drawing.Point(387, 241); |
| | | this.label4.Name = "label4"; |
| | | this.label4.Size = new System.Drawing.Size(136, 16); |
| | | this.label4.Size = new System.Drawing.Size(135, 16); |
| | | this.label4.TabIndex = 14; |
| | | this.label4.Text = "插入时排除字段:"; |
| | | // |
| | |
| | | this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label5.Location = new System.Drawing.Point(387, 276); |
| | | this.label5.Name = "label5"; |
| | | this.label5.Size = new System.Drawing.Size(136, 16); |
| | | this.label5.Size = new System.Drawing.Size(135, 16); |
| | | this.label5.TabIndex = 16; |
| | | this.label5.Text = "更新时排除字段:"; |
| | | // |
| | |
| | | this.button1.UseVisualStyleBackColor = true; |
| | | this.button1.Click += new System.EventHandler(this.entityJava_Click); |
| | | // |
| | | // txtNS |
| | | // txtTabNS |
| | | // |
| | | this.txtNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtNS.Location = new System.Drawing.Point(12, 10); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(100, 26); |
| | | this.txtNS.TabIndex = 21; |
| | | this.txtNS.Text = "20582"; |
| | | this.txtTabNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabNS.Location = new System.Drawing.Point(12, 10); |
| | | this.txtTabNS.Name = "txtTabNS"; |
| | | this.txtTabNS.Size = new System.Drawing.Size(100, 26); |
| | | this.txtTabNS.TabIndex = 21; |
| | | this.txtTabNS.Text = "20582"; |
| | | // |
| | | // button2 |
| | | // |
| | |
| | | this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label6.Location = new System.Drawing.Point(381, 131); |
| | | this.label6.Name = "label6"; |
| | | this.label6.Size = new System.Drawing.Size(144, 16); |
| | | this.label6.Size = new System.Drawing.Size(143, 16); |
| | | this.label6.TabIndex = 24; |
| | | this.label6.Text = "Service名称空间:"; |
| | | // |
| | |
| | | this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label7.Location = new System.Drawing.Point(365, 169); |
| | | this.label7.Name = "label7"; |
| | | this.label7.Size = new System.Drawing.Size(160, 16); |
| | | this.label7.Size = new System.Drawing.Size(159, 16); |
| | | this.label7.TabIndex = 26; |
| | | this.label7.Text = "Controller名称空间:"; |
| | | // |
| | |
| | | this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label8.Location = new System.Drawing.Point(445, 206); |
| | | this.label8.Name = "label8"; |
| | | this.label8.Size = new System.Drawing.Size(80, 16); |
| | | this.label8.Size = new System.Drawing.Size(79, 16); |
| | | this.label8.TabIndex = 28; |
| | | this.label8.Text = "Api标识:"; |
| | | // |
| | |
| | | this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label1.Location = new System.Drawing.Point(437, 18); |
| | | this.label1.Name = "label1"; |
| | | this.label1.Size = new System.Drawing.Size(88, 16); |
| | | this.label1.Size = new System.Drawing.Size(87, 16); |
| | | this.label1.TabIndex = 6; |
| | | this.label1.Text = "表名前缀:"; |
| | | // |
| | | // txtTabNS |
| | | // txtTabPrefix |
| | | // |
| | | this.txtTabNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabNS.Location = new System.Drawing.Point(529, 13); |
| | | this.txtTabNS.Name = "txtTabNS"; |
| | | this.txtTabNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtTabNS.TabIndex = 7; |
| | | this.txtTabNS.Text = "lf."; |
| | | this.txtTabPrefix.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabPrefix.Location = new System.Drawing.Point(529, 13); |
| | | this.txtTabPrefix.Name = "txtTabPrefix"; |
| | | this.txtTabPrefix.Size = new System.Drawing.Size(111, 26); |
| | | this.txtTabPrefix.TabIndex = 7; |
| | | this.txtTabPrefix.Text = "lf."; |
| | | // |
| | | // txtNS |
| | | // |
| | | this.txtNS.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtNS.Location = new System.Drawing.Point(757, 15); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(111, 26); |
| | | this.txtNS.TabIndex = 31; |
| | | this.txtNS.Text = "lf"; |
| | | this.txtNS.TextChanged += new System.EventHandler(this.txtNS_TextChanged); |
| | | // |
| | | // label9 |
| | | // |
| | | this.label9.AutoSize = true; |
| | | this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.label9.Location = new System.Drawing.Point(665, 20); |
| | | this.label9.Name = "label9"; |
| | | this.label9.Size = new System.Drawing.Size(87, 16); |
| | | this.label9.TabIndex = 30; |
| | | this.label9.Text = "名称空间:"; |
| | | // |
| | | // FrmSys |
| | | // |
| | | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); |
| | | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
| | | this.ClientSize = new System.Drawing.Size(1095, 630); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.label9); |
| | | this.Controls.Add(this.txtApiTag); |
| | | this.Controls.Add(this.label8); |
| | | this.Controls.Add(this.txtControllerNS); |
| | |
| | | this.Controls.Add(this.label6); |
| | | this.Controls.Add(this.button3); |
| | | this.Controls.Add(this.button2); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.txtTabNS); |
| | | this.Controls.Add(this.button1); |
| | | this.Controls.Add(this.button6); |
| | | this.Controls.Add(this.button5); |
| | |
| | | this.Controls.Add(this.label3); |
| | | this.Controls.Add(this.txtMapperNS); |
| | | this.Controls.Add(this.label2); |
| | | this.Controls.Add(this.txtTabNS); |
| | | this.Controls.Add(this.txtTabPrefix); |
| | | this.Controls.Add(this.label1); |
| | | this.Controls.Add(this.txtTabPre); |
| | | this.Controls.Add(this.btnReadTab); |
| | |
| | | private System.Windows.Forms.Button button5; |
| | | private System.Windows.Forms.Button button6; |
| | | private System.Windows.Forms.Button button1; |
| | | private System.Windows.Forms.TextBox txtNS; |
| | | private System.Windows.Forms.TextBox txtTabNS; |
| | | private System.Windows.Forms.Button button2; |
| | | private System.Windows.Forms.Button button3; |
| | | private System.Windows.Forms.TextBox txtServiceNS; |
| | |
| | | private System.Windows.Forms.TextBox txtApiTag; |
| | | private System.Windows.Forms.Label label8; |
| | | private System.Windows.Forms.Label label1; |
| | | private System.Windows.Forms.TextBox txtTabNS; |
| | | private System.Windows.Forms.TextBox txtTabPrefix; |
| | | private System.Windows.Forms.TextBox txtNS; |
| | | private System.Windows.Forms.Label label9; |
| | | } |
| | | } |
| | | |
| | |
| | | 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 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); |
| | | |
| | |
| | | |
| | | 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 |
| | |
| | | package {controllerNS}; |
| | | |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.{ns}.server.annotation.SysLog; |
| | | import com.{ns}.server.controller.all.BaseController; |
| | | import com.{ns}.server.entity.all.ResponseMsg; |
| | | import {entityNS}.{entityName}; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.{ns}.server.entity.sys.UserEntity; |
| | | import {serviceNS}.{serviceName}; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import com.{ns}.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | package {serviceNS}; |
| | | |
| | | import {entityNS}.{entityName}; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.{ns}.server.helper.StringHelper; |
| | | import {mapperNS}.{mapperName}; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | select * from stationseries; |
| | | select * from sitepoint order by gid; |
| | | update sitepoint set sitename='轮南首站' where gid=55; |
| | | ------------------------------------------------------------------------------ SQL语句 |
| | | select * from data_dir; |
| | | select * from meta_data; |