<?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.community.huiju.dao.TaSysMenuMapper">

    <select id="getTaSysMenuListByCommunityId" resultType="com.community.huiju.model.TaSysMenu">
        SELECT
            t.id,
            t.community_id AS communityId,
            t.menu_url AS menuUrl,
            t.menu_name AS menuName,
            t.parent_id AS paremtId,
            t.sort,
            t.menu_type AS menuType,
            t.`status`,
            t.remark,
            t.`explain`
        FROM
            ta_sys_menu t
        WHERE
            community_id = '-1'
    </select>

    <insert id="insertTaSysMenu" parameterType="com.community.huiju.model.TaSysMenu" useGeneratedKeys="true" keyProperty="id">
        insert into ta_sys_menu (community_id, menu_url, menu_name, sort, menu_type,  `status`, remark, `explain`)
    values (#{communityId,jdbcType=INTEGER}, #{menuUrl,jdbcType=VARCHAR},
      #{menuName,jdbcType=VARCHAR}, #{sort,jdbcType=VARCHAR}, #{menuType,jdbcType=VARCHAR},
      #{status,jdbcType=CHAR}, #{remark,jdbcType=VARCHAR}, #{explain,jdbcType=VARCHAR})
    </insert>

    <select id="selectTaSysMenuImgById" resultType="com.community.huiju.model.TaSysMenuImg">
        SELECT
            id,
            ta_menu_id as taMenuId,
            menu_icon_img as menuIconImg
        FROM
            ta_sys_menu_img
        WHERE
            ta_menu_id = #{taMenuId,jdbcType=INTEGER}
    </select>

    <insert id="batchInsertImg" parameterType="list" >
        insert into ta_sys_menu_img (ta_menu_id, menu_icon_img)
        values
        <foreach collection="list" item="item" index="index" separator="," >
            (#{item.taMenuId,jdbcType=VARCHAR}, #{item.menuIconImg,jdbcType=VARCHAR})
        </foreach>
    </insert>
</mapper>
