Updated backend
This commit is contained in:
parent
edf54f4fbc
commit
21ae7356ae
1 changed files with 83 additions and 23 deletions
106
backend/main.go
106
backend/main.go
|
|
@ -1453,6 +1453,19 @@ func connect() {
|
||||||
"result": result,
|
"result": result,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case "check-statuspops-local":
|
||||||
|
var resultInt, resultCount int
|
||||||
|
err := dbpop.QueryRow(`SELECT COUNT(OrderPayId) AS resultInt, COUNT(AFNum) AS resultCount FROM orderpaydetail WHERE oprefid = ?`, data).Scan(&resultInt, &resultCount)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"result": resultInt,
|
||||||
|
"result2": resultCount,
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -2322,6 +2335,50 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// router.POST("/api/return-approval-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||||
|
// type returnApprovalData struct {
|
||||||
|
// Data string `json:"data"` //electricalNo
|
||||||
|
// }
|
||||||
|
// var returnapprovalData returnApprovalData
|
||||||
|
// if err := c.ShouldBindJSON(&returnapprovalData); err != nil {
|
||||||
|
// c.String(http.StatusBadRequest, "Invalid request body")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
|
||||||
|
// c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
|
// c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
|
||||||
|
// c.Writer.Header().Set("X-Frame-Options", "DENY")
|
||||||
|
// c.Writer.Header().Set("X-Download-Options", "noopen")
|
||||||
|
// c.Writer.Header().Set("Referrer-Policy", "no-referrer")
|
||||||
|
// c.Writer.Header().Set("Content-Security-Policy", "default-src 'self'; img-src 'self';")
|
||||||
|
// c.Writer.Header().Set("X-Server", "OCBO Server")
|
||||||
|
|
||||||
|
// dbpost, err := db.Prepare("INSERT INTO esign_lock (esign_lockid, referenceNo, lock_code) VALUES (NULL, ?, ?)")
|
||||||
|
// if err != nil {
|
||||||
|
// c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
|
// c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// defer dbpost.Close()
|
||||||
|
|
||||||
|
// exec, err := dbpost.Exec(returnapprovalData.Data)
|
||||||
|
// if err != nil {
|
||||||
|
// panic(err.Error())
|
||||||
|
// }
|
||||||
|
|
||||||
|
// affect, err := exec.RowsAffected()
|
||||||
|
// if err != nil {
|
||||||
|
// panic(err.Error())
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if affect > 0 {
|
||||||
|
// c.String(http.StatusOK, "Success on Saving Lock Data")
|
||||||
|
// } else {
|
||||||
|
// c.String(http.StatusInternalServerError, "Failed on Saving Lock Data")
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
router.DELETE("/api/delete-orderofpayment-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.DELETE("/api/delete-orderofpayment-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||||
type DeleteOP struct {
|
type DeleteOP struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
|
|
@ -2455,8 +2512,8 @@ func connect() {
|
||||||
c.Writer.Header().Set("Content-Security-Policy", "default-src 'self'; img-src 'self';")
|
c.Writer.Header().Set("Content-Security-Policy", "default-src 'self'; img-src 'self';")
|
||||||
c.Writer.Header().Set("X-Server", "OCBO Server")
|
c.Writer.Header().Set("X-Server", "OCBO Server")
|
||||||
|
|
||||||
var resultCount int
|
var resultId, resultCount int
|
||||||
checkErr := dbpop.QueryRow("SELECT COUNT(AFNum) AS resultCount FROM orderpaydetail WHERE OPRefId = ?", deleteOpLocal.Data).Scan(&resultCount)
|
checkErr := dbpop.QueryRow("SELECT COUNT(OrderPayId) AS resultId, COUNT(AFNum) AS resultCount FROM orderpaydetail WHERE OPRefId = ?", deleteOpLocal.Data).Scan(&resultId, &resultCount)
|
||||||
if checkErr != nil {
|
if checkErr != nil {
|
||||||
c.AbortWithError(http.StatusInternalServerError, checkErr)
|
c.AbortWithError(http.StatusInternalServerError, checkErr)
|
||||||
c.String(http.StatusInternalServerError, "Internal Server Error")
|
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||||
|
|
@ -2464,33 +2521,36 @@ func connect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if resultCount > 0 {
|
if resultCount > 0 {
|
||||||
c.String(http.StatusBadRequest, "Error! Payment already exist.")
|
c.String(http.StatusForbidden, "Error! Payment already exist.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dbpost, err := dbpop.Prepare("DELETE FROM orderpaydetail WHERE OPRefId = ?")
|
if resultId > 0 {
|
||||||
if err != nil {
|
dbpost, err := dbpop.Prepare("DELETE FROM orderpaydetail WHERE OPRefId = ?")
|
||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
if err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Internal Server Error")
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||||
}
|
return
|
||||||
defer dbpost.Close()
|
}
|
||||||
|
defer dbpost.Close()
|
||||||
|
|
||||||
exec, err := dbpost.Exec(deleteOpLocal.Data)
|
exec, err := dbpost.Exec(deleteOpLocal.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
affect, err := exec.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if affect > 0 {
|
||||||
|
c.String(http.StatusOK, "Success on Deleting POPS Local")
|
||||||
|
} else {
|
||||||
|
c.String(http.StatusInternalServerError, "Failed on Deleting POPS Local")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
affect, err := exec.RowsAffected()
|
|
||||||
if err != nil {
|
|
||||||
panic(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if affect > 0 {
|
|
||||||
c.String(http.StatusOK, "Success on Deleting POPS Local")
|
|
||||||
} else {
|
|
||||||
c.String(http.StatusInternalServerError, "Failed on Deleting POPS Local")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.DELETE("/api/delete-esigntransactions", func(c *gin.Context) {
|
router.DELETE("/api/delete-esigntransactions", func(c *gin.Context) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue