<?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="cn.com.ty.lift.business.contract.dao.mapper.ContractsHistoryMapper">
    <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.contract.dao.entity.ContractsHistory">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT"/>
        <result column="contracts_id" property="contractsId" jdbcType="BIGINT"/>
        <result column="code" property="code" jdbcType="VARCHAR"/>
        <result column="description" property="description" jdbcType="VARCHAR"/>
        <result column="before_content" property="beforeContent" jdbcType="LONGVARCHAR"/>
        <result column="after_content" property="afterContent" jdbcType="LONGVARCHAR"/>
        <result column="operator_id" property="operatorId" jdbcType="BIGINT"/>
        <result column="operate_date" property="operateDate" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
		id, mt_company_id, contracts_id, code, description,before_content, after_content, operator_id, operate_date
	</sql>

    <select id="queryContractHistory" parameterType="java.lang.Long"
            resultType="cn.com.ty.lift.business.contract.dao.entity.model.response.ContractsHistoryResponse">
        SELECT ch.id,
               ch.contracts_id,
               ch.code,
               ch.description,
               ch.before_content,
               ch.after_content,
               ch.operator_id,
               ch.operate_date,
               ui.name AS operatorName
        FROM contracts_history ch
                 LEFT JOIN user_info ui ON ch.operator_id = ui.user_id
        WHERE contracts_id = #{contractId}
    </select>

</mapper>