<?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.tmerclub.cloud.platform.mapper.SysConfigMapper">
  <resultMap id="sysConfigMap" type="com.tmerclub.cloud.platform.model.SysConfig">
    <id column="id" property="id" />
    <result column="param_key" property="paramKey"/>
    <result column="param_value" property="paramValue"/>
    <result column="remark" property="remark"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `id`,`param_key`,`param_value`,`remark`
  </sql>

  <select id="countByKey" resultType="int">
    select ifnull(count(*),0) from sys_config where param_key = #{paramKey}
  </select>

  <insert id="save">
    insert into sys_config (`param_key`,`param_value`,`remark`)
    values (#{sysConfig.paramKey},#{sysConfig.paramValue},#{sysConfig.remark});
  </insert>
  <update id="update">
    update sys_config
    <set>
      <if test="sysConfig.paramKey != null">
        `param_key` = #{sysConfig.paramKey},
      </if>
      <if test="sysConfig.paramValue != null">
        `param_value` = #{sysConfig.paramValue},
      </if>
      <if test="sysConfig.remark != null">
        `remark` = #{sysConfig.remark},
      </if>
    </set>
    where param_key = #{sysConfig.paramKey}
  </update>
  <update id="updateValueByKey">
    update sys_config set param_value = #{value} where param_key = #{key}
  </update>

    <!-- 根据key，查询value -->
  <select id="queryByKey" resultType="com.tmerclub.cloud.platform.model.SysConfig">
      select * from sys_config where param_key = #{key}
  </select>

</mapper>
