diff --git a/src/main/java/com/ai/da/controller/GlobalAwardController.java b/src/main/java/com/ai/da/controller/GlobalAwardController.java index 2158fcf7..10879652 100644 --- a/src/main/java/com/ai/da/controller/GlobalAwardController.java +++ b/src/main/java/com/ai/da/controller/GlobalAwardController.java @@ -145,12 +145,12 @@ public class GlobalAwardController { return Response.success(globalAwardService.saveContestant(request)); } -// @GetMapping("/contestants/by-email") -// @ApiOperation(value = "根据邮箱查询参赛者", notes = "根据邮箱地址获取参赛者信息") -// public Response getContestantByEmail(@ApiParam(value = "参赛者邮箱地址", required = true) @RequestParam("email") String email) { -// ContestantDTO dto = globalAwardService.getContestantByEmail(email); -// return Response.success(dto); -// } + @GetMapping("/contestants/{id}") + @ApiOperation(value = "根据id查询参赛者", notes = "根据id获取参赛者信息") + public Response getContestantByID(@ApiParam(value = "参赛者id", required = true) @PathVariable("id") String id) { + ContestantDTO dto = globalAwardService.getContestantByID(id); + return Response.success(dto); + } @GetMapping("/checkEmail") public Response checkEmail(@RequestParam("email") String email) { diff --git a/src/main/java/com/ai/da/service/GlobalAwardService.java b/src/main/java/com/ai/da/service/GlobalAwardService.java index 693cfcab..583cf321 100644 --- a/src/main/java/com/ai/da/service/GlobalAwardService.java +++ b/src/main/java/com/ai/da/service/GlobalAwardService.java @@ -13,7 +13,7 @@ public interface GlobalAwardService { Map saveContestant(ContestantDTO request); - com.ai.da.model.dto.ContestantDTO getContestantByEmail(String email); + com.ai.da.model.dto.ContestantDTO getContestantByID(String email); void checkEmail(String email); diff --git a/src/main/java/com/ai/da/service/impl/GlobalAwardServiceImpl.java b/src/main/java/com/ai/da/service/impl/GlobalAwardServiceImpl.java index 9ce1f404..3b744845 100644 --- a/src/main/java/com/ai/da/service/impl/GlobalAwardServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GlobalAwardServiceImpl.java @@ -161,6 +161,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService { .build(); contestantMapper.insert(toInsert); resp.put("success", true); + sendSiteMsg(toInsert.getId(), toInsert.getEmail()); return resp; } else { // update existing contestant @@ -184,18 +185,16 @@ public class GlobalAwardServiceImpl implements GlobalAwardService { } @Override - public ContestantDTO getContestantByEmail(String email) { - if (email == null) { - throw new BusinessException("Email is required."); + public ContestantDTO getContestantByID(String id) { + if (id == null) { + throw new BusinessException("id is required."); } - QueryWrapper qw = new QueryWrapper<>(); - qw.eq("email", email); - Contestant existing = contestantMapper.selectOne(qw); + Contestant existing = contestantMapper.selectById(id); if (existing == null) { return null; } ContestantDTO dto = new ContestantDTO(); - dto.setEmail(existing.getEmail()); +// dto.setEmail(existing.getEmail()); dto.setFirstName(existing.getFirstName()); dto.setLastName(existing.getLastName()); dto.setGender(existing.getGender()); @@ -251,7 +250,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService { String secureToken = UUID.randomUUID().toString().replace("-", ""); redisUtil.addToString(tokenCacheKey + email, secureToken, 3 * 24 * 60 * 60L); - return new CheckOTPVO(secureToken, getContestantByEmail(email)); + return new CheckOTPVO(secureToken, getContestantByID(email)); } else { throw new BusinessException("Verification code is incorrect. Please try again."); } @@ -275,7 +274,16 @@ public class GlobalAwardServiceImpl implements GlobalAwardService { } // 发送站内信 - public void sendSiteMsg(String applicationId, Long userId) { + public void sendSiteMsg(String applicationId, String email) { + Long userId; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(Account::getUserEmail, email); + List accounts = accountMapper.selectList(queryWrapper); + if (accounts.isEmpty()) { + throw new BusinessException("Please register and subscribe to AiDA, then resubmit your application."); + }else { + userId = accounts.get(0).getId(); + } PublishSysNotificationDTO sysNotificationDTO = new PublishSysNotificationDTO(); Notification notification = new Notification(); notification.setType("system"); diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 543387a9..4c8a41c7 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -181,4 +181,4 @@ file.upload.max.size.video=104857600 # 上传任务过期时间(小时) file.upload.task.expiry.hours=24 -global.award.link=https://develop.aida.com.hk/ \ No newline at end of file +global.award.link=https://develop.aida.com.hk/contestants/ \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 28080ddf..b0e5278a 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -179,4 +179,4 @@ file.upload.max.size.video=104857600 # 上传任务过期时间(小时) file.upload.task.expiry.hours=24 -global.award.link=https://www.aida.com.hk/ \ No newline at end of file +global.award.link=https://www.aida.com.hk/contestants/ \ No newline at end of file