|
|
@ -1,11 +1,9 @@
|
|
|
|
package com.tz.platform.competitiion.pc.biz;
|
|
|
|
package com.tz.platform.competitiion.pc.biz;
|
|
|
|
|
|
|
|
|
|
|
|
import com.tz.platform.common.core.base.Result;
|
|
|
|
import com.tz.platform.common.core.base.Result;
|
|
|
|
|
|
|
|
import com.tz.platform.common.core.bo.MemberInfo;
|
|
|
|
import com.tz.platform.competitiion.pc.dto.PageTeamDTO;
|
|
|
|
import com.tz.platform.competitiion.pc.dto.PageTeamDTO;
|
|
|
|
import com.tz.platform.competitiion.pc.vo.AddTeamMemberVO;
|
|
|
|
import com.tz.platform.competitiion.pc.vo.*;
|
|
|
|
import com.tz.platform.competitiion.pc.vo.PageTeamVO;
|
|
|
|
|
|
|
|
import com.tz.platform.competitiion.pc.vo.TeamInfoVO;
|
|
|
|
|
|
|
|
import com.tz.platform.competitiion.pc.vo.TeamMemberVO;
|
|
|
|
|
|
|
|
import com.tz.platform.entity.CompetitionMember;
|
|
|
|
import com.tz.platform.entity.CompetitionMember;
|
|
|
|
import com.tz.platform.entity.CompetitionTeam;
|
|
|
|
import com.tz.platform.entity.CompetitionTeam;
|
|
|
|
import com.tz.platform.feign.user.IFeignUser;
|
|
|
|
import com.tz.platform.feign.user.IFeignUser;
|
|
|
@ -14,8 +12,10 @@ import com.tz.platform.repository.CompetitionTeamDao;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.*;
|
|
|
|
import org.springframework.data.domain.*;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
@ -49,6 +49,9 @@ public class TeamBiz {
|
|
|
|
CompetitionTeam team = new CompetitionTeam();
|
|
|
|
CompetitionTeam team = new CompetitionTeam();
|
|
|
|
team.setStageId(vo.getStageId());
|
|
|
|
team.setStageId(vo.getStageId());
|
|
|
|
team.setCompetitionId(vo.getCompetitionId());
|
|
|
|
team.setCompetitionId(vo.getCompetitionId());
|
|
|
|
|
|
|
|
if(StringUtils.hasText(vo.getTeamName())){
|
|
|
|
|
|
|
|
team.setTeamName(vo.getTeamName());
|
|
|
|
|
|
|
|
}
|
|
|
|
Example<CompetitionTeam> example = Example.of(team,matcher);
|
|
|
|
Example<CompetitionTeam> example = Example.of(team,matcher);
|
|
|
|
Pageable pageable = PageRequest.of(vo.getPageNo(),vo.getPageSize());
|
|
|
|
Pageable pageable = PageRequest.of(vo.getPageNo(),vo.getPageSize());
|
|
|
|
Page<CompetitionTeam> onePage = teamDao.findAll(example,pageable);
|
|
|
|
Page<CompetitionTeam> onePage = teamDao.findAll(example,pageable);
|
|
|
@ -65,6 +68,7 @@ public class TeamBiz {
|
|
|
|
return Result.success("success");
|
|
|
|
return Result.success("success");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public Result<String> addTeamMember(AddTeamMemberVO vo){
|
|
|
|
public Result<String> addTeamMember(AddTeamMemberVO vo){
|
|
|
|
CompetitionTeam team = teamDao.getById(vo.getTeamId());
|
|
|
|
CompetitionTeam team = teamDao.getById(vo.getTeamId());
|
|
|
|
if(team == null){
|
|
|
|
if(team == null){
|
|
|
@ -74,8 +78,31 @@ public class TeamBiz {
|
|
|
|
return Result.error("阶段信息不能为空");
|
|
|
|
return Result.error("阶段信息不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CompetitionMember> existMemberList = memberDao.findAllByCompetitionIdAndStageIdAndUserIdIn(vo.getCompetitionId(),vo.getStageId(),vo.getIds());
|
|
|
|
|
|
|
|
if(existMemberList.size()>0){
|
|
|
|
|
|
|
|
vo.getIds().removeAll(existMemberList.stream().mapToLong(CompetitionMember::getUserId).boxed().collect(Collectors.toList()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MemberInfo> memberInfoList = feignUser.listByIds(vo.getIds());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CompetitionMember> memberList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success("");
|
|
|
|
memberInfoList.forEach(m->{
|
|
|
|
|
|
|
|
CompetitionMember member = new CompetitionMember();
|
|
|
|
|
|
|
|
member.setCompetitionId(team.getCompetitionId());
|
|
|
|
|
|
|
|
member.setName(m.getName());
|
|
|
|
|
|
|
|
member.setSchool(m.getSchool());
|
|
|
|
|
|
|
|
member.setStudentNo(m.getStudentNo());
|
|
|
|
|
|
|
|
member.setUserId(m.getId());
|
|
|
|
|
|
|
|
member.setStageId(team.getStageId());
|
|
|
|
|
|
|
|
member.setTeamId(team.getId());
|
|
|
|
|
|
|
|
memberList.add(member);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memberDao.saveAll(memberList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success("success");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Result<String> updateTeamInfo(TeamInfoVO vo){
|
|
|
|
public Result<String> updateTeamInfo(TeamInfoVO vo){
|
|
|
@ -97,4 +124,40 @@ public class TeamBiz {
|
|
|
|
teamDao.save(team);
|
|
|
|
teamDao.save(team);
|
|
|
|
return Result.success("success");
|
|
|
|
return Result.success("success");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
public Result<String> addTeam(AddTeamVO vo){
|
|
|
|
|
|
|
|
CompetitionTeam team = teamDao.getByTeamName(vo.getTeamName());
|
|
|
|
|
|
|
|
if(team !=null){
|
|
|
|
|
|
|
|
return Result.error("团队名称已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(vo.getIds() == null||vo.getIds().size() == 0){
|
|
|
|
|
|
|
|
return Result.error("请选择团队成员");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
team.setTeamName(vo.getTeamName());
|
|
|
|
|
|
|
|
team.setTeacherName(vo.getTeacher());
|
|
|
|
|
|
|
|
team.setCompetitionId(vo.getCompetitionId());
|
|
|
|
|
|
|
|
team.setStageId(vo.getStageId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompetitionTeam teamInfo = teamDao.save(team);
|
|
|
|
|
|
|
|
List<MemberInfo> memberInfoList = feignUser.listByIds(vo.getIds());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CompetitionMember> memberList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memberInfoList.forEach(m->{
|
|
|
|
|
|
|
|
CompetitionMember member = new CompetitionMember();
|
|
|
|
|
|
|
|
member.setCompetitionId(teamInfo.getCompetitionId());
|
|
|
|
|
|
|
|
member.setName(m.getName());
|
|
|
|
|
|
|
|
member.setSchool(m.getSchool());
|
|
|
|
|
|
|
|
member.setStudentNo(m.getStudentNo());
|
|
|
|
|
|
|
|
member.setUserId(m.getId());
|
|
|
|
|
|
|
|
member.setStageId(teamInfo.getStageId());
|
|
|
|
|
|
|
|
member.setTeamId(teamInfo.getId());
|
|
|
|
|
|
|
|
memberList.add(member);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memberDao.saveAll(memberList);
|
|
|
|
|
|
|
|
return Result.success("success");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|