Skip to content

Commit

Permalink
finish all style api
Browse files Browse the repository at this point in the history
  • Loading branch information
mulmuri committed Nov 28, 2022
1 parent fe98983 commit 7c28946
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
5 changes: 1 addition & 4 deletions database/sql/order.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ SET state_id = (
SELECT state_id
FROM state
WHERE name = (?))
WHERE order_id = (?);

-- name: GetDish :one
SELECT
WHERE order_id = (?);
1 change: 1 addition & 0 deletions model/orderform.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type MenuFormed struct {
DinnerID int `json:"dinnerId"`
ID int `json:"id"`
MenuID int `json:"menuId"`
TypeID int `json:"typeId"`
OptionList []int `json:"optionList"`
}

Expand Down
3 changes: 2 additions & 1 deletion model/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ var RoleDeliveryGangNam string = "GangNam"
var RoleDeliveryDongDaeMun string = "DongDaeMun"

type Task struct {
ID int
ID int `json:"id"`
Type string `json:"type"`
}
8 changes: 4 additions & 4 deletions rest/order/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ func (h *OrderHandler) CancleOrder(c *gin.Context) {

func (h *OrderHandler) RequestCollecting(c *gin.Context) {

var orderid int
if err := c.ShouldBindJSON(&orderid); err != nil {
var order model.OrderID
if err := c.ShouldBindJSON(&order); err != nil {
c.JSON(http.StatusUnprocessableEntity, err.Error())
return
}

orderState, err := h.order.GetOrderState(orderid)
orderState, err := h.order.GetOrderState(order.OrdrID)
if err != nil {
c.JSON(http.StatusUnauthorized, err.Error())
return
Expand All @@ -106,7 +106,7 @@ func (h *OrderHandler) RequestCollecting(c *gin.Context) {
return
}

if err := h.order.FinishOrderStep(orderid); err != nil {
if err := h.order.FinishOrderStep(order.OrdrID); err != nil {
c.JSON(http.StatusUnprocessableEntity, err.Error())
return
}
Expand Down
29 changes: 27 additions & 2 deletions rest/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ func (h *TaskHandler) SetTaskNextStatus(c *gin.Context) {
return
}

if role == "styler" && task.Type == "all" {
state, err := order.OrderManagers.GetOrderState(task.ID)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
if state == 5 {
order.OrderManagers.FinishOrderStep(task.ID)
c.JSON(http.StatusOK, "")
return
}
c.JSON(http.StatusBadRequest, err.Error())
return
}

switch (role) {

case "cook":
order.OrderManagers.SetMenuNextStep(task.ID)
c.JSON(http.StatusOK, "")
Expand All @@ -33,8 +49,17 @@ func (h *TaskHandler) SetTaskNextStatus(c *gin.Context) {
return

case "delivery":
order.OrderManagers.FinishOrderStep(task.ID)
c.JSON(http.StatusOK, "")
state, err := order.OrderManagers.GetOrderState(task.ID)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
if state == 6 || state == 7 || state == 9 {
order.OrderManagers.FinishOrderStep(task.ID)
c.JSON(http.StatusOK, "")
return
}
c.JSON(http.StatusBadRequest, err.Error())
return

default:
Expand Down

0 comments on commit 7c28946

Please sign in to comment.