Updated cors and added get-list-approvers
This commit is contained in:
parent
6a33c504c6
commit
88a28cfdfd
1 changed files with 29 additions and 4 deletions
|
|
@ -43,8 +43,8 @@ func connect() {
|
||||||
|
|
||||||
//DEV
|
//DEV
|
||||||
router.Use(cors.New(cors.Config{
|
router.Use(cors.New(cors.Config{
|
||||||
AllowOrigins: []string{"http://localhost"},
|
AllowOrigins: []string{"http://localhost:5173"},
|
||||||
AllowMethods: []string{"GET"},
|
AllowMethods: []string{"GET", "POST"},
|
||||||
AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"},
|
AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"},
|
||||||
ExposeHeaders: []string{"Content-Length"},
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
|
|
@ -121,7 +121,32 @@ func connect() {
|
||||||
array := []string{}
|
array := []string{}
|
||||||
array2 := []string{}
|
array2 := []string{}
|
||||||
|
|
||||||
results, err := db.Query("SELECT IFNULL(employeeid, '') AS result, IFNULL(employeename, '') AS result2 FROM employee WHERE is_assessment = ? AND is_delete = ? AND employeename NOT LIKE ? AND employeename NOT LIKE ?", 1, 0, "%OFFICE%", "%TEST%")
|
results, err := db.Query("SELECT IFNULL(employeeid, '') AS result, IFNULL(employeename, '') AS result2 FROM employee WHERE is_assessment = ? AND is_delete = ? AND employeename NOT LIKE ? AND employeename NOT LIKE ? AND employeename NOT LIKE ?", 1, 0, "%OFFICE%", "%TEST%", "%SAMPLE%")
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
for results.Next() {
|
||||||
|
err = results.Scan(&result, &result2)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
array = append(array, result)
|
||||||
|
array2 = append(array2, result2)
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"result": array,
|
||||||
|
"result2": array2,
|
||||||
|
})
|
||||||
|
|
||||||
|
case "get-list-approvers":
|
||||||
|
var result2 string
|
||||||
|
|
||||||
|
array := []string{}
|
||||||
|
array2 := []string{}
|
||||||
|
|
||||||
|
results, err := db.Query("SELECT IFNULL(employeeid, '') AS result, IFNULL(employeename, '') AS result2 FROM employee WHERE is_finalapprover = ? AND is_delete = ? AND NOT (employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ? OR employeename LIKE ?)", 1, 0, "%OFFICE%", "%TEST%", "%SAMPLE%", "%BUILDING%", "%OCCUPANCY%")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
c.String(http.StatusBadRequest, err.Error())
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
|
|
@ -284,7 +309,7 @@ func connect() {
|
||||||
array := []string{}
|
array := []string{}
|
||||||
array2 := []string{}
|
array2 := []string{}
|
||||||
|
|
||||||
results, err := db.Query(`SELECT IFNULL(DATE_FORMAT(b.txndate, '%M %d, %Y')0 '') AS result, REPLACE(b.remarks, 'RECEIVE', 'RECEIVED') AS result2
|
results, err := db.Query(`SELECT IFNULL(DATE_FORMAT(b.txndate, '%M %d, %Y'), '') AS result, IFNULL(REPLACE(b.remarks, 'RECEIVE', 'RECEIVED'), '') AS result2
|
||||||
FROM occupancydocflowtxn b, occupancy o WHERE o.occupancyid = b.occupancyreceivingid AND o.controlNo = ? ORDER BY b.occupancydocflowtxnid DESC`, data)
|
FROM occupancydocflowtxn b, occupancy o WHERE o.occupancyid = b.occupancyreceivingid AND o.controlNo = ? ORDER BY b.occupancydocflowtxnid DESC`, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue