44323
2023-11-14 ddbb38c54db9c3670e5ff53f4bf713525de1099d
cloud-server-competition/src/main/java/com/dsh/competition/controller/ParticipantController.java
@@ -1,5 +1,10 @@
package com.dsh.competition.controller;
import com.dsh.competition.feignclient.account.AppUserClient;
import com.dsh.competition.feignclient.account.StudentClient;
import com.dsh.competition.feignclient.account.model.AppUser;
import com.dsh.competition.feignclient.account.model.Student;
import com.dsh.competition.feignclient.account.model.TStudent;
import com.dsh.competition.model.AddParticipant;
import com.dsh.competition.model.EditParticipant;
import com.dsh.competition.model.ParticipantVo;
@@ -13,6 +18,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@@ -59,15 +66,27 @@
    @PostMapping("/api/participant/queryParticipantList")
    @ApiOperation(value = "获取参赛人员列表", tags = {"APP-赛事活动列表", ""})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "isPre(1过滤)", name = "是否过滤未实名", required = true, dataType = "int")
    })
    public ResultUtil<List<ParticipantVo>> queryParticipantList(){
    public ResultUtil<List<ParticipantVo>> queryParticipantList(Integer isPre){
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<ParticipantVo> participantVos = participantService.queryParticipantList(uid);
            if (isPre!=null){
                List<ParticipantVo> filteredParticipants = new ArrayList<>();
                for (ParticipantVo participant : participantVos) {
                    if (participant.getIdcard() != null && !participant.getIdcard().isEmpty()) {
                        filteredParticipants.add(participant);
                    }
                }
            return ResultUtil.success(filteredParticipants);
            }
            return ResultUtil.success(participantVos);
        }catch (Exception e){
            e.printStackTrace();
@@ -78,6 +97,11 @@
   @Resource
   private StudentClient studentClient;
    @Resource
    private AppUserClient appUserClient;
    @ResponseBody
    @PostMapping("/api/participant/editParticipant")
    @ApiOperation(value = "编辑参赛人员", tags = {"APP-赛事活动列表", ""})
@@ -90,7 +114,26 @@
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            int numDigits = String.valueOf(editParticipant.getId()).length();
            if (numDigits==9){
            return participantService.editParticipant(uid, editParticipant);
            }
            else {
                TStudent student = new TStudent();
                student.setId(editParticipant.getId());
                student.setName(editParticipant.getName());
                student.setIdCard(editParticipant.getIdcard());
                student.setHeight(Double.valueOf(editParticipant.getHeight()));
                student.setWeight(editParticipant.getWeight());
                student.setPhone(editParticipant.getPhone());
                studentClient.updateAppUser(student);
                return ResultUtil.success();
            }
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();