<?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.ga.common.system.SystemConfigMapper">

    <resultMap id="ConfigMap" type="com.ga.common.system.SystemConfigVO"/>

    <select id="selectAll" resultMap="ConfigMap">
        SELECT * FROM system_config ORDER BY config_group, config_key
    </select>

    <select id="selectByGroup" resultMap="ConfigMap">
        SELECT * FROM system_config WHERE config_group = #{configGroup} ORDER BY config_key
    </select>

    <select id="selectByKey" resultMap="ConfigMap">
        SELECT * FROM system_config WHERE config_key = #{configKey}
    </select>

    <update id="update" parameterType="com.ga.common.system.SystemConfigVO">
        UPDATE system_config SET
            config_value = #{configValue},
            updated_at   = #{updatedAt},
            updated_by   = #{updatedBy}
        WHERE config_key = #{configKey} AND is_editable = 'Y'
    </update>

</mapper>
