16 changed files with 351 additions and 45 deletions
Split View
Diff Options
-
8Angular-UrbanBazaar/proxy.config.json
-
9Angular-UrbanBazaar/src/app/components/checkout/checkout.component.css
-
3Angular-UrbanBazaar/src/app/components/checkout/checkout.component.html
-
55Angular-UrbanBazaar/src/app/components/checkout/checkout.component.ts
-
21Angular-UrbanBazaar/src/app/models/orders.ts
-
15Angular-UrbanBazaar/src/app/services/orders.service.ts
-
22UB_ProductServiceProxy/pom.xml
-
50UB_ProductServiceProxy/src/main/java/com/example/MessageConfig/MessaageConfig.java
-
2UB_ProductServiceProxy/src/main/java/com/example/urbanbazaar/UbProductServiceProxyApplication.java
-
56UB_ProductServiceProxy/src/main/java/com/example/urbanbazaar/controller/OrderController.java
-
73UB_ProductServiceProxy/src/main/java/com/example/urbanbazaar/model/Order.java
-
39UB_ProductServiceProxy/src/main/java/com/example/urbanbazaar/model/OrderStatus.java
-
16UB_ProductServiceProxy/src/main/java/com/example/urbanbazaar/repository/OrderRepository.java
-
14UB_ProductServiceProxy/src/main/resources/application.properties
-
12grosery_db.sql
-
1springboot-rabbitmq-example
@ -1,20 +1,9 @@ |
|||
export class Orders { |
|||
public orderid: number; |
|||
public orderuserid: number; |
|||
public orderamount: number; |
|||
public ordershipaddress: string; |
|||
public ordershipaddress2: string; |
|||
public ordercity: string; |
|||
public orderzip: string; |
|||
public orderstate: string; |
|||
public ordercountry: string; |
|||
public orderphone: string; |
|||
public ordershippingcost: number; |
|||
public ordertax: number; |
|||
public orderemail: string; |
|||
public orderdate: Date; |
|||
public ordershipped: string; |
|||
public ordertrackingnumber: string; |
|||
orderid:number; |
|||
userid:number; |
|||
productname:string; |
|||
productprice:string; |
|||
|
|||
|
|||
constructor() {} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.example.MessageConfig; |
|||
|
|||
import org.springframework.amqp.core.AmqpTemplate; |
|||
import org.springframework.amqp.core.Binding; |
|||
import org.springframework.amqp.core.BindingBuilder; |
|||
import org.springframework.amqp.core.Queue; |
|||
import org.springframework.amqp.core.TopicExchange; |
|||
import org.springframework.amqp.rabbit.connection.ConnectionFactory; |
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; |
|||
import org.springframework.amqp.support.converter.MessageConverter; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
@Configuration |
|||
public class MessaageConfig { |
|||
|
|||
|
|||
public static final String QUEUE = "ub_queue"; |
|||
public static final String EXCHANGE = "ub_exchange"; |
|||
public static final String ROUTING_KEY = "ub_routingKey"; |
|||
|
|||
@Bean |
|||
public Queue queue() { |
|||
return new Queue(QUEUE); |
|||
} |
|||
|
|||
@Bean |
|||
public TopicExchange exchange() { |
|||
return new TopicExchange(EXCHANGE); |
|||
} |
|||
|
|||
@Bean |
|||
public Binding binding(Queue queue, TopicExchange exchange) { |
|||
return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY); |
|||
} |
|||
|
|||
@Bean |
|||
public MessageConverter converter() { |
|||
return new Jackson2JsonMessageConverter(); |
|||
} |
|||
|
|||
@Bean |
|||
public AmqpTemplate template(ConnectionFactory connectionFactory) { |
|||
final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); |
|||
rabbitTemplate.setMessageConverter(converter()); |
|||
return rabbitTemplate; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
package com.example.urbanbazaar.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.UUID; |
|||
|
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.example.MessageConfig.MessaageConfig; |
|||
import com.example.urbanbazaar.model.Order; |
|||
import com.example.urbanbazaar.model.OrderStatus; |
|||
import com.example.urbanbazaar.repository.OrderRepository; |
|||
|
|||
|
|||
|
|||
@RestController |
|||
//@RequestMapping("/order") |
|||
public class OrderController { |
|||
|
|||
|
|||
@Autowired |
|||
private RabbitTemplate template; |
|||
|
|||
@Autowired |
|||
private OrderRepository repo; |
|||
|
|||
|
|||
@PostMapping("/bookorder") |
|||
public String bookOrder(@RequestBody Order order) { |
|||
repo.save(order); |
|||
OrderStatus orderStatus = new OrderStatus(order, "PROCESS", "orderedDone!"); |
|||
template.convertAndSend(MessaageConfig.EXCHANGE, MessaageConfig.ROUTING_KEY, orderStatus); |
|||
return "Success !!"; |
|||
} |
|||
|
|||
@GetMapping("/showOrder") |
|||
public List<Order>allOrder() |
|||
{ |
|||
return repo.findAll(); |
|||
} |
|||
|
|||
@DeleteMapping("/deleteOrder") |
|||
public void deleteAll() |
|||
{ |
|||
repo.deleteAll(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
package com.example.urbanbazaar.model; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
import javax.persistence.Entity; |
|||
import javax.persistence.GeneratedValue; |
|||
import javax.persistence.Id; |
|||
import javax.persistence.Table; |
|||
|
|||
@Entity |
|||
@Table(name = "orders") |
|||
public class Order implements Serializable { |
|||
|
|||
@Id |
|||
@GeneratedValue |
|||
private int orderid; |
|||
private int userid; |
|||
private String productname; |
|||
private float productprice; |
|||
|
|||
public int getOrderid() { |
|||
return orderid; |
|||
} |
|||
|
|||
public void setOrderid(int orderid) { |
|||
this.orderid = orderid; |
|||
} |
|||
|
|||
public int getUserid() { |
|||
return userid; |
|||
} |
|||
|
|||
public void setUserid(int userid) { |
|||
this.userid = userid; |
|||
} |
|||
|
|||
public String getProductname() { |
|||
return productname; |
|||
} |
|||
|
|||
public void setProductname(String productname) { |
|||
this.productname = productname; |
|||
} |
|||
|
|||
public float getProductprice() { |
|||
return productprice; |
|||
} |
|||
|
|||
public void setProductprice(float productprice) { |
|||
this.productprice = productprice; |
|||
} |
|||
|
|||
public Order(int orderid, int userid, String productname, float productprice) { |
|||
|
|||
this.orderid = orderid; |
|||
this.userid = userid; |
|||
this.productname = productname; |
|||
this.productprice = productprice; |
|||
} |
|||
|
|||
|
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "Order [orderid=" + orderid + ", userid=" + userid + ", productname=" + productname + ", productprice=" |
|||
+ productprice + "]"; |
|||
} |
|||
|
|||
public Order() { |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package com.example.urbanbazaar.model; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
public class OrderStatus implements Serializable { |
|||
private Order order; |
|||
private String status;//progress,completed |
|||
private String message; |
|||
public Order getOrder() { |
|||
return order; |
|||
} |
|||
public void setOrder(Order order) { |
|||
this.order = order; |
|||
} |
|||
public String getStatus() { |
|||
return status; |
|||
} |
|||
public void setStatus(String status) { |
|||
this.status = status; |
|||
} |
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
public void setMessage(String message) { |
|||
this.message = message; |
|||
} |
|||
public OrderStatus(Order order, String status, String message) { |
|||
|
|||
this.order = order; |
|||
this.status = status; |
|||
this.message = message; |
|||
} |
|||
@Override |
|||
public String toString() { |
|||
return "OrderStatus [order=" + order + ", status=" + status + ", message=" + message + "]"; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.example.urbanbazaar.repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
import org.springframework.data.repository.query.Param; |
|||
|
|||
import com.example.urbanbazaar.model.Order; |
|||
|
|||
public interface OrderRepository extends JpaRepository<Order, Integer>{ |
|||
|
|||
// @Query(value="select * from Order o where o.userid=:userid", nativeQuery=true) |
|||
// List<Order>showAll(@Param("userid") int userid); |
|||
|
|||
} |
|||
@ -1,11 +1,19 @@ |
|||
server.port=8014 |
|||
|
|||
spring.datasource.url=jdbc:mysql://10.3.117.7:3306/grocery_db?createDatabaseIfNotExist=true |
|||
spring.datasource.url=jdbc:mysql://localhost:3306/grocery_db?createDatabaseIfNotExist=true |
|||
spring.datasource.username=testuser |
|||
spring.datasource.password=Password123 |
|||
|
|||
server.servlet.context-path=/products |
|||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect |
|||
#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect |
|||
#hibernate.dialect.storage_engine=innodb |
|||
#spring.jpa.database-platform: org.hibernate.dialect.MySQL5InnoDBDialect |
|||
|
|||
spring.jpa.hibernate.ddl-auto=update |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
spring.jackson.serialization.fail-on-empty-beans=false |
|||
|
|||
spring.rabbitmq.port=5672 |
|||
spring.rabbitmq.host=labs4.koteshwar.com |
|||
|
|||
spring.rabbitmq.username=guest |
|||
spring.rabbitmq.password=guest |
|||
@ -0,0 +1 @@ |
|||
Subproject commit 10a0271fcba7f90b09523ad74703297c45b2b620 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue