-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recheck the functionality of every modlue
- Loading branch information
1 parent
824d1bf
commit a95b3da
Showing
14 changed files
with
283 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
FoodyExpress/src/main/java/com/foodyexpress/controller/OrderHistoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.foodyexpress.controller; | ||
|
||
import java.util.List; | ||
|
||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.foodyexpress.exception.CustomerException; | ||
import com.foodyexpress.exception.LoginException; | ||
import com.foodyexpress.exception.OrderHistoryException; | ||
import com.foodyexpress.exception.RestaurantException; | ||
import com.foodyexpress.model.OrderHistory; | ||
import com.foodyexpress.service.OrderHistoryService; | ||
|
||
@RestController | ||
@RequestMapping("/order-history") | ||
public class OrderHistoryController { | ||
|
||
@Autowired | ||
private OrderHistoryService orderHisService; | ||
|
||
@GetMapping("/get") | ||
public ResponseEntity<OrderHistory> OrderHistoryById(@RequestParam(required = false) String key, | ||
@RequestParam(required = false) Integer orderHisId) | ||
throws RestaurantException, LoginException, OrderHistoryException { | ||
OrderHistory orderHistory = orderHisService.getOrderHistoryById(key, orderHisId); | ||
return new ResponseEntity<OrderHistory>(orderHistory, HttpStatus.ACCEPTED); | ||
} | ||
|
||
@GetMapping("/customer-id") | ||
public ResponseEntity<List<OrderHistory>> OrderHistoryByCustomerId(@RequestParam(required = false) String key, | ||
@RequestParam(required = false) Integer customerId) | ||
throws RestaurantException, LoginException, OrderHistoryException, CustomerException { | ||
List<OrderHistory> orderHistoryList = orderHisService.getOrderHistoryByCustomerId(key, customerId); | ||
return new ResponseEntity<List<OrderHistory>>(orderHistoryList, HttpStatus.ACCEPTED); | ||
} | ||
|
||
@GetMapping("/all") | ||
public ResponseEntity<List<OrderHistory>> getAllOrderHistory(@RequestParam(required = false) String key) | ||
throws RestaurantException, LoginException, OrderHistoryException, CustomerException { | ||
List<OrderHistory> orderHistoryList = orderHisService.getAllOrderHistory(key); | ||
return new ResponseEntity<List<OrderHistory>>(orderHistoryList, HttpStatus.ACCEPTED); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
FoodyExpress/src/main/java/com/foodyexpress/exception/OrderHistoryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.foodyexpress.exception; | ||
|
||
public class OrderHistoryException extends Exception { | ||
|
||
public OrderHistoryException() { | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
public OrderHistoryException(String message) { | ||
// TODO Auto-generated constructor stub | ||
super(message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
FoodyExpress/src/main/java/com/foodyexpress/model/ItemCreateDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.foodyexpress.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ToString | ||
public class ItemCreateDTO { | ||
private String itemName; | ||
private String catergoryName; | ||
private Double cost; | ||
} |
30 changes: 30 additions & 0 deletions
30
FoodyExpress/src/main/java/com/foodyexpress/model/OrderHistory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.foodyexpress.model; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToOne; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
public class OrderHistory { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Integer orderHistoryId; | ||
|
||
@NotNull(message = "Customer id required") | ||
private Integer customerId; | ||
|
||
@OneToOne(targetEntity = Bill.class) | ||
private Bill bill; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
FoodyExpress/src/main/java/com/foodyexpress/repository/OrderHistoryRepo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.foodyexpress.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.foodyexpress.model.OrderHistory; | ||
|
||
@Repository | ||
public interface OrderHistoryRepo extends JpaRepository<OrderHistory, Integer> { | ||
|
||
public List<OrderHistory> findByCustomerId(Integer customerId); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
FoodyExpress/src/main/java/com/foodyexpress/service/OrderHistoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.foodyexpress.service; | ||
|
||
import java.util.List; | ||
|
||
import com.foodyexpress.exception.CustomerException; | ||
import com.foodyexpress.exception.LoginException; | ||
import com.foodyexpress.exception.OrderHistoryException; | ||
import com.foodyexpress.model.OrderHistory; | ||
|
||
public interface OrderHistoryService { | ||
|
||
public OrderHistory getOrderHistoryById(String key, Integer orderHisId) | ||
throws OrderHistoryException, LoginException; | ||
|
||
public List<OrderHistory> getOrderHistoryByCustomerId(String key, Integer customerId) | ||
throws OrderHistoryException, LoginException, CustomerException; | ||
|
||
public List<OrderHistory> getAllOrderHistory(String key) throws OrderHistoryException, LoginException; | ||
|
||
} |
Oops, something went wrong.