Browse Source

Menambahkan login JWT dan API CRUD

widyarhn-dev
widyarhn 1 year ago
parent
commit
98c42f1dce
  1. 19
      controllers/usersController.go
  2. BIN
      go-crud.exe
  3. BIN
      go-crud.exe~

19
controllers/usersController.go

@ -220,7 +220,11 @@ func GetLoginRecords(c *gin.Context) {
if result.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Failed to fetch login records",
"code": http.StatusInternalServerError,
"data": nil,
"message": "Failed to fetch login records",
"status": false,
"totalRecord": 0,
})
return
}
@ -235,9 +239,18 @@ func GetLoginRecords(c *gin.Context) {
// Create JSON response
var response struct {
Records []models.LoginRecord `json:"records"`
Code int `json:"code"`
Data []models.LoginRecord `json:"data"`
Message string `json:"message"`
Status bool `json:"status"`
TotalRecord int `json:"totalRecord"`
}
response.Records = loginRecords
response.Code = http.StatusOK
response.Data = loginRecords
response.Message = "OK"
response.Status = true
response.TotalRecord = len(loginRecords)
c.JSON(http.StatusOK, response)
}

BIN
go-crud.exe

Binary file not shown.

BIN
go-crud.exe~

Binary file not shown.
Loading…
Cancel
Save