<?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.im.mapper.ImMsgBizSkillsMapper">
  <resultMap id="imMsgBizSkillsMap" type="com.tmerclub.cloud.im.model.ImMsgBizSkills">
    <id column="id" property="id" />
    <result column="shop_id" property="shopId"/>
    <result column="keywords" property="keywords"/>
    <result column="content" property="content"/>
    <result column="status" property="status"/>
    <result column="remark" property="remark"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
  </resultMap>
  <resultMap id="imMsgBizSkillsVOMap" type="com.tmerclub.cloud.im.vo.ImMsgBizSkillsVO">
    <id column="id" property="id" />
    <result column="shop_id" property="shopId"/>
    <result column="keywords" property="keywords"/>
    <result column="content" property="content"/>
    <result column="status" property="status"/>
    <result column="remark" property="remark"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `id`,`shop_id`,`keywords`,`content`,`status`,`remark`,`create_time`,`update_time`
  </sql>
  <select id="list" resultMap="imMsgBizSkillsVOMap">
    select <include refid="Vo_Column_List"/> from im_msg_biz_skills
    where shop_id = #{shopId} and status = 1
    <if test="imMsgBizSkills.keywords != ''">
      and `keywords` LIKE concat('%',#{imMsgBizSkills.keywords},'%')
    </if>
    <if test="imMsgBizSkills.content != ''">
      and `content` LIKE concat('%', #{imMsgBizSkills.content},'%')
    </if>
    order by update_time desc
  </select>
  <select id="getById" resultMap="imMsgBizSkillsVOMap">
    select <include refid="Vo_Column_List"/> from im_msg_biz_skills where id = #{id} and status = 1
  </select>
  <insert id="save">
    insert into im_msg_biz_skills (`shop_id`,`keywords`,`content`,`status`,`remark`,`create_time`,`update_time`)
    values (#{imMsgBizSkills.shopId},#{imMsgBizSkills.keywords},#{imMsgBizSkills.content},#{imMsgBizSkills.status},#{imMsgBizSkills.remark}, #{imMsgBizSkills.createTime},#{imMsgBizSkills.updateTime});
  </insert>
  <update id="update">
    update im_msg_biz_skills
    <set>
      <if test="imMsgBizSkills.keywords != null">
        `keywords` = #{imMsgBizSkills.keywords},
      </if>
      <if test="imMsgBizSkills.content != null">
        `content` = #{imMsgBizSkills.content},
      </if>
      <if test="imMsgBizSkills.remark != null">
        `remark` = #{imMsgBizSkills.remark},
      </if>
      <if test="imMsgBizSkills.updateTime != null">
        `update_time` = #{imMsgBizSkills.updateTime},
      </if>
    </set>
    where id = #{imMsgBizSkills.id}
  </update>
  <update id="deleteById">
    update im_msg_biz_skills set status = 0 where id = #{id}
  </update>

  <select id="selectByShopIdAndKey" resultMap="imMsgBizSkillsVOMap">
    select <include refid="Vo_Column_List"/> from im_msg_biz_skills where shop_id = #{shopId} and keywords = #{keywords} and status = 1
  </select>

  <select id="getByShopId" resultMap="imMsgBizSkillsVOMap">
    select <include refid="Vo_Column_List"/> from im_msg_biz_skills where shop_id = #{shopId} and status = 1
  </select>
</mapper>
