admin
2020-12-31 74196bcc835d9b76cdd1bc3d85b0dfbe0191fc00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?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.ks.lucky.mapper.LuckyActivityMapper">
    <resultMap id="BaseResultMap" type="com.ks.lucky.pojo.DO.LuckyActivity">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="app_id" jdbcType="BIGINT" property="appId"/>
        <result column="sponsor_id" jdbcType="BIGINT" property="sponsorId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="material_poster" jdbcType="VARCHAR" property="materialPoster"/>
        <result column="material_tag_image" jdbcType="VARCHAR" property="materialTagImage"/>
        <result column="material_" jdbcType="VARCHAR" property="material"/>
        <result column="desc" jdbcType="VARCHAR" property="desc"/>
        <result column="max_person_count" jdbcType="INTEGER" property="maxPersonCount"/>
        <result column="current_person_count" jdbcType="INTEGER" property="currentPersonCount"/>
        <result column="state" jdbcType="INTEGER" property="state"/>
        <result column="state_remarks" jdbcType="VARCHAR" property="stateRemarks"/>
        <result column="pre_finish_time" jdbcType="TIMESTAMP" property="preFinishTime"/>
        <result column="actual_finish_time" jdbcType="TIMESTAMP" property="actualFinishTime"/>
        <result column="pre_open_time" jdbcType="TIMESTAMP" property="preOpenTime"/>
        <result column="actual_open_time" jdbcType="TIMESTAMP" property="actualOpenTime"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="pre_start_time" property="preStartTime" jdbcType="TIMESTAMP"/>
        <result column="actual_start_time" property="actualStartTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, max_person_count,current_person_count, state, state_remarks, pre_finish_time,actual_finish_time, pre_open_time,actual_open_time, create_time, update_time,pre_start_time,actual_start_time</sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/>
        from lucky_activity where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" parameterType="java.lang.Long" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/>
        from lucky_activity where id = #{0} for update
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from lucky_activity where id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" useGeneratedKeys="true" keyProperty="id"
            parameterType="com.ks.lucky.pojo.DO.LuckyActivity">insert into lucky_activity (id, app_id, sponsor_id, `name`, material_poster, material_tag_image, material_, `desc`, max_person_count, current_person_count, state, state_remarks, pre_finish_time,actual_finish_time, pre_open_time, actual_open_time,create_time, update_time,id,pre_start_time,actual_start_time) values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=BIGINT}, #{sponsorId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{materialPoster,jdbcType=VARCHAR}, #{materialTagImage,jdbcType=VARCHAR}, #{material,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{maxPersonCount,jdbcType=INTEGER}, #{currentPersonCount,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{stateRemarks,jdbcType=VARCHAR}, #{preFinishTime,jdbcType=TIMESTAMP}, #{actualFinishTime,jdbcType=TIMESTAMP}, #{preOpenTime,jdbcType=TIMESTAMP}, #{actualOpenTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},#{id,jdbcType=BIGINT},#{preStartTime,jdbcType=TIMESTAMP},#{actualStartTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
            parameterType="com.ks.lucky.pojo.DO.LuckyActivity">insert into lucky_activity
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="appId != null">app_id,</if>
            <if test="sponsorId != null">sponsor_id,</if>
            <if test="name != null">`name`,</if>
            <if test="materialPoster != null">material_poster,</if>
            <if test="materialTagImage != null">material_tag_image,</if>
            <if test="material != null">material_,</if>
            <if test="desc != null">`desc`,</if>
            <if test="maxPersonCount != null">max_person_count,</if>
            <if test="currentPersonCount != null">current_person_count,</if>
            <if test="state != null">state,</if>
            <if test="stateRemarks != null">state_remarks,</if>
            <if test="preFinishTime != null">pre_finish_time,</if>
            <if test="actualFinishTime != null">actual_finish_time,</if>
            <if test="preOpenTime != null">pre_open_time,</if>
            <if test="actualOpenTime != null">actual_open_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="preStartTime != null">pre_start_time,</if>
            <if test="actualStartTime != null">actual_start_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="appId != null">#{appId,jdbcType=BIGINT},</if>
            <if test="sponsorId != null">#{sponsorId,jdbcType=BIGINT},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="materialPoster != null">#{materialPoster,jdbcType=VARCHAR},</if>
            <if test="materialTagImage != null">#{materialTagImage,jdbcType=VARCHAR},</if>
            <if test="material != null">#{material,jdbcType=VARCHAR},</if>
            <if test="desc != null">#{desc,jdbcType=VARCHAR},</if>
            <if test="maxPersonCount != null">#{maxPersonCount,jdbcType=INTEGER},</if>
            <if test="currentPersonCount != null">#{currentPersonCount,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="stateRemarks != null">#{stateRemarks,jdbcType=VARCHAR},</if>
            <if test="preFinishTime != null">#{preFinishTime,jdbcType=TIMESTAMP},</if>
            <if test="actualFinishTime != null">#{actualFinishTime,jdbcType=TIMESTAMP},</if>
            <if test="preOpenTime != null">#{preOpenTime,jdbcType=TIMESTAMP},</if>
            <if test="actualOpenTime != null">#{actualOpenTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="preStartTime != null">#{preStartTime,jdbcType=TIMESTAMP},</if>
            <if test="actualStartTime != null">#{actualStartTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ks.lucky.pojo.DO.LuckyActivity">update lucky_activity
        <set>
            <if test="appId != null">app_id = #{appId,jdbcType=BIGINT},</if>
            <if test="sponsorId != null">sponsor_id = #{sponsorId,jdbcType=BIGINT},</if>
            <if test="name != null">`name` = #{name,jdbcType=VARCHAR},</if>
            <if test="materialPoster != null">material_poster = #{materialPoster,jdbcType=VARCHAR},</if>
            <if test="materialTagImage != null">material_tag_image = #{materialTagImage,jdbcType=VARCHAR},</if>
            <if test="material != null">material_ = #{material,jdbcType=VARCHAR},</if>
            <if test="desc != null">`desc` = #{desc,jdbcType=VARCHAR},</if>
            <if test="maxPersonCount != null">max_person_count = #{maxPersonCount,jdbcType=INTEGER},</if>
            <if test="currentPersonCount != null">current_person_count = #{currentPersonCount,jdbcType=INTEGER},</if>
            <if test="state != null">state = #{state,jdbcType=INTEGER},</if>
            <if test="stateRemarks != null">state_remarks = #{stateRemarks,jdbcType=VARCHAR},</if>
            <if test="preFinishTime != null">pre_finish_time = #{preFinishTime,jdbcType=TIMESTAMP},</if>
            <if test="actualFinishTime != null">actual_finish_time = #{actualFinishTime,jdbcType=TIMESTAMP},</if>
            <if test="preOpenTime != null">pre_open_time = #{preOpenTime,jdbcType=TIMESTAMP},</if>
            <if test="actualOpenTime != null">actual_open_time = #{actualOpenTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">create_time = #{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="preStartTime !=null">pre_start_time =#{preStartTime,jdbcType=TIMESTAMP},</if>
            <if test="actualStartTime !=null">actual_start_time =#{actualStartTime,jdbcType=TIMESTAMP},</if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ks.lucky.pojo.DO.LuckyActivity">
