1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <?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.example.bigevent.mapper.ArticleMapper"> <resultMap id="All" type="com.example.bigevent.entity.Article"> <id property="id" column="id"></id> <result property="createUser" column="create_user"></result> <result property="categoryId" column="category_id"></result> <result property="content" column="content"></result> <result property="coverImg" column="cover_img"></result> <result property="state" column="state"></result> <result property="title" column="title"></result> <result property="createTime" column="create_time"></result> <result property="updateTime" column="update_time"></result> </resultMap> <insert id="add" parameterType="com.example.bigevent.entity.Article"> insert into article(title,content,cover_img,state,category_id,create_user,create_time,update_time)values (#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},now(),now()) </insert> <select id="list" resultMap="All"> select * from article <where> <if test="categoryId!=null"> category_id =#{categoryId} </if> <if test="state!=null"> and state=#{state} </if> and create_user =#{userId} </where> </select> <select id="getOne" resultMap="All"> select * from article where id = #{id} </select> <update id="updateOne" parameterType="com.example.bigevent.entity.Article"> update article set title=#{title},content=#{content},cover_img=#{coverImg},state=#{state},category_id=#{categoryId}, update_time=now() where id =#{id} </update> <delete id="deleteOne" parameterType="integer"> delete from article where id = #{id} </delete> </mapper>
|