LuckDrawLogMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. <select id="get" resultMap="BaseResultMap" parameterType="java.lang.Long">
  22. select
  23. <include refid="Base_Column_List" />
  24. from luck_draw_log l left join luck_draw_prize d on
  25. l.prize_id_ = d.id_
  26. where l.id_ = #{id,jdbcType=BIGINT}
  27. </select>
  28. <delete id="delete" parameterType="java.lang.Long">
  29. delete from
  30. luck_draw_log
  31. where id_ = #{id,jdbcType=BIGINT}
  32. </delete>
  33. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LuckDrawLog">
  34. insert into
  35. luck_draw_log (id_,group_id_, prize_id_, user_id_,
  36. create_on_)
  37. values
  38. (#{id,jdbcType=BIGINT}, #{groupId,jdbcType=INTEGER}, #{prizeId,jdbcType=INTEGER},
  39. #{userId,jdbcType=BIGINT},
  40. #{createOn,jdbcType=TIMESTAMP})
  41. </insert>
  42. <update id="update" parameterType="com.ym.mec.biz.dal.entity.LuckDrawLog">
  43. update luck_draw_log
  44. <set>
  45. <if test="groupId != null">
  46. group_id_ = #{groupId,jdbcType=INTEGER},
  47. </if>
  48. <if test="prizeId != null">
  49. prize_id_ = #{prizeId,jdbcType=INTEGER},
  50. </if>
  51. <if test="userId != null">
  52. user_id_ = #{userId,jdbcType=BIGINT},
  53. </if>
  54. <if test="createOn != null">
  55. create_on_ = #{createOn,jdbcType=TIMESTAMP},
  56. </if>
  57. </set>
  58. where id_ = #{id,jdbcType=BIGINT}
  59. </update>
  60. <select id="queryCount" parameterType="map" resultType="int">
  61. SELECT COUNT(*) FROM luck_draw_log l
  62. LEFT JOIN luck_draw_prize d ON l.prize_id_ = d.id_
  63. LEFT JOIN sys_user u ON u.id_=l.user_id_
  64. <include refid="queryCondition" />
  65. </select>
  66. <select id="queryPage" parameterType="map" resultMap="BaseResultMapExt">
  67. SELECT <include refid="Base_Column_List" />,u.username_,u.phone_,o.name_ organ_name_ FROM luck_draw_log l
  68. LEFT JOIN luck_draw_prize d ON l.prize_id_ = d.id_
  69. LEFT JOIN sys_user u ON u.id_=l.user_id_
  70. LEFT JOIN organization o ON o.id_ = u.organ_id_
  71. <include refid="queryCondition" />
  72. ORDER BY l.create_on_ DESC
  73. <include refid="global.limit" />
  74. </select>
  75. <sql id="queryCondition">
  76. <where>
  77. <if test="prizeId != null">
  78. AND l.prize_id_ = #{id}
  79. </if>
  80. <if test="userId != null">
  81. AND l.user_id_ = #{userId}
  82. </if>
  83. <if test="rewardType != null">
  84. AND d.reward_type_ LIKE CONCAT('%',#{rewardType},'%')
  85. </if>
  86. <if test="groupId != null">
  87. AND l.group_id_ = #{groupId}
  88. </if>
  89. <if test="name != null and name != ''">
  90. AND d.name_ = #{name}
  91. </if>
  92. <if test="startDate != null">
  93. AND l.create_on_ &gt;= #{startDate}
  94. </if>
  95. <if test="endDate != null">
  96. AND l.create_on_ &lt;= #{endDate}
  97. </if>
  98. <if test="organId != null">
  99. AND u.organ_id_ = #{organId}
  100. </if>
  101. <if test="search != null and search != ''">
  102. AND (u.username_ LIKE CONCAT('%',#{search},'%') OR u.id_ = #{search})
  103. </if>
  104. </where>
  105. </sql>
  106. </mapper>