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>
35 lines
749 B
Go
35 lines
749 B
Go
package handler
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/muyuqingfeng/iloom/purchaser-service/internal/service"
|
|
"github.com/muyuqingfeng/iloom/shared/pkg/response"
|
|
)
|
|
|
|
type FactoryHandler struct {
|
|
svc *service.FactoryService
|
|
}
|
|
|
|
func NewFactoryHandler(svc *service.FactoryService) *FactoryHandler {
|
|
return &FactoryHandler{svc: svc}
|
|
}
|
|
|
|
func (h *FactoryHandler) List(c *gin.Context) {
|
|
companyID := c.GetHeader("X-Company-ID")
|
|
if companyID == "" {
|
|
response.BadRequest(c, "missing company id")
|
|
return
|
|
}
|
|
|
|
factories, err := h.svc.List(c.Request.Context(), companyID)
|
|
if err != nil {
|
|
log.Printf("list factories error: %v", err)
|
|
response.InternalError(c, "failed to list factories")
|
|
return
|
|
}
|
|
|
|
response.OK(c, factories)
|
|
}
|