SysMenuDao.xml 5.5 KB
<?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.tianbo.analysis.dao.SysMenuDao">
  <resultMap id="BaseResultMap" type="com.tianbo.analysis.model.SysMenu">
    <id column="ID" jdbcType="DECIMAL" property="id" />
    <result column="PARENTID" jdbcType="DECIMAL" property="parentid" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
    <result column="MENU_SORT" jdbcType="VARCHAR" property="menuSort" />
    <result column="MENU_CONTROLL" jdbcType="VARCHAR" property="menuControll" />
    <result column="MENU_VIEW" jdbcType="VARCHAR" property="menuView" />
    <result column="MENU_NAME" jdbcType="VARCHAR" property="menuName" />
  </resultMap>
  <resultMap id="treeMap" type="com.tianbo.analysis.model.SysMenu">
    <id column="ID" jdbcType="DECIMAL" property="id" />
    <result column="PARENTID" jdbcType="DECIMAL" property="parentid" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
    <result column="MENU_SORT" jdbcType="VARCHAR" property="menuSort" />
    <result column="MENU_CONTROLL" jdbcType="VARCHAR" property="menuControll" />
    <result column="MENU_VIEW" jdbcType="VARCHAR" property="menuView" />
    <result column="MENU_NAME" jdbcType="VARCHAR" property="menuName" />
    <collection property="children" column="ID" javaType="java.util.ArrayList" ofType="com.tianbo.analysis.model.SysMenu" select="selectByParentId">
    </collection>
  </resultMap>
  <sql id="Base_Column_List">
    ID, PARENTID, CREATETIME, MENU_SORT, MENU_CONTROLL, MENU_VIEW, MENU_NAME
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from SYS_MENU
    where ID = #{id,jdbcType=DECIMAL}
  </select>

  <select id="selectByParentId" parameterType="java.lang.Integer" resultMap="treeMap">
    select
    <include refid="Base_Column_List" />
    from SYS_MENU
    where PARENTID = #{id,jdbcType=DECIMAL}
  </select>

  <select id="selectRoleMenu" parameterType="java.util.Map" resultMap="treeMap">
    SELECT
    <include refid="Base_Column_List" />
    FROM SYS_MENU
    WHERE menu_controll = '1'
        and PARENTID = 0
      AND ID IN
    <foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
      #{id}
    </foreach>
    ORDER BY PARENTID, MENU_SORT
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from SYS_MENU
    where ID = #{id,jdbcType=DECIMAL}
  </delete>
  <insert id="insert" keyColumn="ID" keyProperty="id" parameterType="com.tianbo.analysis.model.SysMenu" useGeneratedKeys="true">
    insert into SYS_MENU (PARENTID, CREATETIME, MENU_SORT,
      MENU_CONTROLL, MENU_VIEW, MENU_NAME
      )
    values (#{parentid,jdbcType=DECIMAL}, #{createtime,jdbcType=TIMESTAMP}, #{menuSort,jdbcType=VARCHAR},
      #{menuControll,jdbcType=VARCHAR}, #{menuView,jdbcType=VARCHAR}, #{menuName,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" keyColumn="ID" keyProperty="id" parameterType="com.tianbo.analysis.model.SysMenu" useGeneratedKeys="true">
    insert into SYS_MENU
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="parentid != null">
        PARENTID,
      </if>
      <if test="createtime != null">
        CREATETIME,
      </if>
      <if test="menuSort != null">
        MENU_SORT,
      </if>
      <if test="menuControll != null">
        MENU_CONTROLL,
      </if>
      <if test="menuView != null">
        MENU_VIEW,
      </if>
      <if test="menuName != null">
        MENU_NAME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="parentid != null">
        #{parentid,jdbcType=DECIMAL},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="menuSort != null">
        #{menuSort,jdbcType=VARCHAR},
      </if>
      <if test="menuControll != null">
        #{menuControll,jdbcType=VARCHAR},
      </if>
      <if test="menuView != null">
        #{menuView,jdbcType=VARCHAR},
      </if>
      <if test="menuName != null">
        #{menuName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.analysis.model.SysMenu">
    update SYS_MENU
    <set>
      <if test="parentid != null">
        PARENTID = #{parentid,jdbcType=DECIMAL},
      </if>
      <if test="createtime != null">
        CREATETIME = #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="menuSort != null">
        MENU_SORT = #{menuSort,jdbcType=VARCHAR},
      </if>
      <if test="menuControll != null">
        MENU_CONTROLL = #{menuControll,jdbcType=VARCHAR},
      </if>
      <if test="menuView != null">
        MENU_VIEW = #{menuView,jdbcType=VARCHAR},
      </if>
      <if test="menuName != null">
        MENU_NAME = #{menuName,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tianbo.analysis.model.SysMenu">
    update SYS_MENU
    set PARENTID = #{parentid,jdbcType=DECIMAL},
      CREATETIME = #{createtime,jdbcType=TIMESTAMP},
      MENU_SORT = #{menuSort,jdbcType=VARCHAR},
      MENU_CONTROLL = #{menuControll,jdbcType=VARCHAR},
      MENU_VIEW = #{menuView,jdbcType=VARCHAR},
      MENU_NAME = #{menuName,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=DECIMAL}
  </update>
</mapper>