feat: add USER_ID_MIDDLEWARE constant and update AuthMiddleware to use it
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
"wm-backend/configs/constants"
|
||||
"wm-backend/global"
|
||||
"wm-backend/internal/models"
|
||||
"wm-backend/internal/models/requests"
|
||||
@@ -29,6 +30,7 @@ import (
|
||||
// @Failure 500 {object} response.ErrorResponse
|
||||
// @Router /v1/invoices [post]
|
||||
func InvoiceCreate(c *gin.Context) error {
|
||||
userID, _ := c.Get(constants.USER_ID_MIDDLEWARE)
|
||||
requestBody := requests.CreateInvoiceRequest{}
|
||||
if helper.IsShouldBindJSON(c, &requestBody) {
|
||||
return nil
|
||||
@@ -39,7 +41,7 @@ func InvoiceCreate(c *gin.Context) error {
|
||||
InvoiceConfigID: requestBody.InvoiceConfigID,
|
||||
TotalItems: requestBody.TotalItems,
|
||||
Note: requestBody.Note,
|
||||
CreatedBy: requestBody.CreatedBy,
|
||||
CreatedBy: userID.(string),
|
||||
ApprovedBy: requestBody.ApprovedBy,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user