Go workspace (go.work) with 5 microservices + shared library: - gateway (8080), auth-service (8081), purchaser-service (8082) - textile-service (8083), washing-service (8084) - shared: proto definitions, common packages Infrastructure: docker-compose for local dev, K8s manifests for K3s cluster deployment (mysql/redis/etcd + traefik ingress). Frontend (iloom-flatten) added as git submodule. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/muyuqingfeng/iloom/shared/pkg/response"
|
|
"github.com/muyuqingfeng/iloom/textile-service/internal/service"
|
|
)
|
|
|
|
type PaymentHandler struct {
|
|
svc *service.PaymentService
|
|
}
|
|
|
|
func NewPaymentHandler(svc *service.PaymentService) *PaymentHandler {
|
|
return &PaymentHandler{svc: svc}
|
|
}
|
|
|
|
func (h *PaymentHandler) List(c *gin.Context) {
|
|
companyID := c.GetHeader("X-Company-ID")
|
|
if companyID == "" {
|
|
response.BadRequest(c, "missing X-Company-ID header")
|
|
return
|
|
}
|
|
|
|
payments, err := h.svc.List(c.Request.Context(), companyID)
|
|
if err != nil {
|
|
response.InternalError(c, err.Error())
|
|
return
|
|
}
|
|
|
|
response.OK(c, payments)
|
|
}
|
|
|
|
func (h *PaymentHandler) Confirm(c *gin.Context) {
|
|
companyID := c.GetHeader("X-Company-ID")
|
|
if companyID == "" {
|
|
response.BadRequest(c, "missing X-Company-ID header")
|
|
return
|
|
}
|
|
|
|
paymentID := c.Param("id")
|
|
|
|
if err := h.svc.Confirm(c.Request.Context(), paymentID, companyID); err != nil {
|
|
response.InternalError(c, err.Error())
|
|
return
|
|
}
|
|
|
|
response.OK(c, gin.H{"message": "payment confirmed"})
|
|
}
|