SysOrganizationUserLinkServiceMapper.xml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.jzg.organization.mapper.SysOrganizationUserLinkServiceMapper">
  4. <!-- 结果映射 -->
  5. <resultMap id="BaseResultMap" type="com.jzg.commons.entity.po.SysOrganizationUserLink">
  6. <id column="id" property="id" jdbcType="VARCHAR"/>
  7. <result column="user_id" property="userId" jdbcType="VARCHAR"/>
  8. <result column="organization_id" property="organizationId" jdbcType="VARCHAR"/>
  9. </resultMap>
  10. <!-- 基础列 -->
  11. <sql id="Base_Column_List">
  12. id
  13. , user_id, organization_id
  14. </sql>
  15. <!-- 一个人只有一个团队,更新时修改团队去掉旧团队 AND organization_id = #{orgId} -->
  16. <delete id="deleteOrganizationUser">
  17. DELETE
  18. FROM sys_organization_user_link
  19. WHERE user_id = #{userId}
  20. </delete>
  21. <!-- 根据用户ID获取组织关联信息 -->
  22. <select id="getOrganizationUser" resultMap="BaseResultMap">
  23. SELECT
  24. a.id,
  25. a.user_id,
  26. a.organization_id
  27. FROM sys_organization_user_link a
  28. JOIN sys_organization b ON a.organization_id = b.id AND b.is_delete = 0
  29. <where>
  30. a.is_delete = 0
  31. AND user_id = #{userId,jdbcType=DECIMAL}
  32. </where>
  33. ORDER BY a.id DESC
  34. </select>
  35. </mapper>