From bd85276c0dbc3e9317ac806bef07b75e8f22401c Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期一, 29 七月 2024 09:16:32 +0800
Subject: [PATCH] mapper 及xml整理

---
 pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml |   95 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 64 insertions(+), 31 deletions(-)

diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
index 199414c..4926dde 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
@@ -11,7 +11,7 @@
     <result column="supper_admin" property="supperAdmin" />
     <result column="disabled" property="disabled" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" />
     <result column="deleted" property="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" />
-    <result column="dt" property="dt" />
+    <result column="create_dt" property="dt" />
   </resultMap>
   <resultMap id="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaUser">
     <!--@mbg.generated-->
@@ -21,6 +21,7 @@
     <result property="phone" column="phone"/>
     <result property="password" column="password"/>
     <result property="disabled" column="disabled" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" />
+    <result column="create_dt" property="dt" />
   </resultMap>
   <resultMap id="oneResultMap" type="com.dy.pmsGlobal.pojoBa.BaUser" extends="BaseResultMap">
     <collection property="roles" fetchType="eager" column="{userId=id}" select="com.dy.pmsGlobal.daoBa.BaRoleMapper.selectByUserId" />
@@ -37,14 +38,39 @@
 
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, `name`, phone, `password`, supper_admin, disabled, deleted,dt
+    id, `name`, phone, `password`, supper_admin, disabled, deleted, create_dt
   </sql>
-  <sql id="part_Column_List">
-    ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.password, ${alias}.disabled,${alias}.dt
-  </sql>
+<!--  <sql id="part_Column_List"><![CDATA[-->
+<!--    ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.password, ${alias}.disabled,${alias}.create_dt-->
+<!--  ]]></sql>-->
   <sql id="Login_Column_List">
     id, name, phone, supper_admin
   </sql>
+
+  <select id="selectNameByUserId" parameterType="java.lang.Long" resultType="java.lang.String">
+    select name from ba_user where id=#{id}
+  </select>
+
+  <select id="selectNameById" parameterType="java.lang.Long" resultType="java.lang.String">
+    select name from ba_user where id=#{id}
+  </select>
+
+  <select id="selectByAssistants" resultMap="BaseResultMap">
+    SELECT
+    *
+    FROM
+    ba_user
+    WHERE
+    id IN (
+    SELECT
+    SUBSTRING_INDEX( SUBSTRING_INDEX( #{assistants,jdbcType=VARCHAR}, ',', help_topic_id + 1 ), ',',- 1 ) AS num
+    FROM
+    mysql.help_topic
+    WHERE
+    help_topic_id <![CDATA[ < ]]> LENGTH( #{assistants,jdbcType=VARCHAR} )- LENGTH(
+    REPLACE ( #{assistants,jdbcType=VARCHAR}, ',', '' ))+ 1
+    )
+  </select>
 
   <select id="selectCount" resultType="java.lang.Long">
     select
@@ -64,35 +90,14 @@
     select 
     <include refid="Base_Column_List" />
     from ba_user
-    where id = #{id}
+    where id = #{id} and deleted!=1
   </select>
-
 
   <select id="selectSomeCount" parameterType="java.util.Map" resultType="java.lang.Long">
     select
     count(*)
     from ba_user bu
-    inner join ba_user_role ur on ur.user_id=bu.id
-    where bu.supper_admin!=1 and bu.deleted!=1
-    <trim prefix="and" suffixOverrides="and">
-      <if test="name != null and name != ''">
-        bu.name like concat('%', #{name}, '%') and
-      </if>
-      <if test="phone != null and phone !=''">
-        bu.phone = #{phone,jdbcType=VARCHAR}
-      </if>
-      <if test="roleId != null">
-        ur.role_id=#{roleId,jdbcType=BIGINT}
-      </if>
-    </trim>
-  </select>
-  <select id="selectSome" parameterType="java.util.Map" resultMap="someResultMap">
-    select
-    <include refid="part_Column_List" >
-      <property name="alias" value="bu"/>
-    </include>
-    from ba_user bu
-    inner join ba_user_role ur on ur.user_id=bu.id
+#     left join ba_user_role ur on ur.user_id=bu.id
     where bu.supper_admin!=1 and bu.deleted!=1
     <trim prefix="and" suffixOverrides="and">
       <if test="name != null and name != ''">
@@ -101,9 +106,30 @@
       <if test="phone != null and phone !=''">
         bu.phone = #{phone,jdbcType=VARCHAR} and
       </if>
-      <if test="roleId != null">
-        ur.role_id=#{roleId,jdbcType=BIGINT} and
+<!--      <if test="roleId != null">-->
+<!--        ur.role_id=#{roleId,jdbcType=BIGINT} and-->
+<!--      </if>-->
+      <if test="disabled != null">
+        bu.disabled=#{disabled,jdbcType=BOOLEAN}
       </if>
+    </trim>
+  </select>
+  <select id="selectSome" parameterType="java.util.Map" resultMap="someResultMap">
+    select
+    <include refid="Base_Column_List"/>
+    from ba_user bu
+#     left join ba_user_role ur on ur.user_id=bu.id
+    where bu.supper_admin!=1 and bu.deleted!=1
+    <trim prefix="and" suffixOverrides="and">
+      <if test="name != null and name != ''">
+        bu.name like concat('%', #{name}, '%') and
+      </if>
+      <if test="phone != null and phone !=''">
+        bu.phone = #{phone,jdbcType=VARCHAR} and
+      </if>
+<!--      <if test="roleId != null">-->
+<!--        ur.role_id=#{roleId,jdbcType=BIGINT} and-->
+<!--      </if>-->
       <if test="disabled != null">
         bu.disabled=#{disabled,jdbcType=BOOLEAN}
       </if>
@@ -115,7 +141,14 @@
       </if>
     </trim>
   </select>
-
+  <select id="selectNamesByAssistants" parameterType="java.lang.String" resultType="java.lang.String">
+    SELECT GROUP_CONCAT(name) AS assistantNames FROM ba_user WHERE id IN
+    <if test="assistants != null">
+      <foreach collection="assistants.split(',')" item="item" separator="," open="(" close=")">
+        #{item,jdbcType=BIGINT}
+      </foreach>
+    </if>
+  </select>
 
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     <!--@mbg.generated-->

--
Gitblit v1.8.0