kongdeqiang
2023-07-10 96f927cb94eec4a91df60973d4052cb812856e13
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
<?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.wgcloud.mapper.InspectionTaskMapper">
    <resultMap id="resultMap" type="com.wgcloud.entity.InspectionTask">
        <id column="ID" property="id" jdbcType="CHAR" />
        <result column="TITLE" property="title" jdbcType="CHAR" />
        <result column="TYPE" property="type" jdbcType="CHAR" />
        <result column="PERIOD" property="period" jdbcType="CHAR" />
        <result column="SCOPE" property="scope" jdbcType="CHAR" />
        <result column="START_DATE" property="startDate" jdbcType="CHAR" />
        <result column="END_DATE" property="endDate" jdbcType="CHAR" />
        <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
        <result column="IS_OK" property="isOk" jdbcType="CHAR" />
    </resultMap>
 
    <sql id="tableColumnList">
        ID,TITLE, TYPE, PERIOD, SCOPE, START_DATE,END_DATE,CREATE_TIME,IS_OK
    </sql>
 
    <sql id="queryByParams">
        <if test="title != null">
            <![CDATA[ AND TITLE like '%'+#{title}+'%' ]]>
        </if>
        <if test="isOk != null">
            <![CDATA[ AND IS_OK = #{isOk}  ]]>
        </if>
    </sql>
 
    <update id="updateById" parameterType="com.wgcloud.entity.InspectionTask">
        UPDATE INSPECTION_TASK
        <set>
            <if test="title != null">
                TITLE = #{title},
            </if>
            <if test="type != null">
                TYPE = #{type},
            </if>
            <if test="period != null">
                PERIOD = #{period},
            </if>
            <if test="scope != null">
                SCOPE = #{scope},
            </if>
            <if test="startDate != null">
                START_DATE = #{startDate},
            </if>
            <if test="endDate != null">
                END_DATE = #{endDate},
            </if>
            <if test="createTime != null">
                CREATE_TIME = #{createTime},
            </if>
            <if test="isOk != null">
                IS_OK = #{isOk},
            </if>
        </set>
        WHERE ID = #{id}
    </update>
 
 
    <select id="selectById" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
        <include refid="tableColumnList" />
        FROM INSPECTION_TASK WHERE ID=#{id}
    </select>
 
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        DELETE FROM INSPECTION_TASK WHERE ID = #{id}
    </delete>
 
    <delete id="deleteByAccountAndDate"  parameterType="map">
        DELETE FROM INSPECTION_TASK WHERE
        <if test="_databaseId == 'mysql'">
            <![CDATA[  CREATE_TIME <=#{endTime}]]>
        </if>
        <if test="_databaseId == 'postgresql'">
            <![CDATA[  CREATE_TIME <= cast(#{endTime} as timestamp)]]>
        </if>
    </delete>
 
 
    <delete id="deleteById" parameterType="java.lang.String">
        DELETE FROM INSPECTION_TASK WHERE ID IN
        <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
 
    <insert id="insertList" parameterType="java.util.List" >
          INSERT INTO INSPECTION_TASK (ID,TITLE, TYPE, PERIOD, SCOPE, START_DATE,END_DATE,CREATE_TIME,IS_OK)  VALUES
          <foreach collection="list" item="item" index="index" separator="," >
            (#{item.id},#{item.title},#{item.type},#{item.period},#{item.scope},#{item.startDate},#{item.endDate},#{item.createTime},#{item.isOk})
          </foreach>
     </insert>
 
    <insert id="save" parameterType="com.wgcloud.entity.IntrusionInfo">
        INSERT INTO INSPECTION_TASK
        <trim prefix="(" suffix=")" suffixOverrides="," >
              <if test="id != null" >ID,</if>
              <if test="title != null" > TITLE,</if>
              <if test="type != null">TYPE,</if>
              <if test="period != null" >PERIOD,</if>
              <if test="scope != null" >SCOPE,</if>
              <if test="startDate != null" >START_DATE,</if>
              <if test="endDate != null" >END_DATE,</if>
              <if test="createTime != null" >CREATE_TIME</if>
              <if test="isOk != null" >IS_OK</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
              <if test="id != null" >#{id},</if>
              <if test="title != null" >#{title},</if>
              <if test="type != null" >#{type},</if>
              <if test="period != null" >#{period},</if>
              <if test="scope != null" >#{scope},</if>
              <if test="startDate != null" >#{startDate},</if>
              <if test="endDate != null" >#{endDate},</if>
              <if test="createTime != null" >#{createTime}</if>
              <if test="isOk != null" >#{isOk}</if>
        </trim>
    </insert>
 
    <select id="selectByAccountId" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
            ID,TITLE, TYPE, PERIOD, SCOPE, START_DATE,END_DATE,CREATE_TIME,IS_OK
        FROM INSPECTION_TASK
    </select>
 
      <select id="selectAllByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
        FROM INSPECTION_TASK t
        <where>
            <include refid="queryByParams" />
        </where>
         ORDER BY CREATE_TIME DESC
    </select>
 
    <select id="selectByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
        FROM INSPECTION_TASK
        <where>
            <include refid="queryByParams" />
        </where>
         ORDER BY CREATE_TIME DESC
    </select>
 
    <select id="selectByDate" parameterType="map" resultType="com.wgcloud.entity.InspectionTask">
        SELECT
        <include refid="tableColumnList" />
        FROM INSPECTION_TASK
        <where>
        1=1
        <if test="startDate != null">
            AND START_DATE > #{startDate}+' 00:00:00',
        </if>
        <if test="endDate != null">
            <![CDATA[ and END_DATE < #{endDate}+' 23:59:59' ]]>
        </if>
        </where>
        ORDER BY CREATE_TIME DESC
    </select>
 
</mapper>