UserRoleMapper.xml 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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="cn.com.ty.lift.system.user.dao.mapper.UserRoleMapper" >
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.system.user.dao.entity.UserRole" >
  5. <id column="id" property="id" jdbcType="BIGINT" />
  6. <result column="user_id" property="userId" jdbcType="BIGINT" />
  7. <result column="role_id" property="roleId" jdbcType="BIGINT" />
  8. <result column="company_id" property="companyId" jdbcType="BIGINT"/>
  9. </resultMap>
  10. <sql id="Base_Column_List" >
  11. id, user_id, role_id, company_id
  12. </sql>
  13. <!-- 通过用户id和公司id获取角色用户关联关系 -->
  14. <select id="getByUserRole" parameterType="cn.com.ty.lift.system.user.dao.entity.UserRole" resultType="cn.com.ty.lift.system.user.dao.entity.UserRole">
  15. select
  16. <include refid="Base_Column_List"/>
  17. from user_role
  18. where true
  19. <if test="userId != null">
  20. and user_id = #{userId,jdbcType=BIGINT}
  21. </if>
  22. <if test="roleId != null">
  23. and role_id = #{roleId,jdbcType=BIGINT}
  24. </if>
  25. <if test="companyId != null">
  26. and company_id = #{companyId,jdbcType=BIGINT}
  27. </if>
  28. </select>
  29. </mapper>