<?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.ruoyi.iot.mapper.TDevicePlanMapper">
    <!--     int insert(TDevicePlan tDevicePlan); -->
    <insert id="insert" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO t_device_plan (
        plan_type,status,create_time,run_time,
        repeat_days,repeat_time,user_id,device_id,ccid,port
        ) VALUES (
        #{planType}, #{status},#{createTime},#{runTime},
        #{repeatDays}, #{repeatTime}, #{userId}, #{deviceId},#{ccid},#{port}
        )
    </insert>

    <!-- List<TDevicePlanVO> ListByUserId(Long userId); -->
    <select id="ListByUserId" resultMap="ListResultMap">
        SELECT
        <include refid="ListQueryFields"/>
        FROM
        t_device_plan
        WHERE
        user_id=#{usreId}
    </select>
    <sql id="ListQueryFields">
        <if test="true">
            id, create_time, device_id, status, plan_type, repeat_days, repeat_time
        </if>
    </sql>

    <resultMap id="ListResultMap" type="com.ruoyi.iot.domain.vo.TDevicePlanVO">
        <id column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="device_id" property="deviceId" />
        <result column="status" property="status" />
        <result column="plan_type" property="planType" />
        <result column="repeat_days" property="repeatDays" />
        <result column="repeat_time" property="repeatTime" />
    </resultMap>
</mapper>
