<?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.UniversityConsultMapper"> <resultMap id="ListMap" type="com.sincere.student.model.Consult"> <result column="id" property="id" /> <result column="column_type" property="columnType" /> <result column="universityId" property="universityId" /> <result column="name" property="name" /> <result column="code" property="code" /> <result column="sort" property="sort" /> <result column="img_url" property="imgUrl" /> <result column="status" property="status" /> </resultMap> <select id="getListCount" parameterType="com.sincere.student.dto.ConsultSearchDto" resultType="java.lang.Integer"> select count(DISTINCT c.id) from university_consult c join university_info info on c.university_id = info.id left join university_relate_major r on info.id = r.university_id left join university_major m on m.id = r.major_id <where> <if test="columnType > 0"> and c.column_type = #{columnType} </if> <if test="columnType == 0"> and c.column_type = (select top 1 id from university_column_type where type = 2 order by sort) </if> <if test="columnType == -1"> and 1=1 </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="universityName != null and universityName != ''"> and info.name like #{universityName} </if> <if test="majorName != null and majorName != ''"> and m.major like #{majorName} </if> <if test="status == 1"> and c.status = 1 </if> <if test="status != 1"> and 1 = 1 </if> </where> </select> <select id="getList" parameterType="com.sincere.student.dto.ConsultSearchDto" resultMap="ListMap"> select DISTINCT c.id , c.column_type , info.id as universityId , c.img_url ,c.sort , info.name , info.code ,c.status from university_consult c join university_info info on c.university_id = info.id left join university_relate_major r on info.id = r.university_id left join university_major m on m.id = r.major_id <where> <if test="columnType > 0"> and c.column_type = #{columnType} </if> <if test="columnType == 0"> and c.column_type = (select top 1 id from university_column_type where type = 2 order by sort) </if> <if test="columnType == -1"> and 1=1 </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="universityName != null and universityName != ''"> and info.name like #{universityName} </if> <if test="majorName != null and majorName != ''"> and m.major like #{majorName} </if> <if test="status == 1"> and c.status = 1 </if> <if test="status != 1"> and 1 = 1 </if> </where> order by c.sort </select> <select id="selectByUniversityIdAndColumnType" parameterType="com.sincere.student.model.UniversityConsult" resultMap="DetailMap"> select * from university_consult where university_id =#{universityId} and column_type = #{columnType} </select> <select id="getColumnListCount" parameterType="java.lang.Integer" resultType="java.lang.Integer"> select count(DISTINCT c.id) from university_consult c join university_info info on c.university_id = info.id where c.column_type = #{columnType} and c.status = 1 </select> <select id="getColumnList" parameterType="java.lang.Integer" resultMap="ListMap"> select DISTINCT c.id , info.id as universityId , c.img_url ,c.sort , info.name , info.code from university_consult c join university_info info on c.university_id = info.id where c.column_type = #{columnType} and c.status = 1 order by c.sort </select> <resultMap id="DetailMap" type="com.sincere.student.model.Consult"> <result column="id" property="id" /> <result column="universityId" property="universityId" /> <result column="name" property="name" /> <result column="code" property="code" /> <result column="sort" property="sort" /> <result column="img_url" property="imgUrl" /> <result column="column_type" property="columnType" /> <result column="video_url" property="videoUrl" /> <result column="context" property="context" /> <result column="phone" property="phone" /> </resultMap> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="DetailMap"> select * from university_consult c join university_info info on c.university_id = info.id where c.id =#{id} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from university_consult where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="com.sincere.student.model.UniversityConsult" useGeneratedKeys="true" keyProperty="id"> insert into university_consult (university_id, column_type, video_url, context, img_url, create_time, sort,status) values (#{universityId,jdbcType=INTEGER}, #{columnType,jdbcType=INTEGER}, #{videoUrl,jdbcType=VARCHAR}, #{context,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}, GETDATE(), #{sort,jdbcType=INTEGER},#{status}) </insert> <update id="updateByPrimaryKeySelective" parameterType="com.sincere.student.model.UniversityConsult"> update university_consult <set> <if test="universityId != null"> university_id = #{universityId,jdbcType=INTEGER}, </if> <if test="columnType != null"> column_type = #{columnType,jdbcType=INTEGER}, </if> <if test="videoUrl != null"> video_url = #{videoUrl,jdbcType=VARCHAR}, </if> <if test="context != null"> context = #{context,jdbcType=VARCHAR}, </if> <if test="imgUrl != null"> img_url = #{imgUrl,jdbcType=VARCHAR}, </if> <if test="createTime != null"> create_time = #{createTime,jdbcType=TIMESTAMP}, </if> <if test="sort != null"> sort = #{sort,jdbcType=INTEGER}, </if> <if test="status != null"> status = #{status}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> </mapper>