๐ฆ Plan Service
The Plan Service manages subscription plans and their associated features. Each plan contains pricing, duration, and an array of features with their own usage and durations. It supports full CRUD operations, as well as activation/deactivation.
๐งญ Overviewโ
This service helps manage:
- Subscription plans (e.g., monthly, annual)
- Feature-specific limits for each plan
- Admin-side plan lifecycle (create, update, activate, deactivate)
- Paginated listing and lookup by ID
๐งพ Plan Structureโ
Planโ
| Field | Type | Description |
|---|---|---|
id | uint32 (optional) | Unique plan ID |
name | string | Name of the plan |
description | string | Description of the plan |
price | double | Cost of the plan |
currency | string | Currency code (e.g., "USD", "INR") |
duration | int32 | Duration in days/months |
is_active | bool | Indicates if the plan is currently active |
feature_plans | repeated FeaturePlan | List of features with their limits and durations |
created_at | timestamp | Time of creation |
updated_at | timestamp | Time of last update |
created_by | uint32 | User ID of creator |
updated_by | uint32 | User ID of last updater |
FeaturePlanโ
| Field | Type | Description |
|---|---|---|
feature_id | uint32 | Unique ID of the feature |
duration | uint32 | Duration of the feature in the plan |
usage | uint32 | Number of allowed uses for this feature |
created_at | timestamp | When the feature plan was created |
updated_at | timestamp | Last update time |
created_by | uint32 | User ID of creator |
updated_by | uint32 | User ID of last updater |
๐งโ๐ป gRPC Service Methodsโ
PlanServiceโ
| Method | Request Type | Response Type | Description |
|---|---|---|---|
CreatePlan | CreatePlanRequest | PlanResponse | Create a new plan |
GetPlanByID | GetPlanByIDRequest | PlanResponse | Get details of a specific plan |
ListAllPlans | ListAllPlansRequest | PlanResponse | Get paginated list of all plans |
UpdatePlanByID | UpdatePlanByIDRequest | PlanResponse | Update a specific plan |
ActivatePlanByID | ActivatePlanByIDRequest | CheckResponse | Set a plan to active |
DeactivatePlanByID | DeactivatePlanByIDRequest | CheckResponse | Deactivate a plan |
๐ฆ Request & Response Messagesโ
โ CreatePlanRequestโ
{
"plan": {
"name": "Pro Plan",
"description": "For advanced users",
"price": 49.99,
"currency": "USD",
"duration": 30,
"is_active": true,
"feature_plans": [
{
"feature_id": 1,
"duration": 30,
"usage": 100
}
]
}
}
๐ฅ PlanResponseโ
{
"message": "Plan created successfully",
"code": "201",
"data": [...],
"total": 1
}
๐ CheckResponseโ
{
"message": "Plan activated successfully",
"code": "200",
"check": true
}
๐๏ธ Go Modelsโ
Planโ
type Plan struct {
ID uint32 `json:"id" gorm:"primaryKey"`
Name string `json:"name"`
Description string `json:"description"`
Price float64 `json:"price"`
Currency string `json:"currency"`
Duration uint32 `json:"duration"`
FeaturePlans []FeaturePlan `json:"feature_plans" gorm:"serializer:json"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy uint32 `gorm:"type:bigint" json:"created_by"`
UpdatedBy uint32 `gorm:"type:bigint" json:"updated_by"`
}
FeaturePlanโ
type FeaturePlan struct {
FeatureID uint32 `json:"feature_id" gorm:"primaryKey"`
Duration uint32 `json:"duration" gorm:"primaryKey"`
Usage uint32 `json:"usage"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy uint32 `gorm:"type:bigint" json:"created_by"`
UpdatedBy uint32 `gorm:"type:bigint" json:"updated_by"`
}