|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.iformall.mapper.WxTopicMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxTopic">
- <id column="id" property="id"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="topic_type" jdbcType="INTEGER" property="topicType"/>
- <result column="name" property="name"/>
- <result column="title" property="title"/>
- <result column="content" property="content"/>
- <result column="cover" property="cover"/>
- <result column="cover_picture" property="coverPicture"/>
- <result column="detail_picture" property="detailPicture"/>
- <result column="advert" property="advert"/>
- <result column="begin_time" property="beginTime"/>
- <result column="end_time" property="endTime"/>
- <result column="status" property="status"/>
- <result column="is_only_ad" property="isOnlyAd"/>
-
- <result column="createtime" property="createtime"/>
- <result column="updatetime" property="updatetime"/>
- <result column="bg_color" property="bgColor"/>
-
- </resultMap>
-
- <sql id="allColumns">
- `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`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != topicType">
- and `topic_type` = #{topicType}
- </if>
-
- <if test='statusStr =="0,2" or status==1'>
- <if test=" null != beginTime ">
- and `begin_time` >= #{beginTime}
- </if>
- <if test=" null != endTime ">
- and `begin_time` <= #{endTime}
- </if>
- </if>
- <if test='status ==2 or status==3'>
- <if test=" null != beginTime ">
- and `end_time` >= #{beginTime}
- </if>
- <if test=" null != endTime ">
- and `end_time` <= #{endTime}
- </if>
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
- </if>
- <if test=" null != name and ''!=name ">
- and `name` like concat('%',#{name},'%')
- </if>
- <if test=" null != statusList ">
- and status in
- <foreach collection="statusList" index="index" item="statusItem" open="(" separator="," close=")">
- #{statusItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- <if test=" null == sortColumns">order by begin_time desc,status asc</if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
- select * from wx_topic
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findExist" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
- SELECT * FROM wx_topic WHERE wx_topic.tenant_id = #{tenantId}
- AND (`begin_time` >= #{beginTime} and `end_time` <= #{endTime}) AND `status` = 1
- </select>
-
- <select id="show" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
- select t.* from wx_topic t
- where t.status = 1 and t.`topic_type` = #{topicType}
- <if test="topicType == 1">
- and now() >= t.begin_time and now() <= t.end_time
- </if>
- and t.tenant_id = #{tenantId}
- order by t.begin_time desc limit 1
- </select>
-
- <select id="showList" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
- select t.* from wx_topic t
- where t.status = 1 and t.`topic_type` = 1
- and now() >= t.begin_time and now() <= t.end_time
- and t.tenant_id = #{tenantId}
- order by t.begin_time desc
- </select>
-
- <update id="updateStatus" parameterType="com.iformall.domain.po.WxTopic">
- update wx_topic set status = 3 where id in(
- select t.id from (
- select id from wx_topic where `topic_type` = 1 and status !=3 and now() >= end_time and tenant_id = #{tenantId}
- ) t
- )
- </update>
-
- <update id="couponDownLine" parameterType="com.iformall.domain.po.WxTopic">
- update wx_coupon_channel set status = 1 where status = 0 and target_ad = 8 and sub_target_id in(
- select id from wx_topic where `topic_type` = 1 and status in(2,3) and tenant_id = #{tenantId}
- )
- </update>
-
- </mapper>
|