AlarmGroupMapper.xml 3.34 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.AlarmGroupMapper" >
  <resultMap id="BaseResultMap" type="com.model.AlarmGroup" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="group_name" property="groupName" jdbcType="VARCHAR" />
    <result column="users_name" property="usersName" jdbcType="VARCHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <sql id="All_Column_List" >
    id, group_name, users_name, remark, create_time, update_time
  </sql>
  
  <sql id="Base_Column_List" >
    group_name, users_name, remark, create_time, update_time
  </sql>
  
  <insert id="insert" parameterType="com.model.AlarmGroup" >
    insert into 
    	alarm_group 
     (<include refid="Base_Column_List" />) 
    values 
     (#{groupName,jdbcType=VARCHAR},#{usersName,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},now(),now())
  </insert>
  
  <update id="update" parameterType="com.model.AlarmGroup" >
    update 
    	alarm_group 
    set 
    	group_name = #{groupName,jdbcType=VARCHAR},
        users_name = #{usersName,jdbcType=VARCHAR},
        remark = #{remark,jdbcType=VARCHAR},
        update_time = now()
    where 
    	id = #{id,jdbcType=INTEGER}
  </update>
  
  <delete id="deleteById" parameterType="java.lang.Integer" >
    delete from 
    	alarm_group
    where 
    	id = #{id,jdbcType=INTEGER}
  </delete>
  
  <select id="queryAll" resultMap="BaseResultMap">
    select 
    	id,group_name
    from 
    	alarm_group 
    order by 
    	id desc
  </select>
  
  <select id="queryByGroupName" resultMap="BaseResultMap">
    select
    	<include refid="All_Column_List" />
    from 
    	alarm_group 
    where 
    	id != #{id}
   		AND
    	group_name = #{groupName}
  </select>
  
  <select id="queryByInfo" resultMap="BaseResultMap">
    select
    	<include refid="All_Column_List" />
    from 
    	alarm_group 
    where 
    	1=1
    	<if test="groupName != null and groupName != '' " >
          	AND group_name like CONCAT('%',#{groupName,jdbcType=VARCHAR},'%' ) 
      	</if>
    	<if test="usersName != null and usersName != '' " >
    		AND users_name like CONCAT('%',#{usersName,jdbcType=VARCHAR},'%' ) 
    	</if>
    order by 
    	id desc 
    limit 
    	#{startIndex},#{pageSize}
  </select>
  
  <select id="queryById" resultMap="BaseResultMap">
    select
    	<include refid="All_Column_List" />
    from 
    	alarm_group 
    where 
    	id = #{id}
  </select>
  
  <select id="queryByContantsName" resultMap="BaseResultMap">
    select
    	<include refid="All_Column_List" />
    from 
    	alarm_group 
    where 
    	group_name = #{groupName}
  </select>
  
  <select id="queryCount" resultType="java.lang.Integer">
    select 
    	count(1) 
    from 
    	alarm_group
    where 
    	1=1
    	<if test="groupName != null and groupName != '' " >
          	AND group_name like CONCAT('%',#{groupName,jdbcType=VARCHAR},'%' ) 
      	</if>
    	<if test="usersName != null and usersName != '' " >
    		AND users_name like CONCAT('%',#{usersName,jdbcType=VARCHAR},'%' ) 
    	</if>
  </select>
</mapper>