| | |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | | import org.apache.shardingsphere.transaction.core.TransactionType; |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.context.i18n.LocaleContextHolder; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @PostMapping("/api/v1/invitation/add") |
| | | @ResponseBody |
| | | @ApiOperation(value = "生成邀请码") |
| | | @Transactional |
| | | public R add(@RequestBody InvitationAddDto dto){ |
| | | long existing = xpInvitationCodeService.count(); |
| | | long incoming = Arrays.stream(Optional.ofNullable(dto.getPhones()).orElse("").split(",")) |
| | |
| | | |
| | | if (!StringUtils.hasLength(bindAccount)) { |
| | | errors.add(messageSource.getMessage(I18nKeyConstant.INVITATION_IMPORT_ACCOUNT_EMPTY, new Object[]{rowNum}, I18nKeyConstant.INVITATION_IMPORT_ACCOUNT_EMPTY, LocaleContextHolder.getLocale())); |
| | | } else if (!PhoneUtil.isPhone(bindAccount)) { |
| | | } else if (!PhoneUtil.isMobile(bindAccount)) { |
| | | errors.add(messageSource.getMessage(I18nKeyConstant.INVITATION_IMPORT_ACCOUNT_INVALID, new Object[]{rowNum, bindAccount}, I18nKeyConstant.INVITATION_IMPORT_ACCOUNT_INVALID, LocaleContextHolder.getLocale())); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "校验生成邀请码的手机号是否合法") |
| | | @PostMapping("/api/v1/invitation/validateCode") |
| | | public R<Boolean> validateCode(@RequestParam String phone){ |
| | | if (!PhoneUtil.isMobile(phone)){ |
| | | return R.ok(false); |
| | | } |
| | | List<XpInvitationCode> existsList = xpInvitationCodeService.lambdaQuery() |
| | | .in(XpInvitationCode::getBindAccount, phone) |
| | | .list(); |
| | | return R.ok(CollUtil.isEmpty(existsList)); |
| | | @GetMapping("/api/v1/invitation/validateCode") |
| | | public R<List<String>> validateCode(@RequestParam String phone){ |
| | | List<String> phoneList = Arrays.asList(phone.split(",")); |
| | | List<String> existPhones = phoneList.stream().filter(item -> xpInvitationCodeService.lambdaQuery() |
| | | .in(XpInvitationCode::getBindAccount, item) |
| | | .count() > 0).collect(Collectors.toList()); |
| | | return R.ok(existPhones); |
| | | } |
| | | } |