<?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.jianshui.system.mapper.CompanyservicePropMapper">

    <resultMap type="CompanyserviceProp" id="CompanyservicePropResult">
        <result property="companyid" column="companyid"/>
        <result property="key" column="key"/>
        <result property="value" column="value"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectCompanyservicePropVo">
        select companyid, `key`, `value`, remark
        from companyservice_prop
    </sql>

    <select id="selectCompanyservicePropList" parameterType="CompanyserviceProp" resultMap="CompanyservicePropResult">
        <include refid="selectCompanyservicePropVo"/>
        <where>
            <if test="companyid != null  and companyid != ''">and `companyid` = #{companyid}</if>
            <if test="key != null  and key != ''">and `key` = #{key}</if>
            <if test="value != null  and value != ''">and `value` = #{value}</if>
        </where>
    </select>

    <select id="selectCompanyservicePropByCompanyid" parameterType="Long" resultMap="CompanyservicePropResult">
        <include refid="selectCompanyservicePropVo"/>
        where companyid = #{companyid}
    </select>

    <insert id="insertCompanyserviceProp" parameterType="CompanyserviceProp">
        insert into companyservice_prop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyid != null">companyid,</if>
            <if test="key != null and key != ''">`key`,</if>
            <if test="value != null and value != ''">`value`,</if>
            <if test="remark != null and remark != ''">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyid != null">#{companyid},</if>
            <if test="key != null and key != ''">#{key},</if>
            <if test="value != null and value != ''">#{value},</if>
            <if test="remark != null and remark != ''">#{remark},</if>
        </trim>
    </insert>

    <update id="updateCompanyserviceProp" parameterType="CompanyserviceProp">
        update companyservice_prop
        <trim prefix="SET" suffixOverrides=",">
            <if test="value != null and value != ''">`value` = #{value},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
        </trim>
        where companyid = #{companyid} and `key` = #{key}
    </update>

    <delete id="deleteCompanyservicePropByCompanyid" parameterType="Long">
        delete
        from companyservice_prop
        where companyid = #{companyid}
    </delete>

    <delete id="deleteCompanyservicePropByCompanyids" parameterType="String">
        delete from companyservice_prop where companyid in
        <foreach item="companyid" collection="array" open="(" separator="," close=")">
            #{companyid}
        </foreach>
    </delete>

    <select id="selectPropByKey" resultMap="CompanyservicePropResult">
        <include refid="selectCompanyservicePropVo"/>
        where companyid = #{companyId} and `key` = #{key}
    </select>




</mapper>