UniversitySubmitFileMapper.xml 6.84 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.UniversitySubmitFileMapper">

  <resultMap id="LineMap" type="com.sincere.student.dto.submit.SubmitLine">
    <result column="id"  property="id" />
    <result column="title"  property="title" />
    <collection property="universityList" ofType="com.sincere.student.dto.submit.SubmitUniv">
      <result column="universityId"  property="universityId" />
      <result column="name"  property="universityName" />
      <collection property="majorList" ofType="com.sincere.student.dto.submit.SubmitMajor">
        <result column="major"  property="major" />
        <result column="grade"  property="grade" />
        <result column="enroll_number"  property="enrollNumber" />
        <result column="rank"  property="rank" />
      </collection>
    </collection>
  </resultMap>

  <select id="getAppListCount" parameterType="com.sincere.student.dto.PointSearchDto" resultType="java.lang.Integer">
    select count(DISTINCT(sf.id))
    from university_submit_file sf join university_point p on sf.id = p.submit_id
    join university_info info on p.university_id = info.id
    join university_major m on p.major_id = m.id
    <where>
      <if test="submitId != 0">
        and sf.id = #{submitId}
      </if>
      <if test="universityName != null and universityName != '' ">
        and info.name like #{universityName}
      </if>
      <if test="province != null and province != '' ">
        and info.province = #{province}
      </if>
      <if test="city != null and city != '' ">
        and info.city = #{city}
      </if>
      <if test="majorName != null and majorName != '' ">
        and m.major like #{majorName}
      </if>
      <if test="point != 0 ">
        <![CDATA[ and p.grade > #{point}-5 and p.grade < #{point} +5  ]]>
      </if>
      <if test="rank != 0 ">
        <![CDATA[ and p.rank > #{rank}-100 and p.rank < #{rank} +100  ]]>
      </if>
    </where>
  </select>

  <select id="getAppList" parameterType="com.sincere.student.dto.PointSearchDto" resultMap="LineMap">
    select sf.id , sf.title ,info.id as universityId , info.name , m.major , p.enroll_number , p.rank , p.grade
    from university_submit_file sf join university_point p on sf.id = p.submit_id
    join university_info info on p.university_id = info.id
    join university_major m on p.major_id = m.id
    <where>
        <if test="submitId != 0">
          and sf.id = #{submitId}
        </if>
        <if test="universityName != null and universityName != '' ">
          and info.name like #{universityName}
        </if>
        <if test="province != null and province != '' ">
          and info.province = #{province}
        </if>
        <if test="city != null and city != '' ">
          and info.city = #{city}
        </if>
        <if test="majorName != null and majorName != '' ">
          and m.major like #{majorName}
        </if>
      <if test="point != 0 ">
        <![CDATA[ and p.grade >= #{point}-5 and p.grade <= #{point} +5  ]]>
      </if>
      <if test="rank != 0 ">
        <![CDATA[ and p.rank >= #{rank}-100 and p.rank <= #{rank} +100  ]]>
      </if>
    </where>
    order by sf.id
  </select>

  <resultMap id="BaseResultMap" type="com.sincere.student.model.SubmitFile">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="title" jdbcType="VARCHAR" property="title" />
    <result column="file_url" jdbcType="VARCHAR" property="fileUrl" />
    <result column="year" jdbcType="VARCHAR" property="year" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <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_submit_file
    <where>
      <if test="search != null and search != '' ">
        title like #{search}
      </if>
    </where>
  </select>

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


  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select *
    from university_submit_file
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from university_submit_file
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.sincere.student.model.SubmitFile" useGeneratedKeys="true" keyProperty="id">
    insert into university_submit_file (title, year,
      sort, create_time,file_url)
    values (#{title,jdbcType=VARCHAR}, #{year,jdbcType=VARCHAR},
      #{sort,jdbcType=INTEGER}, GETDATE(),#{fileUrl})
  </insert>
  <insert id="insertSelective" parameterType="com.sincere.student.model.SubmitFile">
    insert into university_submit_file
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="title != null">
        title,
      </if>
      <if test="year != null">
        year,
      </if>
      <if test="sort != null">
        sort,
      </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="year != null">
        #{year,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sincere.student.model.SubmitFile">
    update university_submit_file
    <set>
      <if test="title != null and title != ''">
        title = #{title,jdbcType=VARCHAR},
      </if>
      <if test="year != null and year != ''">
        year = #{year,jdbcType=VARCHAR},
      </if>
      <if test="sort != 0">
        sort = #{sort,jdbcType=INTEGER},
      </if>
      <if test="fileUrl != null and fileUrl != ''">
        file_url = #{fileUrl,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sincere.student.model.SubmitFile">
    update university_submit_file
    set title = #{title,jdbcType=VARCHAR},
      year = #{year,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>