Upstream sync

This commit is contained in:
Senad Uka
2023-10-16 12:03:47 +02:00
parent 533451f39d
commit 00d15ebe7e
4 changed files with 137 additions and 13 deletions

View File

@@ -97,7 +97,7 @@ func GetLatestContracts(c *gin.Context) {
}
// Respond with the contracts and the total count
c.JSON(http.StatusOK, gin.H{"total": total, "data": models.ConvertContractToResponse(contracts)})
c.JSON(http.StatusOK, gin.H{"total": total, "data": models.ConvertContractToDashboardResponse(contracts)})
}
func GetBuyerContracts(c *gin.Context) {
@@ -106,6 +106,7 @@ func GetBuyerContracts(c *gin.Context) {
offsetStr := c.DefaultQuery("offset", "0")
status := c.QueryArray("status")
iDsStr := c.QueryArray("ids[]")
qStr := c.Query("q")
dateCreatedStr := c.Query("date_created")
startTimeStr := c.Query("start_time")
endTimeStr := c.Query("end_time")
@@ -170,14 +171,14 @@ func GetBuyerContracts(c *gin.Context) {
}
// Fetch contracts
contracts, total, st, err := contract.GetContracts(status, "", "", "", "", startTime, endTime, "", nil, contractIDs, &dateCreated, limit, offset)
contracts, total, st, err := contract.GetContracts(status, "", "", "", "", startTime, endTime, qStr, nil, contractIDs, &dateCreated, limit, offset)
if err != nil {
c.JSON(st, gin.H{"error": err.Error()})
return
}
// Respond with the contracts and the total count
c.JSON(http.StatusOK, gin.H{"total": total, "data": models.ConvertContractToResponseModel(contracts)})
c.JSON(http.StatusOK, gin.H{"total": total, "data": models.ConvertContractToListResponse(contracts)})
}
func GetContractStatuses(c *gin.Context) {
@@ -249,7 +250,7 @@ func GetContractByID(c *gin.Context) {
}
// Respond with the contracts and the total count
c.JSON(http.StatusOK, gin.H{"data": contract})
c.JSON(http.StatusOK, gin.H{"data": models.ConvertContractToContractResponse(contract)})
}
func UpdateContract(c *gin.Context) {
@@ -290,5 +291,5 @@ func UpdateContract(c *gin.Context) {
}
// Respond with the contracts and the total count
c.JSON(http.StatusOK, gin.H{"data": contractModel})
c.JSON(http.StatusOK, gin.H{"data": models.ConvertContractToContractResponse(contractModel)})
}