<?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.CompanyserviceDetailMapper">
    
    <resultMap type="CompanyserviceDetail" id="CompanyserviceDetailResult">
        <result property="id"    column="id"    />
        <result property="companyId"    column="company_id"    />
        <result property="isDefault"    column="is_default"    />
        <result property="clerk"    column="clerk"    />
        <result property="checker"    column="checker"    />
        <result property="payee"    column="payee"    />
        <result property="fjh"    column="fjh"    />
        <result property="terminalNumber"    column="terminal_number"    />
        <result property="goldenTaxDiskNo"    column="golden_tax_disk_no"    />
        <result property="clientIp"    column="client_ip"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="udpateTime"    column="udpate_time"    />
    </resultMap>

    <sql id="selectCompanyserviceDetailVo">
        select id, company_id, is_default, clerk, checker, payee, fjh, terminal_number, golden_tax_disk_no,client_ip, create_by, create_time, update_by, udpate_time from companyservice_detail
    </sql>

    <select id="selectCompanyserviceDetailList" parameterType="CompanyserviceDetail" resultMap="CompanyserviceDetailResult">
        <include refid="selectCompanyserviceDetailVo"/>
        <where>  
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="isDefault != null "> and is_default = #{isDefault}</if>
        </where>
    </select>
    
    <select id="selectCompanyserviceDetailById" parameterType="Long" resultMap="CompanyserviceDetailResult">
        <include refid="selectCompanyserviceDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCompanyserviceDetail" parameterType="CompanyserviceDetail" useGeneratedKeys="true" keyProperty="id">
        insert into companyservice_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="companyId != null">company_id,</if>
            <if test="isDefault != null">is_default,</if>
            <if test="clerk != null">clerk,</if>
            <if test="checker != null">checker,</if>
            <if test="payee != null">payee,</if>
            <if test="fjh != null">fjh,</if>
            <if test="terminalNumber != null">terminal_number,</if>
            <if test="goldenTaxDiskNo != null">golden_tax_disk_no,</if>
            <if test="clientIp != null">client_ip,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="udpateTime != null">udpate_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="companyId != null">#{companyId},</if>
            <if test="isDefault != null">#{isDefault},</if>
            <if test="clerk != null">#{clerk},</if>
            <if test="checker != null">#{checker},</if>
            <if test="payee != null">#{payee},</if>
            <if test="fjh != null">#{fjh},</if>
            <if test="terminalNumber != null">#{terminalNumber},</if>
            <if test="goldenTaxDiskNo != null">#{goldenTaxDiskNo},</if>
            <if test="clientIp != null">#{clientIp},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="udpateTime != null">#{udpateTime},</if>
         </trim>
    </insert>

    <update id="updateCompanyserviceDetail" parameterType="CompanyserviceDetail">
        update companyservice_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="isDefault != null">is_default = #{isDefault},</if>
            <if test="clerk != null">clerk = #{clerk},</if>
            <if test="checker != null">checker = #{checker},</if>
            <if test="payee != null">payee = #{payee},</if>
            <if test="fjh != null">fjh = #{fjh},</if>
            <if test="terminalNumber != null">terminal_number = #{terminalNumber},</if>
            <if test="goldenTaxDiskNo != null">golden_tax_disk_no = #{goldenTaxDiskNo},</if>
            <if test="clientIp != null">client_ip = #{clientIp},</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="udpateTime != null">udpate_time = #{udpateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCompanyserviceDetailById" parameterType="Long">
        delete from companyservice_detail where id = #{id}
    </delete>

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