<?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.colums.YjHealthyMapper">
    
    <resultMap type="YjHealthy" id="YjHealthyResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="image"    column="image"    />
        <result property="readNum"    column="read_num"    />
        <result property="startTime"    column="start_time"    />
        <result property="content"    column="content"    />
        <result property="status"    column="status"    />
        <result property="modifyTime"    column="modify_time"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="selectYjHealthyVo">
        select
            yj_healthy.id,
            yj_healthy.title,
            yj_healthy.image,
            yj_healthy.read_num,
            yj_healthy.start_time,
            yj_healthy.content,
            yj_healthy.status,
            yj_healthy.modify_time,
            yj_healthy.dept_id
        from yj_healthy left join sys_dept on yj_healthy.dept_id = sys_dept.dept_id
    </sql>

    <select id="selectYjHealthyList" parameterType="YjHealthy" resultMap="YjHealthyResult">
        <include refid="selectYjHealthyVo"/>
        <where>
            <if test="title != null  and title != ''"> and yj_healthy.title = #{title}</if>
            <if test="image != null  and image != ''"> and yj_healthy.image = #{image}</if>
            <if test="readNum != null "> and yj_healthy.read_num = #{readNum}</if>
            <if test="startTime != null "> and yj_healthy.start_time = #{startTime}</if>
            <if test="content != null  and content != ''"> and yj_healthy.content = #{content}</if>
            <if test="status != null "> and yj_healthy.status = #{status}</if>
            <if test="modifyTime != null "> and yj_healthy.modify_time = #{modifyTime}</if>
            <if test="deptId != null "> and yj_healthy.dept_id = #{deptId}</if>
            <if test="tenantId != null "> and sys_dept.tenant_id = #{tenantId}</if>
        </where>
    </select>

    <select id="selectYjHealthyById" parameterType="String" resultMap="YjHealthyResult">
        <include refid="selectYjHealthyVo"/>
        where yj_healthy.id = #{id}
    </select>

    <insert id="insertYjHealthy" parameterType="YjHealthy">
        insert into yj_healthy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="title != null">title,</if>
            <if test="image != null">image,</if>
            <if test="readNum != null">read_num,</if>
            <if test="startTime != null">start_time,</if>
            <if test="content != null">content,</if>
            <if test="status != null">status,</if>
            <if test="modifyTime != null">modify_time,</if>
            <if test="deptId != null">dept_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="title != null">#{title},</if>
            <if test="image != null">#{image},</if>
            <if test="readNum != null">#{readNum},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="content != null">#{content},</if>
            <if test="status != null">#{status},</if>
            <if test="modifyTime != null">#{modifyTime},</if>
            <if test="deptId != null">#{deptId},</if>
        </trim>
    </insert>

    <update id="updateYjHealthy" parameterType="YjHealthy">
        update yj_healthy
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="image != null">image = #{image},</if>
            <if test="readNum != null">read_num = #{readNum},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="content != null">content = #{content},</if>
            <if test="status != null">status = #{status},</if>
            <if test="modifyTime != null">modify_time = #{modifyTime},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
        </trim>
        where yj_healthy.id = #{id}
    </update>

    <delete id="deleteYjHealthyById" parameterType="String">
        delete from yj_healthy where yj_healthy.id = #{id}
    </delete>

    <delete id="deleteYjHealthyByIds" parameterType="String">
        delete from yj_healthy where yj_healthy.id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>