|
@@ -11,11 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @author tangshanshan
|
|
|
* @date 2017/11/3
|
|
|
*/
|
|
@@ -61,7 +62,7 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
|
|
|
@Override
|
|
|
public Qualification getQualification(Long competitionId, Long userId) {
|
|
|
- return qualificationDao.findLatestQulificationByCompetitionIdAndUserId(competitionId,userId);
|
|
|
+ return qualificationDao.findLatestQulificationByCompetitionIdAndUserId(competitionId, userId);
|
|
|
}
|
|
|
|
|
|
// @Override
|
|
@@ -78,7 +79,7 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
Qualification qualification1 = qualificationDao.findByCompetitionIdAndUserIdAndStatus(qualification.getCompetitionId(),
|
|
|
qualification.getUserId(), qualification.getStatus());
|
|
|
//System.out.println(qualification1.toString());
|
|
|
- if(qualification1 == null) {
|
|
|
+ if (qualification1 == null) {
|
|
|
//修改原有数据
|
|
|
|
|
|
//插入新数据
|
|
@@ -91,6 +92,7 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
}
|
|
|
return qualification1;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public List<Qualification> getQualificationByCompetitionIdAndIndex(Long competitionId, Integer status) {
|
|
|
return qualificationDao.findByCompetitionIdAndStatus(competitionId, status);
|
|
@@ -123,7 +125,7 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
competition2Exam.setCompetitionId(competitionId);
|
|
|
int index = 1;
|
|
|
ArrayList<Competition2Exam> competition2Exams = competition2ExamDao.findByCompetitionIdOrderByIndexDesc(competitionId);
|
|
|
- if (competition2Exams.size()>0) {
|
|
|
+ if (competition2Exams.size() > 0) {
|
|
|
index = competition2Exams.get(0).getIndex() + 1;
|
|
|
}
|
|
|
competition2Exam.setIndex(index);
|
|
@@ -139,15 +141,15 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
|
|
|
@Override
|
|
|
public List<AddOns2Qualification> updateAddons(List<AddOns2Qualification> addonsList, Long qualificationId, Integer type) {
|
|
|
- List<AddOns2Qualification> deletedAddons = addOns2QualificationDao.findByQualificationIdAndAddonsType(qualificationId,type);
|
|
|
+ List<AddOns2Qualification> deletedAddons = addOns2QualificationDao.findByQualificationIdAndAddonsType(qualificationId, type);
|
|
|
addOns2QualificationDao.delete(deletedAddons);
|
|
|
|
|
|
List<AddOns2Qualification> savedAddons = IteratorUtils.toList(addOns2QualificationDao.save(addonsList).iterator());
|
|
|
|
|
|
List<String> changedAddons = deletedAddons.stream().map(AddOns2Qualification::getEmail).collect(Collectors.toList());
|
|
|
changedAddons.addAll(savedAddons.stream().map(AddOns2Qualification::getEmail).collect(Collectors.toList()));
|
|
|
- if(type == AddOns2Qualification.ADDONS_TYPE_TEACHER){
|
|
|
- eventUtil.post(new UpdateContestMentorEvent(qualificationId,changedAddons));
|
|
|
+ if (type == AddOns2Qualification.ADDONS_TYPE_TEACHER) {
|
|
|
+ eventUtil.post(new UpdateContestMentorEvent(qualificationId, changedAddons));
|
|
|
}
|
|
|
return savedAddons;
|
|
|
}
|
|
@@ -164,6 +166,7 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
competition2ExamDao.save(result);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public Competition2Exam getCompetition2TaskbyCompetitionIdAndIndex(Long competitionId, Integer index) {
|
|
|
return competition2ExamDao.findByCompetitionIdAndIndex(competitionId, index);
|
|
@@ -172,7 +175,7 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
@Override
|
|
|
public Competition2Exam updateCompetition2TaskbyCompetitionIdAndIndex(Long competitionId, Integer index, boolean activeStatusAfterUpdating) {
|
|
|
Competition2Exam result = competition2ExamDao.findByCompetitionIdAndIndex(competitionId, index);
|
|
|
- if(result.isActive() == activeStatusAfterUpdating) {
|
|
|
+ if (result.isActive() == activeStatusAfterUpdating) {
|
|
|
return result;
|
|
|
}
|
|
|
result.setActive(activeStatusAfterUpdating);
|
|
@@ -180,12 +183,24 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
- public boolean checkAddons(List<AddonsVO> addonsList, Long qualificationId, Integer type) {
|
|
|
- if (type == null)
|
|
|
- return false;
|
|
|
- if (type == 0)
|
|
|
- return true;
|
|
|
+ public Map<String, Object> checkAddons(List<AddonsVO> addonsList, Long qualificationId, Integer type) {
|
|
|
+ Map<String, Object> res = new HashMap<>();
|
|
|
+// if (type == null)
|
|
|
+// return false;
|
|
|
+// if (type == 0)
|
|
|
+// return true;
|
|
|
+ if (type == null) {
|
|
|
+ res.put("code", 1);
|
|
|
+ res.put("message", "类型出错");
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (type == 0) {
|
|
|
+ res.put("code", 0);
|
|
|
+ res.put("message", "修改成功");
|
|
|
+ return res;
|
|
|
+ }
|
|
|
//获取当前队伍比赛信息
|
|
|
Qualification qualification = qualificationDao.findOne(qualificationId);
|
|
|
//获取所有参加当前比赛的队伍
|
|
@@ -199,7 +214,10 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
for (AddonsVO currAddons : addonsList) {
|
|
|
//如果信息已存在则返回错误
|
|
|
if (currAddons.getEmail().equals(addons.getEmail())) {
|
|
|
- return false;
|
|
|
+ res.put("code", 2);
|
|
|
+ res.put("message", "修改失败,队员'"+addons.getEmail()+"'已加入其它队伍!");
|
|
|
+ return res;
|
|
|
+ //return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -211,13 +229,17 @@ public class CompetitionServiceImpl implements CompetitionService {
|
|
|
if (null != user) {
|
|
|
for (Qualification temp : qualifications) {
|
|
|
if (temp.getUserId().equals(user.getId())) {
|
|
|
- return false;
|
|
|
+ //return false;
|
|
|
+ res.put("code", 3);
|
|
|
+ res.put("message", "修改失败,队员'"+user.getEmail()+"'已是其他队伍的队长");
|
|
|
+ return res;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //默认返回
|
|
|
- return true;
|
|
|
+ res.put("code", 0);
|
|
|
+ res.put("message", "修改成功");
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
}
|