RoleMemberMapper.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.RoleMemberMapper">
  5. <resultMap id="RoleMeberDtoResultMap" type="com.zhyc.xps.sys.dto.RoleMemberDto">
  6. <result column="rm_id" property="rmId" jdbcType="BIGINT" /> <!--PK ID-->
  7. <result column="role_id" property="roleId" jdbcType="BIGINT" /> <!--角色ID-->
  8. <result column="role_type_id" property="roleTypeId" jdbcType="BIGINT" /> <!--角色 Type ID-->
  9. <result column="role_code" property="roleCode" jdbcType="VARCHAR"/> <!--角色 Code-->
  10. <result column="role_name" property="roleName" jdbcType="VARCHAR"/> <!--角色 Name-->
  11. <result column="account_id" property="accountId" jdbcType="BIGINT" /> <!--账号ID-->
  12. </resultMap>
  13. <sql id="Ext_Column_List">
  14. A.rm_id,
  15. A.role_id,
  16. B.role_type_id,
  17. B.role_code,
  18. B.role_name,
  19. A.account_id
  20. </sql>
  21. <!--根据ID获取信息-->
  22. <select id="getFirstRoleByAccountId" parameterType="java.lang.Long" resultMap="RoleMeberDtoResultMap">
  23. SELECT
  24. <include refid="Ext_Column_List"/>
  25. FROM s_role_member AS A
  26. LEFT JOIN s_role AS B ON (A.role_id = B.role_id)
  27. WHERE account_id = #{accountId, jdbcType=BIGINT}
  28. LIMIT 1
  29. </select>
  30. <!--新增-->
  31. <insert id="create" parameterType="com.zhyc.xps.sys.entity.RoleMember">
  32. INSERT INTO s_role_member
  33. <trim prefix="(" suffix=")" suffixOverrides=",">
  34. <if test="rmId != null">
  35. rm_id,
  36. </if>
  37. <if test="roleId != null">
  38. role_id,
  39. </if>
  40. <if test="ocId != null">
  41. oc_id,
  42. </if>
  43. <if test="accountId != null">
  44. account_id,
  45. </if>
  46. </trim>
  47. <trim prefix="values (" suffix=")" suffixOverrides=",">
  48. <if test="rmId != null">
  49. #{rmId ,jdbcType=BIGINT},
  50. </if>
  51. <if test="roleId != null">
  52. #{roleId ,jdbcType=BIGINT},
  53. </if>
  54. <if test="ocId != null">
  55. #{ocId ,jdbcType=BIGINT},
  56. </if>
  57. <if test="accountId != null">
  58. #{accountId ,jdbcType=BIGINT},
  59. </if>
  60. </trim>
  61. </insert>
  62. <!--删除-->
  63. <delete id="delete" parameterType="java.util.Map">
  64. DELETE
  65. FROM s_role_member
  66. WHERE 1 = 1
  67. <if test="roleId != null">
  68. and role_id = #{roleId ,jdbcType=BIGINT}
  69. </if>
  70. <if test="accountId != null">
  71. and account_id = #{accountId ,jdbcType=BIGINT}
  72. </if>
  73. </delete>
  74. </mapper>