store wise orders change
This commit is contained in:
@@ -100,8 +100,13 @@ func (ctl *OrderController) GetOrders(c *fiber.Ctx) error {
|
||||
orders, err = ctl.orderService.GetUserOrders(stat, fdate, tdate, uid, pageno, pagesize, keyword)
|
||||
|
||||
} else {
|
||||
// All orders
|
||||
orders, err = ctl.orderService.GetAllOrders(stat, fdate, tdate, pageno, pagesize, keyword)
|
||||
// No scoping id supplied (tenantid/partnerid/customerid/applocationid/appuserid).
|
||||
// Refuse instead of silently returning every order in the database.
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"status": false,
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "At least one of tenantid, partnerid, customerid, applocationid or appuserid is required",
|
||||
})
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -129,6 +134,14 @@ func (ctl *OrderController) GetOrderSummary(c *fiber.Ctx) error {
|
||||
fdate := c.Query("fromdate")
|
||||
tdate := c.Query("todate")
|
||||
|
||||
if tid == 0 && pid == 0 && cid == 0 && lid == 0 {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "At least one of tenantid, partnerid, customerid or locationid is required",
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
data, err := ctl.orderService.GetOrderSummary(tid, pid, cid, lid, fdate, tdate)
|
||||
if err != nil {
|
||||
return c.Status(http.StatusConflict).JSON(fiber.Map{
|
||||
@@ -151,6 +164,14 @@ func (ctl *OrderController) GetlocationOrderSummary(c *fiber.Ctx) error {
|
||||
tenantIDStr := c.Query("tenantid")
|
||||
tenantID, _ := strconv.Atoi(tenantIDStr)
|
||||
|
||||
if tenantID == 0 {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"status": false,
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "tenantid is required",
|
||||
})
|
||||
}
|
||||
|
||||
data, err := ctl.orderService.GetLocationOrderSummary(tenantID)
|
||||
if err != nil {
|
||||
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{
|
||||
@@ -336,6 +357,14 @@ func (ctl *OrderController) GetCustomerOrders(c *fiber.Ctx) error {
|
||||
}
|
||||
offset := (pageNo - 1) * pageSize
|
||||
|
||||
if customerID == "" {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"code": http.StatusBadRequest,
|
||||
"status": false,
|
||||
"message": "customerid is required",
|
||||
})
|
||||
}
|
||||
|
||||
orders, err := ctl.orderService.GetCustomerOrdersv3(customerID, tenantID, moduleID, fromDate, toDate, orderStatus, keyword, pageSize, offset)
|
||||
if err != nil {
|
||||
log.Println("GetCustomerOrders error:", err)
|
||||
|
||||
Reference in New Issue
Block a user