Added check access

This commit is contained in:
Patrick Alvin Alcala 2025-10-07 11:47:09 +08:00
parent 43310d7b30
commit 84ab9db2a0

View file

@ -698,6 +698,33 @@ func connect() {
})
router.GET("/api/:method/:data/:data2", func(c *gin.Context) {
var result string
method := c.Param("method")
data := c.Param("data")
data2 := c.Param("data2")
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")
switch method {
case "check-access":
err = db.QueryRow("SELECT COUNT(accessid) AS result FROM access a JOIN ref_access ra ON a.ref_accessid = ra.ref_accessid AND ra.access = ? and employeeid = ?", data, data2).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.POST("/api/post-newstatus-electrical", func(c *gin.Context) {
type RegistrationData struct {
Data int `json:"data"`