stock request table created
This commit is contained in:
@@ -377,7 +377,6 @@ func (ctl *OrderController) GetRevenueSummary(c *fiber.Ctx) error {
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
return c.Status(http.StatusOK).JSON(fiber.Map{
|
||||
"code": http.StatusOK,
|
||||
"message": "Success",
|
||||
@@ -386,3 +385,33 @@ func (ctl *OrderController) GetRevenueSummary(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (ctl *OrderController) GetSalesSummary(c *fiber.Ctx) error {
|
||||
tid, _ := strconv.Atoi(c.Query("tenantid"))
|
||||
lid, _ := strconv.Atoi(c.Query("locationid"))
|
||||
fdate := c.Query("fromdate")
|
||||
tdate := c.Query("todate")
|
||||
|
||||
if tid == 0 {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "tenantid query parameter is required",
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
data, err := ctl.orderService.GetSalesSummary(tid, lid, fdate, tdate)
|
||||
if err != nil {
|
||||
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{
|
||||
"code": http.StatusInternalServerError,
|
||||
"message": err.Error(),
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
return c.Status(http.StatusOK).JSON(fiber.Map{
|
||||
"code": http.StatusOK,
|
||||
"message": "Success",
|
||||
"status": true,
|
||||
"details": data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func (ctl *PartnerController) GetActiveRiders(c *fiber.Ctx) error {
|
||||
pid, _ := strconv.Atoi(c.Query("partnerid"))
|
||||
aid, _ := strconv.Atoi(c.Query("applocationid"))
|
||||
uid, _ := strconv.Atoi(c.Query("userid"))
|
||||
tid,_ := strconv.Atoi(c.Query("tenantid"))
|
||||
tid, _ := strconv.Atoi(c.Query("tenantid"))
|
||||
result, err := ctl.partnerService.GetActiveRiders(pid, aid, uid, tid)
|
||||
|
||||
if err != nil {
|
||||
@@ -109,7 +109,6 @@ func (ctl *PartnerController) GetLocationConfig(c *fiber.Ctx) error {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (ctl *PartnerController) GetRiderLogs(c *fiber.Ctx) error {
|
||||
pid, _ := strconv.Atoi(c.Query("partnerid"))
|
||||
aid, _ := strconv.Atoi(c.Query("applocationid"))
|
||||
@@ -134,6 +133,29 @@ func (ctl *PartnerController) GetRiderLogs(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (ctl *PartnerController) GetFleetSummary(c *fiber.Ctx) error {
|
||||
aid, _ := strconv.Atoi(c.Query("applocationid"))
|
||||
tid, _ := strconv.Atoi(c.Query("tenantid"))
|
||||
fdate := c.Query("fromdate")
|
||||
tdate := c.Query("todate")
|
||||
|
||||
result, err := ctl.partnerService.GetFleetSummary(aid, tid, fdate, tdate)
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(fiber.Map{
|
||||
"status": false,
|
||||
"code": http.StatusInternalServerError,
|
||||
"message": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"status": true,
|
||||
"code": http.StatusOK,
|
||||
"message": "Successful",
|
||||
"details": result,
|
||||
})
|
||||
}
|
||||
|
||||
func (ctl *PartnerController) GetRiderInfo(c *fiber.Ctx) error {
|
||||
uid, _ := strconv.Atoi(c.Query("userid"))
|
||||
|
||||
69
controllers/stockrequestController.go
Normal file
69
controllers/stockrequestController.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"nearle/models"
|
||||
"nearle/services"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type StockRequestController struct {
|
||||
stockRequestService services.StockRequestService
|
||||
}
|
||||
|
||||
func NewStockRequestController(stockRequestService services.StockRequestService) *StockRequestController {
|
||||
return &StockRequestController{stockRequestService: stockRequestService}
|
||||
}
|
||||
|
||||
func (ctl *StockRequestController) CreateStockRequest(c *fiber.Ctx) error {
|
||||
var input models.StockRequest
|
||||
if err := c.BodyParser(&input); err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusBadRequest, "message": "Invalid input", "status": false})
|
||||
}
|
||||
|
||||
if input.Status == "" {
|
||||
input.Status = "Pending"
|
||||
}
|
||||
|
||||
err := ctl.stockRequestService.CreateStockRequest(&input)
|
||||
if err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusInternalServerError, "message": err.Error(), "status": false})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{"code": 200, "message": "Stock request created", "status": true, "details": input})
|
||||
}
|
||||
|
||||
func (ctl *StockRequestController) GetStockRequests(c *fiber.Ctx) error {
|
||||
tenantID, _ := strconv.Atoi(c.Query("tenantid", "0"))
|
||||
locationID, _ := strconv.Atoi(c.Query("locationid", "0"))
|
||||
status := c.Query("status", "")
|
||||
pageNo, _ := strconv.Atoi(c.Query("pageno", "1"))
|
||||
pageSize, _ := strconv.Atoi(c.Query("pagesize", "50"))
|
||||
|
||||
data, err := ctl.stockRequestService.GetStockRequests(tenantID, locationID, status, pageNo, pageSize)
|
||||
if err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusInternalServerError, "message": err.Error(), "status": false})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{"code": 200, "message": "Success", "status": true, "details": data})
|
||||
}
|
||||
|
||||
func (ctl *StockRequestController) UpdateStockRequest(c *fiber.Ctx) error {
|
||||
var input struct {
|
||||
RequestID int `json:"requestid"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
if err := c.BodyParser(&input); err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusBadRequest, "message": "Invalid input", "status": false})
|
||||
}
|
||||
|
||||
err := ctl.stockRequestService.UpdateStockRequest(input.RequestID, input.Status)
|
||||
if err != nil {
|
||||
return c.JSON(fiber.Map{"code": http.StatusInternalServerError, "message": err.Error(), "status": false})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{"code": 200, "message": "Stock request updated", "status": true})
|
||||
}
|
||||
@@ -252,6 +252,40 @@ func (ctl *TenantController) CreateLocation(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (ctl *TenantController) DeleteLocation(c *fiber.Ctx) error {
|
||||
locationid, err := strconv.Atoi(c.Query("locationid"))
|
||||
if err != nil {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "Invalid location ID",
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
tenantid, err := strconv.Atoi(c.Query("tenantid"))
|
||||
if err != nil {
|
||||
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "Invalid tenant ID",
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
if err := ctl.tenantService.DeleteLocation(locationid, tenantid); err != nil {
|
||||
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{
|
||||
"code": http.StatusInternalServerError,
|
||||
"message": err.Error(),
|
||||
"status": false,
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"code": http.StatusOK,
|
||||
"message": "Location Successfully Deleted",
|
||||
"status": true,
|
||||
})
|
||||
}
|
||||
|
||||
func (ctl *TenantController) GetStaffs(c *fiber.Ctx) error {
|
||||
tid, _ := strconv.Atoi(c.Query("tenantid"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user