AuthModuleMapper.xml 3.35 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.monitor.mysql.mapper.AuthModuleMapper" >
  <resultMap id="BaseResultMap" type="com.model.AuthModule" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="module_name" property="moduleName" jdbcType="VARCHAR" />
    <result column="module_cname" property="moduleCName" jdbcType="VARCHAR" />
    <result column="module_group" property="moduleGroup" jdbcType="VARCHAR" />
    <result column="module_group_name" property="moduleGroupName" jdbcType="VARCHAR" />
    <result column="module_level" property="moduleLevel" jdbcType="INTEGER" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, module_name, module_level, module_cname, module_group, module_group_name
  </sql>

  <select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from auth_module
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectByName" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select
    <include refid="Base_Column_List" />
    from auth_module
    where module_name = #{moduleName,jdbcType=VARCHAR}
  </select>

  <select id="selectAll" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from auth_module
  </select>

  <select id="selectAllByKeys" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from auth_module
    where 1=1
    <if test="keys != null and keys != '' " >
      AND (module_name like CONCAT('%',#{keys},'%') or module_name like CONCAT('%',#{keys},'%') )
    </if>
    order by module_group,module_group_name,id
  </select>

  <insert id="insert" parameterType="com.model.AuthModule" >
    insert into auth_module
     (module_name,module_level,module_cname, module_group, module_group_name, create_time, update_time)
    values
     (#{moduleName,jdbcType=VARCHAR},#{moduleLevel,jdbcType=INTEGER},
     #{moduleCName,jdbcType=VARCHAR},#{moduleGroup,jdbcType=VARCHAR},
      #{moduleGroupName,jdbcType=VARCHAR},
      now(),now())
  </insert>

  <update id="updateLevel" parameterType="com.model.AuthModule" >
    update auth_module
    set module_level = #{moduleLevel,jdbcType=VARCHAR},
    module_cname = #{moduleCName,jdbcType=VARCHAR},
    module_group = #{moduleGroup,jdbcType=VARCHAR},
    module_group_name = #{moduleGroupName,jdbcType=VARCHAR},
    update_time = now()
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectCount" resultType="java.lang.Integer">
    select
    count(1)
    from auth_module
    where 1=1
    <if test="keys != null and keys != '' " >
      AND (module_name like CONCAT('%',#{keys},'%') or module_name like CONCAT('%',#{keys},'%') )
    </if>
  </select>

  <select id="selectAuthModules" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from auth_module
    where
    1=1
    <if test="keys != null and keys != '' " >
      AND (module_name like CONCAT('%',#{keys},'%') or module_name like CONCAT('%',#{keys},'%') )
    </if>
    order by id desc
    limit #{startIndex},#{pageSize}
  </select>

  <delete id="deleteByName" parameterType="java.lang.String" >
    delete from auth_module
    where module_name = #{name,jdbcType=VARCHAR}
  </delete>
</mapper>