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

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="org.hlrj.duobao_demo.mapper.RecommendationMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="org.hlrj.duobao_demo.entity.Recommendation">
  6. <id column="id" property="id" />
  7. <result column="image_url" property="imageUrl" />
  8. <result column="title" property="title" />
  9. <result column="author" property="author" />
  10. <result column="publish_time" property="publishTime" />
  11. <result column="likes" property="likes" />
  12. <result column="comments" property="comments" />
  13. <result column="shares" property="shares" />
  14. <result column="source" property="source" />
  15. <result column="head" property="head"/>
  16. </resultMap>
  17. <!--点赞操作-->
  18. <update id="addLike" parameterType="org.hlrj.duobao_demo.entity.Recommendation">
  19. update Recommendation
  20. <set>
  21. <if test="imageUrl !=null and imageUrl!=''">
  22. image_url=#{imageUrl},
  23. </if>
  24. <if test="title !=null and title!=''">
  25. title=#{title},
  26. </if>
  27. <if test="author !=null and author!=''">
  28. author=#{author},
  29. </if>
  30. <if test="publishTime !=null and publishTime!=''">
  31. publish_time=#{publishTime},
  32. </if>
  33. <if test="comments !=null and comments!=''">
  34. comments=#{comments},
  35. </if>
  36. <if test="shares !=null">
  37. shares=#{shares},
  38. </if>
  39. <if test="source !=null">
  40. source=#{source},
  41. </if>
  42. <if test="head !=null and head!=''">
  43. head=#{head}
  44. </if>
  45. likes = likes + 1
  46. </set>
  47. where id = #{id}
  48. </update>
  49. <!--更新操作-->
  50. <update id="updateRecommendation" parameterType="org.hlrj.duobao_demo.entity.Recommendation">
  51. update Recommendation
  52. <set>
  53. <if test="imageUrl !=null and imageUrl!=''">
  54. image_url=#{imageUrl},
  55. </if>
  56. <if test="title !=null and title!=''">
  57. title=#{title},
  58. </if>
  59. <if test="author !=null and author!=''">
  60. author=#{author},
  61. </if>
  62. <if test="publishTime !=null and publishTime!=''">
  63. publish_time=#{publishTime},
  64. </if>
  65. <if test="likes !=null">
  66. likes=#{likes},
  67. </if>
  68. <if test="comments !=null and comments!=''">
  69. comments=#{comments},
  70. </if>
  71. <if test="shares !=null">
  72. shares=#{shares},
  73. </if>
  74. <if test="source !=null">
  75. source=#{source},
  76. </if>
  77. <if test="head !=null and head!=''">
  78. head=#{head}
  79. </if>
  80. </set>
  81. where id = #{id}
  82. </update>
  83. </mapper>