后台服务
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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