Protected routes
This commit is contained in:
@@ -35,6 +35,8 @@ func GetLatestContracts(c *gin.Context) {
|
||||
deviceIDsStr := c.QueryArray("deviceIDs[]")
|
||||
iDsStr := c.QueryArray("ids[]")
|
||||
|
||||
company := c.GetInt("companyID")
|
||||
|
||||
// Convert limit and offset to int
|
||||
limit, err := strconv.Atoi(limitStr)
|
||||
if err != nil {
|
||||
@@ -93,7 +95,7 @@ func GetLatestContracts(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Fetch contracts
|
||||
contracts, total, st, err := contract.GetContracts(status, companyName, companyAddress, companyEmail, companyPhone, &startTime, &endTime, contractName, deviceIDs, contractIDs, nil, limit, offset)
|
||||
contracts, total, st, err := contract.GetContracts(status, companyName, companyAddress, companyEmail, companyPhone, &startTime, &endTime, contractName, deviceIDs, contractIDs, nil, company, limit, offset)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(st, gin.H{"error": err.Error()})
|
||||
@@ -114,6 +116,7 @@ func GetBuyerContracts(c *gin.Context) {
|
||||
dateCreatedStr := c.Query("date_created")
|
||||
startTimeStr := c.Query("start_time")
|
||||
endTimeStr := c.Query("end_time")
|
||||
company := c.GetInt("companyID")
|
||||
|
||||
// Convert limit and offset to int
|
||||
limit, err := strconv.Atoi(limitStr)
|
||||
@@ -175,7 +178,7 @@ func GetBuyerContracts(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Fetch contracts
|
||||
contracts, total, st, err := contract.GetContracts(status, "", "", "", "", startTime, endTime, qStr, nil, contractIDs, &dateCreated, limit, offset)
|
||||
contracts, total, st, err := contract.GetContracts(status, "", "", "", "", startTime, endTime, qStr, nil, contractIDs, &dateCreated, company, limit, offset)
|
||||
if err != nil {
|
||||
c.JSON(st, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -354,7 +357,7 @@ func GetContractCountByStatus(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"data": models.ActiveContractsResponse{ActiveCount: activeCount, ExecutedCount : executedCount, MonthlyContracts: monthly}})
|
||||
c.JSON(http.StatusOK, gin.H{"data": models.ActiveContractsResponse{ActiveCount: activeCount, ExecutedCount: executedCount, MonthlyContracts: monthly}})
|
||||
|
||||
}
|
||||
|
||||
@@ -388,5 +391,5 @@ func GetTotalContractCount(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"data" : totalCount})
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"data": totalCount})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user