<?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.WebConfigMapper">
  <resultMap id="webConfigMap" type="com.tmerclub.cloud.platform.model.WebConfig">
    <id column="id" property="id" />
    <result column="config_type" property="configType"/>
    <result column="is_activity" property="isActivity"/>
    <result column="login_logo_img" property="loginLogoImg"/>
    <result column="login_bg_img" property="loginBgImg"/>
    <result column="copyright_cn" property="copyrightCn"/>
    <result column="copyright_en" property="copyrightEn"/>
    <result column="title_content_cn" property="titleContentCn"/>
    <result column="title_content_en" property="titleContentEn"/>
    <result column="title_img" property="titleImg"/>
    <result column="bs_menu_title_open_cn" property="bsMenuTitleOpenCn"/>
    <result column="bs_menu_title_open_en" property="bsMenuTitleOpenEn"/>
    <result column="bs_menu_title_close_cn" property="bsMenuTitleCloseCn"/>
    <result column="bs_menu_title_close_en" property="bsMenuTitleCloseEn"/>
    <result column="bs_top_bar_icon" property="bsTopBarIcon"/>
    <result column="pc_qrcode_img" property="pcQrcodeImg"/>
    <result column="pc_company_name_cn" property="pcCompanyNameCn"/>
    <result column="pc_company_name_en" property="pcCompanyNameEn"/>
    <result column="pc_company_name_short_cn" property="pcCompanyNameShortCn"/>
    <result column="pc_company_name_short_en" property="pcCompanyNameShortEn"/>
    <result column="pc_logo_img_text" property="pcLogoImgText"/>
    <result column="pc_welcome_cn" property="pcWelcomeCn"/>
    <result column="pc_welcome_en" property="pcWelcomeEn"/>
    <result column="pc_company_info_cn" property="pcCompanyInfoCn"/>
    <result column="pc_company_info_en" property="pcCompanyInfoEn"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `id`,`config_type`,`is_activity`,`login_logo_img`,`login_bg_img`,`copyright_cn`,`copyright_en`,`title_content_cn`,`title_content_en`,`title_img`,`bs_menu_title_open_cn`,`bs_menu_title_open_en`,`bs_menu_title_close_cn`,`bs_menu_title_close_en`,`bs_top_bar_icon`,`pc_qrcode_img`,`pc_company_name_cn`,`pc_company_name_en`,`pc_company_name_short_cn`,`pc_company_name_short_en`,`pc_logo_img_text`,`pc_welcome_cn`,`pc_welcome_en`,`pc_company_info_cn`,`pc_company_info_en`
  </sql>
  <select id="list" resultMap="webConfigMap">
    select <include refid="Vo_Column_List"/>
    from web_config where config_type = #{webConfig.configType} order by id desc
  </select>
  <select id="getById" resultMap="webConfigMap">
    select <include refid="Vo_Column_List"/> from web_config where id = #{id}
  </select>
  <insert id="save">
    insert into web_config (`config_type`,`is_activity`,`login_logo_img`,`login_bg_img`,`copyright_cn`,`copyright_en`,`title_content_cn`,`title_content_en`,`title_img`,`bs_menu_title_open_cn`,`bs_menu_title_open_en`,`bs_menu_title_close_cn`,`bs_menu_title_close_en`,`bs_top_bar_icon`,`pc_qrcode_img`,`pc_company_name_cn`,`pc_company_name_en`,`pc_company_name_short_cn`,`pc_company_name_short_en`,`pc_logo_img_text`,`pc_welcome_cn`,`pc_welcome_en`,`pc_company_info_cn`,`pc_company_info_en`)
    values (#{webConfig.configType},#{webConfig.isActivity},#{webConfig.loginLogoImg},#{webConfig.loginBgImg},#{webConfig.copyrightCn},#{webConfig.copyrightEn},#{webConfig.titleContentCn},#{webConfig.titleContentEn},#{webConfig.titleImg},#{webConfig.bsMenuTitleOpenCn},#{webConfig.bsMenuTitleOpenEn},#{webConfig.bsMenuTitleCloseCn},#{webConfig.bsMenuTitleCloseEn},#{webConfig.bsTopBarIcon},#{webConfig.pcQrcodeImg},#{webConfig.pcCompanyNameCn},#{webConfig.pcCompanyNameEn},#{webConfig.pcCompanyNameShortCn},#{webConfig.pcCompanyNameShortEn},#{webConfig.pcLogoImgText},#{webConfig.pcWelcomeCn},#{webConfig.pcWelcomeEn},#{webConfig.pcCompanyInfoCn},#{webConfig.pcCompanyInfoEn});
  </insert>
  <update id="update">
    update web_config
    <set>
      <if test="webConfig.configType != null">
        `config_type` = #{webConfig.configType},
      </if>
      <if test="webConfig.isActivity != null">
        `is_activity` = #{webConfig.isActivity},
      </if>
      <if test="webConfig.loginLogoImg != null">
        `login_logo_img` = #{webConfig.loginLogoImg},
      </if>
      <if test="webConfig.loginBgImg != null">
        `login_bg_img` = #{webConfig.loginBgImg},
      </if>
      <if test="webConfig.copyrightCn != null">
        `copyright_cn` = #{webConfig.copyrightCn},
      </if>
      <if test="webConfig.copyrightEn != null">
        `copyright_en` = #{webConfig.copyrightEn},
      </if>
      <if test="webConfig.titleContentCn != null">
        `title_content_cn` = #{webConfig.titleContentCn},
      </if>
      <if test="webConfig.titleContentEn != null">
        `title_content_en` = #{webConfig.titleContentEn},
      </if>
      <if test="webConfig.titleImg != null">
        `title_img` = #{webConfig.titleImg},
      </if>
      <if test="webConfig.bsMenuTitleOpenCn != null">
        `bs_menu_title_open_cn` = #{webConfig.bsMenuTitleOpenCn},
      </if>
      <if test="webConfig.bsMenuTitleOpenEn != null">
        `bs_menu_title_open_en` = #{webConfig.bsMenuTitleOpenEn},
      </if>
      <if test="webConfig.bsMenuTitleCloseCn != null">
        `bs_menu_title_close_cn` = #{webConfig.bsMenuTitleCloseCn},
      </if>
      <if test="webConfig.bsMenuTitleCloseEn != null">
        `bs_menu_title_close_en` = #{webConfig.bsMenuTitleCloseEn},
      </if>
      <if test="webConfig.bsTopBarIcon != null">
        `bs_top_bar_icon` = #{webConfig.bsTopBarIcon},
      </if>
      <if test="webConfig.pcQrcodeImg != null">
        `pc_qrcode_img` = #{webConfig.pcQrcodeImg},
      </if>
      <if test="webConfig.pcCompanyNameCn != null">
        `pc_company_name_cn` = #{webConfig.pcCompanyNameCn},
      </if>
      <if test="webConfig.pcCompanyNameEn != null">
        `pc_company_name_en` = #{webConfig.pcCompanyNameEn},
      </if>
      <if test="webConfig.pcCompanyNameShortCn != null">
        `pc_company_name_short_cn` = #{webConfig.pcCompanyNameShortCn},
      </if>
      <if test="webConfig.pcCompanyNameShortEn != null">
        `pc_company_name_short_en` = #{webConfig.pcCompanyNameShortEn},
      </if>
      <if test="webConfig.pcLogoImgText != null">
        `pc_logo_img_text` = #{webConfig.pcLogoImgText},
      </if>
      <if test="webConfig.pcWelcomeCn != null">
        `pc_welcome_cn` = #{webConfig.pcWelcomeCn},
      </if>
      <if test="webConfig.pcWelcomeEn != null">
        `pc_welcome_en` = #{webConfig.pcWelcomeEn},
      </if>
      <if test="webConfig.pcCompanyInfoCn != null">
        `pc_company_info_cn` = #{webConfig.pcCompanyInfoCn},
      </if>
      <if test="webConfig.pcCompanyInfoEn != null">
        `pc_company_info_en` = #{webConfig.pcCompanyInfoEn},
      </if>
    </set>
    where id = #{webConfig.id}
  </update>
  <delete id="deleteById">
    delete from web_config where id = #{id}
  </delete>
  <update id="updateActivityState">
    update web_config set is_activity = 0 where config_type = #{configType} and is_activity = 1
  </update>
  <select id="getByType" resultType="com.tmerclub.cloud.platform.vo.WebConfigVO">
    select <include refid="Vo_Column_List"/> from web_config where is_activity = 1 and config_type = #{configType}
  </select>
  <select id="countByType" resultType="int">
    select count(id) from web_config where is_activity = 1 and config_type = #{configType}
  </select>
</mapper>
