Updated backend
This commit is contained in:
parent
458a87d546
commit
b08ac16aef
1 changed files with 31 additions and 11 deletions
|
|
@ -536,28 +536,38 @@ func connect() {
|
||||||
case "get-employeename":
|
case "get-employeename":
|
||||||
err := db.QueryRow("SELECT IFNULL(employeename, '') AS result FROM employee WHERE employeeid = ?", data).Scan(&result)
|
err := db.QueryRow("SELECT IFNULL(employeename, '') AS result FROM employee WHERE employeeid = ?", data).Scan(&result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
if err == sql.ErrNoRows {
|
||||||
c.String(http.StatusBadRequest, err.Error())
|
result = "0"
|
||||||
|
} else {
|
||||||
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"result": result,
|
"result": result,
|
||||||
})
|
})
|
||||||
|
|
||||||
case "get-opdetails-electrical":
|
case "get-opdetails-electrical":
|
||||||
var result2, result3, result4, result5 string
|
var result2, result3, result4, result5, result6, result7, result8, result9, result10 string
|
||||||
array := []string{}
|
array := []string{}
|
||||||
array2 := []string{}
|
array2 := []string{}
|
||||||
array3 := []string{}
|
array3 := []string{}
|
||||||
array4 := []string{}
|
array4 := []string{}
|
||||||
array5 := []string{}
|
array5 := []string{}
|
||||||
|
array6 := []string{}
|
||||||
|
array7 := []string{}
|
||||||
|
array8 := []string{}
|
||||||
|
array9 := []string{}
|
||||||
|
array10 := []string{}
|
||||||
|
|
||||||
results, err := db.Query("SELECT IFNULL(assessedbyid, 0) AS result, IFNULL(reviewedbyid, 0) AS result2, IFNULL(ref_bldgcomputationsheetid, 0) AS result3, IFNULL(amount, 0) AS result4, IFNULL(opDate, '') AS result5 FROM electrical_orderofpayment_new WHERE electricalid = ?", 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.type, '') AS result6, IFNULL(em.employeename, '') AS result7, IFNULL(rb.accountdescription, '') AS result8, IFNULL(o.amount, '') AS result9, IFNULL(o.opDate, '') AS result10
|
||||||
|
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.electricalid = ?`, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
c.String(http.StatusBadRequest, err.Error())
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
for results.Next() {
|
for results.Next() {
|
||||||
err = results.Scan(&result, &result2, &result3, &result4, &result5)
|
err = results.Scan(&result, &result2, &result3, &result4, &result5, &result6, &result7, &result8, &result9, &result10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
c.String(http.StatusBadRequest, err.Error())
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
|
@ -567,17 +577,27 @@ func connect() {
|
||||||
array3 = append(array3, result3)
|
array3 = append(array3, result3)
|
||||||
array4 = append(array4, result4)
|
array4 = append(array4, result4)
|
||||||
array5 = append(array5, result5)
|
array5 = append(array5, result5)
|
||||||
|
array6 = append(array6, result6)
|
||||||
|
array7 = append(array7, result7)
|
||||||
|
array8 = append(array8, result8)
|
||||||
|
array9 = append(array9, result9)
|
||||||
|
array10 = append(array10, result10)
|
||||||
|
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"result": array,
|
"result": array,
|
||||||
"result2": array2,
|
"result2": array2,
|
||||||
"result3": array3,
|
"result3": array3,
|
||||||
"result4": array4,
|
"result4": array4,
|
||||||
"result5": array5,
|
"result5": array5,
|
||||||
|
"result6": array6,
|
||||||
|
"result7": array7,
|
||||||
|
"result8": array8,
|
||||||
|
"result9": array9,
|
||||||
|
"result10": array10,
|
||||||
})
|
})
|
||||||
|
|
||||||
case "get-paymentname":
|
case "get-paymentname":
|
||||||
err := db.QueryRow("SELECT IFNULL(accountdescription, '') AS result FROM ref_bldgcomputationsheet WHERE ref_bldgcomputationsheetid = ?", data).Scan(&result)
|
err := db.QueryRow("SELECT IFNULL(accountdescription, '') AS result FROM ref_bldgcomputationsheet WHERE ref_bldgcomputationsheetid = ?", data).Scan(&result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue