付延余
2022-12-16 f0f8ee8c4a945adbc742d9bab69382b28ad311fb
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
<?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" />
    </resultMap>
 
    <sql id="tableColumnList">
        ID,TITLE, TYPE, PERIOD, SCOPE, START_DATE,END_DATE,CREATE_TIME
    </sql>
 
    <sql id="queryByParams">
        <if test="TITLE != null">
            <![CDATA[ AND TITLE like '%'+#{title}+'%' ]]>
        </if>
    </sql>
 
 
    <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)  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})
          </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>
        </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>
        </trim>
    </insert>
 
    <select id="selectByAccountId" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
            ID,TITLE, TYPE, PERIOD, SCOPE, START_DATE,END_DATE,CREATE_TIME
        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>
 
</mapper>