ElkDao.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.example.nngkxxdp.dao.ElkDao">
  4. <update id="updateDocumentById">
  5. UPDATE question_article_remark
  6. SET is_reply = #{isReply},
  7. update_time = now()
  8. WHERE id = #{id}
  9. </update>
  10. <select id="deptAll" resultType="java.lang.String">
  11. SELECT IF(new_dept_name IS NULL, old_dept_name, new_dept_name) AS deptName
  12. FROM question_article_dept
  13. GROUP BY deptName
  14. ORDER BY new_dept_name DESC
  15. </select>
  16. <select id="getAnswerCount" resultType="java.lang.Integer">
  17. SELECT count(1)
  18. FROM question_article
  19. </select>
  20. <select id="getDeptName" resultType="java.lang.String">
  21. SELECT old_dept_name
  22. FROM question_article_dept
  23. WHERE new_dept_name = #{dept}
  24. </select>
  25. <select id="getCountSub" resultType="java.lang.Integer">
  26. SELECT COUNT(*) FROM question_article_remark
  27. <where>
  28. <if test="search != null and search != ''">
  29. AND (phone LIKE CONCAT('%',#{search},'%') OR phone LIKE CONCAT('%',#{remark},'%'))
  30. </if>
  31. <if test="dept != null and dept != ''">
  32. AND dept_name = #{dept}
  33. </if>
  34. <if test="time != null and time != ''">
  35. AND DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(#{time}, '%Y-%m-%d')
  36. </if>
  37. </where>
  38. ORDER BY create_time DESC
  39. </select>
  40. <select id="getPageSub" resultType="java.util.Map">
  41. SELECT *,DATE_FORMAT(create_time, '%Y-%m-%d') as time FROM question_article_remark
  42. <where>
  43. <if test="search != null and search != ''">
  44. AND (phone LIKE CONCAT('%',#{search},'%') OR phone LIKE CONCAT('%',#{remark},'%'))
  45. </if>
  46. <if test="dept != null and dept != ''">
  47. AND dept_name = #{dept}
  48. </if>
  49. <if test="time != null and time != ''">
  50. AND DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(#{time}, '%Y-%m-%d')
  51. </if>
  52. </where>
  53. ORDER BY create_time DESC
  54. LIMIT #{page}, #{limit}
  55. </select>
  56. <select id="getSubDeptAll" resultType="java.lang.String">
  57. SELECT new_dept_name
  58. FROM question_article_dept
  59. WHERE new_dept_name IS NOT NULL
  60. </select>
  61. <!--获取所有的发文机关-->
  62. <select id="getPubs" resultType="java.util.Map">
  63. SELECT DISTINCT (substring_index(substring_index(pa.puborg, ' ', b.help_topic_id + 1), ' ', - 1)) AS puborg
  64. FROM policy_article pa
  65. JOIN mysql.help_topic b
  66. ON b.help_topic_id &lt; (length(pa.puborg) - length(REPLACE(pa.puborg, ' ', '')) + 1)
  67. WHERE pa.puborg != ' ';
  68. </select>
  69. <!--获取第一级主题分类-->
  70. <select id="getFirstChildType" resultType="java.util.Map">
  71. SELECT id,
  72. pid,
  73. child_type as title
  74. FROM `policy_article_type`
  75. WHERE pid = -1
  76. </select>
  77. <!--获取第二级主题分类-->
  78. <select id="getSecondChildType" resultType="java.util.Map">
  79. SELECT id,
  80. pid,
  81. child_type as title
  82. FROM `policy_article_type`
  83. WHERE pid = #{id}
  84. </select>
  85. <!--获取主题分类条数-->
  86. <select id="getChildTypeCount" resultType="java.lang.Integer">
  87. SELECT count(1) AS count
  88. FROM
  89. `policy_article`
  90. where
  91. childtype != " "
  92. </select>
  93. <select id="getQuestionRemarkCount" resultType="java.lang.Integer">
  94. SELECT count(1)
  95. FROM question_article_remark
  96. <where>
  97. 1=1
  98. <if test="phone != null">
  99. AND phone LIKE CONCAT('%', #{phone}, '%')
  100. </if>
  101. <if test="deptName != null">
  102. AND dept_name LIKE CONCAT('%', #{deptName}, '%')
  103. </if>
  104. <if test="remark != null">
  105. AND remark LIKE CONCAT('%', #{remark}, '%')
  106. </if>
  107. </where>
  108. </select>
  109. <select id="getQuestionRemarkPage" resultType="java.util.Map">
  110. SELECT id,
  111. phone,
  112. dept_name,
  113. remark,
  114. create_time,
  115. is_reply,
  116. update_time
  117. FROM question_article_remark
  118. <where>
  119. 1=1
  120. <if test="phone != null">
  121. AND phone LIKE CONCAT('%', #{phone}, '%')
  122. </if>
  123. <if test="deptName != null">
  124. AND dept_name LIKE CONCAT('%', #{deptName}, '%')
  125. </if>
  126. <if test="remark != null">
  127. AND remark LIKE CONCAT('%', #{remark}, '%')
  128. </if>
  129. </where>
  130. ORDER BY
  131. is_reply,
  132. create_time DESC
  133. limit #{startRows},#{rows}
  134. </select>
  135. <select id="domainAll" resultType="java.lang.String">
  136. select distinct(domain_type)
  137. from question_article
  138. WHERE domain_type IS NOT NULL
  139. </select>
  140. <insert id="saveSub">
  141. insert into question_article_remark(phone, dept_name, remark, is_reply)
  142. values (#{phone}, #{dept}, #{remark}, 0)
  143. </insert>
  144. </mapper>