DomainInfoMapper.xml 1.43 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.DomainInfoMapper" >
  <resultMap id="BaseResultMap" type="com.monitor.model.domain.DomainInfo" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="VARCHAR" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, name, DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime
  </sql>

  <insert id="insert" parameterType="com.monitor.model.domain.DomainInfo" useGeneratedKeys="true" keyProperty="id">
    insert into domain_info
    (
      name, create_time
    )
    values
    (
      #{name,jdbcType=INTEGER}, now()
    )
  </insert>

  <delete id="deleteAll" parameterType="java.lang.Integer" >
    delete from domain_info
  </delete>

  <select id="selectById" resultMap="BaseResultMap">
    select
    t.id as id, t.name as name, DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') AS createTime
    from
    domain_info t, elb_link_domain t1
    where
    t1.elb_id = #{id,jdbcType=INTEGER} and t1.domain_id=t.id
  </select>

  <select id="selectByName" resultMap="BaseResultMap">
    select
      <include refid="Base_Column_List" />
    from
      domain_info
    where
      name = #{name,jdbcType=VARCHAR}
  </select>
</mapper>