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

68 lines
1.6 KiB
Go

package service
import (
"context"
"github.com/muyuqingfeng/iloom/textile-service/internal/model"
"github.com/muyuqingfeng/iloom/textile-service/internal/repository"
)
type PlanWithSteps struct {
repository.PlanSummary
Steps []model.ProcessStep `json:"steps,omitempty"`
InventoryRecords []model.InventoryRecord `json:"inventory_records,omitempty"`
}
type PlanService struct {
repo *repository.PlanRepo
stepRepo *repository.StepRepo
invRepo *repository.InventoryRepo
}
func NewPlanService(repo *repository.PlanRepo, stepRepo *repository.StepRepo, invRepo *repository.InventoryRepo) *PlanService {
return &PlanService{repo: repo, stepRepo: stepRepo, invRepo: invRepo}
}
func (s *PlanService) List(ctx context.Context, companyID string) ([]PlanWithSteps, error) {
plans, err := s.repo.ListByFactory(ctx, companyID)
if err != nil {
return nil, err
}
result := make([]PlanWithSteps, 0, len(plans))
for _, p := range plans {
steps, err := s.stepRepo.GetByPlan(ctx, p.ID)
if err != nil {
return nil, err
}
result = append(result, PlanWithSteps{
PlanSummary: p,
Steps: steps,
})
}
return result, nil
}
func (s *PlanService) GetByID(ctx context.Context, planID, companyID string) (*PlanWithSteps, error) {
plan, err := s.repo.GetByID(ctx, planID)
if err != nil {
return nil, err
}
steps, err := s.stepRepo.GetByPlan(ctx, planID)
if err != nil {
return nil, err
}
records, err := s.invRepo.ListByPlan(ctx, planID)
if err != nil {
return nil, err
}
return &PlanWithSteps{
PlanSummary: *plan,
Steps: steps,
InventoryRecords: records,
}, nil
}