chore(ci): 更新Docker仓库地址至git.oceanpay.cc- 修改Docker登录地址为git.oceanpay.cc
- 更新镜像构建和推送目标地址 - 调整部署阶段的Docker仓库配置 - 移除旧仓库相关环境变量引用 - 更新docker logout命令目标地址- 保持构建参数和标签策略不变
This commit is contained in:
20
.drone.yml
20
.drone.yml
@@ -18,27 +18,23 @@ steps:
|
|||||||
from_secret: docker_login
|
from_secret: docker_login
|
||||||
DOCKER_TOKEN:
|
DOCKER_TOKEN:
|
||||||
from_secret: docker_token
|
from_secret: docker_token
|
||||||
DOCKER_PASSWORD:
|
|
||||||
from_secret: docker_password
|
|
||||||
commands:
|
commands:
|
||||||
- docker login git.kkknametrans.buzz -u $DOCKER_LOGIN -p $DOCKER_TOKEN
|
- docker login git.oceanpay.cc -u $DOCKER_LOGIN -p $DOCKER_TOKEN
|
||||||
- docker build -t git.kkknametrans.buzz/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER} -f manifest/docker/Dockerfile . --build-arg USE_PROXY=0
|
- docker build -t git.oceanpay.cc/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER} -f manifest/docker/Dockerfile . --build-arg USE_PROXY=0
|
||||||
- docker tag git.kkknametrans.buzz/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER} git.kkknametrans.buzz/danial/kami_backend_${DRONE_BRANCH}:latest
|
- docker tag git.oceanpay.cc/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER} git.oceanpay.cc/danial/kami_backend_${DRONE_BRANCH}:latest
|
||||||
- docker push git.kkknametrans.buzz/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER}
|
- docker push git.oceanpay.cc/danial/kami_backend_${DRONE_BRANCH}:${DRONE_BUILD_NUMBER}
|
||||||
- docker push git.kkknametrans.buzz/danial/kami_backend_${DRONE_BRANCH}:latest
|
- docker push git.oceanpay.cc/danial/kami_backend_${DRONE_BRANCH}:latest
|
||||||
- docker logout git.kkknametrans.buzz
|
- docker logout git.oceanpay.cc
|
||||||
- name: deploy to docker compose
|
- name: deploy to docker compose
|
||||||
environment:
|
environment:
|
||||||
DOCKER_LOGIN:
|
DOCKER_LOGIN:
|
||||||
from_secret: docker_login
|
from_secret: docker_login
|
||||||
DOCKER_TOKEN:
|
DOCKER_TOKEN:
|
||||||
from_secret: docker_token
|
from_secret: docker_token
|
||||||
DOCKER_PASSWORD:
|
|
||||||
from_secret: docker_password
|
|
||||||
commands:
|
commands:
|
||||||
- docker login git.kkknametrans.buzz -u $DOCKER_LOGIN -p $DOCKER_TOKEN
|
- docker login git.oceanpay.cc -u $DOCKER_LOGIN -p $DOCKER_TOKEN
|
||||||
- BRANCH=${DRONE_BRANCH} VERSION=${DRONE_BUILD_NUMBER} docker compose -f /data/kami/docker-compose.yaml --profile kami_backend up -d
|
- BRANCH=${DRONE_BRANCH} VERSION=${DRONE_BUILD_NUMBER} docker compose -f /data/kami/docker-compose.yaml --profile kami_backend up -d
|
||||||
- docker logout git.kkknametrans.buzz
|
- docker logout git.oceanpay.cc
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
|
|||||||
144
CLAUDE.md
144
CLAUDE.md
@@ -4,86 +4,120 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
## Development Commands
|
## Development Commands
|
||||||
|
|
||||||
This project uses GoFrame (GF) framework and includes a custom Makefile for common operations:
|
This project uses GoFrame (GF) framework and includes a custom Makefile that delegates to `hack/hack.mk`:
|
||||||
|
|
||||||
### Building and Running
|
### Building and Running
|
||||||
|
|
||||||
- `make build` - Build binary using GoFrame CLI
|
- `make build` - Build binary using GoFrame CLI (`gf build -ew`)
|
||||||
- `go run main.go` - Run the application directly
|
- `go run main.go` - Run the application directly
|
||||||
- `make up` - Update GoFrame and CLI to latest version
|
- `make up` - Update GoFrame and CLI to latest version (`gf up -a`)
|
||||||
|
|
||||||
### Code Generation
|
### Code Generation (GoFrame CLI)
|
||||||
|
|
||||||
- `make ctrl` - Generate controllers from API definitions
|
- `make ctrl` - Generate controllers from API definitions (`gf gen ctrl`)
|
||||||
- `make dao` - Generate DAO/DO/Entity files from database schema
|
- `make dao` - Generate DAO/DO/Entity files from database schema (`gf gen dao`)
|
||||||
- `make service` - Generate service interfaces
|
- `make service` - Generate service interfaces (`gf gen service`)
|
||||||
- `make enums` - Generate enum files from Go code
|
- `make enums` - Generate enum files from Go code (`gf gen enums`)
|
||||||
- `make pb` - Generate protobuf files
|
- `make pb` - Generate protobuf files (`gf gen pb`)
|
||||||
- `make pbentity` - Generate protobuf files for database tables
|
- `make pbentity` - Generate protobuf files for database tables (`gf gen pbentity`)
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
- `go test ./...` - Run all tests
|
- `go test ./...` - Run all tests
|
||||||
- `go test -v ./internal/logic/...` - Run tests for specific packages
|
- `go test -v ./internal/logic/...` - Run tests for specific packages
|
||||||
- `go test ./internal/logic/card_apple_account -v` - Run tests for specific module
|
- `go test ./internal/logic/card_apple_account -v` - Run tests for specific module
|
||||||
|
- `go test -run TestName` - Run specific test
|
||||||
|
|
||||||
### Docker
|
### Docker & Deployment
|
||||||
|
|
||||||
- `make image` - Build Docker image with auto-generated tag
|
- `make image` - Build Docker image with auto-generated git-based tag
|
||||||
- `make image.push` - Build and push Docker image
|
- `make image.push` - Build and push Docker image
|
||||||
- `make deploy` - Deploy to kubernetes environment
|
- `make deploy` - Deploy to kubernetes environment using kustomize
|
||||||
|
|
||||||
## Architecture Overview
|
## Architecture Overview
|
||||||
|
|
||||||
This is a Go-based backend service using the GoFrame framework with the following key components:
|
This is a Go-based backend service for a card redemption platform (卡密兑换平台) using the GoFrame framework:
|
||||||
|
|
||||||
### Core Structure
|
### Application Entry & Flow
|
||||||
|
|
||||||
- **main.go**: Entry point with OpenTelemetry tracing initialization
|
- **main.go**: Entry point with OpenTelemetry initialization, sets service name from `serverName` env var, starts
|
||||||
- **internal/cmd/**: Command definitions and HTTP server setup
|
`cmd.Main`
|
||||||
- **internal/controller/**: HTTP handlers for different business domains
|
- **internal/cmd/cmd.go**: HTTP server setup, binds controllers under `/api` with middleware stack, registers monitoring
|
||||||
- **internal/logic/**: Business logic implementation
|
and cron tasks
|
||||||
- **utility/**: Shared utilities including monitoring and tracing
|
|
||||||
|
|
||||||
### Key Business Domains
|
### Database Architecture (Dual Database Setup)
|
||||||
|
|
||||||
- **Card Management**: Multi-platform card support including Apple, JD, T-Mall, Walmart, C-Trip cards with account
|
The system uses two MySQL databases configured in `manifest/config/config.yaml`:
|
||||||
management and configuration
|
|
||||||
- **Order Processing**: Complete order lifecycle with callback handling, status tracking, and order summary generation
|
|
||||||
- **User Management**: Authentication via JWT, TOTP support, role-based access control with Casbin
|
|
||||||
- **Payment Processing**: Payment method management, deduction tracking, and payment statistics
|
|
||||||
- **Merchant Management**: Merchant configurations, deployment management, and steal rule processing
|
|
||||||
- **Channel & Road Management**: Business routing logic with road pools and entrance management
|
|
||||||
- **Restriction Management**: IP and device ID tracking for access control
|
|
||||||
- **JDCookie Management**: JD cookie rotation, order processing, and account management
|
|
||||||
|
|
||||||
### Technology Stack
|
- **default** (`kami_v2`): Primary database
|
||||||
|
- **v1** (`kami`): Legacy database with `v1` prefix for generated models
|
||||||
|
|
||||||
- **Framework**: GoFrame v2 with code generation capabilities
|
Code generation configuration in `hack/config.yaml` defines separate DAO generation for each database with appropriate
|
||||||
- **Database**: MySQL with GoFrame ORM (DAO/DO/Entity pattern)
|
prefixes.
|
||||||
- **Cache**: Redis for caching and session management
|
|
||||||
- **Tracing**: OpenTelemetry with OTLP exporter for observability
|
|
||||||
- **Monitoring**: Built-in metrics and health checks with Prometheus integration
|
|
||||||
- **Task Scheduling**: Cron jobs for periodic tasks with graceful shutdown
|
|
||||||
- **Authentication**: JWT tokens with TOTP support
|
|
||||||
- **Authorization**: Casbin for role-based access control
|
|
||||||
- **External Integrations**: T-Mall SDK, JD APIs, Walmart APIs, C-Trip APIs
|
|
||||||
- **Rate Limiting**: Built-in rate limiting with Redis backend
|
|
||||||
|
|
||||||
### Configuration
|
### Business Domain Structure
|
||||||
|
|
||||||
- Uses GoFrame's configuration system
|
**Card Platform Management**:
|
||||||
- Environment variables supported (e.g., `serverName`)
|
|
||||||
- Docker deployment ready with Kubernetes manifests
|
|
||||||
|
|
||||||
### Development Notes
|
- Apple cards (`card_apple_*`): Account management, order processing, steal rules
|
||||||
|
- T-Mall cards (`card_t_mall_*`): Account management, order processing, shop management
|
||||||
|
- JD cards (`card_jd_*`, `card_original_jd_*`): JD card variants
|
||||||
|
- Walmart cards (`card_walmart_*`): Walmart card management
|
||||||
|
- C-Trip cards (`card_c_trip_*`): Travel card management
|
||||||
|
- Redeem cards (`card_redeem_*`): Generic redemption system
|
||||||
|
|
||||||
- The project uses GoFrame's code generation capabilities heavily - always run `make dao` after database schema changes
|
**Core Business Systems**:
|
||||||
- Controllers are auto-generated from API definitions in the `api/` directory
|
|
||||||
- Database access follows GoFrame's DAO/DO/Entity pattern with generated models
|
- **Order Processing**: Complete lifecycle with callbacks, status tracking, summaries
|
||||||
- OpenTelemetry tracing is configured for HTTP and gRPC exporters with custom headers
|
- **Merchant Management**: Configurations, deployments, hidden settings, steal rules
|
||||||
- Graceful shutdown handling for cron jobs and connection pools is implemented
|
- **Channel & Road Management**: Business routing with road pools and entrance management
|
||||||
- The service includes extensive external API integrations for various card platforms
|
- **User Management**: Authentication (JWT + TOTP), roles, Casbin authorization
|
||||||
- Rate limiting and restriction management are built-in for security
|
- **Payment Processing**: Payment methods, deductions, statistics
|
||||||
- All external integrations are located in `utility/integration/` with proper abstraction
|
- **Restriction Management**: IP/device tracking for access control
|
||||||
- Business logic is separated by domain in `internal/logic/` with clear boundaries
|
- **JDCookie Management**: Cookie rotation, order processing, account management
|
||||||
|
|
||||||
|
### Technology Stack Details
|
||||||
|
|
||||||
|
- **Framework**: GoFrame v2 with heavy code generation usage
|
||||||
|
- **Database**: MySQL with GoFrame ORM (DAO/DO/Entity pattern), dual database support
|
||||||
|
- **Cache**: Redis for caching, sessions, rate limiting
|
||||||
|
- **Tracing**: OpenTelemetry with custom headers (`x-service-token`)
|
||||||
|
- **Monitoring**: Built-in metrics, health checks, monitor tasks
|
||||||
|
- **Task Scheduling**: Cron jobs with graceful shutdown
|
||||||
|
- **Authentication**: JWT with TOTP support, multi-login capability
|
||||||
|
- **Authorization**: Casbin RBAC with model/policy files
|
||||||
|
- **Rate Limiting**: Redis-based with configurable rules
|
||||||
|
|
||||||
|
### External Integrations
|
||||||
|
|
||||||
|
All external platform integrations are abstracted in `utility/integration/`:
|
||||||
|
|
||||||
|
- **T-Mall**: OAuth gateway integration with eco.taobao.com
|
||||||
|
- **JD**: JD API integration with cookie management
|
||||||
|
- **Walmart**: Walmart API integration
|
||||||
|
- **C-Trip**: Travel platform API integration
|
||||||
|
- **Agiso**: App authentication service
|
||||||
|
|
||||||
|
### Configuration System
|
||||||
|
|
||||||
|
- **Primary Config**: `manifest/config/config.yaml`
|
||||||
|
- **Code Gen Config**: `hack/config.yaml` (database connections, generation paths)
|
||||||
|
- **Environment Support**: `serverName` variable for service identification
|
||||||
|
- **Secret Management**: Encryption keys for frontend/backend, token configuration
|
||||||
|
|
||||||
|
### Critical Development Patterns
|
||||||
|
|
||||||
|
- **Code Generation Workflow**: Database changes → `make dao` → `make service` → `make ctrl`
|
||||||
|
- **API-First**: Controllers generated from `api/` definitions
|
||||||
|
- **Domain Separation**: Each business domain has its own logic folder with clear boundaries
|
||||||
|
- **Graceful Shutdown**: Implemented for cron jobs and connection pools
|
||||||
|
- **Security**: Built-in rate limiting, IP/device restrictions, authentication middleware
|
||||||
|
|
||||||
|
### Testing Strategy
|
||||||
|
|
||||||
|
Focused test coverage in critical business logic areas:
|
||||||
|
|
||||||
|
- Apple account management (`internal/logic/card_apple_account/`)
|
||||||
|
- T-Mall order processing (`internal/logic/card_t_mall_order/`)
|
||||||
|
- Rate limiting (`internal/logic/limiter/`)
|
||||||
|
- Business logic validation with comprehensive test coverage
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.24-alpine AS builder
|
FROM golang:1.25-alpine AS builder
|
||||||
|
|
||||||
ARG USE_PROXY
|
ARG USE_PROXY
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|||||||
Reference in New Issue
Block a user