<?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.ssm.manage.mapper.SsmMemberAgreementMapper">
    <resultMap id="baseMap" type="com.ssm.manage.entity.MemberAgreement">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="storeId" column="store_id" jdbcType="BIGINT"/>
        <result property="content" column="content" jdbcType="VARCHAR"/>
        <result property="addName" column="add_name" jdbcType="VARCHAR"/>
        <result property="addDate" column="add_date" jdbcType="TIMESTAMP"/>
        <result property="updateName" column="update_name" jdbcType="VARCHAR"/>
        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
        <result property="startName" column="start_name" jdbcType="VARCHAR"/>
        <result property="startDate" column="start_date" jdbcType="TIMESTAMP"/>
        <result property="endName" column="end_name" jdbcType="VARCHAR"/>
        <result property="endDate" column="end_date" jdbcType="TIMESTAMP"/>
        <result property="startState" column="start_state" jdbcType="INTEGER"/>
        <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
    </resultMap>
    <update id="updateState">
        update store_memberagreement set start_state = 0
    </update>
    <update id="updateStateByStartState" parameterType="com.ssm.manage.entity.MemberAgreement">
        update store_memberagreement set start_state = 1,start_name = #{startName},start_date = #{startDate} where id = #{id}
    </update>

    <select id="selectList" resultMap="baseMap" parameterType="com.ssm.manage.query.MemberAgreementRequest">
        select * from store_memberagreement
    </select>
    <select id="selectByMember" resultMap="baseMap">
        select * from store_memberagreement where start_state = 1 limit 1
    </select>
</mapper>