LuckDrawLogMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. <select id="countUseNumByIds" resultType="java.lang.String">
  76. SELECT GROUP_CONCAT(DISTINCT ldp.name_) FROM luck_draw_log ldl
  77. LEFT JOIN luck_draw_prize ldp ON ldl.prize_id_ = ldp.id_
  78. WHERE ldl.prize_id_ IN
  79. <foreach collection="prizeIds" open="(" close=")" item="id" separator=",">
  80. #{id}
  81. </foreach>
  82. </select>
  83. <sql id="queryCondition">
  84. <where>
  85. <if test="prizeId != null">
  86. AND l.prize_id_ = #{id}
  87. </if>
  88. <if test="userId != null">
  89. AND l.user_id_ = #{userId}
  90. </if>
  91. <if test="rewardType != null">
  92. AND d.reward_type_ LIKE CONCAT('%',#{rewardType},'%')
  93. </if>
  94. <if test="groupId != null">
  95. AND l.group_id_ = #{groupId}
  96. </if>
  97. <if test="name != null and name != ''">
  98. AND d.name_ = #{name}
  99. </if>
  100. <if test="startDate != null">
  101. AND l.create_on_ &gt;= #{startDate}
  102. </if>
  103. <if test="endDate != null">
  104. AND l.create_on_ &lt;= #{endDate}
  105. </if>
  106. <if test="organId != null">
  107. AND u.organ_id_ = #{organId}
  108. </if>
  109. <if test="defaultFlag != null">
  110. AND d.is_default_ = #{defaultFlag}
  111. </if>
  112. <if test="search != null and search != ''">
  113. AND (u.username_ LIKE CONCAT('%',#{search},'%') OR u.id_ = #{search})
  114. </if>
  115. </where>
  116. </sql>
  117. </mapper>