liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?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="cn.com.basic.panel.entity.Cp_calendar_Agenda">
    <resultMap id="BaseResultMap" type="cn.com.basic.panel.entity.Cp_calendar_Agenda">
        <id column="id" property="id" jdbcType="VARCHAR" />
        <result column="content" property="title" jdbcType="VARCHAR" />
        <result column="starttime" property="start" jdbcType="VARCHAR" />
        <result column="endtime" property="end" jdbcType="VARCHAR" />
        <result column="allday" property="allday" jdbcType="VARCHAR" />
        <result column="color" property="color" jdbcType="VARCHAR" />
        <result column="userid" property="userid" jdbcType="VARCHAR" />
        <result column="is_valid" property="isValid" jdbcType="TINYINT" />
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="update_user_id" property="updateUserId" jdbcType="VARCHAR" />
        <result column="alarmtime" property="alarmtime" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">
        id, content, starttime, endtime, allday, color, userid,
        is_valid , update_time , update_user_id,alarmtime
    </sql>
    <sql id="myCalendarColumns">
        a.id AS "id",
        a.content AS "title",
        a.starttime AS "start",
        a.endtime AS "end",
        a.allday AS "allday",
        a.color AS "color",
        a.userid AS "userid",
        a.alarmtime as "alarmtime"
    </sql>
 
    <sql id="myCalendarJoins">
        LEFT JOIN t_sys_user user ON user.id = a.userid
    </sql>
 
    <sql id="Base_Where_Clause">
        <where>
            <trim prefixOverrides="and">
                <if test="id != null">and a.ID = #{id}</if>
                <if test="start != null">
                    and a.starttime = #{start,jdbcType=VARCHAR}
                </if>
                <if test="end != null">
                    and a.endtime = #{end,jdbcType=VARCHAR}
                </if>
                <if test="allday != null">
                    and a.allday = #{allday,jdbcType=VARCHAR}
                </if>
                <if test="userid != null">
                    and a.userid = #{userid,jdbcType=VARCHAR}
                </if>
                <if test="isValid != null">
                    and a.is_valid = #{isValid,jdbcType=TINYINT}
                </if>
                <if test="updateTime != null">
                    and a.update_time = #{updateTime,jdbcType=TIMESTAMP}
                </if>
                <if test="updateUserId != null">
                    and a.update_user_id = #{updateUserId,jdbcType=VARCHAR}
                </if>
            </trim>
        </where>
        <if test="sorting != null">order by ${sorting}</if>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </sql>
 
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from cp_calendar_agenda
        where id = #{id,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete from
        cp_calendar_agenda
        where id = #{id,jdbcType=VARCHAR}
    </delete>
    <insert id="insert" parameterType="cn.com.basic.panel.entity.Cp_calendar_Agenda">
        insert into cp_calendar_agenda
        (id, content, starttime,
        endtime, allday, color,
        userid,is_valid,update_time,update_user_id,alarmtime)
        values
        (#{id,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
        #{start,jdbcType=VARCHAR},
        #{end,jdbcType=VARCHAR},
        #{allday,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR},
        #{userid,jdbcType=VARCHAR},#{isValid,jdbcType=TINYINT},#{updateTime,jdbcType=VARCHAR},#{updateUserId,jdbcType=VARCHAR},#{alarmtime,jdbcType=VARCHAR})
    </insert>
 
    <update id="updateByIdSelective" parameterType="cn.com.basic.panel.entity.Cp_calendar_Agenda">
        update cp_calendar_agenda
        <set>
            <if test="title != null">
                content = #{title,jdbcType=VARCHAR},
            </if>
            <if test="start != null">
                starttime = #{start,jdbcType=VARCHAR},
            </if>
            <if test="end != null">
                endtime = #{end,jdbcType=VARCHAR},
            </if>
            <if test="allday != null">
                allday = #{allday,jdbcType=VARCHAR},
            </if>
            <if test="color != null">
                color = #{color,jdbcType=VARCHAR},
            </if>
            <if test="userid != null">
                userid = #{userid,jdbcType=VARCHAR},
            </if>
            <if test="isValid != null">
                is_valid = #{isValid,jdbcType=TINYINT},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUserId != null">
                update_user_id = #{updateUserId,jdbcType=VARCHAR},
            </if>
            <if test="alarmtime != null">
                alarmtime = #{alarmtime,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="cn.com.basic.panel.entity.Cp_calendar_Agenda">
        update
        cp_calendar_agenda
        set content = #{content,jdbcType=VARCHAR},
        starttime
        = #{start,jdbcType=VARCHAR},
        endtime = #{end,jdbcType=VARCHAR},
        allday = #{allday,jdbcType=VARCHAR},
        color = #{color,jdbcType=VARCHAR},
        userid = #{userid,jdbcType=VARCHAR},
        is_valid = #{isValid,jdbcType=TINYINT},
        update_time = #{updateTime,jdbcType=VARCHAR},
        update_user_id = #{updateUserId,jdbcType=VARCHAR},
        alarmtime = #{alarmtime,jdbcType=VARCHAR}
        where id
        = #{id,jdbcType=VARCHAR}
    </update>
 
    <select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
        SELECT
        <include refid="myCalendarColumns" />
        FROM cp_calendar_agenda a
        <include refid="myCalendarJoins" />
        <include refid="Base_Where_Clause" />
    </select>
 
    <select id="selectAll" resultMap="BaseResultMap" parameterType="java.util.Map">
        SELECT
        <include refid="myCalendarColumns" />
        FROM cp_calendar_agenda a
        <include refid="myCalendarJoins" />
        <include refid="Base_Where_Clause" />
    </select>
    
    <!-- 查询我接收的通知 start-->
    <select id="selectCalendarCount" resultType="java.lang.Long"
        parameterType="java.util.Map">
        select count(a.id)
        from cp_calendar_agenda a
        <include refid="Base_Where_Clause" />
    </select>
 
    <select id="selectPageCalendar" resultMap="BaseResultMap"
        parameterType="java.util.Map">
        select <include refid="myCalendarColumns" />
        from cp_calendar_agenda a inner join (select a.id from cp_calendar_agenda a
        
        <include refid="Base_Where_Clause" />
        ) b on b.id = a.id
 
    </select>
 
</mapper>