<?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.ruoyi.system.mapper.PosFenleiMapper">

    <resultMap type="PosFenlei" id="PosFenleiResult">
        <result property="id"    column="id"    />
        <result property="mendid"    column="mendid"    />
        <result property="name"    column="name"    />
        <result property="img"    column="img"    />
        <result property="sort"    column="sort"    />
        <result property="language"    column="language"    />
    </resultMap>

    <sql id="selectPosFenleiVo">
        select id, mendid, name, img,sort,language from pos_fenlei
    </sql>

    <select id="selectPosFenleiList" parameterType="PosFenlei" resultMap="PosFenleiResult">
        <include refid="selectPosFenleiVo"/>
        <where>
            <if test="mendid != null "> and mendid = #{mendid}</if>
            <if test="name != null  and name != ''"> and BINARY name like concat('%', #{name}, '%')</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="language != null "> and language = #{language}</if>
        </where>
        order by sort desc
    </select>

    <select id="selectPosFenleiById" parameterType="Long" resultMap="PosFenleiResult">
        <include refid="selectPosFenleiVo"/>
        where id = #{id}
    </select>

    <insert id="insertPosFenlei" parameterType="PosFenlei" useGeneratedKeys="true" keyProperty="id">
        insert into pos_fenlei
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mendid != null">mendid,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="img != null">img,</if>
            <if test="sort != null">sort,</if>
            <if test="language != null">language,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mendid != null">#{mendid},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="img != null">#{img},</if>
            <if test="sort != null">#{sort},</if>
            <if test="language != null">#{language},</if>
         </trim>
    </insert>

    <update id="updatePosFenlei" parameterType="PosFenlei">
        update pos_fenlei
        <trim prefix="SET" suffixOverrides=",">
            <if test="mendid != null">mendid = #{mendid},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="img != null">img = #{img},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="language != null">language = #{language},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePosFenleiById" parameterType="Long">
        delete from pos_fenlei where id = #{id}
    </delete>

    <delete id="deletePosFenleiByIds" parameterType="String">
        delete from pos_fenlei where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
