刘帅
2026-09-08 572df690f72ed4a077d934823f261dec39b3cc7d
cloud-server-management/src/main/resources/mapper/UserMapper.xml
@@ -57,18 +57,38 @@
   <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>
   <delete id="deleteStoreRelations">
      delete from sys_user_store where userId = #{userId}
   </delete>
   <insert id="insertStoreRelations">
      insert into sys_user_store(id, userId, storeId) values
      <foreach collection="storeIds" item="storeId" separator=",">
         <bind name="relationId" value="@com.baomidou.mybatisplus.core.toolkit.IdWorker@getId()"/>
         (#{relationId}, #{userId}, #{storeId})
      </foreach>
   </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="getByAccount" resultType="com.dsh.guns.modular.system.model.User">
      select
@@ -83,7 +103,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,
@@ -115,10 +135,10 @@
      </where>
      order by o.id desc
   </select>
    <select id="searchUsers" resultType="com.dsh.guns.modular.system.model.UserListVO">
   <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 from sys_user t1
       left join sys_dept t2 on t1.deptid = t2.id
      ,t2.simplename as deptName 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},'%')