user-server/src/main/resources/mapper/UserMapper.xml
@@ -39,4 +39,51 @@
        from user
        where state = 1
    </select>
    <select id="getCustom" resultType="com.yuanchu.mom.pojo.User">
        select u.id,c.company,u.name,c.code,u.phone,c.id departId from user u
        left join custom c on u.company = c.id
        where u.id = #{userId}
    </select>
    <select id="getUser" resultType="com.yuanchu.mom.pojo.User">
        select * from user where state = 1
    </select>
    <select id="selectDepartLims" resultType="java.lang.String">
        select name from department_lims
        where  id= (select  SUBSTRING_INDEX(SUBSTRING_INDEX(depart_lims_id, ',', -2), ',', 1) AS depart_lims_id  from user where name=#{prepareUser})
    </select>
    <select id="getUserByRole" resultType="com.yuanchu.mom.pojo.User">
        select u.* from user u
        left join  role r on u.role_id = r.id
        where r.name=#{name}
    </select>
    <!-- 获取用户部门 -->
    <select id="selectUserDepartmentLimsName" resultType="java.lang.String">
        select dl.name
        from user u
                 left join department_lims dl on find_in_set(dl.id, u.depart_lims_id) and dl.id != 1
        where u.id = #{userId}
        limit 1
    </select>
    <!-- 获取当前登录用户部门下的所有用户  -->
    <select id="selectDepartmentLimsUserList" resultType="com.yuanchu.mom.pojo.User">
        select id,
               account,
               name,
               name_en
        from user u
        where depart_lims_id = (select u2.depart_lims_id
                                from user u2
                                where u2.id = #{userId})
    </select>
    <!-- 查询用户和部门 -->
    <select id="selectNameAnddepartment" resultType="java.util.Map">
        select u.name  userName,
               dl.name department
        from user u
                 left join department_lims dl on find_in_set(dl.id, u.depart_lims_id) and dl.id != 1
        where find_in_set(u.id, #{participant})
    </select>
</mapper>