QuestionTitleValueV1ServiceDaoImplMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="questionTitleValueV1ServiceDaoImpl">
  6. <!-- 保存问卷题目选项信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveQuestionTitleValueInfo" parameterType="Map">
  8. insert into question_title_value(
  9. score,value_id,title_id,community_id,qa_value,seq
  10. ) values (
  11. #{score},#{valueId},#{titleId},#{communityId},#{qaValue},#{seq}
  12. )
  13. </insert>
  14. <!-- 查询问卷题目选项信息 add by wuxw 2018-07-03 -->
  15. <select id="getQuestionTitleValueInfo" parameterType="Map" resultType="Map">
  16. select t.score,t.value_id,t.value_id valueId,t.title_id,t.title_id titleId,t.status_cd,t.status_cd
  17. statusCd,t.community_id,t.community_id communityId,t.qa_value,t.qa_value qaValue,t.seq,count(uqav.user_qa_id) personCount
  18. from question_title_value t
  19. left join user_question_answer_value uqav on t.value_id = uqav.value_id and t.title_id = uqav.title_id and uqav.status_cd = '0'
  20. where 1 =1
  21. <if test="score !=null and score != ''">
  22. and t.score= #{score}
  23. </if>
  24. <if test="valueId !=null and valueId != ''">
  25. and t.value_id= #{valueId}
  26. </if>
  27. <if test="titleId !=null and titleId != ''">
  28. and t.title_id= #{titleId}
  29. </if>
  30. <if test="titleIds !=null">
  31. and t.title_id in
  32. <foreach collection="titleIds" item="item" index="index" open="(" close=")" separator=",">
  33. #{item}
  34. </foreach>
  35. </if>
  36. <if test="statusCd !=null and statusCd != ''">
  37. and t.status_cd= #{statusCd}
  38. </if>
  39. <if test="communityId !=null and communityId != ''">
  40. and t.community_id= #{communityId}
  41. </if>
  42. <if test="qaValue !=null and qaValue != ''">
  43. and t.qa_value= #{qaValue}
  44. </if>
  45. <if test="seq !=null and seq != ''">
  46. and t.seq= #{seq}
  47. </if>
  48. group by t.score,t.value_id,t.title_id,t.status_cd,t.community_id,t.qa_value,t.seq
  49. order by t.seq
  50. <if test="page != -1 and page != null ">
  51. limit #{page}, #{row}
  52. </if>
  53. </select>
  54. <!-- 修改问卷题目选项信息 add by wuxw 2018-07-03 -->
  55. <update id="updateQuestionTitleValueInfo" parameterType="Map">
  56. update question_title_value t set t.status_cd = #{statusCd}
  57. <if test="newBId != null and newBId != ''">
  58. ,t.b_id = #{newBId}
  59. </if>
  60. <if test="score !=null and score != ''">
  61. , t.score= #{score}
  62. </if>
  63. <if test="qaValue !=null and qaValue != ''">
  64. , t.qa_value= #{qaValue}
  65. </if>
  66. <if test="seq !=null and seq != ''">
  67. , t.seq= #{seq}
  68. </if>
  69. where 1=1
  70. <if test="valueId !=null and valueId != ''">
  71. and t.value_id= #{valueId}
  72. </if>
  73. <if test="titleId !=null and titleId != ''">
  74. and t.title_id= #{titleId}
  75. </if>
  76. <if test="communityId !=null and communityId != ''">
  77. and t.community_id= #{communityId}
  78. </if>
  79. </update>
  80. <!-- 查询问卷题目选项数量 add by wuxw 2018-07-03 -->
  81. <select id="queryQuestionTitleValuesCount" parameterType="Map" resultType="Map">
  82. select count(1) count
  83. from question_title_value t
  84. where 1 =1
  85. <if test="score !=null and score != ''">
  86. and t.score= #{score}
  87. </if>
  88. <if test="valueId !=null and valueId != ''">
  89. and t.value_id= #{valueId}
  90. </if>
  91. <if test="titleId !=null and titleId != ''">
  92. and t.title_id= #{titleId}
  93. </if>
  94. <if test="statusCd !=null and statusCd != ''">
  95. and t.status_cd= #{statusCd}
  96. </if>
  97. <if test="communityId !=null and communityId != ''">
  98. and t.community_id= #{communityId}
  99. </if>
  100. <if test="qaValue !=null and qaValue != ''">
  101. and t.qa_value= #{qaValue}
  102. </if>
  103. <if test="seq !=null and seq != ''">
  104. and t.seq= #{seq}
  105. </if>
  106. </select>
  107. <select id="queryQuestionOwnerTitleValues" parameterType="Map" resultType="Map">
  108. select qt.qa_title qaTitle,qt.title_id titleId, qt.title_type titleType,qa.qa_id qaId,t.qa_value qaValue,t.seq,count(uqav.user_qa_id) personCount
  109. from question_title_value t
  110. inner join question_title qt on t.title_id = qt.title_id and qt.status_cd = '0'
  111. inner join question_answer_title_rel qatr on t.title_id = qatr.title_id and qatr.status_cd = '0'
  112. inner join question_answer qa on qatr.qa_id = qa.qa_id and qa.status_cd = '0'
  113. left join user_question_answer_value uqav on qa.qa_id = uqav.qa_id and t.value_id = uqav.value_id and t.title_id = uqav.title_id and uqav.status_cd = '0'
  114. where 1=1
  115. and t.community_id = #{communityId}
  116. <if test="titleId !=null and titleId != ''">
  117. and t.title_id= #{titleId}
  118. </if>
  119. <if test="statusCd !=null and statusCd != ''">
  120. and t.status_cd= #{statusCd}
  121. </if>
  122. <if test="qaIds !=null">
  123. and qa.qa_id in
  124. <foreach collection="qaIds" item="item" index="index" open="(" close=")" separator=",">
  125. #{item}
  126. </foreach>
  127. </if>
  128. group by qt.qa_title,qt.title_id , qt.title_type,qa.qa_id,t.qa_value,t.seq
  129. order by t.seq
  130. </select>
  131. </mapper>