24 Commits

Author SHA1 Message Date
kae_mihara
e3f6fa236d
feat:improve product yarn ratio workflow (#5)
* feat: support product yarn batches

* feat: improve product yarn ratio workflow

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-05 08:06:28 +09:00
Chenwei Jiang
bb212aff36 Merge branch 'feat/production-plan-collaboration' into 'main'
feat(production): add production management service with plan collaboration workflow

See merge request kihaneseifu/muyu-apiserver!1
2026-07-04 02:29:54 +00:00
Chenwei Jiang
e9cdad0063 feat(production): add production management service with plan collaboration workflow 2026-07-04 02:29:54 +00:00
Chever John
e7e5bc2386 chore: remove node_modules from tracking and add to .gitignore
node_modules (14 MB, 240 files) accounted for 91.6% of tracked file
size. Dependencies are reproducible via `cd deploy/tools && npm ci`
using the committed package.json and package-lock.json.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-23 09:40:05 +08:00
kae
4c427672a3 fix: inject path param into context for all purchase handlers
Nine gateway handlers for purchase orders, receipts, and suppliers were
passing r.Context() directly to their logic constructors without first
extracting the URL path segment via pathvar.Vars(r)["id"]. This caused
ctxdata.GetPathId to always return an empty string, making GET/PUT/DELETE
operations on individual resources silently return "not found" even when
the record existed in the database.
2026-06-23 00:05:42 +08:00
kae
4733677334 fix: set tenant_id on product insert and regenerate purchase proto
Products were inserted with empty tenant_id because ExtractTenantId was
called after the Insert; moved extraction before the struct so rows are
stored with the correct tenant and appear in list queries.

Regenerated purchase.pb.go and purchase_grpc.pb.go from purchase.proto
using protoc-gen-go v1.36.11; the previous hand-written stubs lacked the
proto.Message interface, causing all purchase gRPC calls to fail with a
marshal error.
2026-06-23 00:05:42 +08:00
kae
4759295ce1 fix: wrap GROUP_CONCAT with COALESCE to prevent NULL scan on products with no pans
FindProductSummary and FindColorDetail aggregate pan.position via GROUP_CONCAT
with a LEFT JOIN. When a product has no pans the join produces all-NULL rows,
causing GROUP_CONCAT to return NULL, which cannot be scanned into a Go string —
making the entire summary query fail silently and the frontend show an empty table.

Fix: wrap both GROUP_CONCAT(pan.position) calls with COALESCE(..., '').

Also removes CostPrice from the generated InvProduct model (field dropped from schema).

Adds integration tests TestFindProductSummaryNoPans and TestFindColorDetailNoPans
to guard against this class of NULL-scan regression.
2026-06-23 00:05:42 +08:00
Chever John
541dd5e4c8 fix: write envsubst output to /tmp to avoid read-only ConfigMap mount
The entrypoint.sh was writing the rendered config back to the same
directory as the source, which fails when the config is mounted from
a Kubernetes ConfigMap (read-only filesystem). Write to /tmp instead.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-18 09:29:18 +08:00
Chever John
a5b1b406ea security: remove hardcoded credentials and add envsubst for go-zero configs
- Clear default passwords in all service configs and local dev YAMLs
- Add entrypoint.sh with envsubst to resolve ${ENV} vars in go-zero YAML
- Update Dockerfiles to install gettext and use entrypoint
- Update docker-compose to pass secrets via environment and require via ${VAR:?...}
- Add .gitignore rules for .env files, add .env.example template

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 23:16:28 +08:00
Chever John
ec8ae6a73b fix(ci): use host networking and custom DNS for DinD builds
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 10:28:18 +08:00
Chever John
7a8df1f0d4 fix: use Aliyun Alpine mirror in Dockerfiles
Alpine CDN unreachable from DinD containers. Switch to
mirrors.aliyun.com for both builder and runtime stages.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 10:25:02 +08:00
Chever John
1cc62101d0 fix(ci): stagger builds in stages and add retry for Harbor load
Split 3 builds into 2 stages (2+1) and add retry: 2.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 10:20:10 +08:00
Chever John
4547ce7fed fix: use Harbor base images and Chinese Go proxy for CI builds
Docker Hub and proxy.golang.org unreachable from k3s cluster (GFW).
Switch Dockerfiles to Harbor base images and goproxy.cn.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 10:17:39 +08:00
Chever John
88f3aec0a7 fix(ci): add Docker daemon wait and TLS env vars for DinD
Set DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH for k8s runner
DinD sidecar communication. Add 'until docker info' wait loop to
ensure daemon is ready before build starts.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 10:10:59 +08:00
Chever John
0bb44305a1 feat: add GitLab CI pipeline for muyu service Docker build
Build 3 muyu services (gateway, system-rpc, inventory-rpc)
as Docker images and push to Harbor registry.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 10:02:01 +08:00
Chever John
7acdc6eecf chore: remove obsolete gateway.yaml
This local-dev config (pointing to 127.0.0.1) has been superseded
by gateway-api.yaml. Removing to align origin/main with upstream/main.
2026-06-15 09:36:13 +08:00
Chever John
a25acdc5e4 chore: sync codebase with upstream
Pull latest changes from upstream/main (GitHub) including:
- Purchase RPC service (proto, server, logic, models)
- Gateway route updates for purchase endpoints
- SQL migration and config updates

Excludes deploy/bin/ pre-compiled arm64 binaries (builds use
multi-stage Dockerfiles targeting amd64).
2026-06-15 09:20:56 +08:00
Chever John
379fb28d92 chore: sync codebase with upstream
Align origin/main with upstream/main (GitHub). The two branches
diverged due to pre-rebase vs post-rebase merge commits for the
k8s-amd64-dockerfiles feature.

Includes: multi-stage Go compilation Dockerfiles, pan-bolt
inventory features, CRM relations, Excel import tooling,
proto/gRPC updates, migration scripts, and tools/ directory.

Excludes deploy/bin/ pre-compiled binaries (arm64, not needed
for amd64 K3s cluster; builds use multi-stage Dockerfiles now).
2026-06-14 15:24:02 +08:00
Chenwei Jiang
c5ab2279c0 Merge pull request 'build(deploy): replace pre-compiled arm64 binaries with multi-stage Go compilation for amd64' (#2) from feat/k8s-amd64-dockerfiles into main
Reviewed-on: https://forgejo.cheverjohn.me/Business/muyuqingfeng-apiserver/pulls/2
2026-06-14 15:12:16 +08:00
Chever John
4144628cb6 build(deploy): replace pre-compiled arm64 binaries with multi-stage Go compilation for amd64
WHY: existing Dockerfiles copied pre-compiled arm64 binaries which cannot
run on the amd64 K3s cluster (exec format error). Also fixed port conflicts
when running muyu alongside iloom in docker-compose.

HOW:
- rewrite 3 Dockerfiles (system/inventory/gateway) to multi-stage builds
  using golang:1.24-alpine with CGO_ENABLED=0 GOARCH=amd64
- parameterize host ports in docker-compose to avoid conflicts (3306->13306,
  6379->16379, 8080->18080)
- fix inv_product unique key from product_name-only to composite
  (product_name, spec, color) to allow same-name products with different specs
- add X-Token to Authorization header middleware in gateway for
  iloom frontend compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-14 12:38:46 +08:00
Chenwei Jiang
9e80cdce0b Merge pull request 'feat: 多租户 CRM + PostgreSQL 图关系 + 租户隔离 + Casbin RBAC' (#1) from feat/multitenant-crm into main
Reviewed-on: https://forgejo.cheverjohn.me/Business/muyuqingfeng-apiserver/pulls/1
2026-03-30 21:01:30 +08:00
Chever John
1f4ccfb54e feat: multi-tenant CRM with PostgreSQL graph, tenant isolation, and Casbin RBAC
- JWT claims extended with tenantId; login enforces strict tenant verification
- AuthorityMiddleware: tenant scope check + Casbin path permission + anti-spoofing
- CRM relation API (upstream/downstream one-hop, create/update/history, full graph)
- CrmRepo backed by PostgreSQL with $N placeholders
- gRPC tenant propagation via UnaryClientInterceptor (x-tenant-id metadata)
- All legacy tables (12) gain tenant_id column with indexes
- All model queries inject WHERE tenant_id filter
- Casbin gorm-adapter downgraded to v3.28.0 for v2 compatibility
- GraphSyncWorker (Kafka -> Neo4j) with idempotent MERGE
- Full graph API restricted to admin role only
- Database migrations for MySQL (CRM tables + tenant columns) and PostgreSQL (CRM init)
- Docker Compose: added postgres service to main stack, graph stack with Kafka/Debezium/Neo4j

Made-with: Cursor
2026-03-30 02:53:55 +00:00
Chever John
3ddc851340 chore: update .gitignore and purge MySQL data from tracking
- Replace hand-written gitignore with Go/macOS/VSCode template
- Add data/ to ignore list (MySQL binaries, redo logs, PEM certs)
- Remove data/ from index to stop tracking sensitive files
  (ca-key.pem, client-key.pem, ibdata, binlogs, etc.)

Made-with: Cursor
2026-02-28 15:41:10 +08:00
Chever John
71a2d912e2 feat: initial commit for muyu-apiserver
Go service with gateway, RPC, model layers and k8s deploy configs.

Made-with: Cursor
2026-02-28 15:29:16 +08:00