Ver Fonte

中文读表生成代码

suochencheng há 8 anos atrás
pai
commit
60603468d6

+ 0 - 1
src/main/java/com/izouma/awesomeadmin/dao/TestAaaMapper.java

@@ -9,7 +9,6 @@ import com.izouma.awesomeadmin.model.TestAaa;
 /**
 *  Dao接口
 */
-@DataSource("dataSourceSqlserver")
 @Repository("com.zoumaframe.dao.TestAaaMapper")
 public interface TestAaaMapper{
 

+ 48 - 16
src/main/java/com/izouma/awesomeadmin/dao/TestAaaMapper.xml

@@ -8,7 +8,17 @@
                                 <result column="remark" property="remark" jdbcType="VARCHAR" />
             </resultMap>
     <sql id="Base_Column_List" >
-            id,            del_flag,            test_name,            remark        </sql>
+        <trim  suffixOverrides="," >
+            id,
+
+            del_flag,
+
+            test_name,
+
+            remark,
+
+            </trim>
+    </sql>
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
         select
         <include refid="Base_Column_List" />
@@ -22,41 +32,50 @@
     <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.TestAaa" useGeneratedKeys="true" keyProperty="id">
         insert into test_aaa
         <trim prefix="(" suffix=")" suffixOverrides="," >
-                                    <if test="delFlag!= null" >
+                <if test="id!= null" >
+                id,
+            </if>
+                <if test="delFlag!= null" >
                 del_flag,
             </if>
-                                <if test="testName!= null" >
+                <if test="testName!= null" >
                 test_name,
             </if>
-                                <if test="remark!= null" >
+                <if test="remark!= null" >
                 remark,
             </if>
-                    </trim>
+            </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
-                                                    <if test="delFlag != null" >
+                    <if test="id != null" >
+                #{id,jdbcType=INTEGER},
+            </if>
+                    <if test="delFlag != null" >
                 #{delFlag,jdbcType=CHAR},
             </if>
-                                            <if test="testName != null" >
+                    <if test="testName != null" >
                 #{testName,jdbcType=VARCHAR},
             </if>
-                                            <if test="remark != null" >
+                    <if test="remark != null" >
                 #{remark,jdbcType=VARCHAR},
             </if>
-                            </trim>
+                </trim>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.TestAaa" >
         update test_aaa
         <set >
-                                                     <if test="delFlag != null" >
+                    <if test="id != null" >
+               id= #{id,jdbcType=INTEGER},
+            </if>
+                     <if test="delFlag != null" >
                del_flag= #{delFlag,jdbcType=CHAR},
             </if>
-                                             <if test="testName != null" >
+                     <if test="testName != null" >
                test_name= #{testName,jdbcType=VARCHAR},
             </if>
-                                             <if test="remark != null" >
+                     <if test="remark != null" >
                remark= #{remark,jdbcType=VARCHAR},
             </if>
-                             </set>
+                 </set>
         where id = #{id,jdbcType=INTEGER}
     </update>
     <select id="queryTestAaaByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
@@ -75,7 +94,13 @@
                      <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
                 and  remark = #{record.remark}
             </if>
-                 </where>
+                  <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+             <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                                                                                                                                                                OR  test_name LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  remark LIKE concat('%',#{record.searchKey},'%')
+                                                             </trim>
+         </if>
+        </where>
         order by id desc
     </select>
     <select id="queryAllTestAaa" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
@@ -94,11 +119,17 @@
                     <if test="remark != null and !&quot;&quot;.equals(remark)">
                 and  remark = #{remark}
             </if>
-                </where>
+                    <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                                                                                                                                                                                                                                                OR  test_name LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  remark LIKE concat('%',#{searchKey},'%')
+                                                                                        </trim>
+            </if>
+        </where>
         order by id desc
     </select>
     <select id="queryTestAaa" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
-        select top 1 <include refid="Base_Column_List"/> from test_aaa
+        select <include refid="Base_Column_List"/> from test_aaa
         <where>
             and del_flag = 'N'
                     <if test="id != null and !&quot;&quot;.equals(id)">
@@ -115,6 +146,7 @@
             </if>
          
         </where>
+        LIMIT 1
     </select>
     <update id="delete">
         UPDATE test_aaa SET del_flag = 'Y'

+ 9 - 0
src/main/java/com/izouma/awesomeadmin/model/TestAaa.java

@@ -13,6 +13,8 @@ public class TestAaa{
     private String testName;
     private String remark;
 
+private String searchKey;
+
     public Integer getId(){
         return this.id;
     }
@@ -42,6 +44,13 @@ public class TestAaa{
         this.remark = remark;
     }
 
+public String getSearchKey() {
+    return searchKey;
+}
+
+public void setSearchKey(String searchKey) {
+    this.searchKey = searchKey;
+}
 
 }
 

+ 4 - 2
src/main/resources/templates/ListTemplate.vm

@@ -6,7 +6,7 @@
              <el-input placeholder="${field.remark}" size="small" v-model="${field.name}" clearable class="filter-item"></el-input>
              #end
              #end*#
-            <el-input placeholder="用户名" size="small" v-model="filter1" clearable class="filter-item"></el-input>
+            <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
             <el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
                 <el-option
                         label="女"
@@ -128,6 +128,7 @@
         },
         methods: {
             pageSizeChange(size) {
+                this.currentPage = 1;
                 this.pageSize = size;
                 this.getData();
             },
@@ -140,7 +141,8 @@
                 url: '/${display.uncapitalize($model.className)}/page',
                 data: {
                     currentPage: this.currentPage,
-                    pageNumber: this.pageSize
+                    pageNumber: this.pageSize,
+                    searchKey: this.filter1,
                 }
                 }).then(res => {
                     if (res.success) {

+ 22 - 0
src/main/resources/templates/MapperXmlSqlServerTemplate.vm

@@ -73,6 +73,17 @@
                     and  ${field.name} = #{record.$field.modelName}
                 </if>
             #end
+
+            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                    #foreach($field in $model.fields)
+                        #if(${field.name}!='id'&&${field.name}!='ID')
+                            OR  ${field.name} LIKE concat('%',#{record.searchKey},'%')
+                        #end
+                    #end
+                </trim>
+            </if>
+
         </where>
         order by id desc
     </select>
@@ -88,6 +99,17 @@
                     and  ${field.name} = #{$field.modelName}
                 </if>
             #end
+
+            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                    #foreach($field in $model.fields)
+                        #if(${field.name}!='id'&&${field.name}!='ID')
+                            OR  ${field.name} LIKE concat('%',#{searchKey},'%')
+                        #end
+                    #end
+                </trim>
+            </if>
+
         </where>
         order by id desc
     </select>

+ 26 - 1
src/main/resources/templates/MapperXmlTemplate.vm

@@ -12,9 +12,12 @@
 #end
     </resultMap>
     <sql id="Base_Column_List" >
+        <trim  suffixOverrides="," >
     #foreach($field in $model.fields)
-        ${field.name}#if($velocityCount!=$model.fields.size()),#end
+        ${field.name},
+
     #end
+        </trim>
     </sql>
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
         select
@@ -63,6 +66,17 @@
                 and  ${field.name} = #{record.$field.modelName}
             </if>
          #end
+         <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+             <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+             #foreach($field in $model.fields)
+                 #if(${field.name}!='id'&&${field.name}!='ID')
+                  #if(${field.showInForm})
+                 OR  ${field.name} LIKE concat('%',#{record.searchKey},'%')
+                  #end
+                 #end
+             #end
+             </trim>
+         </if>
         </where>
         order by id desc
     </select>
@@ -75,6 +89,17 @@
                 and  ${field.name} = #{$field.modelName}
             </if>
         #end
+            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                    #foreach($field in $model.fields)
+                        #if(${field.name}!='id'&&${field.name}!='ID')
+                            #if(${field.showInForm})
+                            OR  ${field.name} LIKE concat('%',#{searchKey},'%')
+                            #end
+                        #end
+                    #end
+                </trim>
+            </if>
         </where>
         order by id desc
     </select>

+ 9 - 0
src/main/resources/templates/ModelTemplate.vm

@@ -15,6 +15,8 @@ public class $model.className{
     private $field.javaType $field.modelName;
 #end
 
+private String searchKey;
+
 #foreach($field in $model.fields)
     public $field.javaType get${display.capitalize($field.modelName)}(){
         return this.$field.modelName;
@@ -25,6 +27,13 @@ public class $model.className{
     }
 #end
 
+public String getSearchKey() {
+    return searchKey;
+}
+
+public void setSearchKey(String searchKey) {
+    this.searchKey = searchKey;
+}
 
 }
 

Diff do ficheiro suprimidas por serem muito extensas
+ 250 - 250
src/main/vue/package-lock.json


+ 7 - 1
src/main/vue/src/pages/TestAaa.vue

@@ -2,7 +2,13 @@
     <div>
         <el-form :model="formData" :rules="rules" ref="form" label-width="80px" label-position="right" size="small"
                  style="max-width: 500px;">
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <el-form-item>
+                                                                                                                    <el-form-item prop="testName" label="姓名">
+                <el-input v-model="formData.testName"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                                                        <el-form-item prop="remark" label="备注">
+                <el-input v-model="formData.remark"></el-input>
+            </el-form-item>
+                                                                                                                                                                                                                                                                    <el-form-item>
                 <el-button @click="onSave" :loading="$store.state.fetchingData" type="primary">保存</el-button>
                 <el-button @click="$router.go(-1)">取消</el-button>
             </el-form-item>

+ 8 - 6
src/main/vue/src/pages/TestAaas.vue

@@ -2,7 +2,7 @@
     <div>
         <div class="filters-container">
           
-            <el-input placeholder="用户名" size="small" v-model="filter1" clearable class="filter-item"></el-input>
+            <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
             <el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
                 <el-option
                         label="女"
@@ -48,13 +48,13 @@
                                                                                                 <el-table-column
                     v-if="isColumnShow('testName')"
                     prop="testName"
-                    label=""
+                    label="姓名"
                     min-width="100">
             </el-table-column>
                                                         <el-table-column
                     v-if="isColumnShow('remark')"
                     prop="remark"
-                    label=""
+                    label="备注"
                     min-width="100">
             </el-table-column>
                                         <el-table-column
@@ -106,12 +106,12 @@
                 filter2: '',
                 tableColumns: [
                                                                                 {
-                        label: '',
+                        label: '姓名',
                         value: 'testName',
                         show: true
                     },
                                                     {
-                        label: '',
+                        label: '备注',
                         value: 'remark',
                         show: true
                     },
@@ -127,6 +127,7 @@
         },
         methods: {
             pageSizeChange(size) {
+                this.currentPage = 1;
                 this.pageSize = size;
                 this.getData();
             },
@@ -139,7 +140,8 @@
                 url: '/testAaa/page',
                 data: {
                     currentPage: this.currentPage,
-                    pageNumber: this.pageSize
+                    pageNumber: this.pageSize,
+                    searchKey: this.filter1,
                 }
                 }).then(res => {
                     if (res.success) {

+ 10 - 0
src/main/vue/src/router/index.js

@@ -136,6 +136,16 @@ const router = new Router({
                     name: 'tableShouyiYaopinxinxi',
                     component: () => import('../pages/TableShouyiYaopinxinxi')
                 },
+                {
+                    path: '/testAaas',
+                    name: 'testAaas',
+                    component: () => import('../pages/TestAaas')
+                },
+                {
+                    path: '/testAaa',
+                    name: 'testAaa',
+                    component: () => import('../pages/TestAaa')
+                },
             ]
         },
         {

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff