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
<?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">
<!--namespace = 所需实现的接口全限定名-->
<mapper namespace="com.ruoyi.iot.mapper.DeviceOrderTimeMapper">
 
    <!--id = 所需重写的接口抽象方法,resultType = 查询后所需返回的对象类型-->
    <resultMap id="DeviceOrderTimeResult" type="DeviceOrderTime">
        <id property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="orderType" column="order_type"/>
        <result property="receiveTimeout" column="receive_timeout"/>
        <result property="finishTimeout" column="finish_timeout"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
 
    <select id="selectDeviceOrderTimeByUserId" resultMap="DeviceOrderTimeResult">
        select id,
               user_id,
               order_type,
               receive_timeout,
               finish_timeout,
               create_time,
               update_time
        from iot_device_ordertime
        where user_id = #{userId}
          and order_type = #{orderType}
    </select>
    <select id="selectDeviceOrderTimeoutById" resultMap="DeviceOrderTimeResult">
        select receive_timeout,finish_timeout
        from iot_device_ordertime
        <where>
            <if test="userId != null and userId != 0">
                and user_id = #{userId}
            </if>
            <if test="orderType != null and orderType != 0">
                and order_type = #{orderType}
            </if>
        </where>
    </select>
    <insert id="insertDeviceOrderTimeout" parameterType="DeviceOrderTime" useGeneratedKeys="true" keyProperty="id">
        insert into iot_device_ordertime(
        <if test="id != null">id,</if>
        <if test="userId != null and userId != 0">user_id,</if>
        <if test="orderType != null and orderType != 0">order_type,</if>
        <if test="receiveTimeout != null">receive_timeout,</if>
        <if test="finishTimeout != null">finish_timeout,</if>
        create_time)
        values (
        <if test="id != null and id != ''">#{id},</if>
        <if test="userId != null and userId != 0">#{userId},</if>
        <if test="orderType != null and orderType != 0">#{orderType},</if>
        <if test="receiveTimeout != null">#{receiveTimeout},</if>
        <if test="finishTimeout != null">#{finishTimeout},</if>
        sysdate())
    </insert>
    <update id="updateDeviceOrderTimeoutById" parameterType="DeviceOrderTime">
        update iot_device_ordertime
        <set>
            <if test="receiveTimeout != null">
                receive_timeout = #{receiveTimeout},
            </if>
            <if test="finishTimeout != null">
                finish_timeout = #{finishTimeout},
            </if>
            update_time = sysdate()
        </set>
        where user_id = #{userId} and order_type = #{orderType}
    </update>
</mapper>