AdvertMapper.xml 1.95 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.AdvertMapper">

    <resultMap id="AdvertMap" type="com.sincere.student.model.Advert">
        <id column="id" property="id"/>
        <result column="type" property="type"/>
        <result column="img_url" property="imgUrl"/>
        <result column="url_link" property="urlLink"/>
        <result column="sort" property="sort"/>
        <result column="status" property="status"/>
        <result column="create_time" property="createTime"/>
        <result column="title" property="title"/>
    </resultMap>

    <select id="getList" parameterType="java.lang.Integer" resultMap="AdvertMap">
        select * from university_advert where type = #{type} order by sort
    </select>

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

    <insert id="create" parameterType="com.sincere.student.model.Advert" >
        insert into university_advert (type,img_url,url_link,sort,status,create_time,title)
        values (#{type},#{imgUrl},#{urlLink},#{sort},#{status},GETDATE(),#{title})
    </insert>

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

    <update id="update" parameterType="com.sincere.student.model.Advert">
        update university_advert
        <trim prefix="set" suffixOverrides=",">
            <if test="imgUrl!=null">
                img_url=#{imgUrl},
            </if>
            <if test="sort!=null">
                sort=#{sort},
            </if>
            <if test="urlLink!=null">
                url_link=#{urlLink},
            </if>
            <if test="title!=null">
                title=#{title},
            </if>
        </trim>
        where id = #{id}
    </update>
</mapper>