<?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" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TaSysMenu" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="menu_name" property="menuName" jdbcType="VARCHAR" />
    <result column="menu_url" property="menuUrl" jdbcType="VARCHAR" />
    <result column="parent_id" property="parentId" jdbcType="INTEGER" />
    <result column="sort" property="sort" jdbcType="INTEGER" />
    <result column="menu_type" property="menuType" jdbcType="CHAR" />
    <result column="status" property="status" jdbcType="CHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, menu_name, menu_url, parent_id, sort, menu_type, status,remark
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from ta_sys_menu
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from ta_sys_menu
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TaSysMenu" >
    insert into ta_sys_menu (id, community_id, menu_name, 
      menu_url, parent_id, sort, 
      menu_type, status)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{menuName,jdbcType=VARCHAR}, 
      #{menuUrl,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, 
      #{menuType,jdbcType=CHAR}, #{status,jdbcType=CHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TaSysMenu" >
    insert into ta_sys_menu
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="menuName != null" >
        menu_name,
      </if>
      <if test="menuUrl != null" >
        menu_url,
      </if>
      <if test="parentId != null" >
        parent_id,
      </if>
      <if test="sort != null" >
        sort,
      </if>
      <if test="menuType != null" >
        menu_type,
      </if>
      <if test="status != null" >
        status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="communityId != null" >
        #{communityId,jdbcType=INTEGER},
      </if>
      <if test="menuName != null" >
        #{menuName,jdbcType=VARCHAR},
      </if>
      <if test="menuUrl != null" >
        #{menuUrl,jdbcType=VARCHAR},
      </if>
      <if test="parentId != null" >
        #{parentId,jdbcType=INTEGER},
      </if>
      <if test="sort != null" >
        #{sort,jdbcType=INTEGER},
      </if>
      <if test="menuType != null" >
        #{menuType,jdbcType=CHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TaSysMenu" >
    update ta_sys_menu
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="menuName != null" >
        menu_name = #{menuName,jdbcType=VARCHAR},
      </if>
      <if test="menuUrl != null" >
        menu_url = #{menuUrl,jdbcType=VARCHAR},
      </if>
      <if test="parentId != null" >
        parent_id = #{parentId,jdbcType=INTEGER},
      </if>
      <if test="sort != null" >
        sort = #{sort,jdbcType=INTEGER},
      </if>
      <if test="menuType != null" >
        menu_type = #{menuType,jdbcType=CHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TaSysMenu" >
    update ta_sys_menu
    set community_id = #{communityId,jdbcType=INTEGER},
      menu_name = #{menuName,jdbcType=VARCHAR},
      menu_url = #{menuUrl,jdbcType=VARCHAR},
      parent_id = #{parentId,jdbcType=INTEGER},
      sort = #{sort,jdbcType=INTEGER},
      menu_type = #{menuType,jdbcType=CHAR},
      status = #{status,jdbcType=CHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectByCommunity" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ta_sys_menu
    where community_id = #{communityId,jdbcType=INTEGER} and status = 0 order by sort
  </select>
</mapper>