You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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