<?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.jkcredit.invoice.hub.mapper.ContractMapper">
    <resultMap id="baseResultMap" type="com.jkcredit.invoice.hub.model.po.contract.ContractPo">
        <id column="id" property="id"/>
        <result column="company_num" property="companyNum"/>
        <result column="service_start_time" property="serviceStartTime"/>
        <result column="service_type" property="serviceType"/>
        <result column="service_end_time" property="serviceEndTime"/>
        <result column="contract_file_name" property="contractFileName"/>
        <result column="base64_str" property="base64Str"/>
        <result column="contract_num" property="contractNum"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="activated" property="activated"/>
        <result column="company_name" property="companyName"/>
    </resultMap>

    <select id="getContracts" resultMap="baseResultMap">
        select * from
        h_contract contract
        <where>
            and contract.activated = 1
            <if test="query.companyNum != null and query.companyNum != ''">
                and contract.company_num = #{query.companyNum}
            </if>
            <if test="query.companyName != null and query.companyName != ''">
                and contract.company_name = #{query.companyName}
            </if>
        </where>
    </select>
</mapper>
