ChoiceMapper.xml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.finikes.oc.vote.dao.ChoiceDao">
  4. <insert id="insert" useGeneratedKeys="true" keyProperty="id" keyColumn="id"
  5. parameterType="com.finikes.oc.vote.entity.Choice">
  6. INSERT INTO t_choice (option_id, choose_time, proxy, assignee_id, house_id, signature, sign_code, img_type)
  7. VALUES (#{optionId}, #{chooseTime}, #{proxy}, #{assigneeId}, #{houseId}, #{signature}, #{signCode}, #{imgType})
  8. </insert>
  9. <update id="update" parameterType="com.finikes.oc.vote.entity.Choice">
  10. UPDATE t_choice
  11. SET option_id = #{optionId},
  12. passport_id = #{passportId},
  13. choose_time = #{chooseTime},
  14. proxy = #{proxy},
  15. assignee_id = #{assigneeId}
  16. WHERE id = #{id}
  17. </update>
  18. <select id="selectByPrimaryKey" parameterType="integer" resultType="com.finikes.oc.vote.entity.Choice">
  19. SELECT id, option_id, passport_id, choose_time, proxy, assignee_id
  20. FROM t_choice
  21. WHERE id = #{primaryKey}
  22. </select>
  23. <select id="isHouseHolderInThisVote" resultType="java.lang.Boolean">
  24. SELECT count(1)
  25. FROM t_option vote_option,
  26. t_choice choice,
  27. t_house_relation relation
  28. WHERE vote_option.vote_id = #{voteId}
  29. AND choice.passport_id = relation.passportId
  30. AND certificateNo = #{certificateNo}
  31. AND state = 1
  32. </select>
  33. <select id="isHouseHolderInThisVote_1" resultType="java.lang.Integer">
  34. select count(1)
  35. from t_choice c
  36. where c.house_id = #{houseId}
  37. and c.option_id in (select id from t_option o where o.vote_id = #{voteId})
  38. </select>
  39. <delete id="deleteByPrimaryKey" parameterType="integer">
  40. DELETE
  41. FROM t_choice
  42. WHERE id = #{primaryKey}
  43. </delete>
  44. <select id="selectByVoteIds" resultType="com.finikes.oc.vote.dto.OptionSummary">
  45. SELECT count(1) quantity, option_id, value, vote_id
  46. FROM t_option,
  47. t_choice
  48. WHERE t_option.vote_id IN
  49. <foreach collection="voteIds" item="item" open="(" separator="," close=")">
  50. #{item}
  51. </foreach>
  52. AND t_choice.option_id = t_option.id
  53. GROUP BY option_id;
  54. </select>
  55. <!--
  56. <select id="getSuggestionSectionByVote" resultType="com.finikes.oc.vote.dto.OptionSuggestion">
  57. select c.id as choiceId, p.id as passportId, p.`name` as passportName, c.suggestion as suggestion
  58. from t_choice c,
  59. t_passport p
  60. where c.option_id in (select id from t_option where vote_id = #{voteId})
  61. and c.passport_id = p.id
  62. ORDER BY c.choose_time desc LIMIT #{offset}, #{sectionCapacity}
  63. </select>
  64. <select id="getSuggestionNumByVote" resultType="java.lang.Integer">
  65. select count(1)
  66. from t_choice c
  67. where c.option_id in
  68. (select id from t_option where vote_id = #{voteId})
  69. </select>
  70. -->
  71. <select id="findByOption" resultType="com.finikes.oc.vote.dto.ChoiceDetail">
  72. SELECT h.fullDisplayName as voterName
  73. FROM t_choice c,
  74. t_house h
  75. WHERE c.option_id = #{optionId}
  76. AND c.house_id = h.id
  77. </select>
  78. </mapper>