Added additional api
This commit is contained in:
parent
3354a74cd7
commit
607a10c1c6
1 changed files with 56 additions and 21 deletions
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"ocbo-esign-backend/connections"
|
"ocbo-esign-backend/connections"
|
||||||
"ocbo-esign-backend/middleware"
|
// "ocbo-esign-backend/middleware"
|
||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
@ -40,7 +40,16 @@ func getCORSConfig(env string) cors.Config {
|
||||||
}
|
}
|
||||||
case "prod":
|
case "prod":
|
||||||
return cors.Config{
|
return cors.Config{
|
||||||
AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph", "https://esign.patalcala.com", "http://localhost:8080", "http://127.0.0.1:8080"},
|
AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph", "https://esign.patalcala.com", "http://localhost:8080", "http://192.168.7.183"},
|
||||||
|
AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"},
|
||||||
|
// AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server", "Authorization"},
|
||||||
|
AllowHeaders: []string{"*"},
|
||||||
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
|
AllowCredentials: true,
|
||||||
|
}
|
||||||
|
case "lan":
|
||||||
|
return cors.Config{
|
||||||
|
AllowOrigins: []string{"*"},
|
||||||
AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"},
|
AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"},
|
||||||
// AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server", "Authorization"},
|
// AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server", "Authorization"},
|
||||||
AllowHeaders: []string{"*"},
|
AllowHeaders: []string{"*"},
|
||||||
|
|
@ -58,6 +67,8 @@ func getConnectionStrings(env string) (string, string, error) {
|
||||||
return connections.GetConnectionString(), connections.GetConnectionStringPops(), nil
|
return connections.GetConnectionString(), connections.GetConnectionStringPops(), nil
|
||||||
case "prod":
|
case "prod":
|
||||||
return connections.GetConnectionStringServer(), connections.GetConnectionStringPopsServer(), nil
|
return connections.GetConnectionStringServer(), connections.GetConnectionStringPopsServer(), nil
|
||||||
|
case "lan":
|
||||||
|
return connections.GetConnectionStringServer(), connections.GetConnectionStringPopsServer(), nil
|
||||||
default:
|
default:
|
||||||
return "", "", fmt.Errorf("unknown environment: %s", env)
|
return "", "", fmt.Errorf("unknown environment: %s", env)
|
||||||
}
|
}
|
||||||
|
|
@ -1480,6 +1491,19 @@ func connect() {
|
||||||
"result2": resultCount,
|
"result2": resultCount,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case "check-esigntransaction":
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -1593,6 +1617,17 @@ func connect() {
|
||||||
"result2": result2,
|
"result2": result2,
|
||||||
"result3": result3,
|
"result3": result3,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case "check-docflowprinting-electrical":
|
||||||
|
err := db.QueryRow("SELECT is_approve AS result FROM electricaldocflowtxn WHERE electricalid = (SELECT electricalid FROM electrical WHERE electricalNo = ?) and remarks = ?", 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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -1640,7 +1675,7 @@ func connect() {
|
||||||
c.Data(resp.StatusCode, "application/json", body)
|
c.Data(resp.StatusCode, "application/json", body)
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/post-registration", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/post-registration", func(c *gin.Context) {
|
||||||
type RegistrationData struct {
|
type RegistrationData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
Data2 string `json:"data2"`
|
Data2 string `json:"data2"`
|
||||||
|
|
@ -1686,7 +1721,7 @@ func connect() {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/post-newstatus-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/post-newstatus-occupancy", func(c *gin.Context) {
|
||||||
type NewstatusData struct {
|
type NewstatusData struct {
|
||||||
Data int `json:"data"` //occuapancyid
|
Data int `json:"data"` //occuapancyid
|
||||||
Data2 string `json:"data2"` //date
|
Data2 string `json:"data2"` //date
|
||||||
|
|
@ -1736,7 +1771,7 @@ func connect() {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/post-newstatus-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/post-newstatus-electrical", func(c *gin.Context) {
|
||||||
type NewstatusData struct {
|
type NewstatusData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
Data2 string `json:"data2"`
|
Data2 string `json:"data2"`
|
||||||
|
|
@ -1786,7 +1821,7 @@ func connect() {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-docflow-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-docflow-occupancy", func(c *gin.Context) {
|
||||||
type UpdateDocflowData struct {
|
type UpdateDocflowData struct {
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
Data2 string `json:"data2"`
|
Data2 string `json:"data2"`
|
||||||
|
|
@ -1835,7 +1870,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-docflow-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-docflow-electrical", func(c *gin.Context) {
|
||||||
type UpdateDocflowData struct {
|
type UpdateDocflowData struct {
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
Data2 string `json:"data2"`
|
Data2 string `json:"data2"`
|
||||||
|
|
@ -1884,7 +1919,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-opprinted-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-opprinted-occupancy", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -1926,7 +1961,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-opprinted-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-opprinted-electrical", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -1968,7 +2003,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-foropreprint-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-foropreprint-electrical", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -2010,7 +2045,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/post-esigntransaction", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/post-esigntransaction", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
Data2 string `json:"data2"`
|
Data2 string `json:"data2"`
|
||||||
|
|
@ -2054,7 +2089,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/post-pops", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/post-pops", func(c *gin.Context) {
|
||||||
type PostPopData struct {
|
type PostPopData struct {
|
||||||
Data string `json:"data"` //applicationNo
|
Data string `json:"data"` //applicationNo
|
||||||
Data2 string `json:"data2"` //date
|
Data2 string `json:"data2"` //date
|
||||||
|
|
@ -2109,7 +2144,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-opapproved-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-opapproved-occupancy", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -2158,7 +2193,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-opapproved-bldgadditional", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-opapproved-bldgadditional", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -2207,7 +2242,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-opapproved-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-opapproved-electrical", func(c *gin.Context) {
|
||||||
type UpdateOpData struct {
|
type UpdateOpData struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -2256,7 +2291,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-name", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-name", func(c *gin.Context) {
|
||||||
type NewnameData struct {
|
type NewnameData struct {
|
||||||
Data int `json:"data"` //employeeid
|
Data int `json:"data"` //employeeid
|
||||||
Data2 string `json:"data2"` //new name
|
Data2 string `json:"data2"` //new name
|
||||||
|
|
@ -2302,7 +2337,7 @@ func connect() {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/update-password", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/update-password", func(c *gin.Context) {
|
||||||
type NewnameData struct {
|
type NewnameData struct {
|
||||||
Data int `json:"data"` //employeeid
|
Data int `json:"data"` //employeeid
|
||||||
Data2 string `json:"data2"` //new password
|
Data2 string `json:"data2"` //new password
|
||||||
|
|
@ -2348,7 +2383,7 @@ func connect() {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/api/save-lockdata", middleware.TokenChecker(), func(c *gin.Context) {
|
router.POST("/api/save-lockdata", func(c *gin.Context) {
|
||||||
type saveLockData struct {
|
type saveLockData struct {
|
||||||
Data string `json:"data"` //referenceNo
|
Data string `json:"data"` //referenceNo
|
||||||
Data2 string `json:"data2"` //lock_data
|
Data2 string `json:"data2"` //lock_data
|
||||||
|
|
@ -2437,7 +2472,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// router.POST("/api/return-approval-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
// router.POST("/api/return-approval-electrical", func(c *gin.Context) {
|
||||||
// type returnApprovalData struct {
|
// type returnApprovalData struct {
|
||||||
// Data string `json:"data"` //electricalNo
|
// Data string `json:"data"` //electricalNo
|
||||||
// }
|
// }
|
||||||
|
|
@ -2481,7 +2516,7 @@ func connect() {
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
||||||
router.DELETE("/api/delete-orderofpayment-electrical", middleware.TokenChecker(), func(c *gin.Context) {
|
router.DELETE("/api/delete-orderofpayment-electrical", func(c *gin.Context) {
|
||||||
type DeleteOP struct {
|
type DeleteOP struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
@ -2538,7 +2573,7 @@ func connect() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.DELETE("/api/delete-orderofpayment-occupancy", middleware.TokenChecker(), func(c *gin.Context) {
|
router.DELETE("/api/delete-orderofpayment-occupancy", func(c *gin.Context) {
|
||||||
type DeleteOP struct {
|
type DeleteOP struct {
|
||||||
Data int `json:"data"`
|
Data int `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue