<?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.lemon.lifecenter.mapper.StaffMapper">
    
    <select id="selectMemberCount" parameterType="StaffDTO" resultType="int">
        <![CDATA[
            SELECT COUNT(*) AS cnt
              FROM MEMBER
             WHERE 1 = 1
               AND id = #{id}
               AND password = #{password}
        ]]>
    </select>
    
    <insert id="insertMember" parameterType="StaffDTO" useGeneratedKeys="true">
        <![CDATA[
            INSERT INTO MEMBER
                        (ID,    PASSWORD,    CREATE_DATE, NAME,    PHONE_NUMBER,   GROUP_IDX,   CENTER_CODE)
                  VALUE (#{id}, #{password}, NOW(),       #{name}, #{phoneNumber}, #{groupIdx}, #{centerCode})
        ]]>
    </insert>
    
    <update id="updateMember" parameterType="StaffDTO">
        <![CDATA[
            UPDATE MEMBER
               SET NAME = #{name},
        ]]>
        <if test='password != null and password != ""'>
        <![CDATA[
                   PASSWORD = #{password}
        ]]>
        </if>
        <![CDATA[
                   PHONE_NUMBER = #{phoneNumber}
             WHERE id = #{id}
        ]]>
    </update>
</mapper>