Chever John 9c39c8cbd7
init: iloom WMS monorepo with K8s deployment manifests
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>
2026-06-14 11:33:31 +08:00

56 lines
1.3 KiB
Go

package handler
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/muyuqingfeng/iloom/shared/pkg/response"
"github.com/muyuqingfeng/iloom/shared/pkg/websocket"
"github.com/muyuqingfeng/iloom/washing-service/internal/service"
)
type CompletionHandler struct {
svc *service.CompletionService
wsHub *websocket.Hub
}
func NewCompletionHandler(svc *service.CompletionService, wsHub *websocket.Hub) *CompletionHandler {
return &CompletionHandler{svc: svc, wsHub: wsHub}
}
func (h *CompletionHandler) Complete(c *gin.Context) {
companyID := c.GetHeader("X-Company-ID")
userID := c.GetHeader("X-User-ID")
if companyID == "" {
response.BadRequest(c, "missing company id")
return
}
washingPlanID := c.Param("id")
var req service.CompleteRequest
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, err.Error())
return
}
completion, err := h.svc.Complete(c.Request.Context(), washingPlanID, companyID, userID, req)
if err != nil {
log.Printf("complete washing plan error: %v", err)
response.InternalError(c, "failed to complete washing plan")
return
}
h.wsHub.BroadcastToCompany(companyID, &websocket.Event{
Table: "washing_plan_completions",
Action: "INSERT",
})
c.JSON(http.StatusCreated, response.Response{
Code: 0,
Message: "success",
Data: completion,
})
}