Просмотр исходного кода

finikes alpha 15(fixed: 投票限制bug)

finikes 2 лет назад
Родитель
Сommit
e49a464d41

+ 2 - 0
src/main/java/com/finikes/oc/vote/dao/ChoiceDao.java

@@ -13,6 +13,8 @@ public interface ChoiceDao extends BaseDao<Choice, Long> {
 
     boolean isHouseHolderInThisVote(@Param("voteId") Integer voteId, @Param("certificateNo") String certificateNo);
 
+    boolean isHouseHolderInThisVote_1(@Param("voteId") Integer voteId, @Param("passportId") Integer passportId);
+
     List<OptionSummary> selectByVoteIds(@Param("voteIds") List<Integer> voteIds);
 
 }

+ 10 - 0
src/main/java/com/finikes/oc/vote/dto/ChoiceDelegationDto.java

@@ -3,12 +3,22 @@ package com.finikes.oc.vote.dto;
 public class ChoiceDelegationDto {
     private Integer optionId;
     private Integer principalId;
+    private String suggestion;
+
+    public String getSuggestion() {
+        return suggestion;
+    }
+
+    public void setSuggestion(String suggestion) {
+        this.suggestion = suggestion;
+    }
 
     @Override
     public String toString() {
         return "ChoiceDelegationDto{" +
                 "optionId=" + optionId +
                 ", principalId=" + principalId +
+                ", suggestion=" + suggestion +
                 '}';
     }
 

+ 11 - 0
src/main/java/com/finikes/oc/vote/dto/ChoiceDto.java

@@ -13,10 +13,21 @@ public class ChoiceDto {
     @NotNull
     private Integer optionId;
 
+    private String suggestion;
+
+    public String getSuggestion() {
+        return suggestion;
+    }
+
+    public void setSuggestion(String suggestion) {
+        this.suggestion = suggestion;
+    }
+
     @Override
     public String toString() {
         return "ChoiceDto{" +
                 "optionId=" + optionId +
+                ", suggestion=" + suggestion +
                 '}';
     }
 

+ 63 - 54
src/main/java/com/finikes/oc/vote/entity/Choice.java

@@ -4,58 +4,67 @@ package com.finikes.oc.vote.entity;
  * 选择
  */
 public class Choice {
-	private long id;
-	private int optionId; // 选项ID
-	private int passportId; // 账号ID
-	private long chooseTime; // 选择的时间
-	private boolean proxy; // 是否代理投票
-	private int assigneeId; // 代理者ID
-
-	public long getId() {
-		return id;
-	}
-
-	public void setId(long id) {
-		this.id = id;
-	}
-
-	public int getOptionId() {
-		return optionId;
-	}
-
-	public void setOptionId(int optionId) {
-		this.optionId = optionId;
-	}
-
-	public int getPassportId() {
-		return passportId;
-	}
-
-	public void setPassportId(int passportId) {
-		this.passportId = passportId;
-	}
-
-	public long getChooseTime() {
-		return chooseTime;
-	}
-
-	public void setChooseTime(long chooseTime) {
-		this.chooseTime = chooseTime;
-	}
-
-	public boolean isProxy() {
-		return proxy;
-	}
-
-	public void setProxy(boolean proxy) {
-		this.proxy = proxy;
-	}
-
-	public int getAssigneeId() {
-		return assigneeId;
-	}
-
-	public void setAssigneeId(int assigneeId) {
-		this.assigneeId = assigneeId;
-	}
+    private long id;
+    private int optionId; // 选项ID
+    private int passportId; // 账号ID
+    private long chooseTime; // 选择的时间
+    private boolean proxy; // 是否代理投票
+    private int assigneeId; // 代理者ID
+    private String suggestion; // 建议或意见
+
+    public String getSuggestion() {
+        return suggestion;
+    }
+
+    public void setSuggestion(String suggestion) {
+        this.suggestion = suggestion;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public int getOptionId() {
+        return optionId;
+    }
+
+    public void setOptionId(int optionId) {
+        this.optionId = optionId;
+    }
+
+    public int getPassportId() {
+        return passportId;
+    }
+
+    public void setPassportId(int passportId) {
+        this.passportId = passportId;
+    }
+
+    public long getChooseTime() {
+        return chooseTime;
+    }
+
+    public void setChooseTime(long chooseTime) {
+        this.chooseTime = chooseTime;
+    }
+
+    public boolean isProxy() {
+        return proxy;
+    }
+
+    public void setProxy(boolean proxy) {
+        this.proxy = proxy;
+    }
+
+    public int getAssigneeId() {
+        return assigneeId;
+    }
+
+    public void setAssigneeId(int assigneeId) {
+        this.assigneeId = assigneeId;
+    }
 }

+ 10 - 2
src/main/java/com/finikes/oc/vote/service/VoteServiceImpl.java

@@ -277,7 +277,11 @@ public class VoteServiceImpl implements VoteService {
                 throw new BusinessException("投票日期已过");
             }
 
-            if (choiceDao.isHouseHolderInThisVote(vote.getId(), houseRelation.getCertificateNo())) {
+            /*if (choiceDao.isHouseHolderInThisVote(vote.getId(), houseRelation.getCertificateNo())) {
+                throw new BusinessException("此房产已经参与过投票了");
+            }*/
+
+            if (choiceDao.isHouseHolderInThisVote_1(vote.getId(), houseRelation.getPassportId())) {
                 throw new BusinessException("此房产已经参与过投票了");
             }
 
@@ -340,7 +344,11 @@ public class VoteServiceImpl implements VoteService {
                 throw new BusinessException("投票日期已过");
             }
 
-            if (choiceDao.isHouseHolderInThisVote(vote.getId(), houseRelation.getCertificateNo())) {
+            /*if (choiceDao.isHouseHolderInThisVote(vote.getId(), houseRelation.getCertificateNo())) {
+                throw new BusinessException("此房产已经参与过投票了");
+            }*/
+
+            if (choiceDao.isHouseHolderInThisVote_1(vote.getId(), houseRelation.getPassportId())) {
                 throw new BusinessException("此房产已经参与过投票了");
             }
 

+ 18 - 7
src/main/resources/mapper/ChoiceMapper.xml

@@ -10,8 +10,12 @@
     </insert>
 
     <update id="update" parameterType="com.finikes.oc.vote.entity.Choice">
-        UPDATE t_choice SET option_id = #{optionId}, passport_id = #{passportId}, choose_time = #{chooseTime},
-        proxy = #{proxy}, assignee_id = #{assigneeId}
+        UPDATE t_choice
+        SET option_id   = #{optionId},
+            passport_id = #{passportId},
+            choose_time = #{chooseTime},
+            proxy       = #{proxy},
+            assignee_id = #{assigneeId}
         WHERE id = #{id}
     </update>
 
@@ -23,12 +27,19 @@
     <select id="isHouseHolderInThisVote" resultType="java.lang.Boolean">
         SELECT count(1)
         FROM t_option vote_option,
-        t_choice choice,
-        t_house_relation relation
+             t_choice choice,
+             t_house_relation relation
         WHERE vote_option.vote_id = #{voteId}
-        AND choice.passport_id = relation.passportId
-        AND certificateNo = #{certificateNo}
-        AND state = 1
+          AND choice.passport_id = relation.passportId
+          AND certificateNo = #{certificateNo}
+          AND state = 1
+    </select>
+
+    <select id="isHouseHolderInThisVote_1" resultType="java.lang.Boolean">
+        select count(1)
+        from t_choice c
+        where c.passport_id = #{passportId}
+          and c.option_id in (select id from t_option o where o.vote_id = #{voteId})
     </select>
 
     <delete id="deleteByPrimaryKey" parameterType="integer">