NewPageFirstNavigationMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.modules.newhome.dao.NewPageFirstNavigationDao">
  4. <sql id="newPageFirstNavigationColumns">
  5. a.id AS "id",
  6. a.navigationName AS "navigationName",
  7. a.type AS "type",
  8. a.icon AS "icon",
  9. a.link AS "link",
  10. a.remark AS "remark",
  11. a.sort AS "sort",
  12. a.wwwEnabledStatus AS "wwwEnabledStatus",
  13. a.crmEnabledStatus AS "crmEnabledStatus",
  14. a.createBy AS "createBy.id",
  15. a.createDate AS "createDate",
  16. a.updateBy AS "updateBy.id",
  17. a.updateDate AS "updateDate",
  18. a.delFlag AS "delFlag"
  19. </sql>
  20. <select id="get" resultType="NewPageFirstNavigation">
  21. SELECT
  22. <include refid="newPageFirstNavigationColumns"/>
  23. FROM new_page_first_navigation a
  24. WHERE a.id = #{id} and a.delFlag = 0
  25. </select>
  26. <select id="findList" resultType="NewPageFirstNavigation">
  27. SELECT
  28. <include refid="newPageFirstNavigationColumns"/>
  29. <if test="statisticsType != null and statisticsType != ''">
  30. ,IFNULL((select sum(c.pv) from cm_praise_statistics c where c.delFlag = 0 and c.type = #{statisticsType} and a.id = c.authorId <if test="startPvCreateTime != null ">AND c.createTime >= #{startPvCreateTime} </if><if test="endPvCreateTime != null ">AND c.createTime <![CDATA[ <= ]]> #{endPvCreateTime} </if>), 0) as pv
  31. </if>
  32. FROM new_page_first_navigation a
  33. <where>
  34. a.delFlag = 0
  35. <if test="type != null and type != ''">
  36. <if test="type == 0 ">and (a.type = 0 or a.type is null )</if>
  37. <if test="type != 0 ">and a.type = #{type}</if>
  38. </if>
  39. </where>
  40. <choose>
  41. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  42. ORDER BY ${page.orderBy}
  43. </when>
  44. <otherwise>
  45. ORDER BY -a.sort DESC, createDate DESC
  46. </otherwise>
  47. </choose>
  48. </select>
  49. <select id="findAllList" resultType="NewPageFirstNavigation">
  50. SELECT
  51. <include refid="newPageFirstNavigationColumns"/>
  52. FROM new_page_first_navigation a
  53. <where>
  54. a.delFlag = 0
  55. <if test="type != null and type != ''">
  56. <if test="type == 0 ">and (a.type = 0 or a.type is null )</if>
  57. <if test="type != 0 ">and a.type = #{type}</if>
  58. </if>
  59. </where>
  60. <choose>
  61. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  62. ORDER BY ${page.orderBy}
  63. </when>
  64. <otherwise>
  65. ORDER BY a.sort DESC
  66. </otherwise>
  67. </choose>
  68. </select>
  69. <insert id="insert" parameterType="NewPageFirstNavigation" keyProperty="id" useGeneratedKeys="true">
  70. INSERT INTO new_page_first_navigation(
  71. navigationName,
  72. type,
  73. link,
  74. remark,
  75. icon,
  76. sort,
  77. wwwEnabledStatus,
  78. crmEnabledStatus,
  79. createBy,
  80. createDate,
  81. updateBy,
  82. updateDate,
  83. delFlag
  84. ) VALUES (
  85. #{navigationName},
  86. #{type},
  87. #{link},
  88. #{remark},
  89. #{icon},
  90. #{sort},
  91. #{wwwEnabledStatus},
  92. #{crmEnabledStatus},
  93. #{createBy.id},
  94. #{createDate},
  95. #{updateBy.id},
  96. #{updateDate},
  97. #{delFlag}
  98. )
  99. </insert>
  100. <update id="update">
  101. UPDATE new_page_first_navigation SET
  102. navigationName = #{navigationName},
  103. type = #{type},
  104. link = #{link},
  105. remark = #{remark},
  106. icon = #{icon},
  107. sort = #{sort},
  108. wwwEnabledStatus = #{wwwEnabledStatus},
  109. crmEnabledStatus = #{crmEnabledStatus},
  110. createBy = #{createBy.id},
  111. createDate = #{createDate},
  112. updateBy = #{updateBy.id},
  113. updateDate = #{updateDate},
  114. delFlag = #{delFlag}
  115. WHERE id = #{id}
  116. </update>
  117. <delete id="delete">
  118. DELETE FROM new_page_first_navigation
  119. WHERE id = #{id}
  120. </delete>
  121. <update id="updateEnabledStatusByIds">
  122. UPDATE new_page_first_navigation a SET a.wwwEnabledStatus = #{param1}
  123. WHERE a.id IN
  124. <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
  125. #{id}
  126. </foreach>
  127. </update>
  128. <update id="updateCrmEnabledStatusByIds">
  129. UPDATE new_page_first_navigation a SET a.crmEnabledStatus = #{param1}
  130. WHERE a.id IN
  131. <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
  132. #{id}
  133. </foreach>
  134. </update>
  135. <update id="saveSort">
  136. UPDATE new_page_first_navigation SET
  137. sort = #{sort}
  138. WHERE id = #{id}
  139. </update>
  140. </mapper>