Skip to content

Instantly share code, notes, and snippets.

package com.eresh.spring.persistence.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedBy;
package com.eresh.spring.rest;
import com.eresh.spring.persistence.entity.Author;
import com.eresh.spring.persistence.repository.AuthorRepository;
import com.eresh.spring.rest.ws.WSAuthorResponse;
import com.eresh.spring.service.AuthorService;
import reactor.core.publisher.Mono;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
public Mono<WSAuthorResponse> findAuthors(Integer offset, Integer limit) {
WSAuthorResponse result = new WSAuthorResponse();
return authorRepository.count()
.map(totalElements -> {
result.setTotalElements(totalElements);
return totalElements;
})
.flatMapMany(el -> authorRepository.retrieveAllAuthors(PageRequest.of(offset, limit)))
.collectList()
.map(data -> {
public Mono<Author> saveAuthor(Author author) {
if (StringUtils.isNotBlank(author.getId())) {
return authorRepository.findByIdAndDeleteIsFalse(author.getId())
.switchIfEmpty(Mono.error(new Exception("No Author found with Id: " + author.getId())))
.doOnSuccess(author1 -> {
author1 = updateAuthor(author, author1);
authorRepository.save(author1)
.subscribe();
});
}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: minikube-sample
spec:
replicas: 3
strategy:
type: Recreate
template:
metadata:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: minikube-sample
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: minikube-ingress
spec:
rules:
- http:
paths:
- path: /home/data
backend:
package com.minikube.sample.rest.controller;
/**
* Created By Gorantla, Eresh on 13/Jan/2020
**/
interface ArithmeticOperation {
Double calculate(Double value1, Double value2);
}
package com.minikube.sample.rest.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* Created By Gorantla, Eresh on 13/Jan/2020
**/
package com.minikube.sample.rest.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
* Created By Gorantla, Eresh on 13/Jan/2020
**/