瀏覽代碼

[增加排序号]

17764228860 5 月之前
父節點
當前提交
4c76dab8ac

+ 22 - 7
src/main/java/com/huaihai/core/expert/mapper/ExpertMapper.xml

@@ -15,6 +15,7 @@
     <result column="is_home" jdbcType="VARCHAR" property="isHome" />
     <result column="certificate" jdbcType="VARCHAR" property="certificate" />
     <result column="position" jdbcType="VARCHAR" property="position" />
+    <result column="sort_index" jdbcType="VARCHAR" property="sortIndex" />
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.huaihai.core.expert.model.Expert">
     <!--
@@ -95,7 +96,7 @@
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     id, name, department_id, phone, create_time, create_user_id, is_home, certificate, 
-    position
+    position, sort_index
   </sql>
   <sql id="Blob_Column_List">
     <!--
@@ -182,11 +183,11 @@
     insert into expert (id, name, department_id, 
       phone, create_time, create_user_id, 
       is_home, certificate, position, 
-      expert_text)
+      sort_index, expert_text)
     values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{departmentId,jdbcType=VARCHAR}, 
       #{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{createUserId,jdbcType=VARCHAR}, 
       #{isHome,jdbcType=VARCHAR}, #{certificate,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR}, 
-      #{expertText,jdbcType=LONGVARCHAR})
+      #{sortIndex,jdbcType=VARCHAR}, #{expertText,jdbcType=LONGVARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.huaihai.core.expert.model.Expert">
     <!--
@@ -222,6 +223,9 @@
       <if test="position != null">
         position,
       </if>
+      <if test="sortIndex != null">
+        sort_index,
+      </if>
       <if test="expertText != null">
         expert_text,
       </if>
@@ -254,6 +258,9 @@
       <if test="position != null">
         #{position,jdbcType=VARCHAR},
       </if>
+      <if test="sortIndex != null">
+        #{sortIndex,jdbcType=VARCHAR},
+      </if>
       <if test="expertText != null">
         #{expertText,jdbcType=LONGVARCHAR},
       </if>
@@ -303,6 +310,9 @@
       <if test="record.position != null">
         position = #{record.position,jdbcType=VARCHAR},
       </if>
+      <if test="record.sortIndex != null">
+        sort_index = #{record.sortIndex,jdbcType=VARCHAR},
+      </if>
       <if test="record.expertText != null">
         expert_text = #{record.expertText,jdbcType=LONGVARCHAR},
       </if>
@@ -326,6 +336,7 @@
       is_home = #{record.isHome,jdbcType=VARCHAR},
       certificate = #{record.certificate,jdbcType=VARCHAR},
       position = #{record.position,jdbcType=VARCHAR},
+      sort_index = #{record.sortIndex,jdbcType=VARCHAR},
       expert_text = #{record.expertText,jdbcType=LONGVARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -345,7 +356,8 @@
       create_user_id = #{record.createUserId,jdbcType=VARCHAR},
       is_home = #{record.isHome,jdbcType=VARCHAR},
       certificate = #{record.certificate,jdbcType=VARCHAR},
-      position = #{record.position,jdbcType=VARCHAR}
+      position = #{record.position,jdbcType=VARCHAR},
+      sort_index = #{record.sortIndex,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -381,6 +393,9 @@
       <if test="position != null">
         position = #{position,jdbcType=VARCHAR},
       </if>
+      <if test="sortIndex != null">
+        sort_index = #{sortIndex,jdbcType=VARCHAR},
+      </if>
       <if test="expertText != null">
         expert_text = #{expertText,jdbcType=LONGVARCHAR},
       </if>
@@ -401,6 +416,7 @@
       is_home = #{isHome,jdbcType=VARCHAR},
       certificate = #{certificate,jdbcType=VARCHAR},
       position = #{position,jdbcType=VARCHAR},
+      sort_index = #{sortIndex,jdbcType=VARCHAR},
       expert_text = #{expertText,jdbcType=LONGVARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -417,7 +433,8 @@
       create_user_id = #{createUserId,jdbcType=VARCHAR},
       is_home = #{isHome,jdbcType=VARCHAR},
       certificate = #{certificate,jdbcType=VARCHAR},
