Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

108 строки
4.3 KiB

  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.iformall.mapper.WxTopicMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxTopic">
  5. <id column="id" property="id"/>
  6. <result column="tenant_id" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="name" property="name"/>
  9. <result column="title" property="title"/>
  10. <result column="content" property="content"/>
  11. <result column="cover" property="cover"/>
  12. <result column="cover_picture" property="coverPicture"/>
  13. <result column="detail_picture" property="detailPicture"/>
  14. <result column="advert" property="advert"/>
  15. <result column="begin_time" property="beginTime"/>
  16. <result column="end_time" property="endTime"/>
  17. <result column="status" property="status"/>
  18. <result column="createtime" property="createtime"/>
  19. <result column="updatetime" property="updatetime"/>
  20. <result column="bg_color" property="bgColor"/>
  21. <result column="couponChannelId" property="couponChannelId"/>
  22. </resultMap>
  23. <sql id="allColumns">
  24. `id`,`tenant_id`,`parent_tenant_id`,`name`,`title`,`content`,`cover`,`cover_picture`,`detail_picture`,`advert`,`begin_time`,`end_time`,`createtime`,`updatetime`,`bg_color`
  25. </sql>
  26. <sql id="dynamicWhereConditions">
  27. where 1 = 1
  28. <if test=" null != id ">
  29. and `id` = #{id}
  30. </if>
  31. <if test=" null != tenantId and '' != tenantId">
  32. and `tenant_id` = #{tenantId}
  33. </if>
  34. <if test=" null != parentTenantId and '' != parentTenantId">
  35. and `parent_tenant_id` = #{parentTenantId}
  36. </if>
  37. <if test='statusStr =="0,2" or status==1'>
  38. <if test=" null != beginTime ">
  39. and `begin_time` >= #{beginTime}
  40. </if>
  41. <if test=" null != endTime ">
  42. and `begin_time` &lt;= #{endTime}
  43. </if>
  44. </if>
  45. <if test='status ==2 or status==3'>
  46. <if test=" null != beginTime ">
  47. and `end_time` >= #{beginTime}
  48. </if>
  49. <if test=" null != endTime ">
  50. and `end_time` &lt;= #{endTime}
  51. </if>
  52. </if>
  53. <if test=" null != status ">
  54. and `status` = #{status}
  55. </if>
  56. <if test=" null != name and ''!=name ">
  57. and `name` like concat('%',#{name},'%')
  58. </if>
  59. <if test=" null != statusList ">
  60. and status in
  61. <foreach collection="statusList" index="index" item="statusItem" open="(" separator="," close=")">
  62. #{statusItem}
  63. </foreach>
  64. </if>
  65. <if test=" null != sortColumns">order by ${sortColumns}</if>
  66. <if test=" null == sortColumns">order by begin_time desc,status asc</if>
  67. </sql>
  68. <select id="findList" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
  69. select * from wx_topic
  70. <include refid="dynamicWhereConditions"/>
  71. </select>
  72. <select id="findExist" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
  73. SELECT * FROM wx_topic WHERE wx_topic.tenant_id = #{tenantId}
  74. AND (`begin_time` >= #{beginTime} and `end_time` &lt;= #{endTime}) AND `status` = 1
  75. </select>
  76. <select id="show" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
  77. select t.*,cc.id as couponChannelId from wx_topic t left join wx_coupon_channel cc on(cc.sub_target_id = t.id)
  78. where t.status = 1
  79. and now() >= t.begin_time and now() &lt;= t.end_time
  80. and t.tenant_id = #{tenantId}
  81. order by t.begin_time desc limit 1
  82. </select>
  83. <update id="updateStatus" parameterType="com.iformall.domain.po.WxTopic">
  84. update wx_topic set status = 3 where id in(
  85. select t.id from (
  86. select id from wx_topic where status !=3 and now() >= end_time and tenant_id = #{tenantId}
  87. ) t
  88. )
  89. </update>
  90. <update id="couponDownLine" parameterType="com.iformall.domain.po.WxTopic">
  91. update wx_coupon_channel set status = 1 where status = 0 and target_ad = 8 and sub_target_id in(
  92. select id from wx_topic where status in(2,3) and tenant_id = #{tenantId}
  93. )
  94. </update>
  95. </mapper>