release-1.3.0
This commit is contained in:
parent
3a09de1b04
commit
e02683277b
13
pom.xml
13
pom.xml
@ -10,9 +10,8 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.tsc.bitbucketbot</groupId>
|
<groupId>com.tsc.bitbucketbot</groupId>
|
||||||
<artifactId>bitbucketbot</artifactId>
|
<artifactId>bitbucketbot</artifactId>
|
||||||
<version>1.3.0-SNAPSHOT</version>
|
<version>1.3.0-RELEASE</version>
|
||||||
<name>bitbucketbot</name>
|
<packaging>jar</packaging>
|
||||||
<description>Demo project for Spring Boot</description>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
@ -92,4 +91,12 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>uPagge</id>
|
||||||
|
<name>Struchkov Mark</name>
|
||||||
|
<email>upagge@mail.ru</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить описание класса.
|
* TODO: Добавить описание класса.
|
||||||
@ -24,4 +26,9 @@ public interface UserRepository extends JpaRepository<User, String> {
|
|||||||
@Query("SELECT u.telegramId FROM User u WHERE u.login=:login")
|
@Query("SELECT u.telegramId FROM User u WHERE u.login=:login")
|
||||||
Long findTelegramIdByLogin(String login);
|
Long findTelegramIdByLogin(String login);
|
||||||
|
|
||||||
|
@Query("SELECT u.telegramId FROM User u WHERE u.login IN :logins AND u.telegramId IS NOT NULL")
|
||||||
|
List<Long> findAllTelegramIdByLogin(Set<String> logins);
|
||||||
|
|
||||||
|
Optional<User> findByLogin(String login);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import com.tsc.bitbucketbot.service.Utils;
|
|||||||
import com.tsc.bitbucketbot.utils.Message;
|
import com.tsc.bitbucketbot.utils.Message;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -21,6 +22,7 @@ import java.util.Optional;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SchedulerComments {
|
public class SchedulerComments {
|
||||||
@ -38,6 +40,7 @@ public class SchedulerComments {
|
|||||||
|
|
||||||
@Scheduled(cron = "0 */5 8-18 * * MON-FRI")
|
@Scheduled(cron = "0 */5 8-18 * * MON-FRI")
|
||||||
public void test() {
|
public void test() {
|
||||||
|
log.info("Начало сканирования комментариев");
|
||||||
long newLastCommentId = commentService.getLastCommentId();
|
long newLastCommentId = commentService.getLastCommentId();
|
||||||
long commentId = newLastCommentId + 1;
|
long commentId = newLastCommentId + 1;
|
||||||
long count = 0;
|
long count = 0;
|
||||||
@ -78,6 +81,7 @@ public class SchedulerComments {
|
|||||||
commentId += 1;
|
commentId += 1;
|
||||||
} while (count < NO_COMMENT);
|
} while (count < NO_COMMENT);
|
||||||
commentService.saveLastCommentId(newLastCommentId);
|
commentService.saveLastCommentId(newLastCommentId);
|
||||||
|
log.info("Конец сканирования комментариев");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPrUrl(long lastCommentId, PullRequest pullRequest) {
|
private String getPrUrl(long lastCommentId, PullRequest pullRequest) {
|
||||||
|
@ -65,43 +65,42 @@ public class SchedulerPullRequest {
|
|||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
Optional<PullRequestSheetJson> sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestClose(), user.getToken(), PullRequestSheetJson.class);
|
Optional<PullRequestSheetJson> sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestClose(), user.getToken(), PullRequestSheetJson.class);
|
||||||
while (sheetJson.isPresent() && sheetJson.get().getValues() != null && !sheetJson.get().getValues().isEmpty()) {
|
while (sheetJson.isPresent() && sheetJson.get().getValues() != null && !sheetJson.get().getValues().isEmpty()) {
|
||||||
final PullRequestSheetJson pullRequestBitbucketSheet = sheetJson.get();
|
final PullRequestSheetJson bitbucketSheet = sheetJson.get();
|
||||||
final List<PullRequestJson> bitbucketPullRequests = pullRequestBitbucketSheet.getValues().stream()
|
final List<PullRequestJson> jsonsPr = bitbucketSheet.getValues().stream()
|
||||||
.filter(
|
.filter(
|
||||||
pullRequestJson -> pullRequestsService.existsByBitbucketIdAndReposId(
|
jsonPr -> pullRequestsService.existsByBitbucketIdAndReposId(
|
||||||
pullRequestJson.getId(),
|
jsonPr.getId(),
|
||||||
pullRequestJson.getFromRef().getRepository().getId()
|
jsonPr.getFromRef().getRepository().getId()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
final Set<Long> pullRequestId = bitbucketPullRequests.stream()
|
final Set<Long> idPr = jsonsPr.stream()
|
||||||
.map(
|
.map(
|
||||||
pullRequestJson -> pullRequestsService.getIdByBitbucketIdAndReposId(
|
jsonPr -> pullRequestsService.getIdByBitbucketIdAndReposId(
|
||||||
pullRequestJson.getId(),
|
jsonPr.getId(),
|
||||||
pullRequestJson.getFromRef().getRepository().getId()
|
jsonPr.getFromRef().getRepository().getId()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
for (PullRequestJson jsonPr : jsonsPr) {
|
||||||
for (PullRequestJson bitbucketPullRequest : bitbucketPullRequests) {
|
final Optional<User> optUser = userService.getByLogin(jsonPr.getAuthor().getUser().getName());
|
||||||
final Optional<User> optUser = userService.getByLogin(bitbucketPullRequest.getAuthor().getUser().getName());
|
|
||||||
if (optUser.isPresent()) {
|
if (optUser.isPresent()) {
|
||||||
final User author = optUser.get();
|
final User author = optUser.get();
|
||||||
final Long telegramId = author.getTelegramId();
|
final Long telegramId = author.getTelegramId();
|
||||||
if (telegramId != null) {
|
if (telegramId != null) {
|
||||||
final PullRequestStatus pullRequestStatus = PullRequestJsonConverter.convertPullRequestStatus(bitbucketPullRequest.getState());
|
final PullRequestStatus statusPr = PullRequestJsonConverter.convertPullRequestStatus(jsonPr.getState());
|
||||||
@NonNull final String message = Message.statusPullRequest(bitbucketPullRequest.getTitle(), bitbucketPullRequest.getLinks().getSelf().get(0).getHref(), PullRequestStatus.OPEN, pullRequestStatus);
|
final String message = Message.statusPullRequest(jsonPr.getTitle(), jsonPr.getLinks().getSelf().get(0).getHref(), PullRequestStatus.OPEN, statusPr);
|
||||||
messageSendService.add(MessageSend.builder().telegramId(telegramId).message(message).build());
|
messageSendService.add(MessageSend.builder().telegramId(telegramId).message(message).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pullRequestsService.deleteAll(pullRequestId);
|
pullRequestsService.deleteAll(idPr);
|
||||||
|
|
||||||
if (pullRequestBitbucketSheet.getNextPageStart() != null) {
|
if (bitbucketSheet.getNextPageStart() != null) {
|
||||||
sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestClose() + pullRequestBitbucketSheet.getNextPageStart(), bitbucketConfig.getToken(), PullRequestSheetJson.class);
|
sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestClose() + bitbucketSheet.getNextPageStart(), bitbucketConfig.getToken(), PullRequestSheetJson.class);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -115,30 +114,25 @@ public class SchedulerPullRequest {
|
|||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
Optional<PullRequestSheetJson> sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestOpen(), user.getToken(), PullRequestSheetJson.class);
|
Optional<PullRequestSheetJson> sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestOpen(), user.getToken(), PullRequestSheetJson.class);
|
||||||
while (sheetJson.isPresent() && sheetJson.get().getValues() != null && !sheetJson.get().getValues().isEmpty()) {
|
while (sheetJson.isPresent() && sheetJson.get().getValues() != null && !sheetJson.get().getValues().isEmpty()) {
|
||||||
final PullRequestSheetJson pullRequestBitbucketSheet = sheetJson.get();
|
final PullRequestSheetJson jsonSheet = sheetJson.get();
|
||||||
final Map<Long, PullRequest> existsPullRequestBitbucket = pullRequestBitbucketSheet.getValues().stream()
|
final Map<Long, PullRequest> existsJsonPr = jsonSheet.getValues().stream()
|
||||||
.filter(
|
|
||||||
pullRequestJson -> pullRequestsService.existsByBitbucketIdAndReposId(
|
|
||||||
pullRequestJson.getId(),
|
|
||||||
pullRequestJson.getFromRef().getRepository().getId()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.map(pullRequestJson -> conversionService.convert(pullRequestJson, PullRequest.class))
|
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
.map(pullRequestJson -> conversionService.convert(pullRequestJson, PullRequest.class))
|
||||||
.peek(pullRequest -> pullRequestsService.getIdByBitbucketIdAndReposId(pullRequest.getBitbucketId(), pullRequest.getRepositoryId()).ifPresent(pullRequest::setId))
|
.peek(pullRequest -> pullRequestsService.getIdByBitbucketIdAndReposId(pullRequest.getBitbucketId(), pullRequest.getRepositoryId()).ifPresent(pullRequest::setId))
|
||||||
|
.filter(pullRequest -> pullRequest.getId() != null)
|
||||||
.collect(Collectors.toMap(PullRequest::getId, pullRequest -> pullRequest));
|
.collect(Collectors.toMap(PullRequest::getId, pullRequest -> pullRequest));
|
||||||
final Set<PullRequest> pullRequests = pullRequestsService.getAllById(existsPullRequestBitbucket.keySet());
|
final Set<PullRequest> pullRequests = pullRequestsService.getAllById(existsJsonPr.keySet());
|
||||||
if (!existsPullRequestBitbucket.isEmpty() && !pullRequests.isEmpty()) {
|
if (!existsJsonPr.isEmpty() && !pullRequests.isEmpty()) {
|
||||||
processingUpdate(existsPullRequestBitbucket, pullRequests);
|
processingUpdate(existsJsonPr, pullRequests);
|
||||||
ids.addAll(
|
ids.addAll(
|
||||||
pullRequestsService.updateAll(existsPullRequestBitbucket.values()).stream()
|
pullRequestsService.updateAll(existsJsonPr.values()).stream()
|
||||||
.map(PullRequest::getId)
|
.map(PullRequest::getId)
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pullRequestBitbucketSheet.getNextPageStart() != null) {
|
if (jsonSheet.getNextPageStart() != null) {
|
||||||
sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestOpen() + pullRequestBitbucketSheet.getNextPageStart(), bitbucketConfig.getToken(), PullRequestSheetJson.class);
|
sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestOpen() + jsonSheet.getNextPageStart(), bitbucketConfig.getToken(), PullRequestSheetJson.class);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -157,31 +151,40 @@ public class SchedulerPullRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processingReviewer(PullRequest pullRequest, PullRequest newPullRequest) {
|
private void processingReviewer(PullRequest pullRequest, PullRequest newPullRequest) {
|
||||||
changeVersionPr(pullRequest, newPullRequest).ifPresent(
|
final Set<String> logins = newPullRequest.getReviewers().stream()
|
||||||
message -> newPullRequest.getReviewers().stream()
|
.map(Reviewer::getUser)
|
||||||
.map(reviewer -> userService.getByLogin(reviewer.getUser()))
|
.collect(Collectors.toSet());
|
||||||
.filter(Optional::isPresent)
|
if (!logins.isEmpty()) {
|
||||||
.map(Optional::get)
|
Optional<String> optMessage = changeVersionPr(pullRequest, newPullRequest);
|
||||||
.filter(user -> user.getTelegramId() != null)
|
if (optMessage.isPresent()) {
|
||||||
.forEach(user -> messageSendService.add(
|
final String message = optMessage.get();
|
||||||
|
userService.getAllTelegramIdByLogin(logins).forEach(
|
||||||
|
telegramId -> messageSendService.add(
|
||||||
MessageSend.builder()
|
MessageSend.builder()
|
||||||
.telegramId(user.getTelegramId())
|
.telegramId(telegramId)
|
||||||
.message(message)
|
.message(message)
|
||||||
.build())
|
.build()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private void processingAuthor(PullRequest pullRequest, PullRequest newPullRequest) {
|
private void processingAuthor(PullRequest pullRequest, PullRequest newPullRequest) {
|
||||||
final User author = pullRequest.getAuthor();
|
final User author = pullRequest.getAuthor();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder builderMessage = new StringBuilder();
|
||||||
if (author.getTelegramId() != null) {
|
if (author.getTelegramId() != null) {
|
||||||
changeStatusPR(pullRequest, newPullRequest).ifPresent(stringBuilder::append);
|
changeStatusPR(pullRequest, newPullRequest).ifPresent(builderMessage::append);
|
||||||
changeReviewersPR(pullRequest, newPullRequest).ifPresent(stringBuilder::append);
|
changeReviewersPR(pullRequest, newPullRequest).ifPresent(builderMessage::append);
|
||||||
final String message = stringBuilder.toString();
|
final String message = builderMessage.toString();
|
||||||
if (!Smile.Constants.EMPTY.equalsIgnoreCase(message)) {
|
if (!Smile.Constants.EMPTY.equalsIgnoreCase(message)) {
|
||||||
messageSendService.add(MessageSend.builder().message(message).telegramId(author.getTelegramId()).build());
|
messageSendService.add(
|
||||||
|
MessageSend.builder()
|
||||||
|
.message(message)
|
||||||
|
.telegramId(author.getTelegramId())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,6 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [31.01.2020]
|
|
||||||
*/
|
|
||||||
public interface PullRequestsService {
|
public interface PullRequestsService {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -7,15 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание интерфейса.
|
|
||||||
*
|
|
||||||
* @author upagge [30.01.2020]
|
|
||||||
*/
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
|
|
||||||
List<User> getAll();
|
|
||||||
|
|
||||||
Optional<User> getByLogin(String login);
|
Optional<User> getByLogin(String login);
|
||||||
|
|
||||||
Set<String> existsByLogin(@NonNull Set<String> logins);
|
Set<String> existsByLogin(@NonNull Set<String> logins);
|
||||||
@ -28,4 +21,6 @@ public interface UserService {
|
|||||||
|
|
||||||
Optional<Long> getTelegramIdByLogin(@NonNull String login);
|
Optional<Long> getTelegramIdByLogin(@NonNull String login);
|
||||||
|
|
||||||
|
List<Long> getAllTelegramIdByLogin(Set<String> logins);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage());
|
log.trace(e.getMessage());
|
||||||
}
|
}
|
||||||
if (sb != null) {
|
if (sb != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -18,11 +18,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [01.02.2020]
|
|
||||||
*/
|
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PullRequestJsonConverter implements Converter<PullRequestJson, PullRequest> {
|
public class PullRequestJsonConverter implements Converter<PullRequestJson, PullRequest> {
|
||||||
|
@ -5,11 +5,6 @@ import com.tsc.bitbucketbot.dto.bitbucket.UserJson;
|
|||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [02.02.2020]
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
public class UserJsonConverter implements Converter<UserJson, User> {
|
public class UserJsonConverter implements Converter<UserJson, User> {
|
||||||
|
|
||||||
|
@ -18,11 +18,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [31.01.2020]
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PullRequestsServiceImpl implements PullRequestsService {
|
public class PullRequestsServiceImpl implements PullRequestsService {
|
||||||
|
@ -16,11 +16,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [30.01.2020]
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
@ -28,11 +23,6 @@ public class UserServiceImpl implements UserService {
|
|||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final BitbucketConfig bitbucketConfig;
|
private final BitbucketConfig bitbucketConfig;
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<User> getAll() {
|
|
||||||
return userRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<User> getByLogin(String login) {
|
public Optional<User> getByLogin(String login) {
|
||||||
return userRepository.findById(login);
|
return userRepository.findById(login);
|
||||||
@ -45,17 +35,21 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<User> reg(@NonNull User user) {
|
public Optional<User> reg(@NonNull User user) {
|
||||||
if (userRepository.existsByLogin(user.getLogin()) && !userRepository.existsByTelegramId(user.getTelegramId())) {
|
final Optional<User> optUser = userRepository.findByLogin(user.getLogin());
|
||||||
|
if (optUser.isPresent()) {
|
||||||
|
final User oldUser = optUser.get();
|
||||||
|
if (oldUser.getTelegramId() == null) {
|
||||||
Optional<PullRequestSheetJson> sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestClose(), user.getToken(), PullRequestSheetJson.class);
|
Optional<PullRequestSheetJson> sheetJson = Utils.urlToJson(bitbucketConfig.getUrlPullRequestClose(), user.getToken(), PullRequestSheetJson.class);
|
||||||
if (sheetJson.isPresent()) {
|
if (sheetJson.isPresent()) {
|
||||||
return Optional.of(userRepository.save(user));
|
oldUser.setTelegramId(user.getTelegramId());
|
||||||
|
return Optional.of(userRepository.save(oldUser));
|
||||||
} else {
|
} else {
|
||||||
throw new RegException("Ваш токен не валиден");
|
throw new RegException("Ваш токен не валиден");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new RegException("Пользователь с таким логином или телеграмом уже есть в системе");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new RegException("Пользователь не найден, подождите обновление базы пользователей!");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> addAll(Set<User> newUsers) {
|
public List<User> addAll(Set<User> newUsers) {
|
||||||
@ -72,4 +66,9 @@ public class UserServiceImpl implements UserService {
|
|||||||
return Optional.ofNullable(userRepository.findTelegramIdByLogin(login));
|
return Optional.ofNullable(userRepository.findTelegramIdByLogin(login));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> getAllTelegramIdByLogin(Set<String> logins) {
|
||||||
|
return userRepository.findAllTelegramIdByLogin(logins);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user