feat: migrate all remaining modules from rainyun-go-sdk

- domain(24), product(8), rbm(10), rca(21), rgs(38), ros(19),
  ssl(5), user(10), workorder(11), public remaining 5
- split nested response structs into reusable named types
- rgs reuses rcs request/response types
- fix source bugs: malformed paths, resp vs &resp, missing bodies
- register all 11 services in sdk.New
This commit is contained in:
2026-08-05 23:09:53 +08:00
parent b8490ef422
commit 51b7e2f319
56 changed files with 4267 additions and 2 deletions
+11
View File
@@ -0,0 +1,11 @@
package user
import "github.com/XingfenD/rainyun_api_go_sdk/apis"
type UserService struct {
client *apis.RyClient
}
func NewUserService(c *apis.RyClient) *UserService {
return &UserService{client: c}
}
+40
View File
@@ -0,0 +1,40 @@
package user
import (
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
// Request2FARequest 请求二次验证
type Request2FARequest struct {
Type string `json:"type"`
}
// 请求二次验证
//
// verificationMethod: 验证方式(sms/totp/email)
func (s *UserService) Request2FA(verificationMethod string) (*common.BasicOperationResponse, error) {
path := "/user/mfa/request"
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, Request2FARequest{Type: verificationMethod}, &resp)
return &resp, err
}
// Verify2FAResultRequest 验证二次验证结果
type Verify2FAResultRequest struct {
AuthCode int `json:"auth_code"`
}
// 验证二次验证结果
//
// authCode: 验证码
func (s *UserService) Verify2FAResult(authCode int) (*common.BasicOperationResponse, error) {
path := "/user/mfa/verify"
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, Verify2FAResultRequest{AuthCode: authCode}, &resp)
return &resp, err
}
+186
View File
@@ -0,0 +1,186 @@
package user
import (
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
type GetUserRewardProductsResponse struct {
Code int `json:"code"`
Data UserRewardProductsData `json:"data"`
}
// UserRewardProductsData 用户可用积分兑换的产品
type UserRewardProductsData struct {
Rcs []any `json:"rcs"`
Rvh []any `json:"rvh"`
Rgs []any `json:"rgs"`
Ros []any `json:"ros"`
Rbm []any `json:"rbm"`
}
// 获取可兑换积分产品列表.
func (s *UserService) GetUserRewardProducts() (*GetUserRewardProductsResponse, error) {
path := "/user/reward/products"
var resp GetUserRewardProductsResponse
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
return &resp, err
}
// 发布优惠券给下级用户
type PublishCouponsToLowerLevelUsersRequest struct {
BaseLimit int `json:"base_limit"` // 满减条件(满多少才能用)
Color string `json:"color"` // 颜色: waring: 黄,danger: 红,success: 绿...
Count int `json:"count"` // 发放数量
ExpDate int `json:"exp_date"` // 过期时间(timestamp)
FriendlyName string `json:"friendly_name"` // 优惠券标题
Type string `json:"type"` // 类型: discount:折扣, normal: 直减
UID int `json:"uid"` // 要发放到用户ID(如:114514),为空时则返回兑换码
UsableDuration string `json:"usable_duration"` // unknown
UsableProduct string `json:"usable_product"` // 可用产品(默认全部),","分隔: renew,create,upgrade
UsableScenes string `json:"usable_scenes"` // 适用操作(默认全部),","分隔: rvh,rcs,rgs,ros,rbm
Value int `json:"value"` // 直减(元)/折扣(折), 折扣时:1~9:一~九折;11~99:一一~九九折
}
// 发布优惠券给下级用户
func (s *UserService) PublishCouponsToLowerLevelUsers(req *PublishCouponsToLowerLevelUsersRequest) (*common.BasicOperationResponse, error) {
path := "/user/vip/coupon"
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}
// 发送优惠券到积分商城
type PostCouponsToPointsMallRequest struct {
AvailableDays int `json:"available_days"` // 可用天数
BaseLimit int `json:"base_limit"` // 满减条件(满多少才能用)
BuyLimit int `json:"buy_limit"` // 领取次数限制
Color string `json:"color"` // 颜色: waring: 黄, danger: 红, success: 绿, info: 蓝
Count int `json:"count"` // 发放数量
EndDate int `json:"end_date"` // 截止日期
FirstSend bool `json:"first_send"` // 绑定微信后立即自动领取(设置后不可手动领取并且不会显示)
FriendlyName string `json:"friendly_name"` // 优惠券名称
Name string `json:"name"` // 标识名称
Order int `json:"order"` // 排序,越大越靠前
Points int `json:"points"` // 领取积分
Type string `json:"type"` // 类型: discount:折扣, normal: 直减
UsableDuration string `json:"usable_duration"` // unknown
UsableProduct string `json:"usable_product"` // 可用产品(默认全部),","分隔: renew,create,upgrade
UsableScenes string `json:"usable_scenes"` // 适用操作(默认全部),","分隔: rvh,rcs,rgs,ros,rbm
Value int `json:"value"` // 直减(元)/折扣(折), 折扣时:1~9:一~九折;11~99:一一~九九折
}
// 发布优惠券到积分商城(供下级领取)
func (s *UserService) PostCouponsToPointsMall(req *PostCouponsToPointsMallRequest) (*common.BasicOperationResponse, error) {
path := "/user/vip/coupon"
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}
type GetPointsMallItemsResponse struct {
Code int `json:"code"`
Data []PointsMallItem `json:"data"`
}
// PointsMallItem 积分商城物品
type PointsMallItem struct {
ID int `json:"id"`
Name string `json:"name"`
Points int `json:"points"`
Type string `json:"type"`
AvailableStock int `json:"available_stock"`
FriendlyName string `json:"friendly_name"`
ItemData PointsMallItemData `json:"item_data"`
BuyLimit int `json:"buy_limit"`
SenderID int `json:"sender_id"`
FirstSend bool `json:"first_send"`
ByInvite bool `json:"by_invite"`
Color string `json:"color"`
Order int `json:"order"`
PublicTime int `json:"public_time"`
EndDate int `json:"end_date"`
AutoRefresh int `json:"auto_refresh"`
RefreshLimit int `json:"refresh_limit"`
MoneyRequired int `json:"money_required"`
}
// PointsMallItemData 积分商城物品数据
type PointsMallItemData struct {
Color string `json:"color,omitempty"`
FriendlyName string `json:"friendly_name,omitempty"`
UsableScenes string `json:"usable_scenes,omitempty"`
AvailableDays int `json:"available_days,omitempty"`
UsableProduct string `json:"usable_product,omitempty"`
BaseLimit int `json:"base_limit,omitempty"`
PublicPoint int `json:"public_point,omitempty"`
Type string `json:"type,omitempty"`
UsableDuration string `json:"usable_duration,omitempty"`
UsablePlanID int `json:"usable_plan_id,omitempty"`
Value any `json:"value,omitempty"`
ProductType string `json:"product_type,omitempty"`
ProductSubtype string `json:"product_subtype,omitempty"`
DurationSeconds int `json:"duration_seconds,omitempty"`
ProductConfig PointsMallProductConfig `json:"product_config,omitempty"`
Desc string `json:"desc,omitempty"`
ImgURL string `json:"img_url,omitempty"`
DescURL string `json:"desc_url,omitempty"`
}
// PointsMallProductConfig 积分商城物品的产品配置
type PointsMallProductConfig struct {
OsID int `json:"os_id"`
PlanID int `json:"plan_id"`
Subtype string `json:"subtype"`
Duration int `json:"duration"`
PayMode string `json:"pay_mode"`
PanelUser string `json:"panel_user"`
EggTypeID int `json:"egg_type_id"`
WithCoupon int `json:"with_coupon"`
CPULimitMode bool `json:"cpu_limit_mode"`
Config PointsMallItemConfig `json:"config"`
}
// PointsMallItemConfig 积分商城物品配置
type PointsMallItemConfig struct {
CPU int `json:"cpu"`
Backup int `json:"backup"`
Memory int `json:"memory"`
NetIn int `json:"net_in"`
NetOut int `json:"net_out"`
Database int `json:"database"`
BaseDisk int `json:"base_disk"`
DataDisk int `json:"data_disk"`
Allocation int `json:"allocation"`
}
// 获取积分商城商品列表
func (s *UserService) GetPointsMallItems() (*GetPointsMallItemsResponse, error) {
path := "/user/reward/items"
var resp GetPointsMallItemsResponse
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
return &resp, err
}
// 兑换积分物品
type RedeemPointsForItemRequest struct {
ItemID int `json:"item_id"`
}
// 兑换积分物品
func (s *UserService) RedeemPointsForItem(id int) (*common.BasicOperationResponse, error) {
path := "/user/reward/items"
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, RedeemPointsForItemRequest{ItemID: id}, &resp)
return &resp, err
}
+123
View File
@@ -0,0 +1,123 @@
package user
import (
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
type GetUserInfoResponse struct {
Code int `json:"code"`
Data UserInfo `json:"data"`
}
// UserInfo 用户信息
type UserInfo struct {
ID int `json:"ID"`
Name string `json:"Name"`
Email string `json:"Email"`
Phone string `json:"Phone"`
Money float64 `json:"Money"`
RegisterTime int `json:"RegisterTime"`
QQOpenID string `json:"QQOpenID"`
QQ any `json:"QQ"`
WechatOpenID string `json:"WechatOpenID"`
CardCode any `json:"CardCode"`
IconURL string `json:"IconUrl"`
Points int `json:"Points"`
MoneyFromPoint int `json:"MoneyFromPoint"`
Inviter int `json:"Inviter"`
APIKey string `json:"APIKey"`
LastIP string `json:"LastIP"`
BanReason string `json:"BanReason"`
UnsubscribeCount int `json:"UnsubscribeCount"`
AlipayAccount string `json:"AlipayAccount"`
AlipayName string `json:"AlipayName"`
LastLogin string `json:"LastLogin"`
LastLoginArea string `json:"LastLoginArea"`
LoginCount int `json:"LoginCount"`
DLWallet int `json:"DLWallet"`
DLLevel int `json:"DLLevel"`
AdminGroup string `json:"AdminGroup"`
TOTPSecret string `json:"TOTPSecret"`
IsLoginEnableTFA bool `json:"IsLoginEnableTFA"`
IsAllowPointUse int `json:"IsAllowPointUse"`
ShareCode string `json:"ShareCode"`
VipLevel int `json:"VipLevel"`
IsAgent bool `json:"IsAgent"`
Valid bool `json:"Valid"`
Source string `json:"Source"`
ConsumeMonthly int `json:"ConsumeMonthly"`
ConsumeAll int `json:"ConsumeAll"`
ConsumeQuarter int `json:"ConsumeQuarter"`
ResellDaily int `json:"ResellDaily"`
ResellMonthly int `json:"ResellMonthly"`
ResellBeforeMonth float64 `json:"ResellBeforeMonth"`
ResellQuarter float64 `json:"ResellQuarter"`
ResellAll float64 `json:"ResellAll"`
StockDaily int `json:"StockDaily"`
StockMonthly int `json:"StockMonthly"`
StockQuarter float64 `json:"StockQuarter"`
StockAll float64 `json:"StockAll"`
SecondStockQuarter int `json:"SecondStockQuarter"`
SecondStockAll int `json:"SecondStockAll"`
SubUserMonthly int `json:"SubUserMonthly"`
SubUserAll int `json:"SubUserAll"`
ResellPointsMonthly int `json:"ResellPointsMonthly"`
ResellPointsAll int `json:"ResellPointsAll"`
Vip UserVipInfo `json:"VIP"`
Certify int `json:"Certify"`
LockPoints int `json:"LockPoints"`
CertifyStatus string `json:"CertifyStatus"`
CertifyType string `json:"CertifyType"`
CertifyAuditNote string `json:"CertifyAuditNote"`
}
// UserVipInfo 用户 VIP 等级信息
type UserVipInfo struct {
Title string `json:"Title"`
SaleRequire int `json:"SaleRequire"`
ResellRequire int `json:"ResellRequire"`
CertifyRequired bool `json:"CertifyRequired"`
SaleProfit float64 `json:"SaleProfit"`
ResellProfit float64 `json:"ResellProfit"`
SecondResellProfit float64 `json:"SecondResellProfit"`
CanSendCoupons bool `json:"CanSendCoupons"`
CanCustomCode bool `json:"CanCustomCode"`
CanSendMsg bool `json:"CanSendMsg"`
CanTryUsual bool `json:"CanTryUsual"`
FreeDomainCount int `json:"FreeDomainCount"`
FreeSSLCount int `json:"FreeSSLCount"`
CanBeAgent bool `json:"CanBeAgent"`
AgentTitle string `json:"AgentTitle"`
StockRequire int `json:"StockRequire"`
SecondStockRequire int `json:"SecondStockRequire"`
StockDiscount float64 `json:"StockDiscount"`
SecondStockProfit float64 `json:"SecondStockProfit"`
}
// 获取用户信息.
func (s *UserService) GetUserInfo() (*GetUserInfoResponse, error) {
path := "/user/"
var resp GetUserInfoResponse
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
return &resp, err
}
// RefreshApikeyRequest 刷新 API 密钥请求
type RefreshApikeyRequest struct {
Option string `json:"option"`
}
// 刷新 api 密钥.
//
// ⚠️不要轻易使用此方法
func (s *UserService) RefreshApikey() (*common.BasicOperationResponse, error) {
path := "/user/"
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, RefreshApikeyRequest{Option: "apikey"}, &resp)
return &resp, err
}