Reapply "feat(loyalty): EnakPoint & EnakCoin" (#32)

This reverts commit 4e24f9bbb0.
This commit is contained in:
efrilm
2026-09-30 15:31:11 +07:00
parent 5e28b05770
commit c6062c4bb9
195 changed files with 20058 additions and 2177 deletions
@@ -0,0 +1,45 @@
package handler
import (
"github.com/gin-gonic/gin"
"apskel-pos-be/internal/constants"
"apskel-pos-be/internal/contract"
"apskel-pos-be/internal/service"
"apskel-pos-be/internal/util"
)
// CustomerDeviceHandler serves /customer/devices, where the customer app registers
// the FCM token of each device it runs on.
type CustomerDeviceHandler struct {
devices service.CustomerDeviceService
}
func NewCustomerDeviceHandler(devices service.CustomerDeviceService) *CustomerDeviceHandler {
return &CustomerDeviceHandler{devices: devices}
}
// Register is PUT /customer/devices.
func (h *CustomerDeviceHandler) Register(c *gin.Context) {
customerID, ok := customerIDFromGin(c, "CustomerDeviceHandler::Register")
if !ok {
return
}
var req contract.RegisterCustomerDeviceRequest
if err := c.ShouldBindJSON(&req); err != nil {
util.HandleResponse(c.Writer, c.Request, contract.BuildErrorResponse([]*contract.ResponseError{
contract.NewResponseError(constants.MissingFieldErrorCode, constants.RequestEntity, "device_id and fcm_token are required"),
}), "CustomerDeviceHandler::Register")
return
}
util.HandleResponse(c.Writer, c.Request, h.devices.Register(c.Request.Context(), customerID, &req), "CustomerDeviceHandler::Register")
}
// Unregister is DELETE /customer/devices/:device_id, for logout.
func (h *CustomerDeviceHandler) Unregister(c *gin.Context) {
customerID, ok := customerIDFromGin(c, "CustomerDeviceHandler::Unregister")
if !ok {
return
}
util.HandleResponse(c.Writer, c.Request, h.devices.Unregister(c.Request.Context(), customerID, c.Param("device_id")), "CustomerDeviceHandler::Unregister")
}