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>
42 lines
917 B
Go
42 lines
917 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/muyuqingfeng/iloom/auth-service/internal/service"
|
|
"github.com/muyuqingfeng/iloom/shared/pkg/response"
|
|
)
|
|
|
|
type CompanyHandler struct {
|
|
svc *service.CompanyService
|
|
}
|
|
|
|
func NewCompanyHandler(svc *service.CompanyService) *CompanyHandler {
|
|
return &CompanyHandler{svc: svc}
|
|
}
|
|
|
|
func (h *CompanyHandler) GetCompany(c *gin.Context) {
|
|
id := c.Param("id")
|
|
company, err := h.svc.GetByID(c.Request.Context(), id)
|
|
if err != nil {
|
|
response.NotFound(c, err.Error())
|
|
return
|
|
}
|
|
response.OK(c, company)
|
|
}
|
|
|
|
func (h *CompanyHandler) ListRelationships(c *gin.Context) {
|
|
companyID := c.GetHeader("X-Company-ID")
|
|
if companyID == "" {
|
|
response.BadRequest(c, "company id not found")
|
|
return
|
|
}
|
|
|
|
rels, err := h.svc.ListRelationships(c.Request.Context(), companyID)
|
|
if err != nil {
|
|
response.InternalError(c, err.Error())
|
|
return
|
|
}
|
|
|
|
response.OK(c, rels)
|
|
}
|