RoleMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.usoftchina.saas.account.mapper.RoleMapper">
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.account.po.Role">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="code" jdbcType="VARCHAR" property="code"/>
  7. <result column="name" jdbcType="VARCHAR" property="name"/>
  8. <result column="description" jdbcType="VARCHAR" property="description"/>
  9. <result column="type" jdbcType="INTEGER" property="type"/>
  10. <result column="company_id" jdbcType="BIGINT" property="companyId"/>
  11. <result column="creator_id" jdbcType="BIGINT" property="creatorId"/>
  12. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  13. <result column="updater_id" jdbcType="BIGINT" property="updaterId"/>
  14. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  15. </resultMap>
  16. <sql id="baseColumns">
  17. ac_role.id,ac_role.code,ac_role.name,ac_role.description,ac_role.type,ac_role.company_id,
  18. ac_role.creator_id,ac_role.create_time,ac_role.updater_id,ac_role.update_time
  19. </sql>
  20. <insert id="insert" parameterType="com.usoftchina.saas.account.po.Role"
  21. useGeneratedKeys="true" keyProperty="id">
  22. insert into ac_role(code,name,description,type,company_id,creator_id,create_time,updater_id,update_time)
  23. values (#{code,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{companyId,jdbcType=BIGINT},
  24. #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updaterId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP})
  25. </insert>
  26. <insert id="insertSelective" parameterType="com.usoftchina.saas.account.po.Role"
  27. useGeneratedKeys="true" keyProperty="id">
  28. insert into ac_role
  29. <trim prefix="(" suffix=")" suffixOverrides=",">
  30. <if test="code != null">
  31. code,
  32. </if>
  33. <if test="name != null">
  34. name,
  35. </if>
  36. <if test="description != null">
  37. description,
  38. </if>
  39. <if test="type != null">
  40. type,
  41. </if>
  42. <if test="companyId != null">
  43. company_id,
  44. </if>
  45. <if test="creatorId != null">
  46. creator_id,
  47. </if>
  48. <if test="createTime != null">
  49. create_time,
  50. </if>
  51. <if test="updaterId != null">
  52. updater_id,
  53. </if>
  54. <if test="updateTime != null">
  55. update_time,
  56. </if>
  57. </trim>
  58. <trim prefix="values (" suffix=")" suffixOverrides=",">
  59. <if test="code != null">
  60. #{code,jdbcType=VARCHAR},
  61. </if>
  62. <if test="name != null">
  63. #{name,jdbcType=VARCHAR},
  64. </if>
  65. <if test="description != null">
  66. #{description,jdbcType=VARCHAR},
  67. </if>
  68. <if test="type != null">
  69. #{type,jdbcType=INTEGER},
  70. </if>
  71. <if test="companyId != null">
  72. #{companyId,jdbcType=BIGINT},
  73. </if>
  74. <if test="creatorId != null">
  75. #{creatorId,jdbcType=BIGINT},
  76. </if>
  77. <if test="createTime != null">
  78. #{createTime,jdbcType=TIMESTAMP},
  79. </if>
  80. <if test="updaterId != null">
  81. #{updaterId,jdbcType=BIGINT},
  82. </if>
  83. <if test="updateTime != null">
  84. #{updateTime,jdbcType=TIMESTAMP},
  85. </if>
  86. </trim>
  87. </insert>
  88. <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.account.po.Role">
  89. update ac_role set code=#{code,jdbcType=VARCHAR},name=#{name,jdbcType=VARCHAR},
  90. description=#{description,jdbcType=VARCHAR},type=#{type,jdbcType=INTEGER},company_id=#{companyId,jdbcType=BIGINT},
  91. creator_id=#{creatorId,jdbcType=BIGINT},create_time=#{createTime,jdbcType=TIMESTAMP},
  92. updater_id=#{updaterId,jdbcType=BIGINT},update_time=#{updateTime,jdbcType=TIMESTAMP} where id=#{id,jdbcType=BIGINT}
  93. </update>
  94. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  95. delete from ac_role where id=#{id,jdbcType=BIGINT}
  96. </delete>
  97. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  98. select <include refid="baseColumns"/> from ac_role where id=#{id,jdbcType=BIGINT}
  99. </select>
  100. <select id="selectByCompanyId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  101. select <include refid="baseColumns"/> from ac_role where company_id=#{companyId,jdbcType=BIGINT}
  102. </select>
  103. <select id="selectByAccountId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  104. select <include refid="baseColumns"/> from ac_role,ac_account_role
  105. where ac_role.id=ac_account_role.role_id and ac_account_role.account_id=#{accountId,jdbcType=BIGINT}
  106. </select>
  107. </mapper>