VoteMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.VoteDao">
  4. <insert id="insert" useGeneratedKeys="true" keyProperty="id" keyColumn="id"
  5. parameterType="com.finikes.oc.vote.entity.Vote">
  6. INSERT INTO t_vote (activity_id, sequence, title, content)
  7. VALUES (#{activityId}, #{sequence}, #{title}, #{content})
  8. </insert>
  9. <update id="update" parameterType="com.finikes.oc.vote.entity.Vote">
  10. UPDATE t_vote
  11. SET activity_id = #{activityId},
  12. sequence = #{sequence},
  13. title = #{title},
  14. content = #{content}
  15. WHERE id = #{id}
  16. </update>
  17. <update id="updateSelective">
  18. UPDATE t_vote
  19. <set>
  20. <if test="activityId != null">
  21. activity_id = #{activityId},
  22. </if>
  23. <if test="sequence != null">
  24. sequence = #{sequence},
  25. </if>
  26. <if test="title != null">
  27. title = #{title},
  28. </if>
  29. <if test="content != null">
  30. content = #{content},
  31. </if>
  32. </set>
  33. WHERE id = #{id}
  34. </update>
  35. <select id="selectByPrimaryKey" parameterType="integer" resultType="com.finikes.oc.vote.entity.Vote">
  36. SELECT id, activity_id, sequence, title, content
  37. FROM t_vote
  38. WHERE id = #{primaryKey}
  39. </select>
  40. <select id="selectByVoteActivityId" resultType="com.finikes.oc.vote.entity.Vote">
  41. SELECT id, activity_id, sequence, title, content
  42. FROM t_vote
  43. WHERE activity_id = #{voteActivityId}
  44. </select>
  45. <delete id="deleteByPrimaryKey" parameterType="integer">
  46. DELETE
  47. FROM t_vote
  48. WHERE id = #{primaryKey}
  49. </delete>
  50. <select id="getHousesNotVote" resultType="com.finikes.oc.estate.entity.House">
  51. SELECT id, unitId, name
  52. FROM t_house h
  53. WHERE h.id NOT IN (
  54. SELECT c.house_id
  55. FROM t_choice c
  56. WHERE c.option_id IN (SELECT id FROM t_option o WHERE o.vote_id = #{voteId}))
  57. LIMIT #{offset}
  58. , #{sectionCapacity}
  59. </select>
  60. <select id="getHousesNotVoteNum" resultType="java.lang.Integer">
  61. SELECT count(1)
  62. FROM t_house h
  63. WHERE h.id NOT IN (
  64. SELECT c.house_id
  65. FROM t_choice c
  66. WHERE c.option_id IN (SELECT id FROM t_option o WHERE o.vote_id = #{voteId}))
  67. </select>
  68. <select id="getHousesVote" resultType="com.finikes.oc.estate.entity.House">
  69. SELECT id, unitId, name
  70. FROM t_house h
  71. WHERE h.id IN (
  72. SELECT c.house_id
  73. FROM t_choice c
  74. WHERE c.option_id IN (SELECT id FROM t_option o WHERE o.vote_id = #{voteId}))
  75. LIMIT #{offset}
  76. , #{sectionCapacity}
  77. </select>
  78. <select id="getHousesVoteNum" resultType="java.lang.Integer">
  79. SELECT count(1)
  80. FROM t_house h
  81. WHERE h.id IN (
  82. SELECT c.house_id
  83. FROM t_choice c
  84. WHERE c.option_id IN (SELECT id FROM t_option o WHERE o.vote_id = #{voteId}))
  85. </select>
  86. </mapper>