| | |
| | | <?xml version="1.0" encoding="utf-8" ?> |
| | | <configuration> |
| | | <appSettings> |
| | | <add key="pgConn" value="Server=127.0.0.1;Port=5432;Database=langfang;User Id=postgres;Password=postgres;"/> |
| | | <!-- 69701 --> |
| | | <!--<add key="pgConn" value="Server=127.0.0.1;Port=5432;Database=langfang;User Id=postgres;Password=postgres;"/>--> |
| | | <!-- 20582 --> |
| | | <add key="pgConn" value="Server=192.168.20.39;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/> |
| | | </appSettings> |
| | | <startup> |
| | | <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package {entityNS}; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.io.Serializable; |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * {bak} |
| | | * @author WWW |
| | | */ |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | @TableName("{tabName}") |
| | | public class {entityName} implements Serializable { |
| | | private static final long serialVersionUID = {uid}L; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package {mapperNS}; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import {entityNS}.{entityName}; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * {bak} |
| | | * @author WWW |
| | | */ |
| | | @Mapper |
| | | @Repository |
| | | public interface {mapperName} extends BaseMapper<{entityName}> { |
| | | /** |
| | | * æ¥è¯¢ä¸æ¡ |
| | | * |
| | | * @param {id} |
| | | * @return |
| | | */ |
| | | @Select("{selectSql}") |
| | | {entityName} selectOne(@Param("{id}") Integer {id}); |
| | | } |
| | |
| | | partial class FrmMain |
| | | { |
| | | /// <summary> |
| | | /// å¿
éç设计å¨åéã |
| | | /// Required designer variable. |
| | | /// </summary> |
| | | private System.ComponentModel.IContainer components = null; |
| | | |
| | | /// <summary> |
| | | /// æ¸
çæææ£å¨ä½¿ç¨çèµæºã |
| | | /// Clean up any resources being used. |
| | | /// </summary> |
| | | /// <param name="disposing">妿åºéæ¾æç®¡èµæºï¼ä¸º trueï¼å¦å为 falseã</param> |
| | | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | if (disposing && (components != null)) |
| | |
| | | base.Dispose(disposing); |
| | | } |
| | | |
| | | #region Windows çªä½è®¾è®¡å¨çæç代ç |
| | | #region Windows Form Designer generated code |
| | | |
| | | /// <summary> |
| | | /// è®¾è®¡å¨æ¯ææéçæ¹æ³ - ä¸è¦ |
| | | /// 使ç¨ä»£ç ç¼è¾å¨ä¿®æ¹æ¤æ¹æ³çå
容ã |
| | | /// Required method for Designer support - do not modify |
| | | /// the contents of this method with the code editor. |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.tabList = new System.Windows.Forms.ListBox(); |
| | | this.btnReadTab = new System.Windows.Forms.Button(); |
| | | this.txtTabPre = new System.Windows.Forms.TextBox(); |
| | | this.label1 = new System.Windows.Forms.Label(); |
| | | this.txtTabNS = new System.Windows.Forms.TextBox(); |
| | | this.txtMapperNS = new System.Windows.Forms.TextBox(); |
| | | this.label2 = new System.Windows.Forms.Label(); |
| | | this.txtEntityNS = new System.Windows.Forms.TextBox(); |
| | | this.label3 = new System.Windows.Forms.Label(); |
| | | this.button4 = new System.Windows.Forms.Button(); |
| | | this.dgvTab = new System.Windows.Forms.DataGridView(); |
| | | this.label4 = new System.Windows.Forms.Label(); |
| | | this.txtInsert = new System.Windows.Forms.TextBox(); |
| | | this.txtUpdate = new System.Windows.Forms.TextBox(); |
| | | this.label5 = new System.Windows.Forms.Label(); |
| | | 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.button2 = new System.Windows.Forms.Button(); |
| | | this.button3 = new System.Windows.Forms.Button(); |
| | | this.txtServiceNS = new System.Windows.Forms.TextBox(); |
| | | this.label6 = new System.Windows.Forms.Label(); |
| | | this.txtControllerNS = new System.Windows.Forms.TextBox(); |
| | | this.label7 = new System.Windows.Forms.Label(); |
| | | this.txtApiTag = new System.Windows.Forms.TextBox(); |
| | | this.label8 = new System.Windows.Forms.Label(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); |
| | | this.btnSys = new System.Windows.Forms.Button(); |
| | | this.btnMybatis = new System.Windows.Forms.Button(); |
| | | this.SuspendLayout(); |
| | | // |
| | | // tabList |
| | | // btnSys |
| | | // |
| | | this.tabList.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.tabList.FormattingEnabled = true; |
| | | this.tabList.ItemHeight = 16; |
| | | this.tabList.Location = new System.Drawing.Point(12, 49); |
| | | this.tabList.Name = "tabList"; |
| | | this.tabList.Size = new System.Drawing.Size(353, 244); |
| | | this.tabList.TabIndex = 0; |
| | | this.tabList.SelectedIndexChanged += new System.EventHandler(this.tabList_SelectedIndexChanged); |
| | | this.btnSys.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnSys.Location = new System.Drawing.Point(142, 63); |
| | | this.btnSys.Name = "btnSys"; |
| | | this.btnSys.Size = new System.Drawing.Size(183, 25); |
| | | this.btnSys.TabIndex = 13; |
| | | this.btnSys.Text = "ç æ ç³» ç» è¡¨"; |
| | | this.btnSys.UseVisualStyleBackColor = true; |
| | | this.btnSys.Click += new System.EventHandler(this.btnSys_Click); |
| | | // |
| | | // btnReadTab |
| | | // btnMybatis |
| | | // |
| | | this.btnReadTab.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnReadTab.Location = new System.Drawing.Point(247, 13); |
| | | this.btnReadTab.Name = "btnReadTab"; |
| | | this.btnReadTab.Size = new System.Drawing.Size(118, 23); |
| | | this.btnReadTab.TabIndex = 1; |
| | | this.btnReadTab.Text = "è¯»åæ°æ®åºè¡¨"; |
| | | this.btnReadTab.UseVisualStyleBackColor = true; |
| | | this.btnReadTab.Click += new System.EventHandler(this.btnReadTab_Click); |
| | | // |
| | | // txtTabPre |
| | | // |
| | | this.txtTabPre.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabPre.Location = new System.Drawing.Point(129, 10); |
| | | this.txtTabPre.Name = "txtTabPre"; |
| | | this.txtTabPre.Size = new System.Drawing.Size(100, 26); |
| | | this.txtTabPre.TabIndex = 2; |
| | | this.txtTabPre.Text = "sys_"; |
| | | // |
| | | // label1 |
| | | // |
| | | this.label1.AutoSize = true; |
| | | 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.TabIndex = 6; |
| | | this.label1.Text = "表ååç¼ï¼"; |
| | | // |
| | | // txtTabNS |
| | | // |
| | | 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."; |
| | | // |
| | | // 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(529, 51); |
| | | this.txtMapperNS.Name = "txtMapperNS"; |
| | | this.txtMapperNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtMapperNS.TabIndex = 9; |
| | | this.txtMapperNS.Text = "com.lf.server.mapper.sys"; |
| | | // |
| | | // label2 |
| | | // |
| | | this.label2.AutoSize = true; |
| | | 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.TabIndex = 8; |
| | | this.label2.Text = "Mapperå称空é´ï¼"; |
| | | // |
| | | // 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(529, 88); |
| | | this.txtEntityNS.Name = "txtEntityNS"; |
| | | this.txtEntityNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtEntityNS.TabIndex = 11; |
| | | this.txtEntityNS.Text = "com.lf.server.entity.sys"; |
| | | // |
| | | // label3 |
| | | // |
| | | this.label3.AutoSize = true; |
| | | 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.TabIndex = 10; |
| | | this.label3.Text = "Entityå称空é´ï¼"; |
| | | // |
| | | // button4 |
| | | // |
| | | this.button4.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button4.Location = new System.Drawing.Point(885, 202); |
| | | this.button4.Name = "button4"; |
| | | this.button4.Size = new System.Drawing.Size(183, 25); |
| | | this.button4.TabIndex = 12; |
| | | this.button4.Text = "ç æ æ æ æ ä»¶"; |
| | | this.button4.UseVisualStyleBackColor = true; |
| | | this.button4.Click += new System.EventHandler(this.generateAll_Click); |
| | | // |
| | | // dgvTab |
| | | // |
| | | this.dgvTab.AllowUserToAddRows = false; |
| | | this.dgvTab.AllowUserToDeleteRows = false; |
| | | this.dgvTab.BackgroundColor = System.Drawing.SystemColors.ButtonFace; |
| | | this.dgvTab.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
| | | this.dgvTab.Location = new System.Drawing.Point(12, 312); |
| | | this.dgvTab.Margin = new System.Windows.Forms.Padding(0); |
| | | this.dgvTab.MultiSelect = false; |
| | | this.dgvTab.Name = "dgvTab"; |
| | | this.dgvTab.ReadOnly = true; |
| | | this.dgvTab.RowHeadersWidth = 40; |
| | | this.dgvTab.RowTemplate.Height = 23; |
| | | this.dgvTab.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; |
| | | this.dgvTab.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; |
| | | this.dgvTab.Size = new System.Drawing.Size(1056, 300); |
| | | this.dgvTab.TabIndex = 13; |
| | | // |
| | | // label4 |
| | | // |
| | | this.label4.AutoSize = true; |
| | | 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.TabIndex = 14; |
| | | this.label4.Text = "æå
¥æ¶æé¤å段ï¼"; |
| | | // |
| | | // txtInsert |
| | | // |
| | | this.txtInsert.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtInsert.Location = new System.Drawing.Point(529, 236); |
| | | this.txtInsert.Name = "txtInsert"; |
| | | this.txtInsert.Size = new System.Drawing.Size(339, 26); |
| | | this.txtInsert.TabIndex = 15; |
| | | this.txtInsert.Text = "id,update_user,update_time"; |
| | | // |
| | | // txtUpdate |
| | | // |
| | | this.txtUpdate.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtUpdate.Location = new System.Drawing.Point(529, 271); |
| | | this.txtUpdate.Name = "txtUpdate"; |
| | | this.txtUpdate.Size = new System.Drawing.Size(339, 26); |
| | | this.txtUpdate.TabIndex = 17; |
| | | this.txtUpdate.Text = "id,create_user,create_time"; |
| | | // |
| | | // label5 |
| | | // |
| | | this.label5.AutoSize = true; |
| | | 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.TabIndex = 16; |
| | | this.label5.Text = "æ´æ°æ¶æé¤å段ï¼"; |
| | | // |
| | | // button5 |
| | | // |
| | | this.button5.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button5.Location = new System.Drawing.Point(885, 14); |
| | | this.button5.Name = "button5"; |
| | | this.button5.Size = new System.Drawing.Size(183, 25); |
| | | this.button5.TabIndex = 18; |
| | | this.button5.Text = "ç æ Mapper.xml"; |
| | | this.button5.UseVisualStyleBackColor = true; |
| | | this.button5.Click += new System.EventHandler(this.mapperXml_Click); |
| | | // |
| | | // button6 |
| | | // |
| | | this.button6.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button6.Location = new System.Drawing.Point(885, 52); |
| | | this.button6.Name = "button6"; |
| | | this.button6.Size = new System.Drawing.Size(183, 25); |
| | | this.button6.TabIndex = 19; |
| | | this.button6.Text = "ç æ Mapper.java"; |
| | | this.button6.UseVisualStyleBackColor = true; |
| | | this.button6.Click += new System.EventHandler(this.mapperJava_Click); |
| | | // |
| | | // button1 |
| | | // |
| | | this.button1.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button1.Location = new System.Drawing.Point(885, 89); |
| | | this.button1.Name = "button1"; |
| | | this.button1.Size = new System.Drawing.Size(183, 25); |
| | | this.button1.TabIndex = 20; |
| | | this.button1.Text = "ç æ Entity.java"; |
| | | this.button1.UseVisualStyleBackColor = true; |
| | | this.button1.Click += new System.EventHandler(this.entityJava_Click); |
| | | // |
| | | // 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(12, 10); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(100, 26); |
| | | this.txtNS.TabIndex = 21; |
| | | this.txtNS.Text = "69701"; |
| | | // |
| | | // button2 |
| | | // |
| | | this.button2.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button2.Location = new System.Drawing.Point(885, 127); |
| | | this.button2.Name = "button2"; |
| | | this.button2.Size = new System.Drawing.Size(183, 25); |
| | | this.button2.TabIndex = 22; |
| | | this.button2.Text = "ç æ Service.java"; |
| | | this.button2.UseVisualStyleBackColor = true; |
| | | this.button2.Click += new System.EventHandler(this.serviceJava_Click); |
| | | // |
| | | // button3 |
| | | // |
| | | this.button3.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button3.Location = new System.Drawing.Point(885, 165); |
| | | this.button3.Name = "button3"; |
| | | this.button3.Size = new System.Drawing.Size(183, 25); |
| | | this.button3.TabIndex = 23; |
| | | this.button3.Text = "çæ Controller.java"; |
| | | this.button3.UseVisualStyleBackColor = true; |
| | | this.button3.Click += new System.EventHandler(this.controllerJava_Click); |
| | | // |
| | | // txtServiceNS |
| | | // |
| | | this.txtServiceNS.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtServiceNS.Location = new System.Drawing.Point(529, 126); |
| | | this.txtServiceNS.Name = "txtServiceNS"; |
| | | this.txtServiceNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtServiceNS.TabIndex = 25; |
| | | this.txtServiceNS.Text = "com.lf.server.service.sys"; |
| | | // |
| | | // label6 |
| | | // |
| | | this.label6.AutoSize = true; |
| | | 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.TabIndex = 24; |
| | | this.label6.Text = "Serviceå称空é´ï¼"; |
| | | // |
| | | // txtControllerNS |
| | | // |
| | | this.txtControllerNS.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtControllerNS.Location = new System.Drawing.Point(529, 164); |
| | | this.txtControllerNS.Name = "txtControllerNS"; |
| | | this.txtControllerNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtControllerNS.TabIndex = 27; |
| | | this.txtControllerNS.Text = "com.lf.server.controller.sys"; |
| | | // |
| | | // label7 |
| | | // |
| | | this.label7.AutoSize = true; |
| | | 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.TabIndex = 26; |
| | | this.label7.Text = "Controllerå称空é´:"; |
| | | // |
| | | // txtApiTag |
| | | // |
| | | this.txtApiTag.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtApiTag.Location = new System.Drawing.Point(529, 201); |
| | | this.txtApiTag.Name = "txtApiTag"; |
| | | this.txtApiTag.Size = new System.Drawing.Size(339, 26); |
| | | this.txtApiTag.TabIndex = 29; |
| | | this.txtApiTag.Text = "è¿ç»´ç®¡ç\\\\{bak}"; |
| | | // |
| | | // label8 |
| | | // |
| | | this.label8.AutoSize = true; |
| | | 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.TabIndex = 28; |
| | | this.label8.Text = "Apiæ è¯ï¼"; |
| | | this.btnMybatis.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnMybatis.Location = new System.Drawing.Point(142, 134); |
| | | this.btnMybatis.Name = "btnMybatis"; |
| | | this.btnMybatis.Size = new System.Drawing.Size(183, 25); |
| | | this.btnMybatis.TabIndex = 14; |
| | | this.btnMybatis.Text = "ç æ Mybatis Plus"; |
| | | this.btnMybatis.UseVisualStyleBackColor = true; |
| | | this.btnMybatis.Click += new System.EventHandler(this.btnMybatis_Click); |
| | | // |
| | | // FrmMain |
| | | // |
| | | 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.txtApiTag); |
| | | this.Controls.Add(this.label8); |
| | | this.Controls.Add(this.txtControllerNS); |
| | | this.Controls.Add(this.label7); |
| | | this.Controls.Add(this.txtServiceNS); |
| | | this.Controls.Add(this.label6); |
| | | this.Controls.Add(this.button3); |
| | | this.Controls.Add(this.button2); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.button1); |
| | | this.Controls.Add(this.button6); |
| | | this.Controls.Add(this.button5); |
| | | this.Controls.Add(this.txtUpdate); |
| | | this.Controls.Add(this.label5); |
| | | this.Controls.Add(this.txtInsert); |
| | | this.Controls.Add(this.label4); |
| | | this.Controls.Add(this.dgvTab); |
| | | this.Controls.Add(this.button4); |
| | | this.Controls.Add(this.txtEntityNS); |
| | | this.Controls.Add(this.label3); |
| | | this.Controls.Add(this.txtMapperNS); |
| | | this.Controls.Add(this.label2); |
| | | this.Controls.Add(this.txtTabNS); |
| | | this.Controls.Add(this.label1); |
| | | this.Controls.Add(this.txtTabPre); |
| | | this.Controls.Add(this.btnReadTab); |
| | | this.Controls.Add(this.tabList); |
| | | this.ClientSize = new System.Drawing.Size(484, 261); |
| | | this.Controls.Add(this.btnMybatis); |
| | | this.Controls.Add(this.btnSys); |
| | | this.Name = "FrmMain"; |
| | | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
| | | this.Text = "FrmMain"; |
| | | this.Load += new System.EventHandler(this.FrmMain_Load); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).EndInit(); |
| | | this.ResumeLayout(false); |
| | | this.PerformLayout(); |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private System.Windows.Forms.ListBox tabList; |
| | | private System.Windows.Forms.Button btnReadTab; |
| | | private System.Windows.Forms.TextBox txtTabPre; |
| | | private System.Windows.Forms.Label label1; |
| | | private System.Windows.Forms.TextBox txtTabNS; |
| | | private System.Windows.Forms.TextBox txtMapperNS; |
| | | private System.Windows.Forms.Label label2; |
| | | private System.Windows.Forms.TextBox txtEntityNS; |
| | | private System.Windows.Forms.Label label3; |
| | | private System.Windows.Forms.Button button4; |
| | | private System.Windows.Forms.DataGridView dgvTab; |
| | | private System.Windows.Forms.Label label4; |
| | | private System.Windows.Forms.TextBox txtInsert; |
| | | private System.Windows.Forms.TextBox txtUpdate; |
| | | private System.Windows.Forms.Label label5; |
| | | 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.Button button2; |
| | | private System.Windows.Forms.Button button3; |
| | | private System.Windows.Forms.TextBox txtServiceNS; |
| | | private System.Windows.Forms.Label label6; |
| | | private System.Windows.Forms.TextBox txtControllerNS; |
| | | private System.Windows.Forms.Label label7; |
| | | private System.Windows.Forms.TextBox txtApiTag; |
| | | private System.Windows.Forms.Label label8; |
| | | private System.Windows.Forms.Button btnSys; |
| | | private System.Windows.Forms.Button btnMybatis; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | using JavaCode.cs; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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; |
| | | |
| | |
| | | { |
| | | public partial class FrmMain : Form |
| | | { |
| | | #region æååé+æé 彿° |
| | | string baseDir = AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | private PostgreHelper _dbHelper; |
| | | |
| | | private List<TabInfo> _list; |
| | | |
| | | public FrmMain() |
| | | { |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | private void FrmMain_Load(object sender, EventArgs e) |
| | | private void btnSys_Click(object sender, EventArgs e) |
| | | { |
| | | _dbHelper = new PostgreHelper(DbEnum.langfang); |
| | | } |
| | | #endregion |
| | | |
| | | #region æ¥è¯¢è¡¨ç»æ |
| | | private void btnReadTab_Click(object sender, EventArgs e) |
| | | { |
| | | string txtTab = this.txtTabPre.Text.Trim(); |
| | | string sql = "select c.relname as \"tab\", cast(obj_description(c.oid) as varchar) as \"desc\", a.attnum as \"num\", a.attname as \"col\", concat_ws('', t.typname, SUBSTRING(format_type(a.atttypid, a.atttypmod) from '\\(.*\\)')) as \"type\", d.description as \"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"; |
| | | |
| | | DataTable dt = _dbHelper.GetDataTable(sql, null); |
| | | |
| | | _list = ModelHandler.FillModel<TabInfo>(dt); |
| | | if (_list == null || _list.Count == 0) |
| | | { |
| | | MessageBox.Show("æ²¡ææ¥è¯¢å°æ°æ®ï¼"); |
| | | return; |
| | | } |
| | | |
| | | List<string> tabList = new List<string>(); |
| | | foreach (TabInfo ti in _list) |
| | | { |
| | | if (!tabList.Contains(ti.tab)) |
| | | { |
| | | tabList.Add(ti.tab); |
| | | } |
| | | } |
| | | |
| | | this.tabList.DataSource = tabList; |
| | | FrmSys frmSys = new FrmSys(); |
| | | frmSys.Show(); |
| | | } |
| | | |
| | | private void tabList_SelectedIndexChanged(object sender, EventArgs e) |
| | | private void btnMybatis_Click(object sender, EventArgs e) |
| | | { |
| | | string tab = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == tab orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | this.dgvTab.DataSource = new BindingList<TabInfo>(tabs); |
| | | if (tabs != null && tabs.Count > 1) |
| | | { |
| | | this.dgvTab.Rows[1].Selected = true; |
| | | this.dgvTab.CurrentCell = this.dgvTab.Rows[1].Cells[0]; |
| | | } |
| | | FrmMyBatisPlus mybatis = new FrmMyBatisPlus(); |
| | | mybatis.Show(); |
| | | } |
| | | |
| | | private void selectAll_Click(object sender, EventArgs e) |
| | | { |
| | | for (int i = 0; i < this.tabList.Items.Count; i++) |
| | | { |
| | | this.tabList.SetSelected(i, true); |
| | | } |
| | | } |
| | | |
| | | private void selectFlag_Click(object sender, EventArgs e) |
| | | { |
| | | for (int i = 0; i < this.tabList.Items.Count; i++) |
| | | { |
| | | bool flag = this.tabList.GetSelected(i); |
| | | this.tabList.SetSelected(i, !flag); |
| | | } |
| | | } |
| | | |
| | | private void selectNone_Click(object sender, EventArgs e) |
| | | { |
| | | for (int i = 0; i < this.tabList.Items.Count; i++) |
| | | { |
| | | this.tabList.SetSelected(i, false); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Mapper.Xml |
| | | private void mapperXml_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateMapperXml(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateMapperXml(string name, List<TabInfo> tabs) |
| | | { |
| | | string tabName = this.txtTabNS.Text.Trim() + name; |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string entityName = shortName + "Entity"; |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string testExpr = colName + " != null"; |
| | | string testWhere = selectTabInfo.col + (colType == "String" ? " like " : " = ") + "#{" + colName + "}"; |
| | | |
| | | string insertCols = GetInsertCols(tabs); |
| | | string insertVal = GetInsertVal(tabs); |
| | | string insertVals = GetInsertVals(tabs); |
| | | string updateVal = GetUpdateVal(tabs); |
| | | string updateVals = GetUpdateVals(tabs); |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "Template\\Mapper.xml")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{tabName}", tabName) |
| | | .Replace("{testExpr}", testExpr) |
| | | .Replace("{testWhere}", testWhere) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{insertCols}", insertCols) |
| | | .Replace("{insertVal}", insertVal) |
| | | .Replace("{insertVals}", insertVals) |
| | | .Replace("{updateVal}", updateVal) |
| | | .Replace("{updateVals}", updateVals); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Mapper.xml"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | |
| | | private static string NameConvert(string name, bool firstUpper) |
| | | { |
| | | string[] strs = name.Split(new char[] { '_' }); |
| | | |
| | | string str = ""; |
| | | for (int i = 0, c = strs.Length; i < c; i++) |
| | | { |
| | | if (i == 0 && !firstUpper) |
| | | { |
| | | str += strs[i]; |
| | | continue; |
| | | } |
| | | str += ToUpperFirst(strs[i]); |
| | | } |
| | | |
| | | return str; |
| | | } |
| | | |
| | | public static string ToUpperFirst(string str) |
| | | { |
| | | return Regex.Replace(str, @"^\w", t => t.Value.ToUpper()); |
| | | } |
| | | |
| | | public string GetInsertCols(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | sb.Append(ti.col + ","); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetInsertVal(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp(6)") |
| | | { |
| | | sb.Append("now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append("#{" + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetInsertVals(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp(6)") |
| | | { |
| | | sb.Append("now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append("#{item." + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetUpdateVal(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtUpdate.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp(6)") |
| | | { |
| | | sb.Append(ti.col + "=now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append(ti.col + "=#{" + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetUpdateVals(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtUpdate.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp(6)") |
| | | { |
| | | sb.Append(ti.col + "=now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append(ti.col + "=#{item." + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | private static void OpenFolder(string folderPath) |
| | | { |
| | | if (string.IsNullOrEmpty(folderPath)) return; |
| | | |
| | | Process process = new Process(); |
| | | ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe"); |
| | | psi.Arguments = folderPath; |
| | | process.StartInfo = psi; |
| | | |
| | | try |
| | | { |
| | | process.Start(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | finally |
| | | { |
| | | process.Close(); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Mapper.java |
| | | private void mapperJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateMapperJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateMapperJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string entityName = shortName + "Entity"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string queryCol = colType + " " + colName; |
| | | string colBak = selectTabInfo.bak; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "Template\\Mapper.java")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{colName}", colName) |
| | | .Replace("{colBak}", colBak) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{queryCol}", queryCol); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Mapper.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | |
| | | private string GetJavaType(TabInfo ti) |
| | | { |
| | | string type = ti.type.Split(new char[] { '(' })[0]; |
| | | switch (type) |
| | | { |
| | | case "timestamp": |
| | | return "Timestamp"; |
| | | case "float4": // float |
| | | return "Float"; |
| | | case "float8": // double |
| | | return "Double"; |
| | | case "bool": // boolean |
| | | return "Boolean"; |
| | | case "numeric": |
| | | return "BigDecimal"; |
| | | case "int8": // long |
| | | return "Long"; |
| | | case "int2": |
| | | case "int4": // int |
| | | return "Integer"; |
| | | default: |
| | | return "String"; |
| | | } |
| | | } |
| | | |
| | | private String GetType(TabInfo ti) |
| | | { |
| | | string type = ti.type.Split(new char[] { '(' })[0]; |
| | | switch (type) |
| | | { |
| | | case "timestamp": |
| | | return "Timestamp"; |
| | | case "float4": |
| | | return "float"; |
| | | case "float8": |
| | | return "double"; |
| | | case "bool": |
| | | return "boolean"; |
| | | case "numeric": |
| | | return "BigDecimal"; |
| | | case "int8": |
| | | return "long"; |
| | | case "int2": |
| | | case "int4": |
| | | return "int"; |
| | | default: |
| | | return "String"; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Entity.java |
| | | private void entityJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateEntityJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateEntityJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string entityName = shortName + "Entity"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | long uid = (long)Math.Floor((new Random()).NextDouble() * 1000000000000000000D); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "Template\\Entity.java")); |
| | | xml = xml |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{uid}", uid.ToString()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | string type = GetType(ti); |
| | | string colName = NameConvert(ti.col, false); |
| | | sb.Append("\r\n private " + type + " " + colName + ";\r\n"); |
| | | } |
| | | |
| | | sb.Append("\r\n public " + entityName + "() {\r\n }\r\n"); |
| | | |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | string type = GetType(ti); |
| | | string col1 = NameConvert(ti.col, true); |
| | | string col2 = NameConvert(ti.col, false); |
| | | |
| | | sb.Append("\r\n public " + type + " get" + col1 + "() {\r\n return " + col2 + ";\r\n }\r\n"); |
| | | sb.Append("\r\n public void set" + col1 + "(" + type + " " + col2 + ") {\r\n this." + col2 + " = " + col2 + ";\r\n }\r\n"); |
| | | } |
| | | sb.Append("}\r\n"); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | sb.Insert(0, xml); |
| | | |
| | | string fileName = shortName + "Entity.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), sb.ToString()); |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Service.java |
| | | private void serviceJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateServiceJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateServiceJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string serviceNS = this.txtServiceNS.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string minMapperName = NameConvert(name, false) + "Mapper"; |
| | | string entityName = shortName + "Entity"; |
| | | string serviceName = shortName + "Service"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string queryCol = colType + " " + colName; |
| | | |
| | | //string where = isString ? "\r\n " + colName + " = \"%\" + (StringHelper.isNull(" + colName + ") ? \"\" : " + colName + ".trim()) + \"%\";\r\n" : ""; |
| | | string where = colType == "String" ? "\r\n " + colName + " = StringHelper.isNull(" + colName + ") ? null : \"%\" + " + colName + ".trim() + \"%\";\r\n" : ""; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "Template\\Service.java")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{minMapperName}", minMapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{serviceNS}", serviceNS) |
| | | .Replace("{serviceName}", serviceName) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{queryCol}", queryCol) |
| | | .Replace("{colName}", colName) |
| | | .Replace("{where}", where); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Service.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Controller.java |
| | | private void controllerJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateControllerJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateControllerJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string serviceNS = this.txtServiceNS.Text.Trim(); |
| | | string controllerNS = this.txtControllerNS.Text.Trim(); |
| | | string apiTag = this.txtApiTag.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string entityName = shortName + "Entity"; |
| | | string serviceName = shortName + "Service"; |
| | | string minServiceName = NameConvert(name, false) + "Service"; |
| | | string controllerName = shortName + "Controller"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | string apiName = NameConvert(name, false); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string queryCol = colType + " " + colName; |
| | | string colBak = selectTabInfo.bak; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "Template\\Controller.java")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{serviceNS}", serviceNS) |
| | | .Replace("{serviceName}", serviceName) |
| | | .Replace("{controllerNS}", controllerNS) |
| | | .Replace("{controllerName}", controllerName) |
| | | .Replace("{minServiceName}", minServiceName) |
| | | .Replace("{queryCol}", queryCol) |
| | | .Replace("{colName}", colName) |
| | | .Replace("{colBak}", colBak) |
| | | .Replace("{colType}", colType) |
| | | .Replace("{apiTag}", apiTag) |
| | | .Replace("{apiName}", apiName) |
| | | .Replace("{bak}", bak); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Controller.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | #endregion |
| | | |
| | | #region çææææä»¶ |
| | | private void generateAll_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateMapperXml(name, tabs); |
| | | GenerateMapperJava(name, tabs); |
| | | GenerateEntityJava(name, tabs); |
| | | GenerateServiceJava(name, tabs); |
| | | GenerateControllerJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "Generate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace JavaCode |
| | | { |
| | | partial class FrmMyBatisPlus |
| | | { |
| | | /// <summary> |
| | | /// Required designer variable. |
| | | /// </summary> |
| | | private System.ComponentModel.IContainer components = null; |
| | | |
| | | /// <summary> |
| | | /// Clean up any resources being used. |
| | | /// </summary> |
| | | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | if (disposing && (components != null)) |
| | | { |
| | | components.Dispose(); |
| | | } |
| | | base.Dispose(disposing); |
| | | } |
| | | |
| | | #region Windows Form Designer generated code |
| | | |
| | | /// <summary> |
| | | /// Required method for Designer support - do not modify |
| | | /// the contents of this method with the code editor. |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.txtNS = 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.dgvTab = new System.Windows.Forms.DataGridView(); |
| | | this.txtEntityNS = new System.Windows.Forms.TextBox(); |
| | | this.label3 = new System.Windows.Forms.Label(); |
| | | this.txtMapperNS = new System.Windows.Forms.TextBox(); |
| | | this.label2 = new System.Windows.Forms.Label(); |
| | | this.btnGenerate = new System.Windows.Forms.Button(); |
| | | this.btnAll = new System.Windows.Forms.Button(); |
| | | this.btnAnti = new System.Windows.Forms.Button(); |
| | | this.btnNone = new System.Windows.Forms.Button(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); |
| | | this.SuspendLayout(); |
| | | // |
| | | // 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(12, 13); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(104, 26); |
| | | this.txtNS.TabIndex = 25; |
| | | this.txtNS.Text = "29257,20582"; |
| | | // |
| | | // txtTabPre |
| | | // |
| | | this.txtTabPre.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabPre.Location = new System.Drawing.Point(136, 13); |
| | | this.txtTabPre.Name = "txtTabPre"; |
| | | this.txtTabPre.Size = new System.Drawing.Size(98, 26); |
| | | this.txtTabPre.TabIndex = 24; |
| | | // |
| | | // btnReadTab |
| | | // |
| | | this.btnReadTab.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnReadTab.Location = new System.Drawing.Point(247, 15); |
| | | this.btnReadTab.Name = "btnReadTab"; |
| | | this.btnReadTab.Size = new System.Drawing.Size(118, 23); |
| | | this.btnReadTab.TabIndex = 23; |
| | | this.btnReadTab.Text = "è¯»åæ°æ®åºè¡¨"; |
| | | this.btnReadTab.UseVisualStyleBackColor = true; |
| | | this.btnReadTab.Click += new System.EventHandler(this.btnReadTab_Click); |
| | | // |
| | | // tabList |
| | | // |
| | | this.tabList.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.tabList.FormattingEnabled = true; |
| | | this.tabList.ItemHeight = 16; |
| | | this.tabList.Location = new System.Drawing.Point(12, 86); |
| | | this.tabList.Name = "tabList"; |
| | | this.tabList.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple; |
| | | this.tabList.Size = new System.Drawing.Size(353, 212); |
| | | this.tabList.TabIndex = 22; |
| | | this.tabList.SelectedIndexChanged += new System.EventHandler(this.tabList_SelectedIndexChanged); |
| | | // |
| | | // dgvTab |
| | | // |
| | | this.dgvTab.AllowUserToAddRows = false; |
| | | this.dgvTab.AllowUserToDeleteRows = false; |
| | | this.dgvTab.BackgroundColor = System.Drawing.SystemColors.ButtonFace; |
| | | this.dgvTab.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
| | | this.dgvTab.Location = new System.Drawing.Point(12, 312); |
| | | this.dgvTab.Margin = new System.Windows.Forms.Padding(0); |
| | | this.dgvTab.MultiSelect = false; |
| | | this.dgvTab.Name = "dgvTab"; |
| | | this.dgvTab.ReadOnly = true; |
| | | this.dgvTab.RowHeadersWidth = 40; |
| | | this.dgvTab.RowTemplate.Height = 23; |
| | | this.dgvTab.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; |
| | | this.dgvTab.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; |
| | | this.dgvTab.Size = new System.Drawing.Size(825, 300); |
| | | this.dgvTab.TabIndex = 26; |
| | | // |
| | | // 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, 61); |
| | | this.txtEntityNS.Name = "txtEntityNS"; |
| | | this.txtEntityNS.Size = new System.Drawing.Size(312, 26); |
| | | this.txtEntityNS.TabIndex = 30; |
| | | this.txtEntityNS.Text = "com.lf.server.entity.db"; |
| | | // |
| | | // label3 |
| | | // |
| | | this.label3.AutoSize = true; |
| | | 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, 66); |
| | | this.label3.Name = "label3"; |
| | | this.label3.Size = new System.Drawing.Size(136, 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, 15); |
| | | this.txtMapperNS.Name = "txtMapperNS"; |
| | | this.txtMapperNS.Size = new System.Drawing.Size(312, 26); |
| | | this.txtMapperNS.TabIndex = 32; |
| | | this.txtMapperNS.Text = "com.lf.server.mapper.db"; |
| | | // |
| | | // label2 |
| | | // |
| | | this.label2.AutoSize = true; |
| | | 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, 20); |
| | | this.label2.Name = "label2"; |
| | | this.label2.Size = new System.Drawing.Size(136, 16); |
| | | this.label2.TabIndex = 31; |
| | | this.label2.Text = "Mapperå称空é´ï¼"; |
| | | // |
| | | // btnGenerate |
| | | // |
| | | this.btnGenerate.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnGenerate.Location = new System.Drawing.Point(525, 115); |
| | | this.btnGenerate.Name = "btnGenerate"; |
| | | this.btnGenerate.Size = new System.Drawing.Size(312, 25); |
| | | this.btnGenerate.TabIndex = 33; |
| | | this.btnGenerate.Text = "ç æ æ ä»¶"; |
| | | this.btnGenerate.UseVisualStyleBackColor = true; |
| | | this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click); |
| | | // |
| | | // btnAll |
| | | // |
| | | this.btnAll.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnAll.Location = new System.Drawing.Point(12, 53); |
| | | this.btnAll.Name = "btnAll"; |
| | | this.btnAll.Size = new System.Drawing.Size(104, 23); |
| | | this.btnAll.TabIndex = 34; |
| | | this.btnAll.Text = "å
¨ é"; |
| | | this.btnAll.UseVisualStyleBackColor = true; |
| | | this.btnAll.Click += new System.EventHandler(this.btnAll_Click); |
| | | // |
| | | // btnAnti |
| | | // |
| | | this.btnAnti.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnAnti.Location = new System.Drawing.Point(136, 52); |
| | | this.btnAnti.Name = "btnAnti"; |
| | | this.btnAnti.Size = new System.Drawing.Size(98, 23); |
| | | this.btnAnti.TabIndex = 35; |
| | | this.btnAnti.Text = "å é"; |
| | | this.btnAnti.UseVisualStyleBackColor = true; |
| | | this.btnAnti.Click += new System.EventHandler(this.btnAnti_Click); |
| | | // |
| | | // btnNone |
| | | // |
| | | this.btnNone.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnNone.Location = new System.Drawing.Point(247, 52); |
| | | this.btnNone.Name = "btnNone"; |
| | | this.btnNone.Size = new System.Drawing.Size(118, 23); |
| | | this.btnNone.TabIndex = 36; |
| | | this.btnNone.Text = "å
¨ ä¸ é"; |
| | | this.btnNone.UseVisualStyleBackColor = true; |
| | | this.btnNone.Click += new System.EventHandler(this.btnNone_Click); |
| | | // |
| | | // 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.btnNone); |
| | | this.Controls.Add(this.btnAnti); |
| | | this.Controls.Add(this.btnAll); |
| | | this.Controls.Add(this.btnGenerate); |
| | | this.Controls.Add(this.txtMapperNS); |
| | | this.Controls.Add(this.label2); |
| | | this.Controls.Add(this.txtEntityNS); |
| | | this.Controls.Add(this.label3); |
| | | this.Controls.Add(this.dgvTab); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.txtTabPre); |
| | | this.Controls.Add(this.btnReadTab); |
| | | this.Controls.Add(this.tabList); |
| | | this.Name = "FrmMyBatisPlus"; |
| | | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
| | | this.Text = "FrmMyBatisPlus"; |
| | | this.Load += new System.EventHandler(this.FrmMyBatisPlus_Load); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).EndInit(); |
| | | this.ResumeLayout(false); |
| | | this.PerformLayout(); |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private System.Windows.Forms.TextBox txtNS; |
| | | private System.Windows.Forms.TextBox txtTabPre; |
| | | private System.Windows.Forms.Button btnReadTab; |
| | | private System.Windows.Forms.ListBox tabList; |
| | | private System.Windows.Forms.DataGridView dgvTab; |
| | | private System.Windows.Forms.TextBox txtEntityNS; |
| | | private System.Windows.Forms.Label label3; |
| | | private System.Windows.Forms.TextBox txtMapperNS; |
| | | private System.Windows.Forms.Label label2; |
| | | private System.Windows.Forms.Button btnGenerate; |
| | | private System.Windows.Forms.Button btnAll; |
| | | private System.Windows.Forms.Button btnAnti; |
| | | private System.Windows.Forms.Button btnNone; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using JavaCode.cs; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace JavaCode |
| | | { |
| | | public partial class FrmMyBatisPlus : Form |
| | | { |
| | | #region æååé+æé 彿° |
| | | string baseDir = AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | private PostgreHelper _dbHelper; |
| | | |
| | | private List<TabInfo> _list; |
| | | |
| | | public FrmMyBatisPlus() |
| | | { |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | private void FrmMyBatisPlus_Load(object sender, EventArgs e) |
| | | { |
| | | _dbHelper = new PostgreHelper(DbEnum.langfang); |
| | | } |
| | | #endregion |
| | | |
| | | // 135502,69701 29257,20582 |
| | | private void btnReadTab_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | 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 as \"tab\", cast(obj_description(c.oid) as varchar) as \"desc\", a.attnum as \"num\", a.attname as \"col\",concat_ws('', t.typname, SUBSTRING(format_type(a.atttypid, a.atttypmod) from '(.*)')) as \"type\", d.description as \"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} order by c.relname desc, a.attnum asc", this.txtNS.Text.Trim(), tabFilter); |
| | | |
| | | DataTable dt = _dbHelper.GetDataTable(sql, null); |
| | | _list = ModelHandler.FillModel<TabInfo>(dt); |
| | | if (_list == null || _list.Count == 0) |
| | | { |
| | | MessageBox.Show("æ²¡ææ¥è¯¢å°æ°æ®ï¼"); |
| | | return; |
| | | } |
| | | |
| | | List<string> tabList = new List<string>(); |
| | | foreach (TabInfo ti in _list) |
| | | { |
| | | if (!tabList.Contains(ti.tab)) |
| | | { |
| | | tabList.Add(ti.tab); |
| | | } |
| | | } |
| | | this.tabList.DataSource = tabList; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void btnAll_Click(object sender, EventArgs e) |
| | | { |
| | | for (int i = 0; i < this.tabList.Items.Count; i++) |
| | | { |
| | | this.tabList.SetSelected(i, true); |
| | | } |
| | | } |
| | | |
| | | private void btnAnti_Click(object sender, EventArgs e) |
| | | { |
| | | for (int i = 0; i < this.tabList.Items.Count; i++) |
| | | { |
| | | bool flag = this.tabList.GetSelected(i); |
| | | this.tabList.SetSelected(i, !flag); |
| | | } |
| | | } |
| | | |
| | | private void btnNone_Click(object sender, EventArgs e) |
| | | { |
| | | for (int i = 0; i < this.tabList.Items.Count; i++) |
| | | { |
| | | this.tabList.SetSelected(i, false); |
| | | } |
| | | } |
| | | |
| | | private void tabList_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | string tab = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == tab orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | this.dgvTab.DataSource = new BindingList<TabInfo>(tabs); |
| | | if (tabs != null && tabs.Count > 1) |
| | | { |
| | | this.dgvTab.Rows[1].Selected = true; |
| | | this.dgvTab.CurrentCell = this.dgvTab.Rows[1].Cells[0]; |
| | | } |
| | | } |
| | | |
| | | private void btnGenerate_Click(object sender, EventArgs e) |
| | | { |
| | | // |
| | | } |
| | | |
| | | private String QueryPrimaryKey(string tab) |
| | | { |
| | | string sql = string.Format("select pg_attribute.attname as colname from pg_constraint inner join pg_class on pg_constraint.conrelid = pg_class.oid inner join pg_attribute on pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum = pg_constraint.conkey[1] inner join pg_type on pg_type.oid = pg_attribute.atttypid where pg_class.relname = '{0}' and pg_constraint.contype='p'", tab); |
| | | |
| | | object obj = _dbHelper.GetScalar(sql, null); |
| | | |
| | | return obj == null ? null : obj.ToString(); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | | The primary goals of this format is to allow a simple XML format |
| | | that is mostly human readable. The generation and parsing of the |
| | | various data types are done through the TypeConverter classes |
| | | associated with the data types. |
| | | |
| | | Example: |
| | | |
| | | ... ado.net/XML headers & schema ... |
| | | <resheader name="resmimetype">text/microsoft-resx</resheader> |
| | | <resheader name="version">2.0</resheader> |
| | | <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
| | | <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
| | | <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
| | | <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
| | | <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
| | | <value>[base64 mime encoded serialized .NET Framework object]</value> |
| | | </data> |
| | | <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
| | | <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
| | | <comment>This is a comment</comment> |
| | | </data> |
| | | |
| | | There are any number of "resheader" rows that contain simple |
| | | name/value pairs. |
| | | |
| | | Each data row contains a name, and value. The row also contains a |
| | | type or mimetype. Type corresponds to a .NET class that support |
| | | text/value conversion through the TypeConverter architecture. |
| | | Classes that don't support this are serialized and stored with the |
| | | mimetype set. |
| | | |
| | | The mimetype is used for serialized objects, and tells the |
| | | ResXResourceReader how to depersist the object. This is currently not |
| | | extensible. For a given mimetype the value must be set accordingly: |
| | | |
| | | Note - application/x-microsoft.net.object.binary.base64 is the format |
| | | that the ResXResourceWriter will generate, however the reader can |
| | | read any of the formats listed below. |
| | | |
| | | mimetype: application/x-microsoft.net.object.binary.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.bytearray.base64 |
| | | value : The object must be serialized into a byte array |
| | | : using a System.ComponentModel.TypeConverter |
| | | : and then encoded with base64 encoding. |
| | | --> |
| | | <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
| | | <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
| | | <xsd:element name="root" msdata:IsDataSet="true"> |
| | | <xsd:complexType> |
| | | <xsd:choice maxOccurs="unbounded"> |
| | | <xsd:element name="metadata"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" use="required" type="xsd:string" /> |
| | | <xsd:attribute name="type" type="xsd:string" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" /> |
| | | <xsd:attribute ref="xml:space" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="assembly"> |
| | | <xsd:complexType> |
| | | <xsd:attribute name="alias" type="xsd:string" /> |
| | | <xsd:attribute name="name" type="xsd:string" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="data"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
| | | <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
| | | <xsd:attribute ref="xml:space" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="resheader"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:choice> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:schema> |
| | | <resheader name="resmimetype"> |
| | | <value>text/microsoft-resx</value> |
| | | </resheader> |
| | | <resheader name="version"> |
| | | <value>2.0</value> |
| | | </resheader> |
| | | <resheader name="reader"> |
| | | <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | </root> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace JavaCode |
| | | { |
| | | partial class FrmSys |
| | | { |
| | | /// <summary> |
| | | /// å¿
éç设计å¨åéã |
| | | /// </summary> |
| | | private System.ComponentModel.IContainer components = null; |
| | | |
| | | /// <summary> |
| | | /// æ¸
çæææ£å¨ä½¿ç¨çèµæºã |
| | | /// </summary> |
| | | /// <param name="disposing">妿åºéæ¾æç®¡èµæºï¼ä¸º trueï¼å¦å为 falseã</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | if (disposing && (components != null)) |
| | | { |
| | | components.Dispose(); |
| | | } |
| | | base.Dispose(disposing); |
| | | } |
| | | |
| | | #region Windows çªä½è®¾è®¡å¨çæç代ç |
| | | |
| | | /// <summary> |
| | | /// è®¾è®¡å¨æ¯ææéçæ¹æ³ - ä¸è¦ |
| | | /// 使ç¨ä»£ç ç¼è¾å¨ä¿®æ¹æ¤æ¹æ³çå
容ã |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.tabList = new System.Windows.Forms.ListBox(); |
| | | this.btnReadTab = new System.Windows.Forms.Button(); |
| | | this.txtTabPre = new System.Windows.Forms.TextBox(); |
| | | this.txtMapperNS = new System.Windows.Forms.TextBox(); |
| | | this.label2 = new System.Windows.Forms.Label(); |
| | | this.txtEntityNS = new System.Windows.Forms.TextBox(); |
| | | this.label3 = new System.Windows.Forms.Label(); |
| | | this.button4 = new System.Windows.Forms.Button(); |
| | | this.dgvTab = new System.Windows.Forms.DataGridView(); |
| | | this.label4 = new System.Windows.Forms.Label(); |
| | | this.txtInsert = new System.Windows.Forms.TextBox(); |
| | | this.txtUpdate = new System.Windows.Forms.TextBox(); |
| | | this.label5 = new System.Windows.Forms.Label(); |
| | | 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.button2 = new System.Windows.Forms.Button(); |
| | | this.button3 = new System.Windows.Forms.Button(); |
| | | this.txtServiceNS = new System.Windows.Forms.TextBox(); |
| | | this.label6 = new System.Windows.Forms.Label(); |
| | | this.txtControllerNS = new System.Windows.Forms.TextBox(); |
| | | this.label7 = new System.Windows.Forms.Label(); |
| | | 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(); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).BeginInit(); |
| | | this.SuspendLayout(); |
| | | // |
| | | // tabList |
| | | // |
| | | this.tabList.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.tabList.FormattingEnabled = true; |
| | | this.tabList.ItemHeight = 16; |
| | | this.tabList.Location = new System.Drawing.Point(12, 49); |
| | | this.tabList.Name = "tabList"; |
| | | this.tabList.Size = new System.Drawing.Size(353, 244); |
| | | this.tabList.TabIndex = 0; |
| | | this.tabList.SelectedIndexChanged += new System.EventHandler(this.tabList_SelectedIndexChanged); |
| | | // |
| | | // btnReadTab |
| | | // |
| | | this.btnReadTab.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.btnReadTab.Location = new System.Drawing.Point(247, 13); |
| | | this.btnReadTab.Name = "btnReadTab"; |
| | | this.btnReadTab.Size = new System.Drawing.Size(118, 23); |
| | | this.btnReadTab.TabIndex = 1; |
| | | this.btnReadTab.Text = "è¯»åæ°æ®åºè¡¨"; |
| | | this.btnReadTab.UseVisualStyleBackColor = true; |
| | | this.btnReadTab.Click += new System.EventHandler(this.btnReadTab_Click); |
| | | // |
| | | // txtTabPre |
| | | // |
| | | this.txtTabPre.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtTabPre.Location = new System.Drawing.Point(129, 10); |
| | | this.txtTabPre.Name = "txtTabPre"; |
| | | this.txtTabPre.Size = new System.Drawing.Size(100, 26); |
| | | this.txtTabPre.TabIndex = 2; |
| | | this.txtTabPre.Text = "sys_"; |
| | | // |
| | | // 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(529, 51); |
| | | this.txtMapperNS.Name = "txtMapperNS"; |
| | | this.txtMapperNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtMapperNS.TabIndex = 9; |
| | | this.txtMapperNS.Text = "com.lf.server.mapper.sys"; |
| | | // |
| | | // label2 |
| | | // |
| | | this.label2.AutoSize = true; |
| | | 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.TabIndex = 8; |
| | | this.label2.Text = "Mapperå称空é´ï¼"; |
| | | // |
| | | // 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(529, 88); |
| | | this.txtEntityNS.Name = "txtEntityNS"; |
| | | this.txtEntityNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtEntityNS.TabIndex = 11; |
| | | this.txtEntityNS.Text = "com.lf.server.entity.sys"; |
| | | // |
| | | // label3 |
| | | // |
| | | this.label3.AutoSize = true; |
| | | 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.TabIndex = 10; |
| | | this.label3.Text = "Entityå称空é´ï¼"; |
| | | // |
| | | // button4 |
| | | // |
| | | this.button4.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button4.Location = new System.Drawing.Point(885, 202); |
| | | this.button4.Name = "button4"; |
| | | this.button4.Size = new System.Drawing.Size(183, 25); |
| | | this.button4.TabIndex = 12; |
| | | this.button4.Text = "ç æ æ æ æ ä»¶"; |
| | | this.button4.UseVisualStyleBackColor = true; |
| | | this.button4.Click += new System.EventHandler(this.generateAll_Click); |
| | | // |
| | | // dgvTab |
| | | // |
| | | this.dgvTab.AllowUserToAddRows = false; |
| | | this.dgvTab.AllowUserToDeleteRows = false; |
| | | this.dgvTab.BackgroundColor = System.Drawing.SystemColors.ButtonFace; |
| | | this.dgvTab.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
| | | this.dgvTab.Location = new System.Drawing.Point(12, 312); |
| | | this.dgvTab.Margin = new System.Windows.Forms.Padding(0); |
| | | this.dgvTab.MultiSelect = false; |
| | | this.dgvTab.Name = "dgvTab"; |
| | | this.dgvTab.ReadOnly = true; |
| | | this.dgvTab.RowHeadersWidth = 40; |
| | | this.dgvTab.RowTemplate.Height = 23; |
| | | this.dgvTab.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; |
| | | this.dgvTab.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; |
| | | this.dgvTab.Size = new System.Drawing.Size(1056, 300); |
| | | this.dgvTab.TabIndex = 13; |
| | | // |
| | | // label4 |
| | | // |
| | | this.label4.AutoSize = true; |
| | | 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.TabIndex = 14; |
| | | this.label4.Text = "æå
¥æ¶æé¤å段ï¼"; |
| | | // |
| | | // txtInsert |
| | | // |
| | | this.txtInsert.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtInsert.Location = new System.Drawing.Point(529, 236); |
| | | this.txtInsert.Name = "txtInsert"; |
| | | this.txtInsert.Size = new System.Drawing.Size(339, 26); |
| | | this.txtInsert.TabIndex = 15; |
| | | this.txtInsert.Text = "id,update_user,update_time"; |
| | | // |
| | | // txtUpdate |
| | | // |
| | | this.txtUpdate.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtUpdate.Location = new System.Drawing.Point(529, 271); |
| | | this.txtUpdate.Name = "txtUpdate"; |
| | | this.txtUpdate.Size = new System.Drawing.Size(339, 26); |
| | | this.txtUpdate.TabIndex = 17; |
| | | this.txtUpdate.Text = "id,create_user,create_time"; |
| | | // |
| | | // label5 |
| | | // |
| | | this.label5.AutoSize = true; |
| | | 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.TabIndex = 16; |
| | | this.label5.Text = "æ´æ°æ¶æé¤å段ï¼"; |
| | | // |
| | | // button5 |
| | | // |
| | | this.button5.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button5.Location = new System.Drawing.Point(885, 14); |
| | | this.button5.Name = "button5"; |
| | | this.button5.Size = new System.Drawing.Size(183, 25); |
| | | this.button5.TabIndex = 18; |
| | | this.button5.Text = "ç æ Mapper.xml"; |
| | | this.button5.UseVisualStyleBackColor = true; |
| | | this.button5.Click += new System.EventHandler(this.mapperXml_Click); |
| | | // |
| | | // button6 |
| | | // |
| | | this.button6.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button6.Location = new System.Drawing.Point(885, 52); |
| | | this.button6.Name = "button6"; |
| | | this.button6.Size = new System.Drawing.Size(183, 25); |
| | | this.button6.TabIndex = 19; |
| | | this.button6.Text = "ç æ Mapper.java"; |
| | | this.button6.UseVisualStyleBackColor = true; |
| | | this.button6.Click += new System.EventHandler(this.mapperJava_Click); |
| | | // |
| | | // button1 |
| | | // |
| | | this.button1.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button1.Location = new System.Drawing.Point(885, 89); |
| | | this.button1.Name = "button1"; |
| | | this.button1.Size = new System.Drawing.Size(183, 25); |
| | | this.button1.TabIndex = 20; |
| | | this.button1.Text = "ç æ Entity.java"; |
| | | this.button1.UseVisualStyleBackColor = true; |
| | | this.button1.Click += new System.EventHandler(this.entityJava_Click); |
| | | // |
| | | // 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(12, 10); |
| | | this.txtNS.Name = "txtNS"; |
| | | this.txtNS.Size = new System.Drawing.Size(100, 26); |
| | | this.txtNS.TabIndex = 21; |
| | | this.txtNS.Text = "20582"; |
| | | // |
| | | // button2 |
| | | // |
| | | this.button2.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button2.Location = new System.Drawing.Point(885, 127); |
| | | this.button2.Name = "button2"; |
| | | this.button2.Size = new System.Drawing.Size(183, 25); |
| | | this.button2.TabIndex = 22; |
| | | this.button2.Text = "ç æ Service.java"; |
| | | this.button2.UseVisualStyleBackColor = true; |
| | | this.button2.Click += new System.EventHandler(this.serviceJava_Click); |
| | | // |
| | | // button3 |
| | | // |
| | | this.button3.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.button3.Location = new System.Drawing.Point(885, 165); |
| | | this.button3.Name = "button3"; |
| | | this.button3.Size = new System.Drawing.Size(183, 25); |
| | | this.button3.TabIndex = 23; |
| | | this.button3.Text = "çæ Controller.java"; |
| | | this.button3.UseVisualStyleBackColor = true; |
| | | this.button3.Click += new System.EventHandler(this.controllerJava_Click); |
| | | // |
| | | // txtServiceNS |
| | | // |
| | | this.txtServiceNS.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtServiceNS.Location = new System.Drawing.Point(529, 126); |
| | | this.txtServiceNS.Name = "txtServiceNS"; |
| | | this.txtServiceNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtServiceNS.TabIndex = 25; |
| | | this.txtServiceNS.Text = "com.lf.server.service.sys"; |
| | | // |
| | | // label6 |
| | | // |
| | | this.label6.AutoSize = true; |
| | | 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.TabIndex = 24; |
| | | this.label6.Text = "Serviceå称空é´ï¼"; |
| | | // |
| | | // txtControllerNS |
| | | // |
| | | this.txtControllerNS.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtControllerNS.Location = new System.Drawing.Point(529, 164); |
| | | this.txtControllerNS.Name = "txtControllerNS"; |
| | | this.txtControllerNS.Size = new System.Drawing.Size(339, 26); |
| | | this.txtControllerNS.TabIndex = 27; |
| | | this.txtControllerNS.Text = "com.lf.server.controller.sys"; |
| | | // |
| | | // label7 |
| | | // |
| | | this.label7.AutoSize = true; |
| | | 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.TabIndex = 26; |
| | | this.label7.Text = "Controllerå称空é´:"; |
| | | // |
| | | // txtApiTag |
| | | // |
| | | this.txtApiTag.Font = new System.Drawing.Font("å®ä½", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); |
| | | this.txtApiTag.Location = new System.Drawing.Point(529, 201); |
| | | this.txtApiTag.Name = "txtApiTag"; |
| | | this.txtApiTag.Size = new System.Drawing.Size(339, 26); |
| | | this.txtApiTag.TabIndex = 29; |
| | | this.txtApiTag.Text = "è¿ç»´ç®¡ç\\\\{bak}"; |
| | | // |
| | | // label8 |
| | | // |
| | | this.label8.AutoSize = true; |
| | | 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.TabIndex = 28; |
| | | this.label8.Text = "Apiæ è¯ï¼"; |
| | | // |
| | | // label1 |
| | | // |
| | | this.label1.AutoSize = true; |
| | | 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.TabIndex = 6; |
| | | this.label1.Text = "表ååç¼ï¼"; |
| | | // |
| | | // txtTabNS |
| | | // |
| | | 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."; |
| | | // |
| | | // 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.txtApiTag); |
| | | this.Controls.Add(this.label8); |
| | | this.Controls.Add(this.txtControllerNS); |
| | | this.Controls.Add(this.label7); |
| | | this.Controls.Add(this.txtServiceNS); |
| | | this.Controls.Add(this.label6); |
| | | this.Controls.Add(this.button3); |
| | | this.Controls.Add(this.button2); |
| | | this.Controls.Add(this.txtNS); |
| | | this.Controls.Add(this.button1); |
| | | this.Controls.Add(this.button6); |
| | | this.Controls.Add(this.button5); |
| | | this.Controls.Add(this.txtUpdate); |
| | | this.Controls.Add(this.label5); |
| | | this.Controls.Add(this.txtInsert); |
| | | this.Controls.Add(this.label4); |
| | | this.Controls.Add(this.dgvTab); |
| | | this.Controls.Add(this.button4); |
| | | this.Controls.Add(this.txtEntityNS); |
| | | this.Controls.Add(this.label3); |
| | | this.Controls.Add(this.txtMapperNS); |
| | | this.Controls.Add(this.label2); |
| | | this.Controls.Add(this.txtTabNS); |
| | | this.Controls.Add(this.label1); |
| | | this.Controls.Add(this.txtTabPre); |
| | | this.Controls.Add(this.btnReadTab); |
| | | this.Controls.Add(this.tabList); |
| | | this.Name = "FrmSys"; |
| | | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
| | | this.Text = "FrmSys"; |
| | | this.Load += new System.EventHandler(this.FrmMain_Load); |
| | | ((System.ComponentModel.ISupportInitialize)(this.dgvTab)).EndInit(); |
| | | this.ResumeLayout(false); |
| | | this.PerformLayout(); |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private System.Windows.Forms.ListBox tabList; |
| | | private System.Windows.Forms.Button btnReadTab; |
| | | private System.Windows.Forms.TextBox txtTabPre; |
| | | private System.Windows.Forms.TextBox txtMapperNS; |
| | | private System.Windows.Forms.Label label2; |
| | | private System.Windows.Forms.TextBox txtEntityNS; |
| | | private System.Windows.Forms.Label label3; |
| | | private System.Windows.Forms.Button button4; |
| | | private System.Windows.Forms.DataGridView dgvTab; |
| | | private System.Windows.Forms.Label label4; |
| | | private System.Windows.Forms.TextBox txtInsert; |
| | | private System.Windows.Forms.TextBox txtUpdate; |
| | | private System.Windows.Forms.Label label5; |
| | | 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.Button button2; |
| | | private System.Windows.Forms.Button button3; |
| | | private System.Windows.Forms.TextBox txtServiceNS; |
| | | private System.Windows.Forms.Label label6; |
| | | private System.Windows.Forms.TextBox txtControllerNS; |
| | | private System.Windows.Forms.Label label7; |
| | | private System.Windows.Forms.TextBox txtApiTag; |
| | | private System.Windows.Forms.Label label8; |
| | | private System.Windows.Forms.Label label1; |
| | | private System.Windows.Forms.TextBox txtTabNS; |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using JavaCode.cs; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | 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 |
| | | { |
| | | public partial class FrmSys : Form |
| | | { |
| | | #region æååé+æé 彿° |
| | | string baseDir = AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | private PostgreHelper _dbHelper; |
| | | |
| | | private List<TabInfo> _list; |
| | | |
| | | public FrmSys() |
| | | { |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | private void FrmMain_Load(object sender, EventArgs e) |
| | | { |
| | | _dbHelper = new PostgreHelper(DbEnum.langfang); |
| | | } |
| | | #endregion |
| | | |
| | | #region æ¥è¯¢è¡¨ç»æ |
| | | 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"; |
| | | |
| | | DataTable dt = _dbHelper.GetDataTable(sql, null); |
| | | |
| | | _list = ModelHandler.FillModel<TabInfo>(dt); |
| | | if (_list == null || _list.Count == 0) |
| | | { |
| | | MessageBox.Show("æ²¡ææ¥è¯¢å°æ°æ®ï¼"); |
| | | return; |
| | | } |
| | | |
| | | List<string> tabList = new List<string>(); |
| | | foreach (TabInfo ti in _list) |
| | | { |
| | | if (!tabList.Contains(ti.tab)) |
| | | { |
| | | tabList.Add(ti.tab); |
| | | } |
| | | } |
| | | |
| | | this.tabList.DataSource = tabList; |
| | | } |
| | | |
| | | private void tabList_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | string tab = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == tab orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | this.dgvTab.DataSource = new BindingList<TabInfo>(tabs); |
| | | if (tabs != null && tabs.Count > 1) |
| | | { |
| | | this.dgvTab.Rows[1].Selected = true; |
| | | this.dgvTab.CurrentCell = this.dgvTab.Rows[1].Cells[0]; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Mapper.Xml |
| | | private void mapperXml_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateMapperXml(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateMapperXml(string name, List<TabInfo> tabs) |
| | | { |
| | | string tabName = this.txtTabNS.Text.Trim() + name; |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string entityName = shortName + "Entity"; |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string testExpr = colName + " != null"; |
| | | string testWhere = selectTabInfo.col + (colType == "String" ? " like " : " = ") + "#{" + colName + "}"; |
| | | |
| | | string insertCols = GetInsertCols(tabs); |
| | | string insertVal = GetInsertVal(tabs); |
| | | string insertVals = GetInsertVals(tabs); |
| | | string updateVal = GetUpdateVal(tabs); |
| | | string updateVals = GetUpdateVals(tabs); |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Mapper.xml")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{tabName}", tabName) |
| | | .Replace("{testExpr}", testExpr) |
| | | .Replace("{testWhere}", testWhere) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{insertCols}", insertCols) |
| | | .Replace("{insertVal}", insertVal) |
| | | .Replace("{insertVals}", insertVals) |
| | | .Replace("{updateVal}", updateVal) |
| | | .Replace("{updateVals}", updateVals); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Mapper.xml"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | |
| | | private static string NameConvert(string name, bool firstUpper) |
| | | { |
| | | string[] strs = name.Split(new char[] { '_' }); |
| | | |
| | | string str = ""; |
| | | for (int i = 0, c = strs.Length; i < c; i++) |
| | | { |
| | | if (i == 0 && !firstUpper) |
| | | { |
| | | str += strs[i]; |
| | | continue; |
| | | } |
| | | str += ToUpperFirst(strs[i]); |
| | | } |
| | | |
| | | return str; |
| | | } |
| | | |
| | | public static string ToUpperFirst(string str) |
| | | { |
| | | return Regex.Replace(str, @"^\w", t => t.Value.ToUpper()); |
| | | } |
| | | |
| | | public string GetInsertCols(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | sb.Append(ti.col + ","); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetInsertVal(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp") |
| | | { |
| | | sb.Append("now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append("#{" + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetInsertVals(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtInsert.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp") |
| | | { |
| | | sb.Append("now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append("#{item." + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetUpdateVal(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtUpdate.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp") |
| | | { |
| | | sb.Append(ti.col + "=now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append(ti.col + "=#{" + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | public string GetUpdateVals(List<TabInfo> tabs) |
| | | { |
| | | List<string> excluds = this.txtUpdate.Text.Trim().Split(new char[] { ',' }).ToList<string>(); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | if (excluds.Contains(ti.col)) |
| | | { |
| | | continue; |
| | | } |
| | | if (ti.type == "timestamp") |
| | | { |
| | | sb.Append(ti.col + "=now(),"); |
| | | continue; |
| | | } |
| | | |
| | | sb.Append(ti.col + "=#{item." + NameConvert(ti.col, false) + "},"); |
| | | } |
| | | |
| | | if (sb.Length > 0) |
| | | { |
| | | sb.Remove(sb.Length - 1, 1); |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | |
| | | private static void OpenFolder(string folderPath) |
| | | { |
| | | if (string.IsNullOrEmpty(folderPath)) return; |
| | | |
| | | Process process = new Process(); |
| | | ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe"); |
| | | psi.Arguments = folderPath; |
| | | process.StartInfo = psi; |
| | | |
| | | try |
| | | { |
| | | process.Start(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | finally |
| | | { |
| | | process.Close(); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Mapper.java |
| | | private void mapperJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateMapperJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateMapperJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string entityName = shortName + "Entity"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string queryCol = colType + " " + colName; |
| | | string colBak = selectTabInfo.bak; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Mapper.java")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{colName}", colName) |
| | | .Replace("{colBak}", colBak) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{queryCol}", queryCol); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Mapper.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | |
| | | private string GetJavaType(TabInfo ti) |
| | | { |
| | | switch (ti.type) |
| | | { |
| | | case "timestamp": |
| | | return "Timestamp"; |
| | | case "float4": // float |
| | | return "Float"; |
| | | case "float8": // double |
| | | return "Double"; |
| | | case "bool": // boolean |
| | | return "Boolean"; |
| | | case "numeric": |
| | | return "BigDecimal"; |
| | | case "int8": // long |
| | | return "Long"; |
| | | case "int2": |
| | | case "int4": // int |
| | | return "Integer"; |
| | | default: |
| | | return "String"; |
| | | } |
| | | } |
| | | |
| | | private String GetType(TabInfo ti) |
| | | { |
| | | switch (ti.type) |
| | | { |
| | | case "timestamp": |
| | | return "Timestamp"; |
| | | case "float4": |
| | | return "float"; |
| | | case "float8": |
| | | return "double"; |
| | | case "bool": |
| | | return "boolean"; |
| | | case "numeric": |
| | | return "BigDecimal"; |
| | | case "int8": |
| | | return "long"; |
| | | case "int2": |
| | | case "int4": |
| | | return "int"; |
| | | default: |
| | | return "String"; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Entity.java |
| | | private void entityJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateEntityJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateEntityJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string entityName = shortName + "Entity"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | long uid = (long)Math.Floor((new Random()).NextDouble() * 1000000000000000000D); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Entity.java")); |
| | | xml = xml |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{uid}", uid.ToString()); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | string type = GetType(ti); |
| | | string colName = NameConvert(ti.col, false); |
| | | sb.Append("\r\n private " + type + " " + colName + ";\r\n"); |
| | | } |
| | | |
| | | sb.Append("\r\n public " + entityName + "() {\r\n }\r\n"); |
| | | |
| | | foreach (TabInfo ti in tabs) |
| | | { |
| | | string type = GetType(ti); |
| | | string col1 = NameConvert(ti.col, true); |
| | | string col2 = NameConvert(ti.col, false); |
| | | |
| | | sb.Append("\r\n public " + type + " get" + col1 + "() {\r\n return " + col2 + ";\r\n }\r\n"); |
| | | sb.Append("\r\n public void set" + col1 + "(" + type + " " + col2 + ") {\r\n this." + col2 + " = " + col2 + ";\r\n }\r\n"); |
| | | } |
| | | sb.Append("}\r\n"); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | sb.Insert(0, xml); |
| | | |
| | | string fileName = shortName + "Entity.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), sb.ToString()); |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Service.java |
| | | private void serviceJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateServiceJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateServiceJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string serviceNS = this.txtServiceNS.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string minMapperName = NameConvert(name, false) + "Mapper"; |
| | | string entityName = shortName + "Entity"; |
| | | string serviceName = shortName + "Service"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string queryCol = colType + " " + colName; |
| | | |
| | | //string where = isString ? "\r\n " + colName + " = \"%\" + (StringHelper.isNull(" + colName + ") ? \"\" : " + colName + ".trim()) + \"%\";\r\n" : ""; |
| | | string where = colType == "String" ? "\r\n " + colName + " = StringHelper.isNull(" + colName + ") ? null : \"%\" + " + colName + ".trim() + \"%\";\r\n" : ""; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Service.java")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{minMapperName}", minMapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{serviceNS}", serviceNS) |
| | | .Replace("{serviceName}", serviceName) |
| | | .Replace("{bak}", bak) |
| | | .Replace("{queryCol}", queryCol) |
| | | .Replace("{colName}", colName) |
| | | .Replace("{where}", where); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Service.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | #endregion |
| | | |
| | | #region çæ Controller.java |
| | | private void controllerJava_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateControllerJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void GenerateControllerJava(string name, List<TabInfo> tabs) |
| | | { |
| | | name = name.Replace(this.txtTabPre.Text, ""); |
| | | |
| | | string shortName = NameConvert(name, true); |
| | | string mapperNS = this.txtMapperNS.Text.Trim(); |
| | | string entityNS = this.txtEntityNS.Text.Trim(); |
| | | string serviceNS = this.txtServiceNS.Text.Trim(); |
| | | string controllerNS = this.txtControllerNS.Text.Trim(); |
| | | string apiTag = this.txtApiTag.Text.Trim(); |
| | | string mapperName = shortName + "Mapper"; |
| | | string entityName = shortName + "Entity"; |
| | | string serviceName = shortName + "Service"; |
| | | string minServiceName = NameConvert(name, false) + "Service"; |
| | | string controllerName = shortName + "Controller"; |
| | | string bak = tabs[0].desc.Replace("表", ""); |
| | | string apiName = NameConvert(name, false); |
| | | |
| | | int idx = this.dgvTab.CurrentRow.Index; |
| | | TabInfo selectTabInfo = tabs[idx]; |
| | | |
| | | string colType = GetJavaType(selectTabInfo); |
| | | string colName = NameConvert(selectTabInfo.col, false); |
| | | string queryCol = colType + " " + colName; |
| | | string colBak = selectTabInfo.bak; |
| | | |
| | | string xml = File.ReadAllText(Path.Combine(baseDir, "SysTemplate\\Controller.java")); |
| | | xml = xml |
| | | .Replace("{mapperNS}", mapperNS) |
| | | .Replace("{mapperName}", mapperName) |
| | | .Replace("{entityNS}", entityNS) |
| | | .Replace("{entityName}", entityName) |
| | | .Replace("{serviceNS}", serviceNS) |
| | | .Replace("{serviceName}", serviceName) |
| | | .Replace("{controllerNS}", controllerNS) |
| | | .Replace("{controllerName}", controllerName) |
| | | .Replace("{minServiceName}", minServiceName) |
| | | .Replace("{queryCol}", queryCol) |
| | | .Replace("{colName}", colName) |
| | | .Replace("{colBak}", colBak) |
| | | .Replace("{colType}", colType) |
| | | .Replace("{apiTag}", apiTag) |
| | | .Replace("{apiName}", apiName) |
| | | .Replace("{bak}", bak); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | | } |
| | | |
| | | string fileName = shortName + "Controller.java"; |
| | | File.WriteAllText(Path.Combine(path, fileName), xml); |
| | | } |
| | | #endregion |
| | | |
| | | #region çææææä»¶ |
| | | private void generateAll_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string name = this.tabList.SelectedItem as string; |
| | | List<TabInfo> tabs = (from p in _list where p.tab == name orderby p.num select p).ToList<TabInfo>(); |
| | | |
| | | GenerateMapperXml(name, tabs); |
| | | GenerateMapperJava(name, tabs); |
| | | GenerateEntityJava(name, tabs); |
| | | GenerateServiceJava(name, tabs); |
| | | GenerateControllerJava(name, tabs); |
| | | |
| | | string path = Path.Combine(baseDir, "SysGenerate"); |
| | | OpenFolder(path); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | | The primary goals of this format is to allow a simple XML format |
| | | that is mostly human readable. The generation and parsing of the |
| | | various data types are done through the TypeConverter classes |
| | | associated with the data types. |
| | | |
| | | Example: |
| | | |
| | | ... ado.net/XML headers & schema ... |
| | | <resheader name="resmimetype">text/microsoft-resx</resheader> |
| | | <resheader name="version">2.0</resheader> |
| | | <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
| | | <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
| | | <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
| | | <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
| | | <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
| | | <value>[base64 mime encoded serialized .NET Framework object]</value> |
| | | </data> |
| | | <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
| | | <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
| | | <comment>This is a comment</comment> |
| | | </data> |
| | | |
| | | There are any number of "resheader" rows that contain simple |
| | | name/value pairs. |
| | | |
| | | Each data row contains a name, and value. The row also contains a |
| | | type or mimetype. Type corresponds to a .NET class that support |
| | | text/value conversion through the TypeConverter architecture. |
| | | Classes that don't support this are serialized and stored with the |
| | | mimetype set. |
| | | |
| | | The mimetype is used for serialized objects, and tells the |
| | | ResXResourceReader how to depersist the object. This is currently not |
| | | extensible. For a given mimetype the value must be set accordingly: |
| | | |
| | | Note - application/x-microsoft.net.object.binary.base64 is the format |
| | | that the ResXResourceWriter will generate, however the reader can |
| | | read any of the formats listed below. |
| | | |
| | | mimetype: application/x-microsoft.net.object.binary.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.bytearray.base64 |
| | | value : The object must be serialized into a byte array |
| | | : using a System.ComponentModel.TypeConverter |
| | | : and then encoded with base64 encoding. |
| | | --> |
| | | <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
| | | <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
| | | <xsd:element name="root" msdata:IsDataSet="true"> |
| | | <xsd:complexType> |
| | | <xsd:choice maxOccurs="unbounded"> |
| | | <xsd:element name="metadata"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" use="required" type="xsd:string" /> |
| | | <xsd:attribute name="type" type="xsd:string" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" /> |
| | | <xsd:attribute ref="xml:space" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="assembly"> |
| | | <xsd:complexType> |
| | | <xsd:attribute name="alias" type="xsd:string" /> |
| | | <xsd:attribute name="name" type="xsd:string" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="data"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
| | | <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
| | | <xsd:attribute ref="xml:space" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="resheader"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:choice> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:schema> |
| | | <resheader name="resmimetype"> |
| | | <value>text/microsoft-resx</value> |
| | | </resheader> |
| | | <resheader name="version"> |
| | | <value>2.0</value> |
| | | </resheader> |
| | | <resheader name="reader"> |
| | | <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | </root> |
| | |
| | | <Compile Include="FrmMain.Designer.cs"> |
| | | <DependentUpon>FrmMain.cs</DependentUpon> |
| | | </Compile> |
| | | <Compile Include="FrmSys.cs"> |
| | | <SubType>Form</SubType> |
| | | </Compile> |
| | | <Compile Include="FrmSys.Designer.cs"> |
| | | <DependentUpon>FrmSys.cs</DependentUpon> |
| | | </Compile> |
| | | <Compile Include="FrmMyBatisPlus.cs"> |
| | | <SubType>Form</SubType> |
| | | </Compile> |
| | | <Compile Include="FrmMyBatisPlus.Designer.cs"> |
| | | <DependentUpon>FrmMyBatisPlus.cs</DependentUpon> |
| | | </Compile> |
| | | <Compile Include="Program.cs" /> |
| | | <Compile Include="Properties\AssemblyInfo.cs" /> |
| | | <EmbeddedResource Include="FrmMain.resx"> |
| | | <DependentUpon>FrmMain.cs</DependentUpon> |
| | | <SubType>Designer</SubType> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="FrmSys.resx"> |
| | | <DependentUpon>FrmSys.cs</DependentUpon> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="FrmMyBatisPlus.resx"> |
| | | <DependentUpon>FrmMyBatisPlus.cs</DependentUpon> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="Properties\Resources.resx"> |
| | | <Generator>ResXFileCodeGenerator</Generator> |
| | |
| | | </Compile> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <None Include="App.config" /> |
| | | <None Include="App.config"> |
| | | <SubType>Designer</SubType> |
| | | </None> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <EmbeddedResource Include="BsTemplate\Entity.java"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="BsTemplate\Mapper.java"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | <Content Include="DLL\Mono.Security.dll" /> |
| | | <Content Include="DLL\Npgsql.dll" /> |
| | | <EmbeddedResource Include="Template\Controller.java"> |
| | | <Content Include="SysTemplate\pg.sql" /> |
| | | <EmbeddedResource Include="SysTemplate\Controller.java"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="Template\Entity.java"> |
| | | <EmbeddedResource Include="SysTemplate\Entity.java"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="Template\Service.java"> |
| | | <EmbeddedResource Include="SysTemplate\Service.java"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="Template\Mapper.java"> |
| | | <EmbeddedResource Include="SysTemplate\Mapper.java"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | <EmbeddedResource Include="Template\Mapper.xml"> |
| | | <EmbeddedResource Include="SysTemplate\Mapper.xml"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | <SubType>Designer</SubType> |
| | | </EmbeddedResource> |
ÎļþÃû´Ó JavaCode/Template/Controller.java ÐÞ¸Ä |
| | |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("æ¯é¡µé¡µæ°æå页æ°å°äº1", null); |
| | | } |
| | | |
| | | int count = {minServiceName}.selectCount({colName}); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<{entityName}> rs = {minServiceName}.selectByPage({colName}, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
ÎļþÃû´Ó JavaCode/Template/Mapper.xml ÐÞ¸Ä |
| | |
| | | |
| | | <delete id="deletes"> |
| | | delete from {tabName} where id in |
| | | <foreach item="ids" collection="list" index="index" open="(" separator="," close=")"> |
| | | #{ids} |
| | | <foreach item="id" collection="ids" index="index" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <update id="update"> |
| | | update {tabName} |
| | | set {updateVal} |
| | | where id=#{id} |
| | | update {tabName} |
| | | set {updateVal} |
| | | where id=#{id} |
| | | </update> |
| | | |
| | | <update id="updates"> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | 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; |
| | | select table_name as name from data_dictionary group by table_name; |
| | | update meta_data set create_time=CURRENT_TIMESTAMP,create_user='admin' where 1=1; -- CURRENT_TIMEï¼CURRENT_DATE |
| | | |
| | | select * from data_files; |
| | | select * from style_data; commit; |
| | | delete from style_data where id > 22; |
| | | select * from data_dictionary order by id; |
| | | select *,queryLevel(path_id) as path from meta_data; |
| | | select queryLevel(2005); |
| | | |
| | | select count(*) from meta_data where Upper(name) like '%A%'; |
| | | select *,queryLevel(path_id) path from meta_data where Upper(name) like '%A%' order by id limit 2 offset 0; |
| | | |
| | | alter table style_data add column path varchar(255); comment on column style_data.path is 'åå¨è·¯å¾'; |
| | | alter table style_data add column img varchar(255); comment on column style_data.img is 'é¢è§å¾ç'; |
| | | |
| | | INSERT INTO public.meta_data( |
| | | name, path_id, create_time, create_user, type, format, up_unit, status, version, x_min, y_min, x_max, y_max, coor_sys, accuracy, operation, remarks, s_url) |
| | | VALUES ('SITEPOINT.shp',2007, CURRENT_TIMESTAMP, 'admin', 'SHP', '.shp','设计é¢/åå¯å®¤','æ£å¸¸', 'v1.0', 0, 0, 0, 0, 'CGCS200', '1:2000', 'upload', '', ''); |
| | | ------------------------------------------------------------------------------ æ°æ®ç®å½ |
| | | DROP TABLE IF EXISTS public.data_dir; |
| | | |
| | | CREATE TABLE public.data_dir |
| | | ( |
| | | id integer, |
| | | name character varying(60), |
| | | pid integer NOT NULL, |
| | | oid integer DEFAULT 1, |
| | | PRIMARY KEY (id) |
| | | ); |
| | | |
| | | COMMENT ON TABLE public.data_dir IS 'æ°æ®ç®å½'; |
| | | COMMENT ON COLUMN public.data_dir.id IS 'ID'; |
| | | COMMENT ON COLUMN public.data_dir.name IS 'åç§°'; |
| | | COMMENT ON COLUMN public.data_dir.pid IS 'ç¶èç¹'; |
| | | COMMENT ON COLUMN public.data_dir.oid IS 'åºå·'; |
| | | |
| | | SELECT COALESCE(MAX(id),1) FROM public.data_dir; |
| | | select * from public.data_dir; |
| | | |
| | | DELETE FROM public.data_dir where id<1000; |
| | | SELECT id,name,pid,oid FROM public.data_dir order by id; |
| | | ------------------------------------------------------------------------------ ä¸ä¼ æä»¶ |
| | | DROP TABLE IF EXISTS public.data_files; |
| | | |
| | | create table public.data_files |
| | | ( |
| | | id serial primary key, |
| | | mid integer, |
| | | guid varchar(40), |
| | | name varchar(255), |
| | | ext varchar(10), |
| | | path varchar(1024), |
| | | subs varchar(1024), |
| | | remark varchar(1024) |
| | | ); |
| | | |
| | | COMMENT ON TABLE public.data_files IS 'ä¸ä¼ æä»¶'; |
| | | COMMENT ON COLUMN public.data_files.id IS 'ID'; |
| | | COMMENT ON COLUMN public.data_files.mid IS 'å
æ°æ®ID'; |
| | | COMMENT ON COLUMN public.data_files.guid IS 'GUID'; |
| | | COMMENT ON COLUMN public.data_files.name IS 'åç§°'; |
| | | COMMENT ON COLUMN public.data_files.ext IS 'æ©å±å'; |
| | | COMMENT ON COLUMN public.data_files.path IS 'è·¯å¾'; |
| | | COMMENT ON COLUMN public.data_files.subs IS 'åæä»¶'; |
| | | COMMENT ON COLUMN public.data_files.remark IS '夿³¨'; |
| | | |
| | | select * from data_files; |
| | | ------------------------------------------------------------------------------ æ¥è¯¢å±çº§ |
| | | with recursive rs as( |
| | | select id,name,pid,oid from public.data_dir where id = 2005 |
| | | union |
| | | select a.id,a.name,a.pid,a.oid from public.data_dir a, rs b where a.id=b.pid |
| | | ) select id,name,pid,oid FROM rs order by id,oid; |
| | | |
| | | |
| | | CREATE OR REPLACE FUNCTION queryLevel(id INTEGER) |
| | | RETURNS VARCHAR as $$ |
| | | declare |
| | | str varchar=''; |
| | | rec varchar; -- public.data_dir%ROWTYPE; |
| | | begin |
| | | for rec in execute 'with recursive rs as(' || |
| | | 'select id,name,pid,oid from public.data_dir where id=' || id || |
| | | ' union select a.id,a.name,a.pid,a.oid from public.data_dir a, rs b where a.id=b.pid '|| |
| | | ') select name FROM rs order by id,oid' |
| | | loop |
| | | str = str || '\' || rec; -- rec.name; |
| | | end loop; |
| | | |
| | | if (char_length(str) > 1) then |
| | | str = SUBSTRING(str, 2); |
| | | end if; |
| | | |
| | | return str; |
| | | end; |
| | | $$ LANGUAGE PLPGSQL; |
| | | |
| | | -- ä¸ä¿ä¸çº¿ç®¡éå·¥ç¨å段\å坿°æ®\åºç¡å°è´¨\åºåå°è´¨ |
| | | select queryLevel(2005); |
| | | |
| | | select id,name,pid,oid,queryLevel(id) from data_dir where 1=1 order by id limit 10; |
| | | |
| | | ------------------------------------------------------------------------------ æ¥è¯¢å±çº§ID |
| | | --drop function queryDir(id INTEGER); |
| | | CREATE OR REPLACE FUNCTION queryDir(id INTEGER) |
| | | RETURNS integer[] as $$ |
| | | declare |
| | | ids integer[]; |
| | | sid integer; |
| | | begin |
| | | for sid in execute 'with recursive rs as(' || |
| | | 'select id,pid from public.data_dir where id=' || id || |
| | | ' union select a.id,a.pid from public.data_dir a, rs b where a.pid=b.id '|| |
| | | ') select id FROM rs order by id' |
| | | loop |
| | | select array_append(ids, sid) into ids; |
| | | end loop; |
| | | |
| | | return ids; |
| | | end; |
| | | $$ LANGUAGE PLPGSQL; |
| | | |
| | | -- {2003,2004,2005,2006,2007,2008,2009} |
| | | select queryDir(2003); |
| | | |
| | | select * from data_dir order by id; |
| | | select * from meta_data where (path_id = ANY(array[2001,2002,2003,2005])); |
| | | select * from meta_data where (path_id = ANY((select queryDir(2005))::integer[])) order by id; |
| | | select * from meta_data where path_id=ANY(queryDir(2005)) order by id; |
| | | ------------------------------------------------------------------------------ |