From 28cea3241b5f5df0f394e784f23a9cc67cff83ba Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Wed, 29 Oct 2025 19:42:10 +0800 Subject: [PATCH] Updated backend --- backend/main.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/backend/main.go b/backend/main.go index 66a416b..b1882ab 100644 --- a/backend/main.go +++ b/backend/main.go @@ -18,12 +18,12 @@ import ( ) // DEV -var connection string = "root:superuser@tcp(localhost:3306)/iips" -var connectionPops string = "root:superuser@tcp(localhost:3306)/pops" +// var connection string = "root:superuser@tcp(localhost:3306)/iips" +// var connectionPops string = "root:superuser@tcp(localhost:3306)/pops" // SERVER -// var connection string = "iips:iipsuser@tcp(192.168.7.100:3306)/iips" -// var connectionPops string = "pops:Pops2023!@tcp(192.168.76.10:3306)/pops" +var connection string = "iips:iipsuser@tcp(192.168.7.100:3306)/iips" +var connectionPops string = "pops:Pops2023!@tcp(192.168.76.10:3306)/pops" func main() { connect() @@ -44,23 +44,23 @@ func connect() { router.Use(cors.Default()) //DEV - router.Use(cors.New(cors.Config{ - AllowOrigins: []string{"http://localhost:5173"}, - AllowMethods: []string{"GET", "POST"}, - AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"}, - ExposeHeaders: []string{"Content-Length"}, - AllowCredentials: true, - })) - - //SERVER // router.Use(cors.New(cors.Config{ - // AllowAllOrigins: true, + // AllowOrigins: []string{"http://localhost:5173"}, // AllowMethods: []string{"GET", "POST"}, - // AllowHeaders: []string{"Origin"}, + // AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"}, // ExposeHeaders: []string{"Content-Length"}, // AllowCredentials: true, // })) + //SERVER + router.Use(cors.New(cors.Config{ + AllowAllOrigins: true, + AllowMethods: []string{"GET", "POST"}, + AllowHeaders: []string{"Origin"}, + ExposeHeaders: []string{"Content-Length"}, + AllowCredentials: true, + })) + router.StaticFile("/", "static/index.html") // shield := "inquiry" @@ -612,8 +612,8 @@ func connect() { array11 := []string{} array12 := []string{} - results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.firstName, '') AS result2, IFNULL(c.middleInitial, '') AS result3, IFNULL(c.lastName, '') AS result4, IFNULL(e.locationofinstallation, '') AS result5, IFNULL(re.type, '') AS result6, IFNULL(em.employeename, '') AS result7, IFNULL(rb.accountdescription, '') AS result8, IFNULL(o.amount, '') AS result9, IFNULL(o.opDate, '') AS result10, IFNULL(e.electricalid, 0) AS result11, IFNULL(o.assessedbyid, 0) AS result12 - FROM electrical e, customer c, electrical_orderofpayment_new o, ref_electrical_type re, ref_bldgcomputationsheet rb, employee em WHERE e.customerid = c.customerid AND e.electricalid = o.electricalid AND e.ref_electrical_typeid = re.ref_electrical_typeid AND o.ref_bldgcomputationsheetid = rb.ref_bldgcomputationsheetid AND o.assessedbyid = em.employeeid AND e.electricalNo = ?`, data) + results, err := db.Query(`SELECT IFNULL(e.electricalNo, '') AS result, IFNULL(c.firstName, '') AS result2, IFNULL(c.middleInitial, '') AS result3, IFNULL(c.lastName, '') AS result4, IFNULL(e.locationofinstallation, '') AS result5, IFNULL(re.occupancyoruse, '') AS result6, IFNULL(em.employeename, '') AS result7, IFNULL(rb.accountdescription, '') AS result8, IFNULL(o.amount, '') AS result9, IFNULL(o.opDate, '') AS result10, IFNULL(e.electricalid, 0) AS result11, IFNULL(o.assessedbyid, 0) AS result12 + FROM electrical e, customer c, electrical_orderofpayment_new o, ref_elec_occupancy re, ref_bldgcomputationsheet rb, employee em WHERE e.customerid = c.customerid AND e.electricalid = o.electricalid AND e.ref_elec_occupancyid = re.ref_elec_occupancyid AND o.ref_bldgcomputationsheetid = rb.ref_bldgcomputationsheetid AND o.assessedbyid = em.employeeid AND e.electricalNo = ?`, data) if err != nil { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error())