UniversityMessageMapper.xml 2.73 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.sincere.student.mapper.UniversityMessageMapper">
  <resultMap id="BaseResultMap" type="com.sincere.student.model.Message">
    <result column="id" jdbcType="INTEGER" property="id" />
    <result column="title" jdbcType="VARCHAR" property="title" />
    <result column="context" jdbcType="VARCHAR" property="context" />
    <result column="phone" jdbcType="VARCHAR" property="phone" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>

  <select id="getListCount" parameterType="com.sincere.student.dto.MessageSearchDto" resultType="java.lang.Integer">
    select count(0) from university_message
    <where>
      <if test="search != null and search != ''">
        and title like #{search}
      </if>
    </where>
  </select>

  <select id="getList" parameterType="com.sincere.student.dto.MessageSearchDto" resultMap="BaseResultMap">
    select * from university_message
    <where>
      <if test="search != null and search != ''">
        and title like #{search}
      </if>
    </where>
  </select>

  <select id="getDetail" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select * from university_message m
    where m.id=#{id}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from university_message
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <insert id="insert" parameterType="com.sincere.student.model.Message">
    insert into university_message (title, context,
      phone, create_time)
    values (#{title,jdbcType=VARCHAR}, #{context,jdbcType=VARCHAR},
      #{phone,jdbcType=VARCHAR}, GETDATE())
  </insert>
  <insert id="insertSelective" parameterType="com.sincere.student.model.Message">
    insert into university_message
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="title != null">
        title,
      </if>
      <if test="context != null">
        context,
      </if>
      <if test="phone != null">
        phone,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="title != null">
        #{title,jdbcType=VARCHAR},
      </if>
      <if test="context != null">
        #{context,jdbcType=VARCHAR},
      </if>
      <if test="phone != null">
        #{phone,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
</mapper>