You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

90 lines
3.1 KiB

<?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="org.hlrj.duobao_demo.mapper.RecommendationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="org.hlrj.duobao_demo.entity.Recommendation">
<id column="id" property="id" />
<result column="image_url" property="imageUrl" />
<result column="title" property="title" />
<result column="author" property="author" />
<result column="publish_time" property="publishTime" />
<result column="likes" property="likes" />
<result column="comments" property="comments" />
<result column="shares" property="shares" />
<result column="source" property="source" />
<result column="head" property="head"/>
</resultMap>
<!--点赞操作-->
<update id="addLike" parameterType="org.hlrj.duobao_demo.entity.Recommendation">
update Recommendation
<set>
<if test="imageUrl !=null and imageUrl!=''">
image_url=#{imageUrl},
</if>
<if test="title !=null and title!=''">
title=#{title},
</if>
<if test="author !=null and author!=''">
author=#{author},
</if>
<if test="publishTime !=null and publishTime!=''">
publish_time=#{publishTime},
</if>
<if test="comments !=null and comments!=''">
comments=#{comments},
</if>
<if test="shares !=null">
shares=#{shares},
</if>
<if test="source !=null">
source=#{source},
</if>
<if test="head !=null and head!=''">
head=#{head}
</if>
likes = likes + 1
</set>
where id = #{id}
</update>
<!--更新操作-->
<update id="updateRecommendation" parameterType="org.hlrj.duobao_demo.entity.Recommendation">
update Recommendation
<set>
<if test="imageUrl !=null and imageUrl!=''">
image_url=#{imageUrl},
</if>
<if test="title !=null and title!=''">
title=#{title},
</if>
<if test="author !=null and author!=''">
author=#{author},
</if>
<if test="publishTime !=null and publishTime!=''">
publish_time=#{publishTime},
</if>
<if test="likes !=null">
likes=#{likes},
</if>
<if test="comments !=null and comments!=''">
comments=#{comments},
</if>
<if test="shares !=null">
shares=#{shares},
</if>
<if test="source !=null">
source=#{source},
</if>
<if test="head !=null and head!=''">
head=#{head}
</if>
</set>
where id = #{id}
</update>
</mapper>