SysSuggestionMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.SysSuggestionDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.SysSuggestion" id="SysSuggestion">
  9. <result column="id_" property="id"/>
  10. <result column="mobile_no_" property="mobileNo"/>
  11. <result column="title_" property="title"/>
  12. <result column="content_" property="content"/>
  13. <result column="device_no_" property="deviceNo"/>
  14. <result column="url_" property="url"/>
  15. <result column="user_id_" property="userId"/>
  16. <result column="username_" property="username"/>
  17. <result column="create_time_" property="createTime"/>
  18. <result column="client_type_" property="clientType"/>
  19. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  20. <result column="tenant_id_" property="tenantId"/>
  21. <result column="suggestion_type_" property="suggestionType"/>
  22. <result column="suggestionTypeName" property="suggestionTypeName"/>
  23. <result column="operator_id_" property="operatorId"/>
  24. <result column="operatorName" property="operatorName"/>
  25. <result column="operator_time_" property="operatorTime"/>
  26. <result column="operator_memo_" property="operatorMemo"/>
  27. <result column="feedback_flag_" property="feedbackFlag"/>
  28. <result column="handle_flag_" property="handleFlag"/>
  29. </resultMap>
  30. <!-- 根据主键查询一条记录 -->
  31. <select id="get" resultMap="SysSuggestion">
  32. SELECT * FROM sys_suggestion WHERE id_ = #{id}
  33. </select>
  34. <!-- 全查询 -->
  35. <select id="findAll" resultMap="SysSuggestion">
  36. SELECT * FROM sys_suggestion where tenant_id_ = #{tenantId} ORDER BY id_
  37. </select>
  38. <!-- 向数据库增加一条记录 -->
  39. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysSuggestion" useGeneratedKeys="true" keyColumn="id"
  40. keyProperty="id">
  41. INSERT INTO sys_suggestion (mobile_no_,title_,content_,user_id_,create_time_,client_type_,type_,url_,tenant_id_,
  42. suggestion_type_,device_no_)
  43. VALUES(#{mobileNo},#{title},#{content},#{userId},now(),#{clientType},
  44. #{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{url},#{tenantId},
  45. #{suggestionType},#{deviceNo})
  46. </insert>
  47. <!-- 根据主键查询一条记录 -->
  48. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysSuggestion">
  49. UPDATE sys_suggestion
  50. <set>
  51. <if test="operatorId != null">
  52. operator_id_ = #{operatorId},
  53. </if>
  54. <if test="operatorTime != null">
  55. operator_time_ = #{operatorTime},
  56. </if>
  57. <if test="operatorMemo != null">
  58. operator_memo_ = #{operatorMemo},
  59. </if>
  60. <if test="feedbackFlag != null">
  61. feedback_flag_ = #{feedbackFlag},
  62. </if>
  63. <if test="handleFlag != null">
  64. handle_flag_ = #{handleFlag},
  65. </if>
  66. <if test="deviceNo != null">
  67. device_no_ = #{deviceNo},
  68. </if>
  69. </set>
  70. WHERE id_ = #{id}
  71. </update>
  72. <!-- 根据主键删除一条记录 -->
  73. <delete id="delete">
  74. DELETE FROM sys_suggestion WHERE id_ = #{id}
  75. </delete>
  76. <sql id="queryCondition">
  77. <where>
  78. ss.tenant_id_ = #{tenantId}
  79. <if test="type!=null">
  80. AND ss.type_ = #{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  81. </if>
  82. <if test="clientType != null and clientType != ''">
  83. AND ss.client_type_ = #{clientType}
  84. </if>
  85. <if test="startTime!=null and startTime!=''">
  86. AND DATE_FORMAT(ss.create_time_,'%Y-%m-%d') &gt;= #{startTime}
  87. </if>
  88. <if test="endTime!=null and endTime!=''">
  89. AND DATE_FORMAT(ss.create_time_,'%Y-%m-%d') &lt;= #{endTime}
  90. </if>
  91. <if test="search != null and search != ''">
  92. AND (su.real_name_ LIKE CONCAT('%', #{search}, '%') OR su.username_ LIKE CONCAT('%', #{search}, '%') OR ss.user_id_=#{search} OR su.phone_=#{search})
  93. </if>
  94. <if test="operatorSearch != null and operatorSearch != ''">
  95. AND (sue.real_name_ LIKE CONCAT('%', #{operatorSearch}, '%') OR ss.operator_id_ = #{operatorSearch} OR sue.phone_ LIKE CONCAT('%', #{operatorSearch}, '%'))
  96. </if>
  97. <if test="suggestionType != null">
  98. AND ss.suggestion_type_ = #{suggestionType}
  99. </if>
  100. <if test="disposeFlag != null">
  101. <if test="disposeFlag == false">
  102. AND ss.operator_id_ IS NULL
  103. </if>
  104. <if test="disposeFlag == true">
  105. AND ss.operator_id_ IS NOT NULL
  106. </if>
  107. </if>
  108. <if test="handleFlag != null">
  109. AND ss.handle_flag_ = #{handleFlag}
  110. </if>
  111. <if test="feedbackFlag != null">
  112. AND ss.feedback_flag_ = #{feedbackFlag}
  113. </if>
  114. <if test="operatorId != null">
  115. AND ss.operator_id_ = #{operatorId}
  116. </if>
  117. <if test="userId != null">
  118. AND ss.user_id_ = #{userId}
  119. </if>
  120. <if test="id != null">
  121. AND ss.id_ = #{id}
  122. </if>
  123. </where>
  124. </sql>
  125. <!-- 分页查询 -->
  126. <select id="queryPage" resultMap="SysSuggestion" parameterType="map">
  127. SELECT ss.*,CASE WHEN ss.client_type_ IN ('STUDENT','SCHOOL') THEN su.username_ ELSE su.real_name_ END username_,
  128. sut.type_ suggestionTypeName,sue.real_name_ operatorName
  129. FROM sys_suggestion ss
  130. LEFT JOIN sys_user su ON su.id_ = ss.user_id_
  131. LEFT JOIN sys_user sue ON sue.id_ = ss.operator_id_
  132. left join sys_suggestion_type sut ON sut.id_ = ss.suggestion_type_
  133. <include refid="queryCondition" />
  134. ORDER BY ss.id_ DESC
  135. <include refid="global.limit"/>
  136. </select>
  137. <!-- 查询当前表的总记录数 -->
  138. <select id="queryCount" resultType="int">
  139. SELECT COUNT(ss.id_) FROM sys_suggestion ss
  140. LEFT JOIN sys_user su ON su.id_ = ss.user_id_
  141. LEFT JOIN sys_user sue ON sue.id_ = ss.operator_id_
  142. <include refid="queryCondition" />
  143. </select>
  144. <select id="getDetail" resultMap="SysSuggestion">
  145. SELECT ss.*,CASE WHEN ss.client_type_='STUDENT' THEN su.username_ ELSE su.real_name_ END username_,
  146. sut.type_ suggestionTypeName
  147. FROM sys_suggestion ss
  148. LEFT JOIN sys_user su ON su.id_ = ss.user_id_
  149. left join sys_suggestion_type sut ON sut.id_ = ss.suggestion_type_
  150. WHERE ss.id_ = #{id}
  151. </select>
  152. <select id="countByTypeId" resultType="java.lang.Integer">
  153. select COUNT(0) from sys_suggestion where suggestion_type_ = #{suggestionTypeId}
  154. </select>
  155. </mapper>