Skip to content

Instantly share code, notes, and snippets.

View diegosilva13's full-sized avatar
🎯
Focusing

Diego Brener diegosilva13

🎯
Focusing
View GitHub Profile
{
"product": "Apple",
"price": "1.25"
}
package com.coderef.delivery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableEurekaClient
public class DeliveryOrderServiceApplication {
package com.coderef.delivery.security;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
package com.coderef.delivery.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.validation.ConstraintViolationException;
import java.util.stream.Collectors;
package com.coderef.delivery.controller;
import com.coderef.delivery.model.Order;
import com.coderef.delivery.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
package com.coderef.delivery.service;
import com.coderef.delivery.model.Order;
import com.coderef.delivery.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@Service
public class OrderService {
package com.coderef.delivery.repository;
import com.coderef.delivery.model.Order;
import org.springframework.data.repository.CrudRepository;
public interface OrderRepository extends CrudRepository<Order, Integer> {
}
package com.coderef.delivery.model;
import org.hibernate.validator.constraints.NotEmpty;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Entity
@Table(name = "`order`")
package com.coderef.delivery.controller;
import com.coderef.delivery.model.Order;
import com.coderef.delivery.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
server:
port: 9093
eureka:
instance:
hostname: localhost
port: 9091
client:
registerWithEureka: true
fetchRegistry: false