update lucky_activity set app_id = #{appId,jdbcType=BIGINT}, sponsor_id = #{sponsorId,jdbcType=BIGINT}, `name` = #{name,jdbcType=VARCHAR}, material_poster = #{materialPoster,jdbcType=VARCHAR}, material_tag_image = #{materialTagImage,jdbcType=VARCHAR}, material_ = #{material,jdbcType=VARCHAR}, `desc` = #{desc,jdbcType=VARCHAR}, max_person_count = #{maxPersonCount,jdbcType=INTEGER}, current_person_count = #{currentPersonCount,jdbcType=INTEGER}, state = #{state,jdbcType=INTEGER}, state_remarks = #{stateRemarks,jdbcType=VARCHAR}, pre_finish_time = #{preFinishTime,jdbcType=TIMESTAMP}, actual_finish_time = #{actualFinishTime,jdbcType=TIMESTAMP}, pre_open_time = #{preOpenTime,jdbcType=TIMESTAMP}, actual_open_time = #{actualOpenTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP} ,pre_start_time =#{preStartTime,jdbcType=TIMESTAMP} ,actual_start_time =#{actualStartTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT}</update>
    <sql id="queryWhere">
        <if test="query.key!=null">and `name` like '${query.key}%'</if>
        <if test="query.appId!=null">and app_id=#{query.appId}</if>
        <if test="query.sponsorId!=null">and sponsor_id= #{query.sponsorId}</if>
        <if test="query.full!=null">
            <if test="query.full=true">and max_person_count=current_person_count</if>
        </if>
        <if test="query.stateList!=null">
            <foreach collection="query.stateList" item="state" open=" and (" close=")" separator=" or ">state=#{state}
            </foreach>
        </if>
 
        <if test="query.excludeActivityIds!=null">
            <foreach collection="query.excludeActivityIds" item="activityId" open=" and (" close=")" separator=" and ">id!=#{activityId}
            </foreach>
        </if>
 
        <if test="query.minCreateTime!=null">and create_time&gt;=#{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">and #{query.maxCreateTime}&gt;create_time</if>
        <if test="query.minStartTime!=null">and pre_start_time&gt;=#{query.minStartTime}</if>
        <if test="query.maxStartTime!=null">and #{query.maxStartTime}&gt;start_time</if>
        <if test="query.minFinishTime!=null">and pre_finish_time&gt;=#{query.minFinishTime}</if>
        <if test="query.maxFinishTime!=null">and #{query.maxFinishTime}&gt;pre_finish_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/>
        from lucky_activity where 1=1
        <include refid="queryWhere"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" separator="," open=" order by ">
                ${item}
            </foreach>
        </if>
        limit #{query.start},#{query.count}
    </select>
    <select id="count" resultType="java.lang.Long">select count(*) from lucky_activity where 1=1
        <include refid="queryWhere"/>
    </select>
    <update id="addJoinCount">update lucky_activity set current_person_count=current_person_count+#{joinCount} where id=#{activityId}</update>
</mapper>