|
|
@@ -5,15 +5,9 @@ import com.finikes.oc.management.dao.HouseRelationDAO;
|
|
|
import com.finikes.oc.management.entity.HouseRelation;
|
|
|
import com.finikes.oc.common.LockService;
|
|
|
import com.finikes.oc.common.PassportHelper;
|
|
|
-import com.finikes.oc.vote.dao.ChoiceDao;
|
|
|
-import com.finikes.oc.vote.dao.OptionDao;
|
|
|
-import com.finikes.oc.vote.dao.VoteActivityDao;
|
|
|
-import com.finikes.oc.vote.dao.VoteDao;
|
|
|
+import com.finikes.oc.vote.dao.*;
|
|
|
import com.finikes.oc.vote.dto.*;
|
|
|
-import com.finikes.oc.vote.entity.Choice;
|
|
|
-import com.finikes.oc.vote.entity.Option;
|
|
|
-import com.finikes.oc.vote.entity.Vote;
|
|
|
-import com.finikes.oc.vote.entity.VoteActivity;
|
|
|
+import com.finikes.oc.vote.entity.*;
|
|
|
import com.finikes.oc.common.exception.BusinessException;
|
|
|
import com.finikes.oc.vote.mapper.VoteActivityMapper;
|
|
|
import com.finikes.oc.vote.mapper.VoteMapper;
|
|
|
@@ -44,14 +38,17 @@ public class VoteServiceImpl implements VoteService {
|
|
|
|
|
|
private final HouseRelationDAO houseRelationDAO;
|
|
|
|
|
|
+ private final SignCodeDAO signCodeDAO;
|
|
|
+
|
|
|
public VoteServiceImpl(ChoiceDao choiceDao, OptionDao optionDao, VoteActivityDao voteActivityDao, VoteDao voteDao,
|
|
|
- LockService lockService, HouseRelationDAO houseRelationDAO) {
|
|
|
+ LockService lockService, HouseRelationDAO houseRelationDAO, SignCodeDAO signCodeDAO) {
|
|
|
this.choiceDao = choiceDao;
|
|
|
this.optionDao = optionDao;
|
|
|
this.voteActivityDao = voteActivityDao;
|
|
|
this.voteDao = voteDao;
|
|
|
this.lockService = lockService;
|
|
|
this.houseRelationDAO = houseRelationDAO;
|
|
|
+ this.signCodeDAO = signCodeDAO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -227,7 +224,7 @@ public class VoteServiceImpl implements VoteService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void madeChoice(ChoiceDto dto) {
|
|
|
+ public int madeChoice(ChoiceDto dto) {
|
|
|
Passport passport = PassportHelper.currentPassport();
|
|
|
if (passport == null) {
|
|
|
throw new BusinessException("获取登录状态异常");
|
|
|
@@ -284,6 +281,10 @@ public class VoteServiceImpl implements VoteService {
|
|
|
throw new BusinessException("此房产已经参与过投票了");
|
|
|
}
|
|
|
|
|
|
+ SignCode signCode = new SignCode();
|
|
|
+ signCodeDAO.nextCode(signCode);
|
|
|
+ int code = signCode.getCode();
|
|
|
+
|
|
|
Choice choice = new Choice();
|
|
|
choice.setPassportId(passport.getId());
|
|
|
choice.setOptionId(dto.getOptionId());
|
|
|
@@ -291,8 +292,11 @@ public class VoteServiceImpl implements VoteService {
|
|
|
choice.setChooseTime(now);
|
|
|
choice.setHouseId(dto.getHouseId());
|
|
|
choice.setSignature(dto.getSignature());
|
|
|
+ choice.setSignCode(code);
|
|
|
|
|
|
choiceDao.insert(choice);
|
|
|
+
|
|
|
+ return code;
|
|
|
} finally {
|
|
|
lockService.unlock(voteResourceId, ownerId);
|
|
|
lockService.unlock(houseResourceId, ownerId);
|
|
|
@@ -300,7 +304,7 @@ public class VoteServiceImpl implements VoteService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void madeChoiceDelegation(ChoiceDelegationDto dto) {
|
|
|
+ public int madeChoiceDelegation(ChoiceDelegationDto dto) {
|
|
|
int houseId = dto.getHouseId();
|
|
|
Passport passport = PassportHelper.currentPassport();
|
|
|
if (passport == null) {
|
|
|
@@ -348,6 +352,10 @@ public class VoteServiceImpl implements VoteService {
|
|
|
throw new BusinessException("此房产已经参与过投票了");
|
|
|
}
|
|
|
|
|
|
+ SignCode signCode = new SignCode();
|
|
|
+ signCodeDAO.nextCode(new SignCode());
|
|
|
+ int code = signCode.getCode();
|
|
|
+
|
|
|
Choice choice = new Choice();
|
|
|
choice.setOptionId(dto.getOptionId());
|
|
|
choice.setAssigneeId(passport.getId());
|
|
|
@@ -355,8 +363,11 @@ public class VoteServiceImpl implements VoteService {
|
|
|
choice.setChooseTime(now);
|
|
|
choice.setHouseId(houseId);
|
|
|
choice.setSignature(dto.getSignature());
|
|
|
+ choice.setSignCode(code);
|
|
|
|
|
|
choiceDao.insert(choice);
|
|
|
+
|
|
|
+ return code;
|
|
|
} finally {
|
|
|
lockService.unlock(voteResourceId, ownerId);
|
|
|
lockService.unlock(houseResourceId, ownerId);
|