14 changed files with 383 additions and 109 deletions
Unified View
Diff Options
-
130Angular-UrbanBazaar/package-lock.json
-
13Angular-UrbanBazaar/src/app/components/cart/cart.component.css
-
10Angular-UrbanBazaar/src/app/components/cart/cart.component.html
-
1Angular-UrbanBazaar/src/app/components/cart/cart.component.ts
-
1Angular-UrbanBazaar/src/app/components/home/home.component.css
-
15Angular-UrbanBazaar/src/app/models/cart.ts
-
2Angular-UrbanBazaar/src/app/services/cart.service.ts
-
23UB_CartServiceProxy/src/main/java/com/example/urbanbazaar/controller/CartController.java
-
9UB_CartServiceProxy/src/main/java/com/example/urbanbazaar/model/Cart.java
-
3UB_CartServiceProxy/src/main/java/com/example/urbanbazaar/repository/CartRepository.java
-
68UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/controller/OrderController.java
-
186UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/model/Orders.java
-
17UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/repository/OrderRepository.java
-
14grocery_db_tables.sql
@ -1,13 +1,10 @@ |
|||||
export class Cart { |
export class Cart { |
||||
|
|
||||
public productid : number; |
|
||||
|
public cartid : number; |
||||
|
public userid : number; |
||||
|
public orderid : number; |
||||
public productname : string; |
public productname : string; |
||||
public productprice : number; |
public productprice : number; |
||||
public productweight : number; |
|
||||
public productshortdesc : string; |
|
||||
public productlongdesc : string; |
|
||||
public productimage : string; |
|
||||
public productcategoryid : number; |
|
||||
|
|
||||
constructor() {} |
|
||||
|
public quantity : number; |
||||
|
|
||||
|
constructor() {} |
||||
} |
} |
||||
@ -0,0 +1,68 @@ |
|||||
|
package com.example.urbanbazaar.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.NoSuchElementException; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
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.RestController; |
||||
|
|
||||
|
import com.example.urbanbazaar.model.Orders; |
||||
|
import com.example.urbanbazaar.repository.OrderRepository; |
||||
|
|
||||
|
|
||||
|
@RestController |
||||
|
public class OrderController { |
||||
|
|
||||
|
@Autowired |
||||
|
private OrderRepository repo; |
||||
|
|
||||
|
@PostMapping("/addOrder") |
||||
|
public void addOrders( @RequestBody Orders order) { |
||||
|
repo.save(order); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/findOrder/{id}") |
||||
|
public ResponseEntity<Orders> findOrder(@PathVariable Integer id) { |
||||
|
|
||||
|
try { |
||||
|
Orders order = repo.findById(id).get(); |
||||
|
return new ResponseEntity<Orders>(order,HttpStatus.OK); |
||||
|
} catch (NoSuchElementException e) { |
||||
|
return new ResponseEntity<Orders>(HttpStatus.NOT_FOUND); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/findOrdersByUser/{id}") |
||||
|
public ResponseEntity<List<Orders>> findOrderByUser(@PathVariable Integer id) { |
||||
|
|
||||
|
try { |
||||
|
List<Orders> orders = repo.findByorderuserid(id); |
||||
|
return new ResponseEntity<List<Orders>>(orders, HttpStatus.OK); |
||||
|
} catch (NoSuchElementException e) { |
||||
|
return new ResponseEntity<List<Orders>>(HttpStatus.NOT_FOUND); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/trackOrder/{trackid}") |
||||
|
public ResponseEntity<Orders> searchOrderByTrackingNumber(@PathVariable String trackid) |
||||
|
{ |
||||
|
try { |
||||
|
Orders order = repo.findByTrackId(trackid); |
||||
|
return new ResponseEntity<Orders>(order,HttpStatus.OK); |
||||
|
} catch (NoSuchElementException e) { |
||||
|
return new ResponseEntity<Orders>(HttpStatus.NOT_FOUND); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/showAllOrders") |
||||
|
public List<Orders> showAllOrders() |
||||
|
{ |
||||
|
return repo.findAll(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,186 @@ |
|||||
|
package com.example.urbanbazaar.model; |
||||
|
|
||||
|
import java.sql.Date; |
||||
|
import javax.persistence.Entity; |
||||
|
import javax.persistence.GeneratedValue; |
||||
|
import javax.persistence.Id; |
||||
|
import javax.persistence.Table; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name = "orders") |
||||
|
public class Orders { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue |
||||
|
private int orderid; |
||||
|
private int orderuserid; |
||||
|
private float orderamount; |
||||
|
private String ordershipaddress; |
||||
|
private String ordershipaddress2; |
||||
|
private String ordercity; |
||||
|
private String orderzip; |
||||
|
private String orderstate; |
||||
|
private String ordercountry; |
||||
|
private String orderphone; |
||||
|
private float ordershippingcost; |
||||
|
private float ordertax; |
||||
|
private String orderemail; |
||||
|
private Date orderdate; |
||||
|
private String ordershipped; |
||||
|
private String ordertrackingnumber; |
||||
|
|
||||
|
public int getOrderid() { |
||||
|
return orderid; |
||||
|
} |
||||
|
|
||||
|
public void setOrderid(int orderid) { |
||||
|
this.orderid = orderid; |
||||
|
} |
||||
|
|
||||
|
public int getOrderuserid() { |
||||
|
return orderuserid; |
||||
|
} |
||||
|
|
||||
|
public void setOrderuserid(int orderuserid) { |
||||
|
this.orderuserid = orderuserid; |
||||
|
} |
||||
|
|
||||
|
public float getOrderamount() { |
||||
|
return orderamount; |
||||
|
} |
||||
|
|
||||
|
public void setOrderamount(float orderamount) { |
||||
|
this.orderamount = orderamount; |
||||
|
} |
||||
|
|
||||
|
public String getOrdershipaddress() { |
||||
|
return ordershipaddress; |
||||
|
} |
||||
|
|
||||
|
public void setOrdershipaddress(String ordershipaddress) { |
||||
|
this.ordershipaddress = ordershipaddress; |
||||
|
} |
||||
|
|
||||
|
public String getOrdershipaddress2() { |
||||
|
return ordershipaddress2; |
||||
|
} |
||||
|
|
||||
|
public void setOrdershipaddress2(String ordershipaddress2) { |
||||
|
this.ordershipaddress2 = ordershipaddress2; |
||||
|
} |
||||
|
|
||||
|
public String getOrdercity() { |
||||
|
return ordercity; |
||||
|
} |
||||
|
|
||||
|
public void setOrdercity(String ordercity) { |
||||
|
this.ordercity = ordercity; |
||||
|
} |
||||
|
|
||||
|
public String getOrderzip() { |
||||
|
return orderzip; |
||||
|
} |
||||
|
|
||||
|
public void setOrderzip(String orderzip) { |
||||
|
this.orderzip = orderzip; |
||||
|
} |
||||
|
|
||||
|
public String getOrderstate() { |
||||
|
return orderstate; |
||||
|
} |
||||
|
|
||||
|
public void setOrderstate(String orderstate) { |
||||
|
this.orderstate = orderstate; |
||||
|
} |
||||
|
|
||||
|
public String getOrdercountry() { |
||||
|
return ordercountry; |
||||
|
} |
||||
|
|
||||
|
public void setOrdercountry(String ordercountry) { |
||||
|
this.ordercountry = ordercountry; |
||||
|
} |
||||
|
|
||||
|
public String getOrderphone() { |
||||
|
return orderphone; |
||||
|
} |
||||
|
|
||||
|
public void setOrderphone(String orderphone) { |
||||
|
this.orderphone = orderphone; |
||||
|
} |
||||
|
|
||||
|
public float getOrdershippingcost() { |
||||
|
return ordershippingcost; |
||||
|
} |
||||
|
|
||||
|
public void setOrdershippingcost(float ordershippingcost) { |
||||
|
this.ordershippingcost = ordershippingcost; |
||||
|
} |
||||
|
|
||||
|
public float getOrdertax() { |
||||
|
return ordertax; |
||||
|
} |
||||
|
|
||||
|
public void setOrdertax(float ordertax) { |
||||
|
this.ordertax = ordertax; |
||||
|
} |
||||
|
|
||||
|
public String getOrderemail() { |
||||
|
return orderemail; |
||||
|
} |
||||
|
|
||||
|
public void setOrderemail(String orderemail) { |
||||
|
this.orderemail = orderemail; |
||||
|
} |
||||
|
|
||||
|
public Date getOrderdate() { |
||||
|
return orderdate; |
||||
|
} |
||||
|
|
||||
|
public void setOrderdate(Date orderdate) { |
||||
|
this.orderdate = orderdate; |
||||
|
} |
||||
|
|
||||
|
public String getOrdershipped() { |
||||
|
return ordershipped; |
||||
|
} |
||||
|
|
||||
|
public void setOrdershipped(String ordershipped) { |
||||
|
this.ordershipped = ordershipped; |
||||
|
} |
||||
|
|
||||
|
public String getOrdertrackingnumber() { |
||||
|
return ordertrackingnumber; |
||||
|
} |
||||
|
|
||||
|
public void setOrdertrackingnumber(String ordertrackingnumber) { |
||||
|
this.ordertrackingnumber = ordertrackingnumber; |
||||
|
} |
||||
|
|
||||
|
public Orders(int orderid, int orderuserid, float orderamount, String ordershipaddress, String ordershipaddress2, |
||||
|
String ordercity, String orderzip, String orderstate, String ordercountry, String orderphone, |
||||
|
float ordershippingcost, float ordertax, String orderemail, Date orderdate, String ordershipped, |
||||
|
String ordertrackingnumber) { |
||||
|
this.orderid = orderid; |
||||
|
this.orderuserid = orderuserid; |
||||
|
this.orderamount = orderamount; |
||||
|
this.ordershipaddress = ordershipaddress; |
||||
|
this.ordershipaddress2 = ordershipaddress2; |
||||
|
this.ordercity = ordercity; |
||||
|
this.orderzip = orderzip; |
||||
|
this.orderstate = orderstate; |
||||
|
this.ordercountry = ordercountry; |
||||
|
this.orderphone = orderphone; |
||||
|
this.ordershippingcost = ordershippingcost; |
||||
|
this.ordertax = ordertax; |
||||
|
this.orderemail = orderemail; |
||||
|
this.orderdate = orderdate; |
||||
|
this.ordershipped = ordershipped; |
||||
|
this.ordertrackingnumber = ordertrackingnumber; |
||||
|
} |
||||
|
|
||||
|
public Orders() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
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.Orders; |
||||
|
|
||||
|
public interface OrderRepository extends JpaRepository<Orders, Integer> { |
||||
|
|
||||
|
@Query("SELECT o FROM Orders o WHERE o.ordertrackingnumber=:id") |
||||
|
public Orders findByTrackId(@Param("id") String id); |
||||
|
|
||||
|
public List<Orders> findByorderuserid(int id); |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue