ArticleMapper.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.caimei.mapper.cmMapper.ArticleMapper">
  4. <insert id="insertArticle">
  5. insert into cm_brand_article(authUserId, title, image, content, auditStatus, status, createTime, auditBy, auditTime)
  6. values (#{authUserId}, #{title}, #{image}, #{content}, #{auditStatus}, #{status}, #{createTime}, #{auditBy}, #{auditTime})
  7. </insert>
  8. <update id="updateArticleByArticleId">
  9. update cm_brand_article
  10. set title = #{title},
  11. image = #{image},
  12. content = #{content},
  13. status = #{status},
  14. auditStatus = #{auditStatus}
  15. where id = #{id}
  16. </update>
  17. <update id="updateArticleStatusByArticleId">
  18. update cm_brand_article
  19. set status = #{status}
  20. where id = #{articleId}
  21. </update>
  22. <update id="updateArticleAuditStatus">
  23. update cm_brand_article
  24. set status = #{status},
  25. auditStatus = #{auditStatus},
  26. invalidReason = #{invalidReason},
  27. auditBy = #{auditBy},
  28. auditTime = #{auditTime}
  29. where id = #{articleId}
  30. </update>
  31. <delete id="deleteArticleByArticleId">
  32. delete from cm_brand_article where id = #{articleId}
  33. </delete>
  34. <select id="getArticleList" resultType="com.caimei.model.vo.ArticleListVo">
  35. select a.id as articleId,a.title as articleTitle,a.image as articleImage,
  36. a.auditStatus,a.invalidReason,a.status,a.createTime,
  37. au.name as auditBy,a.auditTime
  38. from cm_brand_article a
  39. left join cm_brand_auth_user au on a.auditBy = au.authUserId
  40. where a.authUserId = #{authUserId}
  41. <if test="articleTitle != null and articleTitle != ''">
  42. and a.title like concat('%',#{articleTitle},'%')
  43. </if>
  44. <if test="auditStatus != null">
  45. and a.auditStatus = #{auditStatus}
  46. </if>
  47. <if test="status != null">
  48. and a.status = #{status}
  49. </if>
  50. <choose>
  51. <when test="listType == 2">
  52. order by a.auditStatus desc, a.createTime desc
  53. </when>
  54. <otherwise>
  55. order by a.createTime desc
  56. </otherwise>
  57. </choose>
  58. </select>
  59. <select id="getArticleForm" resultType="com.caimei.model.vo.ArticleFormVo">
  60. select id as articleId, title as articleTitle, image as articleImage, content as articleContent, createTime
  61. from cm_brand_article
  62. where id = #{articleId}
  63. </select>
  64. <select id="getWxArticleList" resultType="com.caimei.model.vo.WxArticleListVo">
  65. select id as articleId, title as articleTitle, image as articleImage, date_format(createTime, '%Y-%m-%d') as
  66. createTime
  67. from cm_brand_article a
  68. where authUserId = #{authUserId}
  69. and status = 1
  70. <if test="articleTitle != null and articleTitle != ''">
  71. and title like concat('%',#{articleTitle},'%')
  72. </if>
  73. order by a.createTime desc
  74. </select>
  75. </mapper>