| | |
| | | package com.dsh.competition.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.competition.entity.Participant; |
| | | import com.dsh.competition.entity.UserCompetition; |
| | | import com.dsh.competition.feignclient.account.AppUserClient; |
| | | import com.dsh.competition.feignclient.account.StudentClient; |
| | |
| | | import com.dsh.competition.model.SaveParticipant; |
| | | import com.dsh.competition.service.IParticipantService; |
| | | import com.dsh.competition.service.UserCompetitionService; |
| | | import com.dsh.competition.util.JuHeUtil; |
| | | import com.dsh.competition.util.ResultUtil; |
| | | import com.dsh.competition.util.TokenUtil; |
| | | import com.dsh.competition.util.ToolUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | private TokenUtil tokenUtil; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/participant/addParticipant") |
| | | @ApiOperation(value = "添加参赛人员", tags = {"APP-赛事活动列表", ""}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil addParticipant(AddParticipant addParticipant){ |
| | | public ResultUtil addParticipant(AddParticipant addParticipant) { |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return participantService.addParticipant(uid, addParticipant); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | @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(Integer isPre){ |
| | | public ResultUtil<List<ParticipantVo>> queryParticipantList(Integer isPre) { |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<ParticipantVo> participantVos = participantService.queryParticipantList(uid); |
| | | if (isPre!=null){ |
| | | if (isPre != null) { |
| | | List<ParticipantVo> filteredParticipants = new ArrayList<>(); |
| | | |
| | | for (ParticipantVo participant : participantVos) { |
| | |
| | | filteredParticipants.add(participant); |
| | | } |
| | | } |
| | | return ResultUtil.success(filteredParticipants); |
| | | return ResultUtil.success(filteredParticipants); |
| | | } |
| | | |
| | | return ResultUtil.success(participantVos); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/participant/editParticipant") |
| | | @ApiOperation(value = "编辑参赛人员", tags = {"APP-赛事活动列表", ""}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil editParticipant(EditParticipant editParticipant){ |
| | | public ResultUtil editParticipant(EditParticipant editParticipant) { |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | int numDigits = String.valueOf(editParticipant.getId()).length(); |
| | | |
| | | |
| | | |
| | | if (numDigits==9){ |
| | | return participantService.editParticipant(uid, editParticipant); |
| | | } |
| | | else { |
| | | if (numDigits == 9) { |
| | | Participant byId = participantService.getById(editParticipant.getId()); |
| | | editParticipant.setName(byId.getName()); |
| | | return participantService.editParticipant(uid, editParticipant); |
| | | } else { |
| | | |
| | | |
| | | TStudent student = new TStudent(); |
| | | student.setId(editParticipant.getId()); |
| | | student.setName(editParticipant.getName()); |
| | | |
| | | TStudent student1 = studentClient.queryById(editParticipant.getId()); |
| | | student.setName(student1.getName()); |
| | | student.setIdCard(editParticipant.getIdcard()); |
| | | student.setHeight(Double.valueOf(editParticipant.getHeight())); |
| | | student.setWeight(editParticipant.getWeight()); |
| | | if (editParticipant.getHeight() != null) { |
| | | student.setHeight(Double.valueOf(editParticipant.getHeight())); |
| | | } |
| | | |
| | | if (editParticipant.getWeight() != null) { |
| | | student.setWeight(editParticipant.getWeight()); |
| | | } |
| | | |
| | | if (ToolUtil.isNotEmpty(student.getName()) && ToolUtil.isNotEmpty(student.getIdCard())) { |
| | | Boolean aBoolean = JuHeUtil.idcardAuthentication(student.getIdCard(), student.getName()); |
| | | if (!aBoolean) { |
| | | return ResultUtil.error("身份证和姓名不匹配"); |
| | | } |
| | | } |
| | | |
| | | |
| | | student.setPhone(editParticipant.getPhone()); |
| | | studentClient.updateAppUser(student); |
| | | return ResultUtil.success(); |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil delParticipant(Integer id){ |
| | | public ResultUtil delParticipant(Integer id) { |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return participantService.delParticipant(id); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 保存学员后同步参赛人员信息 |
| | | * |
| | | * @param saveParticipant |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/participant/saveParticipant") |
| | | public void saveParticipant(@RequestBody SaveParticipant saveParticipant){ |
| | | public void saveParticipant(@RequestBody SaveParticipant saveParticipant) { |
| | | try { |
| | | participantService.saveParticipant(saveParticipant); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/participant/counts") |
| | | public Integer counts(@RequestBody Integer stuId){ |
| | | return userCompetitionService.count(new QueryWrapper<UserCompetition>().eq("participantId",stuId)); |
| | | public Integer counts(@RequestBody Integer stuId) { |
| | | return userCompetitionService.count(new QueryWrapper<UserCompetition>().eq("participantId", stuId)); |
| | | } |
| | | } |