<?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.SqmyInfoMapper">
    
    <resultMap type="SqmyInfo" id="SqmyInfoResult">
        <result property="sqmyId"    column="sqmy_id"    />
        <result property="sqmyUserId"    column="sqmy_user_id"    />
        <result property="title"    column="title"    />
        <result property="titleType"    column="title_type"    />
        <result property="proposalContent"    column="proposal_content"    />
        <result property="contactName"    column="contact_name"    />
        <result property="contactPhone"    column="contact_phone"    />
        <result property="sqmyName"    column="sqmy_name"    />
        <result property="sqmyPhone"    column="sqmy_phone"    />
        <result property="unit"    column="unit"    />
        <result property="isPublicity"    column="is_publicity"    />
        <result property="isSecret"    column="is_secret"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSqmyInfoVo">
        select sqmy_id, sqmy_user_id, title, title_type, proposal_content, contact_name, contact_phone, sqmy_name, sqmy_phone, unit, is_publicity, is_secret, create_by, create_time, update_by, update_time, remark from sqmy_info
    </sql>

    <select id="selectSqmyInfoList" parameterType="SqmyInfo" resultMap="SqmyInfoResult">
        <include refid="selectSqmyInfoVo"/>
        <where>  
            <if test="sqmyUserId != null "> and sqmy_user_id = #{sqmyUserId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="titleType != null  and titleType != ''"> and title_type = #{titleType}</if>
            <if test="proposalContent != null  and proposalContent != ''"> and proposal_content = #{proposalContent}</if>
            <if test="contactName != null  and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
            <if test="sqmyName != null  and sqmyName != ''"> and sqmy_name like concat('%', #{sqmyName}, '%')</if>
            <if test="sqmyPhone != null  and sqmyPhone != ''"> and sqmy_phone = #{sqmyPhone}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="isPublicity != null  and isPublicity != ''"> and is_publicity = #{isPublicity}</if>
            <if test="isSecret != null  and isSecret != ''"> and is_secret = #{isSecret}</if>
        </where>
    </select>
    
    <select id="selectSqmyInfoBySqmyId" parameterType="Long" resultMap="SqmyInfoResult">
        <include refid="selectSqmyInfoVo"/>
        where sqmy_id = #{sqmyId}
    </select>
        
    <insert id="insertSqmyInfo" parameterType="SqmyInfo" useGeneratedKeys="true" keyProperty="sqmyId">
        insert into sqmy_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sqmyUserId != null">sqmy_user_id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="titleType != null">title_type,</if>
            <if test="proposalContent != null">proposal_content,</if>
            <if test="contactName != null and contactName != ''">contact_name,</if>
            <if test="contactPhone != null and contactPhone != ''">contact_phone,</if>
            <if test="sqmyName != null and sqmyName != ''">sqmy_name,</if>
            <if test="sqmyPhone != null and sqmyPhone != ''">sqmy_phone,</if>
            <if test="unit != null">unit,</if>
            <if test="isPublicity != null">is_publicity,</if>
            <if test="isSecret != null">is_secret,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sqmyUserId != null">#{sqmyUserId},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="titleType != null">#{titleType},</if>
            <if test="proposalContent != null">#{proposalContent},</if>
            <if test="contactName != null and contactName != ''">#{contactName},</if>
            <if test="contactPhone != null and contactPhone != ''">#{contactPhone},</if>
            <if test="sqmyName != null and sqmyName != ''">#{sqmyName},</if>
            <if test="sqmyPhone != null and sqmyPhone != ''">#{sqmyPhone},</if>
            <if test="unit != null">#{unit},</if>
            <if test="isPublicity != null">#{isPublicity},</if>
            <if test="isSecret != null">#{isSecret},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateSqmyInfo" parameterType="SqmyInfo">
        update sqmy_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="sqmyUserId != null">sqmy_user_id = #{sqmyUserId},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="titleType != null">title_type = #{titleType},</if>
            <if test="proposalContent != null">proposal_content = #{proposalContent},</if>
            <if test="contactName != null and contactName != ''">contact_name = #{contactName},</if>
            <if test="contactPhone != null and contactPhone != ''">contact_phone = #{contactPhone},</if>
            <if test="sqmyName != null and sqmyName != ''">sqmy_name = #{sqmyName},</if>
            <if test="sqmyPhone != null and sqmyPhone != ''">sqmy_phone = #{sqmyPhone},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="isPublicity != null">is_publicity = #{isPublicity},</if>
            <if test="isSecret != null">is_secret = #{isSecret},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where sqmy_id = #{sqmyId}
    </update>

    <delete id="deleteSqmyInfoBySqmyId" parameterType="Long">
        delete from sqmy_info where sqmy_id = #{sqmyId}
    </delete>

    <delete id="deleteSqmyInfoBySqmyIds" parameterType="String">
        delete from sqmy_info where sqmy_id in 
        <foreach item="sqmyId" collection="array" open="(" separator="," close=")">
            #{sqmyId}
        </foreach>
    </delete>
</mapper>