Updated backend
This commit is contained in:
parent
8fff47ef1d
commit
c80faad1c7
1 changed files with 60 additions and 23 deletions
|
|
@ -1333,32 +1333,69 @@ func connect() {
|
|||
"result": result,
|
||||
})
|
||||
|
||||
// case "check-qr":
|
||||
// var count int
|
||||
// err := db.QueryRow("SELECT COUNT(esignid) AS result FROM esign WHERE SUBSTR(signature, 36) = ?", data).Scan(&count)
|
||||
// if err != nil {
|
||||
// c.AbortWithError(http.StatusBadRequest, err)
|
||||
// c.String(http.StatusBadRequest, err.Error())
|
||||
// return
|
||||
// }
|
||||
// if count > 0 {
|
||||
// err := db.QueryRow("SELECT IFNULL(e.employeename, '') AS result FROM esign es JOIN employee e ON es.employeeid = e.employeeid WHERE SUBSTR(signature, 36) = ?", 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,
|
||||
// })
|
||||
// } else {
|
||||
// c.JSON(http.StatusBadRequest, gin.H{
|
||||
// "result": count,
|
||||
// })
|
||||
// }
|
||||
|
||||
case "check-qr":
|
||||
var count int
|
||||
err := db.QueryRow("SELECT COUNT(esignid) AS result FROM esign WHERE SUBSTR(signature, 36) = ?", data).Scan(&count)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if count > 0 {
|
||||
err := db.QueryRow("SELECT IFNULL(e.employeename, '') AS result FROM esign es JOIN employee e ON es.employeeid = e.employeeid WHERE SUBSTR(signature, 36) = ?", 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,
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"result": count,
|
||||
})
|
||||
}
|
||||
|
||||
case "get-transactions":
|
||||
var result2 string
|
||||
array := []string{}
|
||||
array2 := []string{}
|
||||
|
||||
results, err := db.Query(`SELECT IFNULL(referenceNo, '') AS result, IFNULL(date_signed, '') AS result2 FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?))`, data)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
for results.Next() {
|
||||
err = results.Scan(&result, &result2)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
array = append(array, result)
|
||||
array2 = append(array2, result2)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
"result2": array2,
|
||||
})
|
||||
|
||||
case "get-transactions-count":
|
||||
err := db.QueryRow(`SELECT COUNT(esign_transactionsid) AS result FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?))`, 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,
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
router.GET("/api/:method/:data/:data2/fetch-data", func(c *gin.Context) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue