From 788007ca03478d46f30c666729e819f3b06c0a1c Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Mon, 22 Sep 2025 11:43:49 +0800 Subject: [PATCH] Added getting list of assessors on backend --- backend/main.go | 50 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/backend/main.go b/backend/main.go index ad6bb32..0177a75 100644 --- a/backend/main.go +++ b/backend/main.go @@ -98,22 +98,47 @@ func connect() { case "get-listopapproval-electrical": array := []string{} - results, err := db.Query("SELECT DISTINCT electricalid FROM electricaldocflowtxn WHERE remarks = 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL'") + results, err := db.Query("SELECT DISTINCT electricalid as result FROM electricaldocflowtxn WHERE remarks = 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL'") if err != nil { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error()) } for results.Next() { - err = results.Scan(&result) - if err != nil { - c.AbortWithError(http.StatusBadRequest, err) - c.String(http.StatusBadRequest, err.Error()) - } - array = append(array, result) - } - c.JSON(http.StatusOK, gin.H{ - "result": array, - }) + err = results.Scan(&result) + if err != nil { + c.AbortWithError(http.StatusBadRequest, err) + c.String(http.StatusBadRequest, err.Error()) + } + array = append(array, result) + } + c.JSON(http.StatusOK, gin.H{ + "result": array, + }) + + case "get-list-assessors": + var result2 string + + array := []string{} + array2 := []string{} + + results, err := db.Query("SELECT employeeid as result, employeename as result2 FROM employee WHERE is_assessment = 1") + if err != nil { + c.AbortWithError(http.StatusBadRequest, err) + c.String(http.StatusBadRequest, err.Error()) + } + for results.Next() { + err = results.Scan(&result, &result2) + if err != nil { + c.AbortWithError(http.StatusBadRequest, err) + c.String(http.StatusBadRequest, err.Error()) + } + array = append(array, result) + array2 = append(array2, result2) + } + c.JSON(http.StatusOK, gin.H{ + "result": array, + "result2": array2, + }) } }) @@ -336,6 +361,7 @@ func connect() { "result4": array4, }) + case "get-laststatus-building": err := db.QueryRow(`SELECT IFNULL(remarks, '') AS result FROM docflowtxn WHERE docflowtxnid = (SELECT MAX(docflowtxnid) FROM docflowtxn WHERE receivingid = ?)`, data).Scan(&result) if err != nil { @@ -397,6 +423,8 @@ func connect() { "result": result, }) + + case "GetFeesBuilding": var result2, result3 string array := []string{}