roles.sql.xml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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="rolesSqlMapper">
  5. <!--mybatis ehcache缓存配置 -->
  6. <!-- 以下两个<cache>标签二选一,第一个可以输出日志,第二个不输出日志
  7. <cache type="org.mybatis.caches.ehcache.LoggingEhcache" />-->
  8. <!-- <cache type="org.mybatis.caches.ehcache.EhcacheCache"/> -->
  9. <!-- 以下与实体类的中字段一致 -->
  10. <sql id="selectId">
  11. id,
  12. enable,
  13. name,
  14. roleKey,
  15. description
  16. </sql>
  17. <!--resultType="Roles" 每返回一条结果封装到Account里 -->
  18. <select id="query" resultType="com.cloudcross.ssp.model.Roles" parameterType="java.util.HashMap">
  19. select
  20. <include refid="selectId" />
  21. from t_ly_role
  22. <where>
  23. <if test="t.name != null and t.name != ''">
  24. name like '%${t.name}%'
  25. </if>
  26. </where>
  27. </select>
  28. <select id="queryAll" resultType="com.cloudcross.ssp.model.Roles" parameterType="com.cloudcross.ssp.model.Roles">
  29. select
  30. <include refid="selectId" />
  31. from t_ly_role
  32. <where>
  33. <if test="name != null and name != ''">
  34. name like '%${name}%'
  35. </if>
  36. </where>
  37. </select>
  38. <select id="isExist" resultType="com.cloudcross.ssp.model.Roles" parameterType="String">
  39. select
  40. <include refid="selectId" />
  41. from t_ly_role
  42. where name = #{name}
  43. </select>
  44. <insert id="add" parameterType="com.cloudcross.ssp.model.Roles">
  45. insert into t_ly_role ( enable,name,roleKey,description)
  46. values (#{enable},
  47. #{name}, #{roleKey},
  48. #{description})
  49. </insert>
  50. <delete id="delete" parameterType="String">
  51. delete from t_ly_role where
  52. id=#{id}
  53. </delete>
  54. <select id="getById" parameterType="String" resultType="com.cloudcross.ssp.model.Roles">
  55. select
  56. <include refid="selectId" />
  57. from t_ly_role where id=#{id}
  58. </select>
  59. <update id="update" parameterType="com.cloudcross.ssp.model.Roles">
  60. update t_ly_role
  61. <set>
  62. <if test="name != null and name != ''">
  63. name=#{name},
  64. </if>
  65. <if test="enable != null and enable != ''">
  66. enable=#{enable},
  67. </if>
  68. <if test="description != null and description != ''">
  69. description=#{description},
  70. </if>
  71. <if test="roleKey != null and roleKey != ''">
  72. roleKey=#{roleKey}
  73. </if>
  74. </set>
  75. where id=#{id}
  76. </update>
  77. <select id="findbyAccountRole" parameterType="String" resultType="com.cloudcross.ssp.model.Roles">
  78. select
  79. <include refid="selectId" />
  80. from t_ly_role where id in (SELECT role_id FROM t_acc_role WHERE acc_id=#{accountId})
  81. </select>
  82. <delete id="deleteAccountRole" parameterType="String">
  83. delete from t_acc_role
  84. where acc_id=#{accountId}
  85. </delete>
  86. <insert id="addAccRole" parameterType="com.cloudcross.ssp.model.RoleAccount">
  87. insert into t_acc_role (acc_id,role_id) value (#{accountId},#{roleId})
  88. </insert>
  89. </mapper>