Added two new apis
This commit is contained in:
parent
b330d6685a
commit
4ea8fe21d4
1 changed files with 53 additions and 0 deletions
|
|
@ -157,6 +157,7 @@ func connect() {
|
||||||
"result": array,
|
"result": array,
|
||||||
"result2": array2,
|
"result2": array2,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -439,8 +440,60 @@ func connect() {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"result": result,
|
"result": result,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case "get-employeeid":
|
||||||
|
err := db.QueryRow("SELECT IFNULL(employeeid, 0) AS result FROM employee WHERE employeename = ?", data).Scan(&result)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"result": result,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.POST("/api/post-registration", func(c *gin.Context) {
|
||||||
|
type RegistrationData struct {
|
||||||
|
Data string `json:"data"`
|
||||||
|
Data2 string `json:"data2"`
|
||||||
|
}
|
||||||
|
var registrationData RegistrationData
|
||||||
|
if err := c.ShouldBindJSON(®istrationData); 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")
|
||||||
|
|
||||||
|
dbpost, err := db.Prepare("INSERT INTO esign (esignid, employeeid, signature) VALUES (NULL, ?, ?)")
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
defer dbpost.Close()
|
||||||
|
|
||||||
|
exec, err := dbpost.Exec(registrationData.Data, registrationData.Data2)
|
||||||
|
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 Registrating e-Sign")
|
||||||
|
} else {
|
||||||
|
c.String(http.StatusInternalServerError, "Failed on Registrating e-Sign")
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
router.Run(":4320")
|
router.Run(":4320")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue