参赛团队成员删除
parent
bc5058acb8
commit
2cbfe68e4d
@ -0,0 +1,15 @@
|
||||
package com.tz.platform.common.core.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MemberInfo {
|
||||
private String studentNo;
|
||||
private Long id;
|
||||
private String school;
|
||||
private String name;
|
||||
private String province;
|
||||
private Integer provinceId;
|
||||
private Integer regionId;
|
||||
private Integer levelId;
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.tz.platform.competitiion.pc;
|
||||
|
||||
import com.tz.platform.common.core.base.BaseController;
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.competitiion.pc.biz.TeamBiz;
|
||||
import com.tz.platform.competitiion.pc.dto.PageTeamDTO;
|
||||
import com.tz.platform.competitiion.pc.vo.AddTeamMemberVO;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/pc/competition/team")
|
||||
public class CompetitionTeamController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private TeamBiz teamBiz;
|
||||
|
||||
@PostMapping(value = "list")
|
||||
public Result<PageTeamDTO> list(@RequestBody PageTeamVO vo){
|
||||
return teamBiz.list(vo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "deleteMember")
|
||||
public Result<String> deleteMember(@RequestBody TeamMemberVO vo){
|
||||
return teamBiz.deleteMember(vo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "editTeamInfo")
|
||||
public Result<String> editTeamInfo(@RequestBody TeamInfoVO vo){
|
||||
return teamBiz.updateTeamInfo(vo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "addMember")
|
||||
public Result<String> addTeamMember(@RequestBody AddTeamMemberVO vo){
|
||||
return teamBiz.addTeamMember(vo);
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package com.tz.platform.competitiion.pc.biz;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.competitiion.pc.dto.PageTeamDTO;
|
||||
import com.tz.platform.competitiion.pc.vo.AddTeamMemberVO;
|
||||
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.CompetitionTeam;
|
||||
import com.tz.platform.feign.user.IFeignUser;
|
||||
import com.tz.platform.repository.CompetitionMemberDao;
|
||||
import com.tz.platform.repository.CompetitionTeamDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class TeamBiz {
|
||||
@Autowired
|
||||
private CompetitionTeamDao teamDao;
|
||||
|
||||
@Autowired
|
||||
private CompetitionMemberDao memberDao;
|
||||
|
||||
@Autowired
|
||||
private IFeignUser feignUser;
|
||||
|
||||
public Result<PageTeamDTO> list(PageTeamVO vo){
|
||||
|
||||
if(vo.getPageSize() == null || vo.getPageSize()<0){
|
||||
vo.setPageSize(20);
|
||||
}
|
||||
vo.setPageNo(vo.getPageNo() -1);
|
||||
if(vo.getPageNo() == null||vo.getPageNo()<0){
|
||||
vo.setPageNo(1);
|
||||
}
|
||||
if(vo.getCompetitionId() == null){
|
||||
return Result.error("大赛id不能为空");
|
||||
}
|
||||
if(vo.getStageId() == null){
|
||||
return Result.error("赛段id不能为空");
|
||||
}
|
||||
ExampleMatcher matcher = ExampleMatcher.matching().withIgnoreNullValues();
|
||||
CompetitionTeam team = new CompetitionTeam();
|
||||
team.setStageId(vo.getStageId());
|
||||
team.setCompetitionId(vo.getCompetitionId());
|
||||
Example<CompetitionTeam> example = Example.of(team,matcher);
|
||||
Pageable pageable = PageRequest.of(vo.getPageNo(),vo.getPageSize());
|
||||
Page<CompetitionTeam> onePage = teamDao.findAll(example,pageable);
|
||||
List<Integer> teamIds = onePage.getContent().stream().mapToInt(CompetitionTeam::getId).boxed().collect(Collectors.toList());
|
||||
List<CompetitionMember> memberList = memberDao.findAllByCompetitionIdAndStageIdAndTeamIdIn(vo.getCompetitionId(),vo.getStageId(),teamIds);
|
||||
PageTeamDTO dto = new PageTeamDTO();
|
||||
dto.setList(memberList);
|
||||
dto.setPage(onePage);
|
||||
return Result.success(dto);
|
||||
}
|
||||
|
||||
public Result<String> deleteMember(TeamMemberVO vo){
|
||||
memberDao.deleteById(vo.getId());
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
public Result<String> addTeamMember(AddTeamMemberVO vo){
|
||||
CompetitionTeam team = teamDao.getById(vo.getTeamId());
|
||||
if(team == null){
|
||||
return Result.error("未找到团队信息");
|
||||
}
|
||||
if(vo.getStageId() == null){
|
||||
return Result.error("阶段信息不能为空");
|
||||
}
|
||||
|
||||
|
||||
return Result.success("");
|
||||
}
|
||||
|
||||
public Result<String> updateTeamInfo(TeamInfoVO vo){
|
||||
if(vo.getId() == null){
|
||||
return Result.error("团队id不能这空");
|
||||
}
|
||||
if(StringUtils.isEmpty(vo.getName())){
|
||||
return Result.error("名称不能为空");
|
||||
}
|
||||
CompetitionTeam team = teamDao.getById(vo.getId());
|
||||
if(team == null){
|
||||
return Result.error("未找到团队信息");
|
||||
}
|
||||
if(vo.getType() == 1){
|
||||
team.setTeamName(vo.getName());
|
||||
}else{
|
||||
team.setTeacherName(vo.getName());
|
||||
}
|
||||
teamDao.save(team);
|
||||
return Result.success("success");
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.tz.platform.competitiion.pc.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AddTeamMemberVO {
|
||||
private Integer teamId;
|
||||
private Long competitionId;
|
||||
private Integer stageId;
|
||||
private List<Long> ids;
|
||||
}
|
Loading…
Reference in New Issue