<?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.ylx.massage.mapper.SensitiveWordMapper">

    <resultMap type="com.ylx.massage.domain.SensitiveWord" id="SensitiveWordMap">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="word" column="word" jdbcType="VARCHAR"/>
        <result property="category" column="category" jdbcType="VARCHAR"/>
        <result property="level" column="level" jdbcType="INTEGER"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
    </resultMap>

    <!-- 批量插入敏感词 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        INSERT INTO t_sensitive_word (word, category, level, status, remark, create_time, update_time, is_delete)
        VALUES
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.word}, #{entity.category}, #{entity.level}, #{entity.status}, #{entity.remark}, #{entity.createTime}, #{entity.updateTime}, #{entity.isDelete})
        </foreach>
    </insert>

    <!-- 根据敏感词查询 -->
    <select id="selectByWord" resultMap="SensitiveWordMap">
        SELECT * FROM t_sensitive_word
        WHERE word = #{word} AND is_delete = 0
        LIMIT 1
    </select>

</mapper>
