Files
hi-server/apis/admin/promo.api
T
2026-05-26 22:49:46 -07:00

156 lines
5.1 KiB
Plaintext

syntax = "v1"
info (
title: "Promo API"
desc: "API for ppanel"
author: "Tension"
email: "tension@ppanel.com"
version: "0.0.1"
)
import "../types.api"
type (
PromoRule {
Id int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Params interface{} `json:"params"`
Priority int64 `json:"priority"`
Enabled bool `json:"enabled"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
CreatePromoRuleRequest {
Name string `json:"name" validate:"required,max=100"`
Type string `json:"type" validate:"required,oneof=new_user inactive_user campaign"`
Params interface{} `json:"params" validate:"required"`
Priority int64 `json:"priority" validate:"gte=0"`
Enabled *bool `json:"enabled" validate:"required"`
StartTime int64 `json:"start_time" validate:"required"`
EndTime int64 `json:"end_time" validate:"required"`
}
UpdatePromoRuleRequest {
Id int64 `json:"id" validate:"required"`
Name string `json:"name" validate:"required,max=100"`
Type string `json:"type" validate:"required,oneof=new_user inactive_user campaign"`
Params interface{} `json:"params" validate:"required"`
Priority int64 `json:"priority" validate:"gte=0"`
Enabled *bool `json:"enabled" validate:"required"`
StartTime int64 `json:"start_time" validate:"required"`
EndTime int64 `json:"end_time" validate:"required"`
}
DeletePromoRuleRequest {
Id int64 `path:"id" validate:"required"`
}
GetPromoRuleDetailRequest {
Id int64 `path:"id" validate:"required"`
}
GetPromoRuleListRequest {
Page int64 `form:"page" validate:"required"`
Size int64 `form:"size" validate:"required"`
Type string `form:"type,omitempty" validate:"omitempty,oneof=new_user inactive_user campaign"`
Enabled *bool `form:"enabled,omitempty"`
Search string `form:"search,omitempty"`
}
GetPromoRuleListResponse {
Total int64 `json:"total"`
List []PromoRule `json:"list"`
}
PromoPriceInput {
SubscribeId int64 `json:"subscribe_id" validate:"required"`
PromoPrice int64 `json:"promo_price" validate:"required,gt=0"`
}
PromoPrice {
Id int64 `json:"id"`
SubscribeId int64 `json:"subscribe_id"`
PromoRuleId int64 `json:"promo_rule_id"`
PromoPrice int64 `json:"promo_price"`
UnitPrice int64 `json:"unit_price"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
CreatePromoPriceRequest {
PromoRuleId int64 `json:"promo_rule_id" validate:"required"`
Items []PromoPriceInput `json:"items" validate:"required,dive"`
}
GetPromoPriceListRequest {
Page int64 `form:"page" validate:"required"`
Size int64 `form:"size" validate:"required"`
PromoRuleId int64 `form:"promo_rule_id" validate:"required"`
}
GetPromoPriceListResponse {
Total int64 `json:"total"`
List []PromoPrice `json:"list"`
}
DeletePromoPriceRequest {
Id int64 `path:"id" validate:"required"`
}
PromoUsage {
Id int64 `json:"id"`
UserId int64 `json:"user_id"`
PromoRuleId int64 `json:"promo_rule_id"`
SubscribeId int64 `json:"subscribe_id"`
OrderNo string `json:"order_no"`
PromoPrice int64 `json:"promo_price"`
CreatedAt int64 `json:"created_at"`
}
GetPromoUsageListRequest {
Page int64 `form:"page" validate:"required"`
Size int64 `form:"size" validate:"required"`
PromoRuleId int64 `form:"rule_id,omitempty"`
UserId int64 `form:"user_id,omitempty"`
SubscribeId int64 `form:"subscribe_id,omitempty"`
OrderNo string `form:"order_no,omitempty"`
}
GetPromoUsageListResponse {
Total int64 `json:"total"`
List []PromoUsage `json:"list"`
}
)
@server (
prefix: v1/admin/promo
group: admin/promo
middleware: AuthMiddleware
)
service ppanel {
@doc "Create promo rule"
@handler CreatePromoRule
post /rule (CreatePromoRuleRequest) returns (PromoRule)
@doc "Get promo rule list"
@handler GetPromoRuleList
get /rule/list (GetPromoRuleListRequest) returns (GetPromoRuleListResponse)
@doc "Get promo rule detail"
@handler GetPromoRuleDetail
get /rule/:id (GetPromoRuleDetailRequest) returns (PromoRule)
@doc "Update promo rule"
@handler UpdatePromoRule
put /rule/:id (UpdatePromoRuleRequest) returns (PromoRule)
@doc "Delete promo rule"
@handler DeletePromoRule
delete /rule/:id (DeletePromoRuleRequest)
@doc "Batch set promo price"
@handler CreatePromoPrice
post /price (CreatePromoPriceRequest)
@doc "Get promo price list"
@handler GetPromoPriceList
get /price/list (GetPromoPriceListRequest) returns (GetPromoPriceListResponse)
@doc "Delete promo price"
@handler DeletePromoPrice
delete /price/:id (DeletePromoPriceRequest)
@doc "Get promo usage list"
@handler GetPromoUsageList
get /usage/list (GetPromoUsageListRequest) returns (GetPromoUsageListResponse)
}