Updated backend deps and added env
This commit is contained in:
parent
d8296d9c0e
commit
54fe8ade87
3 changed files with 101 additions and 7 deletions
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
// "crypto/rand"
|
||||
|
|
@ -10,11 +11,12 @@ import (
|
|||
// "encoding/base64"
|
||||
// "encoding/pem"
|
||||
// "errors"
|
||||
// "os"
|
||||
"os"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
// DEV
|
||||
|
|
@ -26,6 +28,11 @@ var connectionPops string = "root:superuser@tcp(localhost:3306)/pops"
|
|||
// var connectionPops string = "pops:Pops2023!@tcp(192.168.76.10:3306)/pops"
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
}
|
||||
|
||||
connect()
|
||||
}
|
||||
|
||||
|
|
@ -231,9 +238,10 @@ func connect() {
|
|||
})
|
||||
|
||||
case "get-list-registered":
|
||||
headId := os.Getenv("HEADID")
|
||||
array := []string{}
|
||||
|
||||
results, err := db.Query("SELECT IFNULL(employeeid, 0) AS result FROM esign WHERE employeeid <> ?", 276)
|
||||
results, err := db.Query("SELECT IFNULL(employeeid, 0) AS result FROM esign WHERE employeeid <> ?", headId)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
@ -557,6 +565,28 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-idbyapplication-building":
|
||||
err := db.QueryRow(`SELECT IFNULL(receivingid, '') AS result FROM receiving WHERE applicationNo = ?`, data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
case "get-idbyapplication-occupancy":
|
||||
err := db.QueryRow(`SELECT IFNULL(occupancyid, '') AS result FROM occupancy WHERE controlNo = ?`, data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
case "get-idbyapplication-electrical":
|
||||
err := db.QueryRow(`SELECT IFNULL(electricalid, '') AS result FROM electrical WHERE electricalNo = ?`, data).Scan(&result)
|
||||
if err != nil {
|
||||
|
|
@ -782,6 +812,56 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
case "get-popsdetails-occupancy":
|
||||
var result2, result3, result4, result5, result6, result7, result8, result9 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
array3 := []string{}
|
||||
array4 := []string{}
|
||||
array5 := []string{}
|
||||
array6 := []string{}
|
||||
array7 := []string{}
|
||||
array8 := []string{}
|
||||
array9 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(o.controlNo, '') AS result, IFNULL(c.customerid, 0) AS result2, IFNULL(IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName)), '') AS result3,
|
||||
IFNULL(r.locationofconstruction, '') AS result4, IFNULL(op.amount, '') AS result5, IFNULL(op.amt_Gflgu, '') AS result6, IFNULL(op.amt_Gfdpwh, '') AS result7, IFNULL(op.amt_Tfbo, '') AS result8, IFNULL(ref.accountcode, '') AS result9
|
||||
FROM occupancy o JOIN receiving r ON o.bldgApplicationNo = r.applicationNo JOIN customer c ON r.customerid = c.customerid JOIN occupancy_orderofpayment op ON o.occupancyid = op.occupancyid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
|
||||
WHERE o.occupancyid = (SELECT occupancyid FROM occupancy WHERE controlNo = ?)`, data)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
for results.Next() {
|
||||
err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8, &result9)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
array = append(array, result)
|
||||
array2 = append(array2, result2)
|
||||
array3 = append(array3, result3)
|
||||
array4 = append(array4, result4)
|
||||
array5 = append(array5, result5)
|
||||
array6 = append(array6, result6)
|
||||
array7 = append(array7, result7)
|
||||
array8 = append(array8, result8)
|
||||
array9 = append(array9, result9)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
"result3": array3,
|
||||
"result4": array4,
|
||||
"result5": array5,
|
||||
"result6": array6,
|
||||
"result7": array7,
|
||||
"result8": array8,
|
||||
"result9": array9,
|
||||
})
|
||||
|
||||
case "get-popsdetails-electrical":
|
||||
var result2, result3, result4, result5, result6, result7, result8, result9 string
|
||||
array := []string{}
|
||||
|
|
@ -797,7 +877,7 @@ func connect() {
|
|||
results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.customerid, 0) AS result2, IFNULL(IF(c.firstName IS NULL OR c.firstName = '', c.lastName, CONCAT(c.firstName, ' ', IF(c.middleInitial IS NULL OR c.middleInitial = '', '', CONCAT(c.middleInitial, '. ')), c.lastName)), '') AS result3,
|
||||
IFNULL(e.locationofinstallation, '') AS result4, IFNULL(op.amount, '') AS result5, IFNULL(op.amt_Gflgu, '') AS result6, IFNULL(op.amt_Gfdpwh, '') AS result7, IFNULL(op.amt_Tfbo, '') AS result8, IFNULL(ref.accountcode, '') AS result9
|
||||
FROM electrical e JOIN customer c ON e.customerid = c.customerid JOIN electrical_orderofpayment_new op ON e.electricalid = op.electricalid JOIN ref_bldgcomputationsheet ref ON op.ref_bldgcomputationsheetid = ref.ref_bldgcomputationsheetid
|
||||
WHERE e.electricalid = ?`, data)
|
||||
WHERE e.electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)`, data)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue