Updated backend
This commit is contained in:
parent
4eb6b70830
commit
ca4883eb1c
1 changed files with 65 additions and 0 deletions
|
|
@ -46,6 +46,14 @@ func getCORSConfig(env string) cors.Config {
|
||||||
ExposeHeaders: []string{"Content-Length"},
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
}
|
}
|
||||||
|
case "lan":
|
||||||
|
return cors.Config{
|
||||||
|
AllowOrigins: []string{"*"},
|
||||||
|
AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"},
|
||||||
|
AllowHeaders: []string{"*"},
|
||||||
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
|
AllowCredentials: true,
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return cors.DefaultConfig()
|
return cors.DefaultConfig()
|
||||||
}
|
}
|
||||||
|
|
@ -1466,6 +1474,19 @@ func connect() {
|
||||||
"result2": resultCount,
|
"result2": resultCount,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case "login":
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -2335,6 +2356,50 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.POST("/api/update-opforapproval-electrical", func(c *gin.Context) {
|
||||||
|
type forApprovalData struct {
|
||||||
|
Data string `json:"data"` //electricalNo
|
||||||
|
}
|
||||||
|
var forapprovalData forApprovalData
|
||||||
|
if err := c.ShouldBindJSON(&forapprovalData); 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("UPDATE electrical_orderofpayment_new SET is_approve = 0, is_release = 0, popstransmitted = 0 WHERE is_paid = 0 AND electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?)")
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
|
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer dbpost.Close()
|
||||||
|
|
||||||
|
exec, err := dbpost.Exec(forapprovalData.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 Updating Re-Approval")
|
||||||
|
} else {
|
||||||
|
c.String(http.StatusInternalServerError, "Failed on Updating Re-Approval")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// router.POST("/api/return-approval-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
// router.POST("/api/return-approval-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
||||||
// type returnApprovalData struct {
|
// type returnApprovalData struct {
|
||||||
// Data string `json:"data"` //electricalNo
|
// Data string `json:"data"` //electricalNo
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue