ArticleMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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="com.caimei365.user.mapper.ArticleMapper">
  4. <delete id="deleteArticle">
  5. delete from info where id = #{articleId}
  6. </delete>
  7. <select id="getShopArticleById" resultType="com.caimei365.user.model.vo.ShopArticleVo">
  8. select id as articleId,
  9. title,
  10. label,
  11. keyword,
  12. publisher,
  13. source,
  14. recommendContent,
  15. infoContent as articleContent,
  16. typeId,
  17. guidanceImage,
  18. enabledStatus as status
  19. from info
  20. where id = #{articleId}
  21. </select>
  22. <select id="getArticleTypeList" resultType="com.caimei365.user.model.vo.ArticleTypeVo">
  23. select id as typeId, name as typeName from info_type where enabledStatus = '1' order by sort desc,createDate desc
  24. </select>
  25. <select id="getArticleLabelId" resultType="java.lang.Integer">
  26. select id from info_label where name = #{label}
  27. </select>
  28. <select id="getShopArticleList" resultType="com.caimei365.user.model.vo.ShopArticleVo">
  29. select i.id as articleId,
  30. title,
  31. ip.num as praiseNum,
  32. ip.pv as pvNum,
  33. publisher,
  34. source,
  35. it.name as typeName,
  36. guidanceImage,
  37. i.pubdate as publishDate,
  38. i.createDate,
  39. i.auditStatus,
  40. i.failReason,
  41. i.enabledStatus as status
  42. from info i
  43. left join info_type it on i.typeId = it.id
  44. left join info_praise ip on i.id = ip.infoId
  45. where shopId = #{shopId} and publishSource = 2
  46. <if test="articleId != null">
  47. and i.id = #{articleId}
  48. </if>
  49. <if test="title != null and title != ''">
  50. and title like concat('%',#{title},'%')
  51. </if>
  52. <if test="publisher != null and publisher != ''">
  53. and publisher like concat('%',#{publisher},'%')
  54. </if>
  55. <if test="typeId != null">
  56. and typeId = #{typeId}
  57. </if>
  58. <if test="auditStatus != null">
  59. and auditStatus = #{auditStatus}
  60. </if>
  61. order by i.createDate desc
  62. </select>
  63. <select id="getArticleLabelList" resultType="java.lang.String">
  64. select value from sys_dict where type = 'sys_config' limit 1
  65. </select>
  66. <insert id="insertShopArticle" parameterType="com.caimei365.user.model.po.ArticlePo" keyProperty="articleId" useGeneratedKeys="true">
  67. insert into info (typeId, title, label, publisher, source, publishSource, shopId, keyword,
  68. recommendContent, infoContent, guidanceImage,
  69. recommendStatus, enabledStatus, basePraise, basePv, priorityIndex,
  70. auditStatus, createDate)
  71. values (#{typeId}, #{title}, #{label}, #{publisher}, #{source}, #{publishSource}, #{shopId},
  72. #{keyword}, #{recommendContent}, #{articleContent}, #{guidanceImage}, #{recommendStatus},
  73. #{status}, #{basePraise}, #{basePv}, #{priorityIndex}, #{auditStatus}, NOW())
  74. </insert>
  75. <insert id="insertArticleLabel">
  76. insert into info_label (name, createDate)
  77. values (#{label}, NOW())
  78. </insert>
  79. <insert id="insertArticlePraise">
  80. insert into info_praise (infoId, num, pv)
  81. values (#{articleId}, 0, 0)
  82. </insert>
  83. <update id="updateShopArticle">
  84. update info
  85. set typeId = #{typeId},
  86. title = #{title},
  87. label = #{label},
  88. publisher = #{publisher},
  89. source = #{source},
  90. keyword = #{keyword},
  91. recommendContent = #{recommendContent},
  92. infoContent = #{articleContent},
  93. guidanceImage = #{guidanceImage},
  94. enabledStatus = #{status},
  95. auditStatus = #{auditStatus}
  96. where id = #{articleId}
  97. </update>
  98. <update id="updateArticleStatus">
  99. update info set enabledStatus = #{status} where id = #{articleId}
  100. </update>
  101. </mapper>