LuckDrawLogMapper.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.LuckDrawLogDao">
  4. <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.LuckDrawLog">
  5. <id column="id_" property="id" jdbcType="BIGINT" />
  6. <result column="group_id_" property="groupId" jdbcType="INTEGER" />
  7. <result column="prize_id_" property="prizeId" jdbcType="INTEGER" />
  8. <result column="user_id_" property="userId" jdbcType="BIGINT" />
  9. <result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
  10. <result column="name_" property="luckDrawPrize.name" jdbcType="VARCHAR" />
  11. <result column="reward_type_" property="luckDrawPrize.rewardType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  12. </resultMap>
  13. <resultMap id="BaseResultMapExt" type="com.ym.mec.biz.dal.entity.LuckDrawLog" extends="BaseResultMap">
  14. <result column="username_" property="user.username" jdbcType="VARCHAR" />
  15. <result column="phone_" property="user.phone" jdbcType="VARCHAR" />
  16. <result column="organ_name_" property="user.organName" jdbcType="VARCHAR" />
  17. </resultMap>
  18. <sql id="Base_Column_List">
  19. l.id_,l.group_id_, l.prize_id_,d.name_,d.reward_type_, l.user_id_, l.create_on_
  20. </sql>
  21. <sql id="queryCondition">
  22. <where>
  23. <if test="prizeId != null">
  24. and l.prize_id_ = #{id}
  25. </if>
  26. <if test="userId != null">
  27. and l.user_id_ = #{userId}
  28. </if>
  29. <if test="name != null">
  30. and d.name_ like concat('%',#{name},'%')
  31. </if>
  32. <if test="rewardType != null">
  33. and d.reward_type_ like concat('%',#{rewardType},'%')
  34. </if>
  35. <if test="groupId != null">
  36. and l.group_id_ = #{groupId}
  37. </if>
  38. <if test="startDate != null">
  39. and l.create_on_ &gt;= #{startDate}
  40. </if>
  41. <if test="endDate != null">
  42. and l.create_on_ &lt;= #{endDate}
  43. </if>
  44. <if test="organId != null">
  45. and u.organ_id_ = #{organId}
  46. </if>
  47. </where>
  48. </sql>
  49. <select id="get" resultMap="BaseResultMap" parameterType="java.lang.Long">
  50. select
  51. <include refid="Base_Column_List" />
  52. from luck_draw_log l left join luck_draw_prize d on
  53. l.prize_id_ = d.id_
  54. where l.id_ = #{id,jdbcType=BIGINT}
  55. </select>
  56. <delete id="delete" parameterType="java.lang.Long">
  57. delete from
  58. luck_draw_log
  59. where id_ = #{id,jdbcType=BIGINT}
  60. </delete>
  61. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawLog">
  62. insert into
  63. luck_draw_log (id_,group_id_, prize_id_, user_id_,
  64. create_on_)
  65. values
  66. (#{id,jdbcType=BIGINT}, #{groupId,jdbcType=INTEGER}, #{prizeId,jdbcType=INTEGER},
  67. #{userId,jdbcType=BIGINT},
  68. #{createOn,jdbcType=TIMESTAMP})
  69. </insert>
  70. <update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawLog">
  71. update luck_draw_log
  72. <set>
  73. <if test="groupId != null">
  74. group_id_ = #{groupId,jdbcType=INTEGER},
  75. </if>
  76. <if test="prizeId != null">
  77. prize_id_ = #{prizeId,jdbcType=INTEGER},
  78. </if>
  79. <if test="userId != null">
  80. user_id_ = #{userId,jdbcType=BIGINT},
  81. </if>
  82. <if test="createOn != null">
  83. create_on_ = #{createOn,jdbcType=TIMESTAMP},
  84. </if>
  85. </set>
  86. where id_ = #{id,jdbcType=BIGINT}
  87. </update>
  88. <select id="queryCount" parameterType="map" resultType="int">
  89. select count(*) from luck_draw_log l
  90. left join luck_draw_prize d on l.prize_id_ = d.id_
  91. left join sys_user u on u.id_=l.user_id_
  92. <include refid="queryCondition" />
  93. </select>
  94. <select id="queryPage" parameterType="map" resultMap="BaseResultMapExt">
  95. select <include refid="Base_Column_List" />,u.username_,u.phone_,o.name_ organ_name_ from luck_draw_log l
  96. left join luck_draw_prize d on l.prize_id_ = d.id_
  97. left join sys_user u on u.id_=l.user_id_
  98. left join organization o on o.id_ = u.organ_id_
  99. <include refid="queryCondition" />
  100. order by l.create_on_ desc
  101. <include refid="global.limit" />
  102. </select>
  103. </mapper>