-      position = #{position,jdbcType=VARCHAR}
+      position = #{position,jdbcType=VARCHAR},
+      sort_index = #{sortIndex,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
   <resultMap extends="BaseResultMap" id="MapTypeResultMap" type="java.util.Map">
@@ -434,8 +451,6 @@
   <select id="getExpertList" parameterType="com.huaihai.core.expert.dto.ExpertDto" resultMap="MapTypeResultMap">
     select
     <include refid="Base_Column_List" />
-    ,
-    <include refid="Blob_Column_List" />
     from expert
     <where>
       <if test="name!=null">

+ 35 - 0
src/main/java/com/huaihai/core/expert/model/Expert.java

@@ -75,6 +75,14 @@ public class Expert implements Serializable {
      */
     private String position;
 
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column expert.sort_index
+     *
+     * @mbggenerated
+     */
+    private String sortIndex;
+
     /**
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database column expert.expert_text
@@ -307,6 +315,30 @@ public class Expert implements Serializable {
         this.position = position == null ? null : position.trim();
     }
 
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column expert.sort_index
+     *
+     * @return the value of expert.sort_index
+     *
+     * @mbggenerated
+     */
+    public String getSortIndex() {
+        return sortIndex;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column expert.sort_index
+     *
+     * @param sortIndex the value for expert.sort_index
+     *
+     * @mbggenerated
+     */
+    public void setSortIndex(String sortIndex) {
+        this.sortIndex = sortIndex == null ? null : sortIndex.trim();
+    }
+
     /**
      * This method was generated by MyBatis Generator.
      * This method returns the value of the database column expert.expert_text
@@ -358,6 +390,7 @@ public class Expert implements Serializable {
             && (this.getIsHome() == null ? other.getIsHome() == null : this.getIsHome().equals(other.getIsHome()))
             && (this.getCertificate() == null ? other.getCertificate() == null : this.getCertificate().equals(other.getCertificate()))
             && (this.getPosition() == null ? other.getPosition() == null : this.getPosition().equals(other.getPosition()))
+            && (this.getSortIndex() == null ? other.getSortIndex() == null : this.getSortIndex().equals(other.getSortIndex()))
             && (this.getExpertText() == null ? other.getExpertText() == null : this.getExpertText().equals(other.getExpertText()));
     }
 
@@ -380,6 +413,7 @@ public class Expert implements Serializable {
         result = prime * result + ((getIsHome() == null) ? 0 : getIsHome().hashCode());
         result = prime * result + ((getCertificate() == null) ? 0 : getCertificate().hashCode());
         result = prime * result + ((getPosition() == null) ? 0 : getPosition().hashCode());
+        result = prime * result + ((getSortIndex() == null) ? 0 : getSortIndex().hashCode());
         result = prime * result + ((getExpertText() == null) ? 0 : getExpertText().hashCode());
         return result;
     }
@@ -405,6 +439,7 @@ public class Expert implements Serializable {
         sb.append(", isHome=").append(isHome);
         sb.append(", certificate=").append(certificate);
         sb.append(", position=").append(position);
+        sb.append(", sortIndex=").append(sortIndex);
         sb.append(", expertText=").append(expertText);
         sb.append(", serialVersionUID=").append(serialVersionUID);
         sb.append("]");

+ 70 - 0
src/main/java/com/huaihai/core/expert/model/ExpertExample.java

@@ -823,6 +823,76 @@ public class ExpertExample {
             addCriterion("position not between", value1, value2, "position");
             return (Criteria) this;
         }
+
+        public Criteria andSortIndexIsNull() {
+            addCriterion("sort_index is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexIsNotNull() {
+            addCriterion("sort_index is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexEqualTo(String value) {
+            addCriterion("sort_index =", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexNotEqualTo(String value) {
+            addCriterion("sort_index <>", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexGreaterThan(String value) {
+            addCriterion("sort_index >", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexGreaterThanOrEqualTo(String value) {
+            addCriterion("sort_index >=", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexLessThan(String value) {
+            addCriterion("sort_index <", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexLessThanOrEqualTo(String value) {
+            addCriterion("sort_index <=", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexLike(String value) {
+            addCriterion("sort_index like", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexNotLike(String value) {
+            addCriterion("sort_index not like", value, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexIn(List<String> values) {
+            addCriterion("sort_index in", values, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexNotIn(List<String> values) {
+            addCriterion("sort_index not in", values, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexBetween(String value1, String value2) {
+            addCriterion("sort_index between", value1, value2, "sortIndex");
+            return (Criteria) this;
+        }
+
+        public Criteria andSortIndexNotBetween(String value1, String value2) {
+            addCriterion("sort_index not between", value1, value2, "sortIndex");
+            return (Criteria) this;
+        }
     }
 
     /**

+ 22 - 5
src/main/java/com/huaihai/core/expert/service/ExpertService.java

@@ -2,6 +2,7 @@ package com.huaihai.core.expert.service;
 
 import com.huaihai.common.model.Result;
 import com.huaihai.common.utils.CreateResultDataUtils;
+import com.huaihai.common.utils.PageInfoUtils;
 import com.huaihai.common.utils.crud.CrudUtils;
 import com.huaihai.core.common.PutDataToListService;
 import com.huaihai.core.expert.dto.ExpertDto;
@@ -107,12 +108,28 @@ public class ExpertService {
      * @param expertDto
      */
     public Result getExpertList(ExpertDto expertDto) {
-        return CrudUtils.getInstance().getDataByPage(expertDto, () -> {
-            List<Map<String, String>> expertList = expertMapper.getExpertList(expertDto);
-            expertList = putDataToListService.putDataToList(expertList, "departmentName", "departmentId", "departmentName");
-            expertList = putDataToListService.putDataToList(expertList, "userName", "createUserId", "createUserName");
-            return expertList;
+        //return CrudUtils.getInstance().getDataByPage(expertDto, () -> {
+        List<Map<String, String>> expertList = expertMapper.getExpertList(expertDto);
+        expertList = putDataToListService.putDataToList(expertList, "departmentName", "departmentId", "departmentName");
+        expertList = putDataToListService.putDataToList(expertList, "userName", "createUserId", "createUserName");
+        //根据排序号排序 升序
+        expertList.sort((map1, map2) -> {
+            String str1 = map1.get("sortIndex");
+            String str2 = map2.get("sortIndex");
+
+            // 如果时间是null或空,认为它排在最后
+            if (str1 == null || str1.isEmpty()) return 1;
+            if (str2 == null || str2.isEmpty()) return -1;
+
+            // 转换为Long类型进行比较
+            long time1 = Long.parseLong(str1);
+            long time2 = Long.parseLong(str2);
+
+            // 返回降序
+            return Long.compare(time1, time2);
         });
+        return PageInfoUtils.getDataByPage(expertDto,expertList);
+        //});
 
     }
 

+ 4 - 4
src/main/resources/generatorConfig.xml

@@ -31,19 +31,19 @@
             <property name="forceBigDecimals" value="false"/>
         </javaTypeResolver>
         <!-- 生成模型的包名和位置 -->
-        <javaModelGenerator targetPackage="com.huaihai.core.departmentManagement.model"
+        <javaModelGenerator targetPackage="com.huaihai.core.expert.model"
                             targetProject="src/main/java">
             <property name="enableSubPackages" value="true"/>
             <property name="trimStrings" value="true"/>
         </javaModelGenerator>
         <!-- 生成映射文件的包名和位置 -->
-        <sqlMapGenerator targetPackage="com.huaihai.core.departmentManagement.mapper"
+        <sqlMapGenerator targetPackage="com.huaihai.core.expert.mapper"
                          targetProject="src/main/java">
             <property name="enableSubPackages" value="true"/>
         </sqlMapGenerator>
         <!-- 生成DAO的包名和位置 -->
         <javaClientGenerator type="XMLMAPPER"
-                             targetPackage="com.huaihai.core.departmentManagement.mapper"
+                             targetPackage="com.huaihai.core.expert.mapper"
                              targetProject="src/main/java">
             <property name="enableSubPackages" value="true"/>
         </javaClientGenerator>
@@ -56,7 +56,7 @@
                enableUpdateByPrimaryKey="true"
                enableDeleteByPrimaryKey="true" >
         </table>-->
-            <table  tableName="department_management" domainObjectName="DepartmentManagement"
+            <table  tableName="expert" domainObjectName="Expert"
                enableCountByExample="true" enableUpdateByExample="true"
                enableDeleteByExample="true" enableSelectByExample="true"
                selectByExampleQueryId="true" enableSelectByPrimaryKey="true"