UniversityMapper.xml 3.14 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.UniversityMapper">

    <resultMap id="UniversityMap" type="com.sincere.student.model.University">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="code" property="code"/>
        <result column="university_type" property="universityType"/>
        <result column="department" property="department"/>
        <result column="province" property="province"/>
        <result column="city" property="city"/>
        <result column="level" property="level"/>
        <result column="create_time" property="createTime"/>
        <result column="phone" property="phone"/>
        <result column="logo_url" property="logoUrl"/>
    </resultMap>

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

    <select id="getList" parameterType="com.sincere.student.dto.UniversitySearchDto" resultMap="UniversityMap">
        select * from university_info
        <where>
            <if test="search != null and search != ''">
                and name like #{search}
            </if>
        </where>
    </select>

    <insert id="create" parameterType="com.sincere.student.model.University" >
        insert into university_info (name,code,university_type,department,province,city,level,create_time,phone,logo_url)
        values (#{name},#{code},#{universityType},#{department},#{province},#{city},#{level},GETDATE(),#{phone},#{logoUrl})
    </insert>

    <delete id="delete" parameterType="java.lang.Integer">
        delete university_info where id = #{id}
    </delete>

    <update id="update" parameterType="com.sincere.student.model.University">
        update university_info
        <trim prefix="set" suffixOverrides=",">
            <if test="name!=null">
                name=#{name},
            </if>
            <if test="code!=null">
                code=#{code},
            </if>
            <if test="universityType!=null">
                university_type=#{universityType},
            </if>
            <if test="department!=null">
                department=#{department},
            </if>
            <if test="province!=null">
                province=#{province},
            </if>
            <if test="city!=null">
                city=#{city},
            </if>
            <if test="level!=null">
                level=#{level},
            </if>
            <if test="phone!=null">
                phone=#{phone},
            </if>
            <if test="logoUrl!=null">
                logo_url=#{logoUrl},
            </if>
        </trim>
        where id = #{id}
    </update>

    <select id="selectByName" parameterType="java.lang.String" resultType="java.lang.Integer">
        select id from university_info where name = #{name}
    </select>
</mapper>