<?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.system.mapper.StUserMapper">
    
    <resultMap type="StUser" id="StUserResult">
        <result property="userId"    column="user_id"    />
        <result property="seOnlineTime"    column="se_online_time"    />
        <result property="thOnlineTime"    column="th_online_time"    />
        <result property="seMrTime"    column="se_mr_time"    />
        <result property="thMrTime"    column="th_mr_time"    />
        <result property="seConsumption"    column="se_consumption"    />
        <result property="thConsumption"    column="th_consumption"    />
        <result property="seWork"    column="se_work"    />
        <result property="thWork"    column="th_work"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="date"    column="date"    />
    </resultMap>

    <sql id="selectStUserVo">
        select user_id, se_online_time, th_online_time, se_mr_time, th_mr_time, se_consumption, th_consumption, se_work, th_work, create_time, update_time, date from st_user
    </sql>

    <select id="selectStUserList" parameterType="StUser" resultMap="StUserResult">
        <include refid="selectStUserVo"/>
        <where>  
            <if test="seOnlineTime != null "> and se_online_time = #{seOnlineTime}</if>
            <if test="thOnlineTime != null "> and th_online_time = #{thOnlineTime}</if>
            <if test="seMrTime != null "> and se_mr_time = #{seMrTime}</if>
            <if test="thMrTime != null "> and th_mr_time = #{thMrTime}</if>
            <if test="seConsumption != null "> and se_consumption = #{seConsumption}</if>
            <if test="thConsumption != null "> and th_consumption = #{thConsumption}</if>
            <if test="seWork != null "> and se_work = #{seWork}</if>
            <if test="thWork != null "> and th_work = #{thWork}</if>
            <if test="date != null "> and date = #{date}</if>
        </where>
    </select>
    
    <select id="selectStUserByUserId" parameterType="Long" resultMap="StUserResult">
        <include refid="selectStUserVo"/>
        where user_id = #{userId}
    </select>

    <select id="getAllUserIds" resultType="java.lang.Long">
        select user_id from st_user
    </select>
        
    <insert id="insertStUser" parameterType="StUser" useGeneratedKeys="true" keyProperty="userId">
        insert into st_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="seOnlineTime != null">se_online_time,</if>
            <if test="thOnlineTime != null">th_online_time,</if>
            <if test="seMrTime != null">se_mr_time,</if>
            <if test="thMrTime != null">th_mr_time,</if>
            <if test="seConsumption != null">se_consumption,</if>
            <if test="thConsumption != null">th_consumption,</if>
            <if test="seWork != null">se_work,</if>
            <if test="thWork != null">th_work,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="date != null">date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="seOnlineTime != null">#{seOnlineTime},</if>
            <if test="thOnlineTime != null">#{thOnlineTime},</if>
            <if test="seMrTime != null">#{seMrTime},</if>
            <if test="thMrTime != null">#{thMrTime},</if>
            <if test="seConsumption != null">#{seConsumption},</if>
            <if test="thConsumption != null">#{thConsumption},</if>
            <if test="seWork != null">#{seWork},</if>
            <if test="thWork != null">#{thWork},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="date != null">#{date},</if>
         </trim>
    </insert>

    <update id="updateStUser" parameterType="StUser">
        update st_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="seOnlineTime != null">se_online_time = #{seOnlineTime},</if>
            <if test="thOnlineTime != null">th_online_time = #{thOnlineTime},</if>
            <if test="seMrTime != null">se_mr_time = #{seMrTime},</if>
            <if test="thMrTime != null">th_mr_time = #{thMrTime},</if>
            <if test="seConsumption != null">se_consumption = #{seConsumption},</if>
            <if test="thConsumption != null">th_consumption = #{thConsumption},</if>
            <if test="seWork != null">se_work = #{seWork},</if>
            <if test="thWork != null">th_work = #{thWork},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="date != null">date = #{date},</if>
        </trim>
        where user_id = #{userId}
    </update>

    <delete id="deleteStUserByUserId" parameterType="Long">
        delete from st_user where user_id = #{userId}
    </delete>

    <delete id="deleteStUserByUserIds" parameterType="String">
        delete from st_user where user_id in 
        <foreach item="userId" collection="array" open="(" separator="," close=")">
            #{userId}
        </foreach>
    </delete>
</mapper>