刘帅
7 天以前 d41e0da5df20d559b0b9b8c180d1bf70ba7c1845
cloud-server-management/src/main/resources/mapper/UserMapper.xml
@@ -8,7 +8,6 @@
      <result column="avatar" property="avatar" />
      <result column="account" property="account" />
      <result column="password" property="password" />
      <result column="passWordUpdate" property="passWordUpdate"/>
      <result column="salt" property="salt" />
      <result column="name" property="name" />
      <result column="birthday" property="birthday" />
@@ -20,6 +19,8 @@
      <result column="status" property="status" />
      <result column="createtime" property="createtime" />
      <result column="version" property="version" />
      <result column="objectType" property="objectType"/>
      <result column="objectId" property="objectId"/>
   </resultMap>
   <sql id="Base_Column_List">
@@ -33,7 +34,7 @@
      id, account, name, birthday,password, sex, email, avatar,
      phone, roleid,salt,
      deptid, status,
      createtime, version,roleType,objectId
      createtime, version,objectType,objectId
   </sql>
   <select id="selectUsers" resultType="map">
@@ -52,24 +53,62 @@
      <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
         and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
      </if>
      order by id desc
   </select>
   <update id="setStatus">
      update sys_user set status = #{status} where id =
      #{userId}
                                        #{userId}
   </update>
   <update id="changePwd">
      update sys_user set password = #{pwd} where id =
      #{userId}
                                       #{userId}
   </update>
   <update id="setRoles">
      update sys_user set roleid = #{roleIds} where id =
      #{userId}
                                         #{userId}
   </update>
   <select id="getByAccount" resultType="user">
   <delete id="deleteStoreRelations">
      delete from sys_user_store where userId = #{userId}
   </delete>
   <insert id="insertStoreRelation">
      insert into sys_user_store(id, userId, storeId) values (#{id}, #{userId}, #{storeId})
   </insert>
   <select id="getStoreIdsByUserId" resultType="java.lang.Integer">
      select distinct storeId from (
                               select storeId from sys_user_store where userId = #{userId}
                               union all
                               select objectId as storeId from sys_user where id = #{userId} and objectType = 3 and objectId is not null
                               union all
                               select id as storeId from t_store where storeStaffId = #{userId}
                         ) relation_store
   </select>
   <select id="getUserIdsByStoreIds" resultType="java.lang.Integer">
      select distinct userId from (
         select userId from sys_user_store
         where isDeleted = 0 and storeId in
         <foreach collection="storeIds" separator="," item="storeId" open="(" close=")">
            #{storeId}
         </foreach>
         union all
         select id as userId from sys_user
         where objectType = 3 and objectId in
         <foreach collection="storeIds" separator="," item="storeId" open="(" close=")">
            #{storeId}
         </foreach>
         union all
         select storeStaffId as userId from t_store
         where storeStaffId is not null and id in
         <foreach collection="storeIds" separator="," item="storeId" open="(" close=")">
            #{storeId}
         </foreach>
      ) relation_user
   </select>
   <select id="getByAccount" resultType="com.dsh.guns.modular.system.model.User">
      select
      <include refid="Base_Column_List_With_Pwd" />
      from sys_user where account = #{account} and status != 3
@@ -82,7 +121,7 @@
   <select id="getUserListPage" resultType="map" parameterType="com.baomidou.mybatisplus.extension.plugins.pagination.Page">
      SELECT * FROM (select CASE when d2.simplename is null then d1.simplename else d2.simplename end as parentName,
       uu.sex as sexName,
      uu.sex as sexName,
      d1.simplename as deptName, uu.status  as statusName,
      rr.roleName,
      DATE_FORMAT(uu.createtime, '%Y-%m-%d %H:%i:%s') as createtime1,
@@ -105,8 +144,46 @@
         <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
            and (o.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
         </if>
         <if test="objectType ==3">
            and (o.objectType =3  and o.objectId =#{objectId})
         </if>
         <if test="objectType ==1">
            and o.objectType =1
         </if>
      </where>
      order by o.id desc
   </select>
   <select id="searchUsers" resultType="com.dsh.guns.modular.system.model.UserListVO">
      select t1.id,t1.name ,t1.phone ,t1.avatar,t1.birthday,t1.sex,t1.idCard,t1.status,t1.version
      ,t2.simplename as deptName,
      (select group_concat(r.name separator ',') from sys_role r where find_in_set(r.id, t1.roleid)) as roleName from sys_user t1
      left join sys_dept t2 on t1.deptid = t2.id
      <where>
         <if test="query.name != null and query.name != ''">
            and t1.name like CONCAT('%',#{query.name},'%')
         </if>
         <if test="query.phone != null and query.phone != ''">
            and t1.phone like CONCAT('%',#{query.phone},'%')
         </if>
         <if test="query.idCard != null and query.idCard != ''">
            and t1.idCard like CONCAT('%',#{query.idCard},'%')
         </if>
         <if test="query.isSales == 1">
            and (t2.simplename like CONCAT('%','销售','%')
            or t2.fullname like CONCAT('%','销售','%'))
         </if>
         <if test="query.status != null and query.status != ''">
            and t1.status = #{query.status}
         </if>
         <if test="query.storeIds != null and query.storeIds.size()>0">
            AND t1.id IN
            <foreach collection="query.storeIds" separator="," item="id" open="(" close=")">
               #{id}
            </foreach>
         </if>
         and t1.status != 3
      </where>
      order by t1.id desc
   </select>
</mapper>