# NSUserPlanService > 用户DNS套餐服务 --- ## buyNSUserPlan > 使用余额购买用户套餐 - 角色:`admin` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/buyNSUserPlan` - RPC:`rpc buyNSUserPlan(BuyNSUserPlanRequest) returns (BuyNSUserPlanResponse);` **请求对象 (`BuyNSUserPlanRequest`)** ```json { "userId": "int64 // 用户ID", "planId": "int64", "period": "string" } ``` **响应对象 (`BuyNSUserPlanResponse`)** ```json { "userPlanId": "int64" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/buyNSUserPlan" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## countNSUserPlans > 计算用户套餐数量 - 角色:`admin` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/countNSUserPlans` - RPC:`rpc countNSUserPlans(CountNSUserPlansRequest) returns (RPCCountResponse);` **请求对象 (`CountNSUserPlansRequest`)** ```json { "userId": "int64 // 用户ID", "nsPlanId": "int64", "periodUnit": "string", "isExpired": "bool", "expireDays": "int32" } ``` **响应对象 (`RPCCountResponse`)** ```json { "count": "int64 // 数量" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/countNSUserPlans" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## createNSUserPlan > 创建用户套餐 - 角色:`admin` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/createNSUserPlan` - RPC:`rpc createNSUserPlan(CreateNSUserPlanRequest) returns (CreateNSUserPlanResponse);` **请求对象 (`CreateNSUserPlanRequest`)** ```json { "userId": "int64 // 用户ID", "nsPlanId": "int64", "dayFrom": "string // YYYYMMDD", "dayTo": "string // YYYYMMDD", "periodUnit": "string // yearly|monthly" } ``` **响应对象 (`CreateNSUserPlanResponse`)** ```json { "nsUserPlanId": "int64" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/createNSUserPlan" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## deleteNSUserPlan > 删除用户套餐 - 角色:`admin` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/deleteNSUserPlan` - RPC:`rpc deleteNSUserPlan(DeleteNSUserPlanRequest) returns (RPCSuccess);` **请求对象 (`DeleteNSUserPlanRequest`)** ```json { "nsUserPlanId": "int64" } ``` **响应对象 (`RPCSuccess`)** ```json {} ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/deleteNSUserPlan" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## findNSUserPlan > 读取用户套餐 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/findNSUserPlan` - RPC:`rpc findNSUserPlan(FindNSUserPlanRequest) returns (FindNSUserPlanResponse);` **请求对象 (`FindNSUserPlanRequest`)** ```json { "userId": "int64 // 和 nsUserPlanId 二选一", "nsUserPlanId": "int64" } ``` **响应对象 (`FindNSUserPlanResponse`)** ```json { "nsUserPlan": "NSUserPlan" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/findNSUserPlan" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## listNSUserPlans > 列出单页套餐 - 角色:`admin` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/listNSUserPlans` - RPC:`rpc listNSUserPlans(ListNSUserPlansRequest) returns (ListNSUserPlansResponse);` **请求对象 (`ListNSUserPlansRequest`)** ```json { "userId": "int64 // 用户ID", "nsPlanId": "int64", "periodUnit": "string", "isExpired": "bool", "expireDays": "int32", "offset": "int64 // 读取位置", "size": "int64 // 数量,通常不能小于0" } ``` **响应对象 (`ListNSUserPlansResponse`)** ```json { "nsUserPlans": "[]NSUserPlan" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/listNSUserPlans" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## updateNSUserPlan > 修改用户套餐 - 角色:`admin` - HTTP:`POST https://backend.dooki.cloud/NSUserPlanService/updateNSUserPlan` - RPC:`rpc updateNSUserPlan(UpdateNSUserPlanRequest) returns (RPCSuccess);` **请求对象 (`UpdateNSUserPlanRequest`)** ```json { "nsUserPlanId": "int64", "nsPlanId": "int64", "dayFrom": "string // YYYYMMDD", "dayTo": "string // YYYYMMDD", "periodUnit": "string // yearly|monthly" } ``` **响应对象 (`RPCSuccess`)** ```json {} ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSUserPlanService/updateNSUserPlan" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` ---