LuckDrawCountMapper.xml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.ym.mec.biz.dal.dao.LuckDrawCountDao" >
  4. <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.LuckDrawCount" >
  5. <id column="user_id_" property="userId" jdbcType="BIGINT" />
  6. <result column="used_count_" property="usedCount" jdbcType="INTEGER" />
  7. <result column="available_count_" property="availableCount" jdbcType="INTEGER" />
  8. <result column="available_amount_" property="availableAmount" jdbcType="BIGINT" />
  9. <result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
  10. <result column="group_id_" property="groupId"/>
  11. <result column="tenant_id_" property="tenantId" />
  12. </resultMap>
  13. <sql id="Base_Column_List" >
  14. user_id_, used_count_, available_count_, available_amount_, modify_on_,group_id_,tenant_id_
  15. </sql>
  16. <select id="get" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  17. select
  18. <include refid="Base_Column_List" />
  19. from luck_draw_count
  20. where user_id_ = #{userId,jdbcType=BIGINT}
  21. </select>
  22. <select id="getLock" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  23. select
  24. <include refid="Base_Column_List" />
  25. from luck_draw_count
  26. where user_id_ = #{userId,jdbcType=BIGINT} for update
  27. </select>
  28. <select id="findAll" resultMap="BaseResultMap">
  29. select * from luck_draw_count where tenant_id_ = #{tenantId}
  30. </select>
  31. <select id="findByIdAndGroupId" resultMap="BaseResultMap">
  32. SELECT * FROM luck_draw_count WHERE user_id_ = #{userId} AND group_id_ = #{groupId}
  33. </select>
  34. <select id="findLockByIdAndGroupId" resultMap="BaseResultMap">
  35. SELECT * FROM luck_draw_count WHERE user_id_ = #{userId} AND group_id_ = #{groupId} FOR UPDATE
  36. </select>
  37. <delete id="delete" parameterType="java.lang.Long" >
  38. delete from luck_draw_count
  39. where user_id_ = #{userId,jdbcType=BIGINT}
  40. </delete>
  41. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawCount" >
  42. insert into luck_draw_count (user_id_, used_count_, available_count_, available_amount_,
  43. modify_on_,group_id_,tenant_id_)
  44. values (#{userId}, #{usedCount}, #{availableCount}, #{availableAmount},
  45. NOW(),#{groupId},#{tenantId})
  46. </insert>
  47. <update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawCount" >
  48. update luck_draw_count
  49. <set >
  50. <if test="groupId != null" >
  51. group_id_ = #{groupId},
  52. </if>
  53. <if test="usedCount != null" >
  54. used_count_ = #{usedCount,jdbcType=INTEGER},
  55. </if>
  56. <if test="availableCount != null" >
  57. available_count_ = #{availableCount,jdbcType=INTEGER},
  58. </if>
  59. <if test="availableAmount != null" >
  60. available_amount_ = #{availableAmount,jdbcType=BIGINT},
  61. </if>
  62. <if test="modifyOn != null" >
  63. modify_on_ = #{modifyOn,jdbcType=TIMESTAMP},
  64. </if>
  65. </set>
  66. where user_id_ = #{userId,jdbcType=BIGINT} and tenant_id_ = #{tenantId}
  67. </update>
  68. </mapper>