linwei
2024-01-31 b3b566ebdfed4005aaa513da3d5d2fd3924903cc
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -61,7 +61,7 @@
            </foreach>
            )
        </if>
        ORDER BY id
        ORDER BY create_time desc
    </select>
    <select id="getUser" resultMap="userResultMap">
@@ -107,10 +107,28 @@
        and (account = #{phoneNumber} or phone = #{phoneNumber})
    </select>
    <!--用户详情map-->
    <resultMap id="selectUserDetailMap" type="org.springblade.modules.system.vo.UserDetailVO" autoMapping="true">
        <id property="id" column="id" />
        <collection property="deptList"  javaType="java.util.List"
                    ofType="org.springblade.modules.system.vo.DeptDetailVO" autoMapping="true">
            <id property="id" column="cid"/>
            <id property="level" column="region_level"/>
        </collection>
    </resultMap>
    <!--用户详情接口-->
    <select id="getUserInfo" resultType="org.springblade.modules.system.vo.UserDetailVO">
        SELECT * FROM blade_user where is_deleted = 0
        and id = #{userId}
    <select id="getUserInfo" resultMap="selectUserDetailMap">
        SELECT
        bu.*,
        bd.id as cid,bd.parent_id,bd.ancestors,bd.dept_category,bd.dept_name,bd.full_name,bd.sort,bd.region_code,
        br.region_level
        FROM blade_user bu
        left join blade_user_dept bud on bud.user_id = bu.id
        left join blade_dept bd on bud.dept_id = bd.id and bd.is_deleted = 0
        left join blade_region br on br.code = bd.region_code
        where bu.is_deleted = 0
        and bu.id = #{userId}
    </select>
@@ -184,5 +202,25 @@
        and bu.dept_id!=''
    </select>
    <select id="getUserInfoByPropertyId" resultType="org.springblade.modules.system.entity.User"
            parameterType="java.lang.String">
            SELECT
            *
            FROM
            blade_user bu
            WHERE
            bu.role_id = #{roleId}
            and bu.dept_id IN (
            SELECT
            id
            FROM
            ( SELECT id, parent_id FROM blade_dept ORDER BY parent_id, id ) org_query,
            (SELECT   @id := #{deptId} ) initialisation
            WHERE
            FIND_IN_SET( parent_id, @id ) > 0 AND @id := CONCAT( @id, ',', id )
            )
    </select>
</mapper>