feat: 初次启动

This commit is contained in:
Blizzard
2026-04-27 21:23:13 +08:00
parent e515f6a287
commit bb8ad4d515
148 changed files with 8602 additions and 5678 deletions
+3
View File
@@ -1,4 +1,7 @@
Name: file-api Name: file-api
Log:
Encoding: plain
Host: 0.0.0.0 Host: 0.0.0.0
Port: 9002 Port: 9002
+3
View File
@@ -1,4 +1,7 @@
Name: file.rpc Name: file.rpc
Log:
Encoding: plain
ListenOn: 0.0.0.0:9102 ListenOn: 0.0.0.0:9102
Etcd: Etcd:
Hosts: Hosts:
+36
View File
@@ -0,0 +1,36 @@
Name: gateway
Host: 0.0.0.0
Port: 8888
Log:
Encoding: plain
Mode: console
# 跨域配置
Cors:
Enable: true
AllowOrigins:
- "*"
AllowMethods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
AllowHeaders:
- Content-Type
- Authorization
- X-Requested-With
# 上游服务路由表
Upstreams:
- Prefix: /api/user
Target: http://127.0.0.1:9001
- Prefix: /api/file
Target: http://127.0.0.1:9002
- Prefix: /api/sys
Target: http://127.0.0.1:9003
- Prefix: /api/plant
Target: http://127.0.0.1:9004
- Prefix: /api/radio
Target: http://127.0.0.1:9005
+58
View File
@@ -0,0 +1,58 @@
package main
import (
"flag"
"fmt"
"net/http"
"sundynix-micro-go/app/gateway/internal/config"
"sundynix-micro-go/app/gateway/internal/handler"
"sundynix-micro-go/app/gateway/internal/middleware"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
)
var configFile = flag.String("f", "etc/gateway.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
// 构建反向代理路由器
proxyRouter := handler.NewProxyRouter(c.Upstreams)
// 构建请求处理链
var finalHandler http.Handler = proxyRouter
// 注入 CORS 中间件
if c.Cors.Enable {
corsMiddleware := middleware.NewCorsMiddleware(c.Cors.AllowOrigins, c.Cors.AllowMethods, c.Cors.AllowHeaders)
finalHandler = http.HandlerFunc(corsMiddleware.Handle(func(w http.ResponseWriter, r *http.Request) {
proxyRouter.ServeHTTP(w, r)
}))
}
// 健康检查
mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
fmt.Fprintf(w, `{"code":200,"msg":"gateway is healthy","upstreams":%d}`, len(c.Upstreams))
})
mux.Handle("/", finalHandler)
addr := fmt.Sprintf("%s:%d", c.Host, c.Port)
logx.Infof("===== Sundynix Gateway 启动 =====")
logx.Infof("监听地址: %s", addr)
logx.Infof("路由数量: %d", len(c.Upstreams))
for _, u := range c.Upstreams {
logx.Infof(" %s -> %s", u.Prefix, u.Target)
}
logx.Infof("================================")
if err := http.ListenAndServe(addr, mux); err != nil {
logx.Errorf("网关启动失败: %v", err)
}
}
+21
View File
@@ -0,0 +1,21 @@
package config
import "github.com/zeromicro/go-zero/rest"
type Config struct {
rest.RestConf
Cors struct {
Enable bool
AllowOrigins []string
AllowMethods []string
AllowHeaders []string
}
Upstreams []Upstream
}
type Upstream struct {
Prefix string // URL 前缀,如 /api/user
Target string // 后端地址,如 http://127.0.0.1:9001
}
+95
View File
@@ -0,0 +1,95 @@
package handler
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"strings"
"time"
"sundynix-micro-go/app/gateway/internal/config"
"github.com/zeromicro/go-zero/core/logx"
)
// ProxyRouter 反向代理路由器
type ProxyRouter struct {
routes []*route
}
type route struct {
prefix string
proxy *httputil.ReverseProxy
target string
}
// NewProxyRouter 根据配置构建路由表
func NewProxyRouter(upstreams []config.Upstream) *ProxyRouter {
router := &ProxyRouter{}
for _, u := range upstreams {
targetURL, err := url.Parse(u.Target)
if err != nil {
logx.Errorf("解析上游地址失败 [%s]: %v", u.Target, err)
continue
}
target := targetURL // 显式捕获循环变量
proxy := &httputil.ReverseProxy{
Rewrite: func(pr *httputil.ProxyRequest) {
pr.SetXForwarded()
pr.Out.URL.Scheme = target.Scheme
pr.Out.URL.Host = target.Host
pr.Out.Host = target.Host
// 路径透传:前端请求 /api/user/info -> 转发到 user-api 的 /api/user/info
// 不剥前缀,后端API的路由本身就包含 /api/user 前缀
},
}
// 自定义 Transport:超时控制
proxy.Transport = &http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 20,
IdleConnTimeout: 90 * time.Second,
}
// 错误处理
prefix := u.Prefix
targetAddr := u.Target
proxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) {
logx.Errorf("代理请求失败 [%s%s -> %s]: %v", prefix, r.URL.Path, targetAddr, err)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadGateway)
fmt.Fprintf(w, `{"code":502,"msg":"上游服务不可用: %s"}`, prefix)
}
router.routes = append(router.routes, &route{
prefix: u.Prefix,
proxy: proxy,
target: u.Target,
})
logx.Infof("路由注册: %s -> %s", u.Prefix, u.Target)
}
return router
}
// ServeHTTP 根据 URL 前缀匹配路由并转发
func (pr *ProxyRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
for _, rt := range pr.routes {
if strings.HasPrefix(path, rt.prefix) {
logx.Infof("[Gateway] %s %s -> %s", r.Method, path, rt.target)
rt.proxy.ServeHTTP(w, r)
return
}
}
// 没有匹配的路由
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, `{"code":404,"msg":"路由未找到: %s"}`, path)
}
+55
View File
@@ -0,0 +1,55 @@
package middleware
import (
"net/http"
"strings"
)
// CorsMiddleware 跨域中间件
type CorsMiddleware struct {
allowOrigins []string
allowMethods []string
allowHeaders []string
}
func NewCorsMiddleware(origins, methods, headers []string) *CorsMiddleware {
return &CorsMiddleware{
allowOrigins: origins,
allowMethods: methods,
allowHeaders: headers,
}
}
func (m *CorsMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
origin := r.Header.Get("Origin")
if origin == "" {
next(w, r)
return
}
allowed := false
for _, o := range m.allowOrigins {
if o == "*" || o == origin {
allowed = true
break
}
}
if allowed {
w.Header().Set("Access-Control-Allow-Origin", origin)
w.Header().Set("Access-Control-Allow-Methods", strings.Join(m.allowMethods, ", "))
w.Header().Set("Access-Control-Allow-Headers", strings.Join(m.allowHeaders, ", "))
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Max-Age", "3600")
}
// 预检请求直接返回
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusNoContent)
return
}
next(w, r)
}
}
+10 -26
View File
@@ -1,22 +1,20 @@
Name: plant-api Name: plant-api
Log:
Encoding: plain
Host: 0.0.0.0 Host: 0.0.0.0
Port: 9004 Port: 9004
Auth: Auth:
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872 AccessSecret: sundynix-jwt-secret-2024
AccessExpire: 7200 AccessExpire: 604800
# MySQL PlantRpc:
DB: Etcd:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local Hosts:
- 192.168.100.127:2379
Key: plant.rpc
# Redis
Cache:
- Host: 127.0.0.1:6379
Pass: sundynix
Type: node
# RPC 依赖
UserRpc: UserRpc:
Etcd: Etcd:
Hosts: Hosts:
@@ -28,17 +26,3 @@ FileRpc:
Hosts: Hosts:
- 192.168.100.127:2379 - 192.168.100.127:2379
Key: file.rpc Key: file.rpc
# 百度植物识别
BaiduImgClassify:
ApiKey: hpBfjwy8ifv3qswYGYjUCNKN
SecretKey: i5aXZdM4XZVuDroBslL0f3uIuwbAyXFS
# 微信支付
WechatPay:
MchId: "1735188493"
MchCertificateSerialNumber: "3725BFCA9CA3AF819AEC5D0CB7D3540BBC67F2CF"
MchApiV3Key: "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6"
PrivateKeyPath: "/Users/blizzard/privateFolder/cert/apiclient_key.pem"
PublicKeyPath: "/Users/blizzard/privateFolder/cert/pub_key.pem"
NotifyUrl: "https://prod.sundynix.cn/api/wechatpay/notify"
+1 -20
View File
@@ -14,26 +14,7 @@ type Config struct {
AccessSecret string AccessSecret string
AccessExpire int64 AccessExpire int64
} }
DB struct { PlantRpc zrpc.RpcClientConf
DataSource string
}
Cache []struct {
Host string
Pass string
Type string
}
UserRpc zrpc.RpcClientConf UserRpc zrpc.RpcClientConf
FileRpc zrpc.RpcClientConf FileRpc zrpc.RpcClientConf
BaiduImgClassify struct {
ApiKey string
SecretKey string
}
WechatPay struct {
MchId string
MchCertificateSerialNumber string
MchApiV3Key string
PrivateKeyPath string
PublicKeyPath string
NotifyUrl string
}
} }
@@ -1,4 +1,3 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
@@ -7,7 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type AddCarePlanLogic struct { type AddCarePlanLogic struct {
@@ -22,12 +21,9 @@ func NewAddCarePlanLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddCa
func (l *AddCarePlanLogic) AddCarePlan(req *types.CarePlanReq) error { func (l *AddCarePlanLogic) AddCarePlan(req *types.CarePlanReq) error {
userId := fmt.Sprintf("%v", l.ctx.Value("userId")) userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
plan := plantModel.SundynixCarePlan{ _, err := l.svcCtx.PlantRpc.AddCarePlan(l.ctx, &plant.AddCarePlanReq{
UserID: userId, PlantID: req.PlantId, Name: req.Name, UserId: userId, PlantId: req.PlantId, Name: req.Name, Icon: req.Icon,
TargetAction: req.TargetAction, Period: req.Period, Icon: req.Icon, TargetAction: req.TargetAction, Period: int32(req.Period),
} })
if err := l.svcCtx.DB.Create(&plan).Error; err != nil { return err
return fmt.Errorf("创建养护计划失败")
}
return nil
} }
@@ -1,4 +1,3 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
@@ -7,7 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type AddCareRecordLogic struct { type AddCareRecordLogic struct {
@@ -22,12 +21,8 @@ func NewAddCareRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Add
func (l *AddCareRecordLogic) AddCareRecord(req *types.CareRecordReq) error { func (l *AddCareRecordLogic) AddCareRecord(req *types.CareRecordReq) error {
userId := fmt.Sprintf("%v", l.ctx.Value("userId")) userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
record := plantModel.SundynixCareRecord{ _, err := l.svcCtx.PlantRpc.AddCareRecord(l.ctx, &plant.AddCareRecordReq{
UserID: userId, PlantID: req.PlantId, PlanID: req.PlanId, UserId: userId, PlantId: req.PlantId, PlanId: req.PlanId, Action: req.Action, Note: req.Note,
Name: req.Action, Remark: req.Note, })
} return err
if err := l.svcCtx.DB.Create(&record).Error; err != nil {
return fmt.Errorf("创建养护记录失败")
}
return nil
} }
@@ -1,4 +1,3 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
@@ -7,7 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type AddGrowthRecordLogic struct { type AddGrowthRecordLogic struct {
@@ -22,11 +21,8 @@ func NewAddGrowthRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *A
func (l *AddGrowthRecordLogic) AddGrowthRecord(req *types.GrowthRecordReq) error { func (l *AddGrowthRecordLogic) AddGrowthRecord(req *types.GrowthRecordReq) error {
userId := fmt.Sprintf("%v", l.ctx.Value("userId")) userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
record := plantModel.SundynixGrowthRecord{ _, err := l.svcCtx.PlantRpc.AddGrowthRecord(l.ctx, &plant.AddGrowthRecordReq{
PlantID: req.PlantId, UserID: userId, Content: req.Content, UserId: userId, PlantId: req.PlantId, Content: req.Content, ImgIds: req.ImgIds,
} })
if err := l.svcCtx.DB.Create(&record).Error; err != nil { return err
return fmt.Errorf("创建成长记录失败")
}
return nil
} }
@@ -1,4 +1,3 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
@@ -7,8 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
"time"
) )
type CreatePlantLogic struct { type CreatePlantLogic struct {
@@ -23,20 +21,10 @@ func NewCreatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
func (l *CreatePlantLogic) CreatePlant(req *types.CreatePlantReq) error { func (l *CreatePlantLogic) CreatePlant(req *types.CreatePlantReq) error {
userId := fmt.Sprintf("%v", l.ctx.Value("userId")) userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
plantTime, _ := time.Parse("2006-01-02", req.PlantTime) _, err := l.svcCtx.PlantRpc.CreatePlant(l.ctx, &plant.CreatePlantReq{
plant := plantModel.SundynixMyPlant{ UserId: userId, Name: req.Name, PlantTime: req.PlantTime, Placement: req.Placement,
UserID: userId, Name: req.Name, PlantTime: plantTime, Placement: req.Placement,
PotMaterial: req.PotMaterial, PotSize: req.PotSize, Sunlight: req.Sunlight, PotMaterial: req.PotMaterial, PotSize: req.PotSize, Sunlight: req.Sunlight,
PlantingMaterial: req.PlantingMaterial, Status: 1, PlantingMaterial: req.PlantingMaterial, ImgIds: req.ImgIds,
} })
if err := l.svcCtx.DB.Create(&plant).Error; err != nil { return err
l.Errorf("创建植物失败: %v", err)
return fmt.Errorf("创建植物失败")
}
if len(req.ImgIds) > 0 {
for _, imgID := range req.ImgIds {
l.svcCtx.DB.Create(&plantModel.SundynixMyPlantOss{MyPlantID: plant.ID, OssID: imgID})
}
}
return nil
} }
@@ -1,13 +1,11 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
"context" "context"
"fmt"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type DeletePlantLogic struct { type DeletePlantLogic struct {
@@ -21,13 +19,6 @@ func NewDeletePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
} }
func (l *DeletePlantLogic) DeletePlant(req *types.IdsReq) error { func (l *DeletePlantLogic) DeletePlant(req *types.IdsReq) error {
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&plantModel.SundynixMyPlant{}).Error; err != nil { _, err := l.svcCtx.PlantRpc.DeletePlant(l.ctx, &plant.IdsReq{Ids: req.Ids})
return fmt.Errorf("删除植物失败") return err
}
// 清理关联数据
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixCarePlan{})
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixCareRecord{})
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixCareTask{})
l.svcCtx.DB.Where("plant_id IN ?", req.Ids).Delete(&plantModel.SundynixGrowthRecord{})
return nil
} }
@@ -1,4 +1,3 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
@@ -7,7 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type GetMyPlantListLogic struct { type GetMyPlantListLogic struct {
@@ -22,22 +21,11 @@ func NewGetMyPlantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
func (l *GetMyPlantListLogic) GetMyPlantList(req *types.PlantListReq) (resp interface{}, err error) { func (l *GetMyPlantListLogic) GetMyPlantList(req *types.PlantListReq) (resp interface{}, err error) {
userId := fmt.Sprintf("%v", l.ctx.Value("userId")) userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
var plants []plantModel.SundynixMyPlant result, err := l.svcCtx.PlantRpc.GetPlantList(l.ctx, &plant.PlantListReq{
var total int64 UserId: userId, Current: int32(req.Current), PageSize: int32(req.PageSize), Name: req.Name,
db := l.svcCtx.DB.Model(&plantModel.SundynixMyPlant{}).Where("user_id = ?", userId) })
if req.Name != "" { if err != nil {
db = db.Where("name LIKE ?", "%"+req.Name+"%") return nil, err
} }
db.Count(&total) return map[string]interface{}{"list": result.List, "total": result.Total}, nil
current, pageSize := req.Current, req.PageSize
if current <= 0 {
current = 1
}
if pageSize <= 0 {
pageSize = 10
}
if err := db.Offset((current - 1) * pageSize).Limit(pageSize).Order("created_at DESC").Find(&plants).Error; err != nil {
return nil, fmt.Errorf("查询植物列表失败")
}
return map[string]interface{}{"list": plants, "total": total, "current": current, "size": pageSize}, nil
} }
@@ -1,14 +1,11 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
"context" "context"
"fmt"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type GetPlantDetailLogic struct { type GetPlantDetailLogic struct {
@@ -22,24 +19,9 @@ func NewGetPlantDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
} }
func (l *GetPlantDetailLogic) GetPlantDetail(req *types.IdPathReq) (resp interface{}, err error) { func (l *GetPlantDetailLogic) GetPlantDetail(req *types.IdPathReq) (resp interface{}, err error) {
var plant plantModel.SundynixMyPlant result, err := l.svcCtx.PlantRpc.GetPlantDetail(l.ctx, &plant.IdReq{Id: req.Id})
if err := l.svcCtx.DB.Where("id = ?", req.Id).First(&plant).Error; err != nil { if err != nil {
if err == gorm.ErrRecordNotFound { return nil, err
return nil, fmt.Errorf("植物不存在")
} }
return nil, fmt.Errorf("查询植物失败") return result, nil
}
// 查询关联图片ID
var ossIds []string
l.svcCtx.DB.Model(&plantModel.SundynixMyPlantOss{}).Where("sundynix_my_plant_id = ?", plant.ID).Pluck("sundynix_oss_id", &ossIds)
// 查询养护计划
var plans []plantModel.SundynixCarePlan
l.svcCtx.DB.Where("plant_id = ?", plant.ID).Find(&plans)
// 查询成长记录
var records []plantModel.SundynixGrowthRecord
l.svcCtx.DB.Where("plant_id = ?", plant.ID).Order("created_at DESC").Limit(10).Find(&records)
return map[string]interface{}{
"plant": plant, "imgIds": ossIds, "carePlans": plans, "growthRecords": records,
}, nil
} }
@@ -1,13 +1,11 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant package myPlant
import ( import (
"context" "context"
"fmt"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc" "sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types" "sundynix-micro-go/app/plant/api/internal/types"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plant"
) )
type UpdatePlantLogic struct { type UpdatePlantLogic struct {
@@ -21,32 +19,10 @@ func NewUpdatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
} }
func (l *UpdatePlantLogic) UpdatePlant(req *types.UpdatePlantReq) error { func (l *UpdatePlantLogic) UpdatePlant(req *types.UpdatePlantReq) error {
updates := map[string]interface{}{} _, err := l.svcCtx.PlantRpc.UpdatePlant(l.ctx, &plant.UpdatePlantReq{
if req.Name != "" { Id: req.Id, Name: req.Name, Status: int32(req.Status), Placement: req.Placement,
updates["name"] = req.Name PotMaterial: req.PotMaterial, PotSize: req.PotSize, Sunlight: req.Sunlight,
} PlantingMaterial: req.PlantingMaterial, ImgIds: req.ImgIds,
if req.Status > 0 { })
updates["status"] = req.Status return err
}
if req.Placement != "" {
updates["placement"] = req.Placement
}
if req.PotMaterial != "" {
updates["pot_material"] = req.PotMaterial
}
if req.PotSize != "" {
updates["pot_size"] = req.PotSize
}
if req.Sunlight != "" {
updates["sunlight"] = req.Sunlight
}
if req.PlantingMaterial != "" {
updates["planting_material"] = req.PlantingMaterial
}
if len(updates) > 0 {
if err := l.svcCtx.DB.Model(&plantModel.SundynixMyPlant{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
return fmt.Errorf("更新植物失败")
}
}
return nil
} }
+3 -37
View File
@@ -6,57 +6,23 @@ package svc
import ( import (
"sundynix-micro-go/app/file/rpc/fileservice" "sundynix-micro-go/app/file/rpc/fileservice"
"sundynix-micro-go/app/plant/api/internal/config" "sundynix-micro-go/app/plant/api/internal/config"
plantModel "sundynix-micro-go/app/plant/model" "sundynix-micro-go/app/plant/rpc/plantservice"
"sundynix-micro-go/app/user/rpc/userservice" "sundynix-micro-go/app/user/rpc/userservice"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc" "github.com/zeromicro/go-zero/zrpc"
"gorm.io/driver/mysql"
"gorm.io/gorm"
) )
type ServiceContext struct { type ServiceContext struct {
Config config.Config Config config.Config
DB *gorm.DB PlantRpc plantservice.PlantService
UserRpc userservice.UserService UserRpc userservice.UserService
FileRpc fileservice.FileService FileRpc fileservice.FileService
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
if err != nil {
logx.Errorf("连接数据库失败: %v", err)
panic(err)
}
// 自动迁移
if err := db.AutoMigrate(
&plantModel.SundynixPlantUserProfile{},
&plantModel.SundynixMyPlant{},
&plantModel.SundynixCarePlan{},
&plantModel.SundynixCareRecord{},
&plantModel.SundynixCareTask{},
&plantModel.SundynixGrowthRecord{},
&plantModel.SundynixWiki{},
&plantModel.SundynixWikiClass{},
&plantModel.SundynixPost{},
&plantModel.SundynixPostComment{},
&plantModel.SundynixPostLike{},
&plantModel.SundynixPostTopic{},
&plantModel.SundynixUserStar{},
&plantModel.SundynixExchangeItem{},
&plantModel.SundynixExchangeOrder{},
&plantModel.SundynixLevelConfig{},
&plantModel.SundynixBadgeConfig{},
&plantModel.SundynixUserBadge{},
&plantModel.SundynixAiChatHistory{},
); err != nil {
logx.Errorf("数据库迁移失败: %v", err)
}
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
DB: db, PlantRpc: plantservice.NewPlantService(zrpc.MustNewClient(c.PlantRpc)),
UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)), UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)),
FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)), FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)),
} }
+8 -2
View File
@@ -1,6 +1,12 @@
Name: plant.rpc Name: plant.rpc
ListenOn: 0.0.0.0:8080
Log:
Encoding: plain
ListenOn: 0.0.0.0:9014
Etcd: Etcd:
Hosts: Hosts:
- 127.0.0.1:2379 - 192.168.100.127:2379
Key: plant.rpc Key: plant.rpc
DB:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
+3
View File
@@ -4,4 +4,7 @@ import "github.com/zeromicro/go-zero/zrpc"
type Config struct { type Config struct {
zrpc.RpcServerConf zrpc.RpcServerConf
DB struct {
DataSource string
}
} }
@@ -24,8 +24,8 @@ func NewAddCarePlanLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddCa
} }
// 养护 // 养护
func (l *AddCarePlanLogic) AddCarePlan(in *plant.AddCarePlanReq) (*plant.AddCarePlanResp, error) { func (l *AddCarePlanLogic) AddCarePlan(in *plant.AddCarePlanReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.AddCarePlanResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewAddCareRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Add
} }
} }
func (l *AddCareRecordLogic) AddCareRecord(in *plant.AddCareRecordReq) (*plant.AddCareRecordResp, error) { func (l *AddCareRecordLogic) AddCareRecord(in *plant.AddCareRecordReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.AddCareRecordResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewAddGrowthRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *A
} }
} }
func (l *AddGrowthRecordLogic) AddGrowthRecord(in *plant.AddGrowthRecordReq) (*plant.AddGrowthRecordResp, error) { func (l *AddGrowthRecordLogic) AddGrowthRecord(in *plant.AddGrowthRecordReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.AddGrowthRecordResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewCommentPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comme
} }
} }
func (l *CommentPostLogic) CommentPost(in *plant.CommentPostReq) (*plant.CommentPostResp, error) { func (l *CommentPostLogic) CommentPost(in *plant.CommentPostReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.CommentPostResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewCreateExchangeOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext
} }
} }
func (l *CreateExchangeOrderLogic) CreateExchangeOrder(in *plant.CreateExchangeOrderReq) (*plant.CreateExchangeOrderResp, error) { func (l *CreateExchangeOrderLogic) CreateExchangeOrder(in *plant.CreateExchangeOrderReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.CreateExchangeOrderResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,9 +23,9 @@ func NewCreatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
} }
} }
// 植物 // 我的植物
func (l *CreatePlantLogic) CreatePlant(in *plant.CreatePlantReq) (*plant.CreatePlantResp, error) { func (l *CreatePlantLogic) CreatePlant(in *plant.CreatePlantReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.CreatePlantResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewCreatePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
} }
// 社区 // 社区
func (l *CreatePostLogic) CreatePost(in *plant.CreatePostReq) (*plant.CreatePostResp, error) { func (l *CreatePostLogic) CreatePost(in *plant.CreatePostReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.CreatePostResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewCreateTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
} }
} }
func (l *CreateTopicLogic) CreateTopic(in *plant.CreateTopicReq) (*plant.CreateTopicResp, error) { func (l *CreateTopicLogic) CreateTopic(in *plant.CreateTopicReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.CreateTopicResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewCreateWikiClassLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
} }
} }
func (l *CreateWikiClassLogic) CreateWikiClass(in *plant.CreateWikiClassReq) (*plant.CreateWikiClassResp, error) { func (l *CreateWikiClassLogic) CreateWikiClass(in *plant.CreateWikiClassReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.CreateWikiClassResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeletePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
} }
} }
func (l *DeletePlantLogic) DeletePlant(in *plant.DeletePlantReq) (*plant.DeletePlantResp, error) { func (l *DeletePlantLogic) DeletePlant(in *plant.IdsReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.DeletePlantResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeletePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete
} }
} }
func (l *DeletePostLogic) DeletePost(in *plant.DeletePostReq) (*plant.DeletePostResp, error) { func (l *DeletePostLogic) DeletePost(in *plant.IdsReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.DeletePostResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeleteTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
} }
} }
func (l *DeleteTopicLogic) DeleteTopic(in *plant.DeleteTopicReq) (*plant.DeleteTopicResp, error) { func (l *DeleteTopicLogic) DeleteTopic(in *plant.IdsReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.DeleteTopicResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetBadgeConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
} }
} }
func (l *GetBadgeConfigListLogic) GetBadgeConfigList(in *plant.GetBadgeConfigListReq) (*plant.GetBadgeConfigListResp, error) { func (l *GetBadgeConfigListLogic) GetBadgeConfigList(in *plant.BadgeConfigListReq) (*plant.BadgeConfigListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetBadgeConfigListResp{}, nil return &plant.BadgeConfigListResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewGetExchangeItemListLogic(ctx context.Context, svcCtx *svc.ServiceContext
} }
// 兑换 // 兑换
func (l *GetExchangeItemListLogic) GetExchangeItemList(in *plant.GetExchangeItemListReq) (*plant.GetExchangeItemListResp, error) { func (l *GetExchangeItemListLogic) GetExchangeItemList(in *plant.ExchangeItemListReq) (*plant.ExchangeItemListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetExchangeItemListResp{}, nil return &plant.ExchangeItemListResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewGetLevelConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
} }
// 配置 // 配置
func (l *GetLevelConfigListLogic) GetLevelConfigList(in *plant.GetLevelConfigListReq) (*plant.GetLevelConfigListResp, error) { func (l *GetLevelConfigListLogic) GetLevelConfigList(in *plant.PageReq) (*plant.LevelConfigListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetLevelConfigListResp{}, nil return &plant.LevelConfigListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetPlantDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
} }
} }
func (l *GetPlantDetailLogic) GetPlantDetail(in *plant.GetPlantDetailReq) (*plant.GetPlantDetailResp, error) { func (l *GetPlantDetailLogic) GetPlantDetail(in *plant.IdReq) (*plant.PlantDetailResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetPlantDetailResp{}, nil return &plant.PlantDetailResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetPlantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetP
} }
} }
func (l *GetPlantListLogic) GetPlantList(in *plant.GetPlantListReq) (*plant.GetPlantListResp, error) { func (l *GetPlantListLogic) GetPlantList(in *plant.PlantListReq) (*plant.PlantListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetPlantListResp{}, nil return &plant.PlantListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetPostDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
} }
} }
func (l *GetPostDetailLogic) GetPostDetail(in *plant.GetPostDetailReq) (*plant.GetPostDetailResp, error) { func (l *GetPostDetailLogic) GetPostDetail(in *plant.IdReq) (*plant.PostDetailResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetPostDetailResp{}, nil return &plant.PostDetailResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPo
} }
} }
func (l *GetPostListLogic) GetPostList(in *plant.GetPostListReq) (*plant.GetPostListResp, error) { func (l *GetPostListLogic) GetPostList(in *plant.PostListReq) (*plant.PostListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetPostListResp{}, nil return &plant.PostListResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewGetTopicListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetT
} }
// 话题 // 话题
func (l *GetTopicListLogic) GetTopicList(in *plant.Empty) (*plant.GetTopicListResp, error) { func (l *GetTopicListLogic) GetTopicList(in *plant.IdReq) (*plant.TopicListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetTopicListResp{}, nil return &plant.TopicListResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
} }
// 用户Profile // 用户Profile
func (l *GetUserProfileLogic) GetUserProfile(in *plant.GetUserProfileReq) (*plant.GetUserProfileResp, error) { func (l *GetUserProfileLogic) GetUserProfile(in *plant.GetProfileReq) (*plant.PlantUserProfile, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetUserProfileResp{}, nil return &plant.PlantUserProfile{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetWikiClassListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
} }
} }
func (l *GetWikiClassListLogic) GetWikiClassList(in *plant.Empty) (*plant.GetWikiClassListResp, error) { func (l *GetWikiClassListLogic) GetWikiClassList(in *plant.IdReq) (*plant.WikiClassListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetWikiClassListResp{}, nil return &plant.WikiClassListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetWikiDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
} }
} }
func (l *GetWikiDetailLogic) GetWikiDetail(in *plant.GetWikiDetailReq) (*plant.GetWikiDetailResp, error) { func (l *GetWikiDetailLogic) GetWikiDetail(in *plant.IdReq) (*plant.WikiDetailResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetWikiDetailResp{}, nil return &plant.WikiDetailResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewGetWikiListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWi
} }
// 百科 // 百科
func (l *GetWikiListLogic) GetWikiList(in *plant.GetWikiListReq) (*plant.GetWikiListResp, error) { func (l *GetWikiListLogic) GetWikiList(in *plant.WikiListReq) (*plant.WikiListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.GetWikiListResp{}, nil return &plant.WikiListResp{}, nil
} }
@@ -1,30 +0,0 @@
package logic
import (
"context"
"sundynix-micro-go/app/plant/rpc/internal/svc"
"sundynix-micro-go/app/plant/rpc/plant"
"github.com/zeromicro/go-zero/core/logx"
)
type IncrUserCounterLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewIncrUserCounterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IncrUserCounterLogic {
return &IncrUserCounterLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *IncrUserCounterLogic) IncrUserCounter(in *plant.IncrUserCounterReq) (*plant.IncrUserCounterResp, error) {
// todo: add your logic here and delete this line
return &plant.IncrUserCounterResp{}, nil
}
@@ -23,8 +23,8 @@ func NewLikePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikePost
} }
} }
func (l *LikePostLogic) LikePost(in *plant.LikePostReq) (*plant.LikePostResp, error) { func (l *LikePostLogic) LikePost(in *plant.LikePostReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.LikePostResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
) )
type ToggleStarLogic struct { type ToggleWikiStarLogic struct {
ctx context.Context ctx context.Context
svcCtx *svc.ServiceContext svcCtx *svc.ServiceContext
logx.Logger logx.Logger
} }
func NewToggleStarLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ToggleStarLogic { func NewToggleWikiStarLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ToggleWikiStarLogic {
return &ToggleStarLogic{ return &ToggleWikiStarLogic{
ctx: ctx, ctx: ctx,
svcCtx: svcCtx, svcCtx: svcCtx,
Logger: logx.WithContext(ctx), Logger: logx.WithContext(ctx),
} }
} }
func (l *ToggleStarLogic) ToggleStar(in *plant.ToggleStarReq) (*plant.ToggleStarResp, error) { func (l *ToggleWikiStarLogic) ToggleWikiStar(in *plant.ToggleStarReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.ToggleStarResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewUpdatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
} }
} }
func (l *UpdatePlantLogic) UpdatePlant(in *plant.UpdatePlantReq) (*plant.UpdatePlantResp, error) { func (l *UpdatePlantLogic) UpdatePlant(in *plant.UpdatePlantReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.UpdatePlantResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewUpdateUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext)
} }
} }
func (l *UpdateUserProfileLogic) UpdateUserProfile(in *plant.UpdateUserProfileReq) (*plant.UpdateUserProfileResp, error) { func (l *UpdateUserProfileLogic) UpdateUserProfile(in *plant.UpdateProfileReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &plant.UpdateUserProfileResp{}, nil return &plant.CommonResp{}, nil
} }
@@ -24,154 +24,149 @@ func NewPlantServiceServer(svcCtx *svc.ServiceContext) *PlantServiceServer {
} }
// 用户Profile // 用户Profile
func (s *PlantServiceServer) GetUserProfile(ctx context.Context, in *plant.GetUserProfileReq) (*plant.GetUserProfileResp, error) { func (s *PlantServiceServer) GetUserProfile(ctx context.Context, in *plant.GetProfileReq) (*plant.PlantUserProfile, error) {
l := logic.NewGetUserProfileLogic(ctx, s.svcCtx) l := logic.NewGetUserProfileLogic(ctx, s.svcCtx)
return l.GetUserProfile(in) return l.GetUserProfile(in)
} }
func (s *PlantServiceServer) UpdateUserProfile(ctx context.Context, in *plant.UpdateUserProfileReq) (*plant.UpdateUserProfileResp, error) { func (s *PlantServiceServer) UpdateUserProfile(ctx context.Context, in *plant.UpdateProfileReq) (*plant.CommonResp, error) {
l := logic.NewUpdateUserProfileLogic(ctx, s.svcCtx) l := logic.NewUpdateUserProfileLogic(ctx, s.svcCtx)
return l.UpdateUserProfile(in) return l.UpdateUserProfile(in)
} }
func (s *PlantServiceServer) IncrUserCounter(ctx context.Context, in *plant.IncrUserCounterReq) (*plant.IncrUserCounterResp, error) { // 我的植物
l := logic.NewIncrUserCounterLogic(ctx, s.svcCtx) func (s *PlantServiceServer) CreatePlant(ctx context.Context, in *plant.CreatePlantReq) (*plant.CommonResp, error) {
return l.IncrUserCounter(in)
}
// 植物
func (s *PlantServiceServer) CreatePlant(ctx context.Context, in *plant.CreatePlantReq) (*plant.CreatePlantResp, error) {
l := logic.NewCreatePlantLogic(ctx, s.svcCtx) l := logic.NewCreatePlantLogic(ctx, s.svcCtx)
return l.CreatePlant(in) return l.CreatePlant(in)
} }
func (s *PlantServiceServer) UpdatePlant(ctx context.Context, in *plant.UpdatePlantReq) (*plant.UpdatePlantResp, error) { func (s *PlantServiceServer) UpdatePlant(ctx context.Context, in *plant.UpdatePlantReq) (*plant.CommonResp, error) {
l := logic.NewUpdatePlantLogic(ctx, s.svcCtx) l := logic.NewUpdatePlantLogic(ctx, s.svcCtx)
return l.UpdatePlant(in) return l.UpdatePlant(in)
} }
func (s *PlantServiceServer) DeletePlant(ctx context.Context, in *plant.DeletePlantReq) (*plant.DeletePlantResp, error) { func (s *PlantServiceServer) DeletePlant(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeletePlantLogic(ctx, s.svcCtx) l := logic.NewDeletePlantLogic(ctx, s.svcCtx)
return l.DeletePlant(in) return l.DeletePlant(in)
} }
func (s *PlantServiceServer) GetPlantList(ctx context.Context, in *plant.GetPlantListReq) (*plant.GetPlantListResp, error) { func (s *PlantServiceServer) GetPlantList(ctx context.Context, in *plant.PlantListReq) (*plant.PlantListResp, error) {
l := logic.NewGetPlantListLogic(ctx, s.svcCtx) l := logic.NewGetPlantListLogic(ctx, s.svcCtx)
return l.GetPlantList(in) return l.GetPlantList(in)
} }
func (s *PlantServiceServer) GetPlantDetail(ctx context.Context, in *plant.GetPlantDetailReq) (*plant.GetPlantDetailResp, error) { func (s *PlantServiceServer) GetPlantDetail(ctx context.Context, in *plant.IdReq) (*plant.PlantDetailResp, error) {
l := logic.NewGetPlantDetailLogic(ctx, s.svcCtx) l := logic.NewGetPlantDetailLogic(ctx, s.svcCtx)
return l.GetPlantDetail(in) return l.GetPlantDetail(in)
} }
// 养护 // 养护
func (s *PlantServiceServer) AddCarePlan(ctx context.Context, in *plant.AddCarePlanReq) (*plant.AddCarePlanResp, error) { func (s *PlantServiceServer) AddCarePlan(ctx context.Context, in *plant.AddCarePlanReq) (*plant.CommonResp, error) {
l := logic.NewAddCarePlanLogic(ctx, s.svcCtx) l := logic.NewAddCarePlanLogic(ctx, s.svcCtx)
return l.AddCarePlan(in) return l.AddCarePlan(in)
} }
func (s *PlantServiceServer) AddCareRecord(ctx context.Context, in *plant.AddCareRecordReq) (*plant.AddCareRecordResp, error) { func (s *PlantServiceServer) AddCareRecord(ctx context.Context, in *plant.AddCareRecordReq) (*plant.CommonResp, error) {
l := logic.NewAddCareRecordLogic(ctx, s.svcCtx) l := logic.NewAddCareRecordLogic(ctx, s.svcCtx)
return l.AddCareRecord(in) return l.AddCareRecord(in)
} }
func (s *PlantServiceServer) AddGrowthRecord(ctx context.Context, in *plant.AddGrowthRecordReq) (*plant.AddGrowthRecordResp, error) { func (s *PlantServiceServer) AddGrowthRecord(ctx context.Context, in *plant.AddGrowthRecordReq) (*plant.CommonResp, error) {
l := logic.NewAddGrowthRecordLogic(ctx, s.svcCtx) l := logic.NewAddGrowthRecordLogic(ctx, s.svcCtx)
return l.AddGrowthRecord(in) return l.AddGrowthRecord(in)
} }
// 百科 // 百科
func (s *PlantServiceServer) GetWikiList(ctx context.Context, in *plant.GetWikiListReq) (*plant.GetWikiListResp, error) { func (s *PlantServiceServer) GetWikiList(ctx context.Context, in *plant.WikiListReq) (*plant.WikiListResp, error) {
l := logic.NewGetWikiListLogic(ctx, s.svcCtx) l := logic.NewGetWikiListLogic(ctx, s.svcCtx)
return l.GetWikiList(in) return l.GetWikiList(in)
} }
func (s *PlantServiceServer) GetWikiDetail(ctx context.Context, in *plant.GetWikiDetailReq) (*plant.GetWikiDetailResp, error) { func (s *PlantServiceServer) GetWikiDetail(ctx context.Context, in *plant.IdReq) (*plant.WikiDetailResp, error) {
l := logic.NewGetWikiDetailLogic(ctx, s.svcCtx) l := logic.NewGetWikiDetailLogic(ctx, s.svcCtx)
return l.GetWikiDetail(in) return l.GetWikiDetail(in)
} }
func (s *PlantServiceServer) GetWikiClassList(ctx context.Context, in *plant.Empty) (*plant.GetWikiClassListResp, error) { func (s *PlantServiceServer) GetWikiClassList(ctx context.Context, in *plant.IdReq) (*plant.WikiClassListResp, error) {
l := logic.NewGetWikiClassListLogic(ctx, s.svcCtx) l := logic.NewGetWikiClassListLogic(ctx, s.svcCtx)
return l.GetWikiClassList(in) return l.GetWikiClassList(in)
} }
func (s *PlantServiceServer) CreateWikiClass(ctx context.Context, in *plant.CreateWikiClassReq) (*plant.CreateWikiClassResp, error) { func (s *PlantServiceServer) CreateWikiClass(ctx context.Context, in *plant.CreateWikiClassReq) (*plant.CommonResp, error) {
l := logic.NewCreateWikiClassLogic(ctx, s.svcCtx) l := logic.NewCreateWikiClassLogic(ctx, s.svcCtx)
return l.CreateWikiClass(in) return l.CreateWikiClass(in)
} }
func (s *PlantServiceServer) ToggleStar(ctx context.Context, in *plant.ToggleStarReq) (*plant.ToggleStarResp, error) { func (s *PlantServiceServer) ToggleWikiStar(ctx context.Context, in *plant.ToggleStarReq) (*plant.CommonResp, error) {
l := logic.NewToggleStarLogic(ctx, s.svcCtx) l := logic.NewToggleWikiStarLogic(ctx, s.svcCtx)
return l.ToggleStar(in) return l.ToggleWikiStar(in)
} }
// 社区 // 社区
func (s *PlantServiceServer) CreatePost(ctx context.Context, in *plant.CreatePostReq) (*plant.CreatePostResp, error) { func (s *PlantServiceServer) CreatePost(ctx context.Context, in *plant.CreatePostReq) (*plant.CommonResp, error) {
l := logic.NewCreatePostLogic(ctx, s.svcCtx) l := logic.NewCreatePostLogic(ctx, s.svcCtx)
return l.CreatePost(in) return l.CreatePost(in)
} }
func (s *PlantServiceServer) GetPostList(ctx context.Context, in *plant.GetPostListReq) (*plant.GetPostListResp, error) { func (s *PlantServiceServer) DeletePost(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewGetPostListLogic(ctx, s.svcCtx)
return l.GetPostList(in)
}
func (s *PlantServiceServer) GetPostDetail(ctx context.Context, in *plant.GetPostDetailReq) (*plant.GetPostDetailResp, error) {
l := logic.NewGetPostDetailLogic(ctx, s.svcCtx)
return l.GetPostDetail(in)
}
func (s *PlantServiceServer) DeletePost(ctx context.Context, in *plant.DeletePostReq) (*plant.DeletePostResp, error) {
l := logic.NewDeletePostLogic(ctx, s.svcCtx) l := logic.NewDeletePostLogic(ctx, s.svcCtx)
return l.DeletePost(in) return l.DeletePost(in)
} }
func (s *PlantServiceServer) CommentPost(ctx context.Context, in *plant.CommentPostReq) (*plant.CommentPostResp, error) { func (s *PlantServiceServer) GetPostList(ctx context.Context, in *plant.PostListReq) (*plant.PostListResp, error) {
l := logic.NewGetPostListLogic(ctx, s.svcCtx)
return l.GetPostList(in)
}
func (s *PlantServiceServer) GetPostDetail(ctx context.Context, in *plant.IdReq) (*plant.PostDetailResp, error) {
l := logic.NewGetPostDetailLogic(ctx, s.svcCtx)
return l.GetPostDetail(in)
}
func (s *PlantServiceServer) CommentPost(ctx context.Context, in *plant.CommentPostReq) (*plant.CommonResp, error) {
l := logic.NewCommentPostLogic(ctx, s.svcCtx) l := logic.NewCommentPostLogic(ctx, s.svcCtx)
return l.CommentPost(in) return l.CommentPost(in)
} }
func (s *PlantServiceServer) LikePost(ctx context.Context, in *plant.LikePostReq) (*plant.LikePostResp, error) { func (s *PlantServiceServer) LikePost(ctx context.Context, in *plant.LikePostReq) (*plant.CommonResp, error) {
l := logic.NewLikePostLogic(ctx, s.svcCtx) l := logic.NewLikePostLogic(ctx, s.svcCtx)
return l.LikePost(in) return l.LikePost(in)
} }
// 话题 // 话题
func (s *PlantServiceServer) GetTopicList(ctx context.Context, in *plant.Empty) (*plant.GetTopicListResp, error) { func (s *PlantServiceServer) GetTopicList(ctx context.Context, in *plant.IdReq) (*plant.TopicListResp, error) {
l := logic.NewGetTopicListLogic(ctx, s.svcCtx) l := logic.NewGetTopicListLogic(ctx, s.svcCtx)
return l.GetTopicList(in) return l.GetTopicList(in)
} }
func (s *PlantServiceServer) CreateTopic(ctx context.Context, in *plant.CreateTopicReq) (*plant.CreateTopicResp, error) { func (s *PlantServiceServer) CreateTopic(ctx context.Context, in *plant.CreateTopicReq) (*plant.CommonResp, error) {
l := logic.NewCreateTopicLogic(ctx, s.svcCtx) l := logic.NewCreateTopicLogic(ctx, s.svcCtx)
return l.CreateTopic(in) return l.CreateTopic(in)
} }
func (s *PlantServiceServer) DeleteTopic(ctx context.Context, in *plant.DeleteTopicReq) (*plant.DeleteTopicResp, error) { func (s *PlantServiceServer) DeleteTopic(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteTopicLogic(ctx, s.svcCtx) l := logic.NewDeleteTopicLogic(ctx, s.svcCtx)
return l.DeleteTopic(in) return l.DeleteTopic(in)
} }
// 配置
func (s *PlantServiceServer) GetLevelConfigList(ctx context.Context, in *plant.GetLevelConfigListReq) (*plant.GetLevelConfigListResp, error) {
l := logic.NewGetLevelConfigListLogic(ctx, s.svcCtx)
return l.GetLevelConfigList(in)
}
func (s *PlantServiceServer) GetBadgeConfigList(ctx context.Context, in *plant.GetBadgeConfigListReq) (*plant.GetBadgeConfigListResp, error) {
l := logic.NewGetBadgeConfigListLogic(ctx, s.svcCtx)
return l.GetBadgeConfigList(in)
}
// 兑换 // 兑换
func (s *PlantServiceServer) GetExchangeItemList(ctx context.Context, in *plant.GetExchangeItemListReq) (*plant.GetExchangeItemListResp, error) { func (s *PlantServiceServer) GetExchangeItemList(ctx context.Context, in *plant.ExchangeItemListReq) (*plant.ExchangeItemListResp, error) {
l := logic.NewGetExchangeItemListLogic(ctx, s.svcCtx) l := logic.NewGetExchangeItemListLogic(ctx, s.svcCtx)
return l.GetExchangeItemList(in) return l.GetExchangeItemList(in)
} }
func (s *PlantServiceServer) CreateExchangeOrder(ctx context.Context, in *plant.CreateExchangeOrderReq) (*plant.CreateExchangeOrderResp, error) { func (s *PlantServiceServer) CreateExchangeOrder(ctx context.Context, in *plant.CreateExchangeOrderReq) (*plant.CommonResp, error) {
l := logic.NewCreateExchangeOrderLogic(ctx, s.svcCtx) l := logic.NewCreateExchangeOrderLogic(ctx, s.svcCtx)
return l.CreateExchangeOrder(in) return l.CreateExchangeOrder(in)
} }
// 配置
func (s *PlantServiceServer) GetLevelConfigList(ctx context.Context, in *plant.PageReq) (*plant.LevelConfigListResp, error) {
l := logic.NewGetLevelConfigListLogic(ctx, s.svcCtx)
return l.GetLevelConfigList(in)
}
func (s *PlantServiceServer) GetBadgeConfigList(ctx context.Context, in *plant.BadgeConfigListReq) (*plant.BadgeConfigListResp, error) {
l := logic.NewGetBadgeConfigListLogic(ctx, s.svcCtx)
return l.GetBadgeConfigList(in)
}
+39 -3
View File
@@ -1,13 +1,49 @@
package svc package svc
import "sundynix-micro-go/app/plant/rpc/internal/config" import (
plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/internal/config"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type ServiceContext struct { type ServiceContext struct {
Config config.Config Config config.Config
DB *gorm.DB
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
Config: c, if err != nil {
logx.Errorf("连接数据库失败: %v", err)
panic(err)
} }
if err := db.AutoMigrate(
&plantModel.SundynixPlantUserProfile{},
&plantModel.SundynixMyPlant{},
&plantModel.SundynixCarePlan{},
&plantModel.SundynixCareRecord{},
&plantModel.SundynixCareTask{},
&plantModel.SundynixGrowthRecord{},
&plantModel.SundynixWiki{},
&plantModel.SundynixWikiClass{},
&plantModel.SundynixPost{},
&plantModel.SundynixPostComment{},
&plantModel.SundynixPostLike{},
&plantModel.SundynixPostTopic{},
&plantModel.SundynixUserStar{},
&plantModel.SundynixExchangeItem{},
&plantModel.SundynixExchangeOrder{},
&plantModel.SundynixLevelConfig{},
&plantModel.SundynixBadgeConfig{},
&plantModel.SundynixUserBadge{},
&plantModel.SundynixAiChatHistory{},
); err != nil {
logx.Errorf("数据库迁移失败: %v", err)
}
return &ServiceContext{Config: c, DB: db}
} }
+180 -103
View File
@@ -4,8 +4,29 @@ package plant;
option go_package = "./plant"; option go_package = "./plant";
// ========== 通用 ==========
message CommonResp {
int64 code = 1;
string msg = 2;
}
message IdReq {
string id = 1;
}
message IdsReq {
repeated string ids = 1;
}
message PageReq {
int32 current = 1;
int32 pageSize = 2;
}
// ========== 用户Profile ========== // ========== 用户Profile ==========
message UserProfile {
message PlantUserProfile {
string id = 1; string id = 1;
string userId = 2; string userId = 2;
string nickName = 3; string nickName = 3;
@@ -23,22 +44,18 @@ message UserProfile {
int64 photoCount = 15; int64 photoCount = 15;
} }
message GetUserProfileReq { string userId = 1; } message GetProfileReq {
message GetUserProfileResp { UserProfile profile = 1; } string userId = 1;
message UpdateUserProfileReq { }
message UpdateProfileReq {
string userId = 1; string userId = 1;
string nickName = 2; string nickName = 2;
string avatarId = 3; string avatarId = 3;
} }
message UpdateUserProfileResp {}
message IncrUserCounterReq {
string userId = 1;
string field = 2; // care_count, water_count, etc.
int64 delta = 3;
}
message IncrUserCounterResp {}
// ========== 我的植物 ========== // ========== 我的植物 ==========
message PlantInfo { message PlantInfo {
string id = 1; string id = 1;
string userId = 2; string userId = 2;
@@ -65,7 +82,6 @@ message CreatePlantReq {
string plantingMaterial = 8; string plantingMaterial = 8;
repeated string imgIds = 9; repeated string imgIds = 9;
} }
message CreatePlantResp { string id = 1; }
message UpdatePlantReq { message UpdatePlantReq {
string id = 1; string id = 1;
@@ -76,35 +92,36 @@ message UpdatePlantReq {
string potSize = 6; string potSize = 6;
string sunlight = 7; string sunlight = 7;
string plantingMaterial = 8; string plantingMaterial = 8;
repeated string imgIds = 9;
} }
message UpdatePlantResp {}
message DeletePlantReq { repeated string ids = 1; } message PlantListReq {
message DeletePlantResp {}
message GetPlantListReq {
string userId = 1; string userId = 1;
int32 current = 2; int32 current = 2;
int32 pageSize = 3; int32 pageSize = 3;
string name = 4; string name = 4;
} }
message GetPlantListResp {
message PlantListResp {
repeated PlantInfo list = 1; repeated PlantInfo list = 1;
int64 total = 2; int64 total = 2;
} }
message GetPlantDetailReq { string id = 1; } message PlantDetailResp {
message GetPlantDetailResp { PlantInfo plant = 1; } PlantInfo plant = 1;
repeated CarePlanInfo carePlans = 2;
repeated GrowthRecordInfo growthRecords = 3;
}
// ========== 养护计划 ==========
// ========== 养护 ==========
message CarePlanInfo { message CarePlanInfo {
string id = 1; string id = 1;
string userId = 2; string plantId = 2;
string plantId = 3; string name = 3;
string name = 4; string icon = 4;
string icon = 5; string targetAction = 5;
string targetAction = 6; int32 period = 6;
int32 period = 7;
} }
message AddCarePlanReq { message AddCarePlanReq {
@@ -115,7 +132,8 @@ message AddCarePlanReq {
string targetAction = 5; string targetAction = 5;
int32 period = 6; int32 period = 6;
} }
message AddCarePlanResp { string id = 1; }
// ========== 养护记录 ==========
message AddCareRecordReq { message AddCareRecordReq {
string userId = 1; string userId = 1;
@@ -124,7 +142,15 @@ message AddCareRecordReq {
string action = 4; string action = 4;
string note = 5; string note = 5;
} }
message AddCareRecordResp {}
// ========== 成长记录 ==========
message GrowthRecordInfo {
string id = 1;
string plantId = 2;
string content = 3;
int64 createdAt = 4;
}
message AddGrowthRecordReq { message AddGrowthRecordReq {
string userId = 1; string userId = 1;
@@ -132,9 +158,9 @@ message AddGrowthRecordReq {
string content = 3; string content = 3;
repeated string imgIds = 4; repeated string imgIds = 4;
} }
message AddGrowthRecordResp {}
// ========== 百科 ========== // ========== 百科 ==========
message WikiInfo { message WikiInfo {
string id = 1; string id = 1;
string name = 2; string name = 2;
@@ -143,41 +169,52 @@ message WikiInfo {
string genus = 5; string genus = 5;
int32 difficulty = 6; int32 difficulty = 6;
int32 isHot = 7; int32 isHot = 7;
int64 createdAt = 8; string growthHabit = 8;
string lightIntensity = 9;
string optimalTempPeriod = 10;
int64 createdAt = 11;
} }
message GetWikiListReq { message WikiListReq {
int32 current = 1; int32 current = 1;
int32 pageSize = 2; int32 pageSize = 2;
string name = 3; string name = 3;
string classId = 4; string classId = 4;
int32 isHot = 5; int32 isHot = 5;
} }
message GetWikiListResp {
message WikiListResp {
repeated WikiInfo list = 1; repeated WikiInfo list = 1;
int64 total = 2; int64 total = 2;
} }
message GetWikiDetailReq { string id = 1; } message WikiDetailResp {
message GetWikiDetailResp { WikiInfo wiki = 1; } WikiInfo wiki = 1;
}
message WikiClassInfo { message WikiClassInfo {
string id = 1; string id = 1;
string name = 2; string name = 2;
string ossId = 3; string ossId = 3;
} }
message GetWikiClassListResp { repeated WikiClassInfo list = 1; }
message CreateWikiClassReq { string name = 1; string ossId = 2; } message WikiClassListResp {
message CreateWikiClassResp { string id = 1; } repeated WikiClassInfo list = 1;
}
message CreateWikiClassReq {
string name = 1;
string icon = 2;
}
message ToggleStarReq { message ToggleStarReq {
string userId = 1; string userId = 1;
string targetId = 2; string targetId = 2;
string type = 3; string type = 3;
} }
message ToggleStarResp { bool starred = 1; }
// ========== 社区 ========== // ========== 社区帖子 ==========
message PostInfo { message PostInfo {
string id = 1; string id = 1;
string userId = 2; string userId = 2;
@@ -199,24 +236,32 @@ message CreatePostReq {
repeated string imgIds = 5; repeated string imgIds = 5;
string topicId = 6; string topicId = 6;
} }
message CreatePostResp { string id = 1; }
message GetPostListReq { message PostListReq {
int32 current = 1; int32 current = 1;
int32 pageSize = 2; int32 pageSize = 2;
string keyword = 3; string keyword = 3;
string topicId = 4; string topicId = 4;
string userId = 5;
} }
message GetPostListResp {
message PostListResp {
repeated PostInfo list = 1; repeated PostInfo list = 1;
int64 total = 2; int64 total = 2;
} }
message GetPostDetailReq { string id = 1; } message PostDetailResp {
message GetPostDetailResp { PostInfo post = 1; } PostInfo post = 1;
repeated PostCommentInfo comments = 2;
}
message DeletePostReq { repeated string ids = 1; } message PostCommentInfo {
message DeletePostResp {} string id = 1;
string userId = 2;
string content = 3;
string parentId = 4;
int64 createdAt = 5;
}
message CommentPostReq { message CommentPostReq {
string userId = 1; string userId = 1;
@@ -224,27 +269,58 @@ message CommentPostReq {
string content = 3; string content = 3;
string parentId = 4; string parentId = 4;
} }
message CommentPostResp {}
message LikePostReq { message LikePostReq {
string userId = 1; string userId = 1;
string postId = 2; string postId = 2;
} }
message LikePostResp { bool liked = 1; }
// ========== 话题 ========== // ========== 话题 ==========
message TopicInfo { message TopicInfo {
string id = 1; string id = 1;
string name = 2; string name = 2;
int32 postCount = 3; int32 postCount = 3;
} }
message GetTopicListResp { repeated TopicInfo list = 1; }
message CreateTopicReq { string name = 1; } message TopicListResp {
message CreateTopicResp { string id = 1; } repeated TopicInfo list = 1;
message DeleteTopicReq { repeated string ids = 1; } }
message DeleteTopicResp {}
message CreateTopicReq {
string name = 1;
string icon = 2;
string desc = 3;
}
// ========== 兑换商城 ==========
message ExchangeItemInfo {
string id = 1;
string name = 2;
string desc = 3;
string imgId = 4;
int64 cost = 5;
int32 stock = 6;
}
message ExchangeItemListReq {
int32 current = 1;
int32 pageSize = 2;
}
message ExchangeItemListResp {
repeated ExchangeItemInfo list = 1;
int64 total = 2;
}
message CreateExchangeOrderReq {
string userId = 1;
string itemId = 2;
}
// ========== 配置 ========== // ========== 配置 ==========
message LevelConfigInfo { message LevelConfigInfo {
string id = 1; string id = 1;
int32 level = 2; int32 level = 2;
@@ -252,8 +328,10 @@ message LevelConfigInfo {
int64 minSunlight = 4; int64 minSunlight = 4;
string perks = 5; string perks = 5;
} }
message GetLevelConfigListReq { int32 current = 1; int32 pageSize = 2; }
message GetLevelConfigListResp { repeated LevelConfigInfo list = 1; int64 total = 2; } message LevelConfigListResp {
repeated LevelConfigInfo list = 1;
}
message BadgeConfigInfo { message BadgeConfigInfo {
string id = 1; string id = 1;
@@ -266,63 +344,62 @@ message BadgeConfigInfo {
int64 threshold = 8; int64 threshold = 8;
int64 rewardSunlight = 9; int64 rewardSunlight = 9;
} }
message GetBadgeConfigListReq { int32 current = 1; int32 pageSize = 2; string dimension = 3; }
message GetBadgeConfigListResp { repeated BadgeConfigInfo list = 1; int64 total = 2; }
// ========== 兑换 ========== message BadgeConfigListReq {
message ExchangeItemInfo { int32 current = 1;
string id = 1; int32 pageSize = 2;
string name = 2; string dimension = 3;
string desc = 3;
int64 cost = 4;
int32 stock = 5;
} }
message GetExchangeItemListReq { int32 current = 1; int32 pageSize = 2; }
message GetExchangeItemListResp { repeated ExchangeItemInfo list = 1; int64 total = 2; }
message CreateExchangeOrderReq { string userId = 1; string itemId = 2; } message BadgeConfigListResp {
message CreateExchangeOrderResp { string id = 1; } repeated BadgeConfigInfo list = 1;
int64 total = 2;
// ========== 通用 ========== }
message Empty {}
// ========== 服务定义 ========== // ========== 服务定义 ==========
service PlantService { service PlantService {
// 用户Profile // 用户Profile
rpc GetUserProfile(GetUserProfileReq) returns (GetUserProfileResp); rpc GetUserProfile(GetProfileReq) returns (PlantUserProfile);
rpc UpdateUserProfile(UpdateUserProfileReq) returns (UpdateUserProfileResp); rpc UpdateUserProfile(UpdateProfileReq) returns (CommonResp);
rpc IncrUserCounter(IncrUserCounterReq) returns (IncrUserCounterResp);
// 植物 // 我的植物
rpc CreatePlant(CreatePlantReq) returns (CreatePlantResp); rpc CreatePlant(CreatePlantReq) returns (CommonResp);
rpc UpdatePlant(UpdatePlantReq) returns (UpdatePlantResp); rpc UpdatePlant(UpdatePlantReq) returns (CommonResp);
rpc DeletePlant(DeletePlantReq) returns (DeletePlantResp); rpc DeletePlant(IdsReq) returns (CommonResp);
rpc GetPlantList(GetPlantListReq) returns (GetPlantListResp); rpc GetPlantList(PlantListReq) returns (PlantListResp);
rpc GetPlantDetail(GetPlantDetailReq) returns (GetPlantDetailResp); rpc GetPlantDetail(IdReq) returns (PlantDetailResp);
// 养护 // 养护
rpc AddCarePlan(AddCarePlanReq) returns (AddCarePlanResp); rpc AddCarePlan(AddCarePlanReq) returns (CommonResp);
rpc AddCareRecord(AddCareRecordReq) returns (AddCareRecordResp); rpc AddCareRecord(AddCareRecordReq) returns (CommonResp);
rpc AddGrowthRecord(AddGrowthRecordReq) returns (AddGrowthRecordResp); rpc AddGrowthRecord(AddGrowthRecordReq) returns (CommonResp);
// 百科 // 百科
rpc GetWikiList(GetWikiListReq) returns (GetWikiListResp); rpc GetWikiList(WikiListReq) returns (WikiListResp);
rpc GetWikiDetail(GetWikiDetailReq) returns (GetWikiDetailResp); rpc GetWikiDetail(IdReq) returns (WikiDetailResp);
rpc GetWikiClassList(Empty) returns (GetWikiClassListResp); rpc GetWikiClassList(IdReq) returns (WikiClassListResp);
rpc CreateWikiClass(CreateWikiClassReq) returns (CreateWikiClassResp); rpc CreateWikiClass(CreateWikiClassReq) returns (CommonResp);
rpc ToggleStar(ToggleStarReq) returns (ToggleStarResp); rpc ToggleWikiStar(ToggleStarReq) returns (CommonResp);
// 社区 // 社区
rpc CreatePost(CreatePostReq) returns (CreatePostResp); rpc CreatePost(CreatePostReq) returns (CommonResp);
rpc GetPostList(GetPostListReq) returns (GetPostListResp); rpc DeletePost(IdsReq) returns (CommonResp);
rpc GetPostDetail(GetPostDetailReq) returns (GetPostDetailResp); rpc GetPostList(PostListReq) returns (PostListResp);
rpc DeletePost(DeletePostReq) returns (DeletePostResp); rpc GetPostDetail(IdReq) returns (PostDetailResp);
rpc CommentPost(CommentPostReq) returns (CommentPostResp); rpc CommentPost(CommentPostReq) returns (CommonResp);
rpc LikePost(LikePostReq) returns (LikePostResp); rpc LikePost(LikePostReq) returns (CommonResp);
// 话题 // 话题
rpc GetTopicList(Empty) returns (GetTopicListResp); rpc GetTopicList(IdReq) returns (TopicListResp);
rpc CreateTopic(CreateTopicReq) returns (CreateTopicResp); rpc CreateTopic(CreateTopicReq) returns (CommonResp);
rpc DeleteTopic(DeleteTopicReq) returns (DeleteTopicResp); rpc DeleteTopic(IdsReq) returns (CommonResp);
// 配置
rpc GetLevelConfigList(GetLevelConfigListReq) returns (GetLevelConfigListResp);
rpc GetBadgeConfigList(GetBadgeConfigListReq) returns (GetBadgeConfigListResp);
// 兑换 // 兑换
rpc GetExchangeItemList(GetExchangeItemListReq) returns (GetExchangeItemListResp); rpc GetExchangeItemList(ExchangeItemListReq) returns (ExchangeItemListResp);
rpc CreateExchangeOrder(CreateExchangeOrderReq) returns (CreateExchangeOrderResp); rpc CreateExchangeOrder(CreateExchangeOrderReq) returns (CommonResp);
// 配置
rpc GetLevelConfigList(PageReq) returns (LevelConfigListResp);
rpc GetBadgeConfigList(BadgeConfigListReq) returns (BadgeConfigListResp);
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+102 -129
View File
@@ -15,111 +15,89 @@ import (
type ( type (
AddCarePlanReq = plant.AddCarePlanReq AddCarePlanReq = plant.AddCarePlanReq
AddCarePlanResp = plant.AddCarePlanResp
AddCareRecordReq = plant.AddCareRecordReq AddCareRecordReq = plant.AddCareRecordReq
AddCareRecordResp = plant.AddCareRecordResp
AddGrowthRecordReq = plant.AddGrowthRecordReq AddGrowthRecordReq = plant.AddGrowthRecordReq
AddGrowthRecordResp = plant.AddGrowthRecordResp
BadgeConfigInfo = plant.BadgeConfigInfo BadgeConfigInfo = plant.BadgeConfigInfo
BadgeConfigListReq = plant.BadgeConfigListReq
BadgeConfigListResp = plant.BadgeConfigListResp
CarePlanInfo = plant.CarePlanInfo CarePlanInfo = plant.CarePlanInfo
CommentPostReq = plant.CommentPostReq CommentPostReq = plant.CommentPostReq
CommentPostResp = plant.CommentPostResp CommonResp = plant.CommonResp
CreateExchangeOrderReq = plant.CreateExchangeOrderReq CreateExchangeOrderReq = plant.CreateExchangeOrderReq
CreateExchangeOrderResp = plant.CreateExchangeOrderResp
CreatePlantReq = plant.CreatePlantReq CreatePlantReq = plant.CreatePlantReq
CreatePlantResp = plant.CreatePlantResp
CreatePostReq = plant.CreatePostReq CreatePostReq = plant.CreatePostReq
CreatePostResp = plant.CreatePostResp
CreateTopicReq = plant.CreateTopicReq CreateTopicReq = plant.CreateTopicReq
CreateTopicResp = plant.CreateTopicResp
CreateWikiClassReq = plant.CreateWikiClassReq CreateWikiClassReq = plant.CreateWikiClassReq
CreateWikiClassResp = plant.CreateWikiClassResp
DeletePlantReq = plant.DeletePlantReq
DeletePlantResp = plant.DeletePlantResp
DeletePostReq = plant.DeletePostReq
DeletePostResp = plant.DeletePostResp
DeleteTopicReq = plant.DeleteTopicReq
DeleteTopicResp = plant.DeleteTopicResp
Empty = plant.Empty
ExchangeItemInfo = plant.ExchangeItemInfo ExchangeItemInfo = plant.ExchangeItemInfo
GetBadgeConfigListReq = plant.GetBadgeConfigListReq ExchangeItemListReq = plant.ExchangeItemListReq
GetBadgeConfigListResp = plant.GetBadgeConfigListResp ExchangeItemListResp = plant.ExchangeItemListResp
GetExchangeItemListReq = plant.GetExchangeItemListReq GetProfileReq = plant.GetProfileReq
GetExchangeItemListResp = plant.GetExchangeItemListResp GrowthRecordInfo = plant.GrowthRecordInfo
GetLevelConfigListReq = plant.GetLevelConfigListReq IdReq = plant.IdReq
GetLevelConfigListResp = plant.GetLevelConfigListResp IdsReq = plant.IdsReq
GetPlantDetailReq = plant.GetPlantDetailReq
GetPlantDetailResp = plant.GetPlantDetailResp
GetPlantListReq = plant.GetPlantListReq
GetPlantListResp = plant.GetPlantListResp
GetPostDetailReq = plant.GetPostDetailReq
GetPostDetailResp = plant.GetPostDetailResp
GetPostListReq = plant.GetPostListReq
GetPostListResp = plant.GetPostListResp
GetTopicListResp = plant.GetTopicListResp
GetUserProfileReq = plant.GetUserProfileReq
GetUserProfileResp = plant.GetUserProfileResp
GetWikiClassListResp = plant.GetWikiClassListResp
GetWikiDetailReq = plant.GetWikiDetailReq
GetWikiDetailResp = plant.GetWikiDetailResp
GetWikiListReq = plant.GetWikiListReq
GetWikiListResp = plant.GetWikiListResp
IncrUserCounterReq = plant.IncrUserCounterReq
IncrUserCounterResp = plant.IncrUserCounterResp
LevelConfigInfo = plant.LevelConfigInfo LevelConfigInfo = plant.LevelConfigInfo
LevelConfigListResp = plant.LevelConfigListResp
LikePostReq = plant.LikePostReq LikePostReq = plant.LikePostReq
LikePostResp = plant.LikePostResp PageReq = plant.PageReq
PlantDetailResp = plant.PlantDetailResp
PlantInfo = plant.PlantInfo PlantInfo = plant.PlantInfo
PlantListReq = plant.PlantListReq
PlantListResp = plant.PlantListResp
PlantUserProfile = plant.PlantUserProfile
PostCommentInfo = plant.PostCommentInfo
PostDetailResp = plant.PostDetailResp
PostInfo = plant.PostInfo PostInfo = plant.PostInfo
PostListReq = plant.PostListReq
PostListResp = plant.PostListResp
ToggleStarReq = plant.ToggleStarReq ToggleStarReq = plant.ToggleStarReq
ToggleStarResp = plant.ToggleStarResp
TopicInfo = plant.TopicInfo TopicInfo = plant.TopicInfo
TopicListResp = plant.TopicListResp
UpdatePlantReq = plant.UpdatePlantReq UpdatePlantReq = plant.UpdatePlantReq
UpdatePlantResp = plant.UpdatePlantResp UpdateProfileReq = plant.UpdateProfileReq
UpdateUserProfileReq = plant.UpdateUserProfileReq
UpdateUserProfileResp = plant.UpdateUserProfileResp
UserProfile = plant.UserProfile
WikiClassInfo = plant.WikiClassInfo WikiClassInfo = plant.WikiClassInfo
WikiClassListResp = plant.WikiClassListResp
WikiDetailResp = plant.WikiDetailResp
WikiInfo = plant.WikiInfo WikiInfo = plant.WikiInfo
WikiListReq = plant.WikiListReq
WikiListResp = plant.WikiListResp
PlantService interface { PlantService interface {
// 用户Profile // 用户Profile
GetUserProfile(ctx context.Context, in *GetUserProfileReq, opts ...grpc.CallOption) (*GetUserProfileResp, error) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error)
UpdateUserProfile(ctx context.Context, in *UpdateUserProfileReq, opts ...grpc.CallOption) (*UpdateUserProfileResp, error) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error)
IncrUserCounter(ctx context.Context, in *IncrUserCounterReq, opts ...grpc.CallOption) (*IncrUserCounterResp, error) // 我的植物
// 植物 CreatePlant(ctx context.Context, in *CreatePlantReq, opts ...grpc.CallOption) (*CommonResp, error)
CreatePlant(ctx context.Context, in *CreatePlantReq, opts ...grpc.CallOption) (*CreatePlantResp, error) UpdatePlant(ctx context.Context, in *UpdatePlantReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdatePlant(ctx context.Context, in *UpdatePlantReq, opts ...grpc.CallOption) (*UpdatePlantResp, error) DeletePlant(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
DeletePlant(ctx context.Context, in *DeletePlantReq, opts ...grpc.CallOption) (*DeletePlantResp, error) GetPlantList(ctx context.Context, in *PlantListReq, opts ...grpc.CallOption) (*PlantListResp, error)
GetPlantList(ctx context.Context, in *GetPlantListReq, opts ...grpc.CallOption) (*GetPlantListResp, error) GetPlantDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PlantDetailResp, error)
GetPlantDetail(ctx context.Context, in *GetPlantDetailReq, opts ...grpc.CallOption) (*GetPlantDetailResp, error)
// 养护 // 养护
AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*AddCarePlanResp, error) AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*CommonResp, error)
AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*AddCareRecordResp, error) AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*CommonResp, error)
AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*AddGrowthRecordResp, error) AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*CommonResp, error)
// 百科 // 百科
GetWikiList(ctx context.Context, in *GetWikiListReq, opts ...grpc.CallOption) (*GetWikiListResp, error) GetWikiList(ctx context.Context, in *WikiListReq, opts ...grpc.CallOption) (*WikiListResp, error)
GetWikiDetail(ctx context.Context, in *GetWikiDetailReq, opts ...grpc.CallOption) (*GetWikiDetailResp, error) GetWikiDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiDetailResp, error)
GetWikiClassList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GetWikiClassListResp, error) GetWikiClassList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassListResp, error)
CreateWikiClass(ctx context.Context, in *CreateWikiClassReq, opts ...grpc.CallOption) (*CreateWikiClassResp, error) CreateWikiClass(ctx context.Context, in *CreateWikiClassReq, opts ...grpc.CallOption) (*CommonResp, error)
ToggleStar(ctx context.Context, in *ToggleStarReq, opts ...grpc.CallOption) (*ToggleStarResp, error) ToggleWikiStar(ctx context.Context, in *ToggleStarReq, opts ...grpc.CallOption) (*CommonResp, error)
// 社区 // 社区
CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*CreatePostResp, error) CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*CommonResp, error)
GetPostList(ctx context.Context, in *GetPostListReq, opts ...grpc.CallOption) (*GetPostListResp, error) DeletePost(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetPostDetail(ctx context.Context, in *GetPostDetailReq, opts ...grpc.CallOption) (*GetPostDetailResp, error) GetPostList(ctx context.Context, in *PostListReq, opts ...grpc.CallOption) (*PostListResp, error)
DeletePost(ctx context.Context, in *DeletePostReq, opts ...grpc.CallOption) (*DeletePostResp, error) GetPostDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PostDetailResp, error)
CommentPost(ctx context.Context, in *CommentPostReq, opts ...grpc.CallOption) (*CommentPostResp, error) CommentPost(ctx context.Context, in *CommentPostReq, opts ...grpc.CallOption) (*CommonResp, error)
LikePost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*LikePostResp, error) LikePost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*CommonResp, error)
// 话题 // 话题
GetTopicList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GetTopicListResp, error) GetTopicList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*TopicListResp, error)
CreateTopic(ctx context.Context, in *CreateTopicReq, opts ...grpc.CallOption) (*CreateTopicResp, error) CreateTopic(ctx context.Context, in *CreateTopicReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteTopic(ctx context.Context, in *DeleteTopicReq, opts ...grpc.CallOption) (*DeleteTopicResp, error) DeleteTopic(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
// 配置
GetLevelConfigList(ctx context.Context, in *GetLevelConfigListReq, opts ...grpc.CallOption) (*GetLevelConfigListResp, error)
GetBadgeConfigList(ctx context.Context, in *GetBadgeConfigListReq, opts ...grpc.CallOption) (*GetBadgeConfigListResp, error)
// 兑换 // 兑换
GetExchangeItemList(ctx context.Context, in *GetExchangeItemListReq, opts ...grpc.CallOption) (*GetExchangeItemListResp, error) GetExchangeItemList(ctx context.Context, in *ExchangeItemListReq, opts ...grpc.CallOption) (*ExchangeItemListResp, error)
CreateExchangeOrder(ctx context.Context, in *CreateExchangeOrderReq, opts ...grpc.CallOption) (*CreateExchangeOrderResp, error) CreateExchangeOrder(ctx context.Context, in *CreateExchangeOrderReq, opts ...grpc.CallOption) (*CommonResp, error)
// 配置
GetLevelConfigList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*LevelConfigListResp, error)
GetBadgeConfigList(ctx context.Context, in *BadgeConfigListReq, opts ...grpc.CallOption) (*BadgeConfigListResp, error)
} }
defaultPlantService struct { defaultPlantService struct {
@@ -134,154 +112,149 @@ func NewPlantService(cli zrpc.Client) PlantService {
} }
// 用户Profile // 用户Profile
func (m *defaultPlantService) GetUserProfile(ctx context.Context, in *GetUserProfileReq, opts ...grpc.CallOption) (*GetUserProfileResp, error) { func (m *defaultPlantService) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetUserProfile(ctx, in, opts...) return client.GetUserProfile(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateUserProfile(ctx context.Context, in *UpdateUserProfileReq, opts ...grpc.CallOption) (*UpdateUserProfileResp, error) { func (m *defaultPlantService) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateUserProfile(ctx, in, opts...) return client.UpdateUserProfile(ctx, in, opts...)
} }
func (m *defaultPlantService) IncrUserCounter(ctx context.Context, in *IncrUserCounterReq, opts ...grpc.CallOption) (*IncrUserCounterResp, error) { // 我的植物
client := plant.NewPlantServiceClient(m.cli.Conn()) func (m *defaultPlantService) CreatePlant(ctx context.Context, in *CreatePlantReq, opts ...grpc.CallOption) (*CommonResp, error) {
return client.IncrUserCounter(ctx, in, opts...)
}
// 植物
func (m *defaultPlantService) CreatePlant(ctx context.Context, in *CreatePlantReq, opts ...grpc.CallOption) (*CreatePlantResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreatePlant(ctx, in, opts...) return client.CreatePlant(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdatePlant(ctx context.Context, in *UpdatePlantReq, opts ...grpc.CallOption) (*UpdatePlantResp, error) { func (m *defaultPlantService) UpdatePlant(ctx context.Context, in *UpdatePlantReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdatePlant(ctx, in, opts...) return client.UpdatePlant(ctx, in, opts...)
} }
func (m *defaultPlantService) DeletePlant(ctx context.Context, in *DeletePlantReq, opts ...grpc.CallOption) (*DeletePlantResp, error) { func (m *defaultPlantService) DeletePlant(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeletePlant(ctx, in, opts...) return client.DeletePlant(ctx, in, opts...)
} }
func (m *defaultPlantService) GetPlantList(ctx context.Context, in *GetPlantListReq, opts ...grpc.CallOption) (*GetPlantListResp, error) { func (m *defaultPlantService) GetPlantList(ctx context.Context, in *PlantListReq, opts ...grpc.CallOption) (*PlantListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPlantList(ctx, in, opts...) return client.GetPlantList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetPlantDetail(ctx context.Context, in *GetPlantDetailReq, opts ...grpc.CallOption) (*GetPlantDetailResp, error) { func (m *defaultPlantService) GetPlantDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PlantDetailResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPlantDetail(ctx, in, opts...) return client.GetPlantDetail(ctx, in, opts...)
} }
// 养护 // 养护
func (m *defaultPlantService) AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*AddCarePlanResp, error) { func (m *defaultPlantService) AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.AddCarePlan(ctx, in, opts...) return client.AddCarePlan(ctx, in, opts...)
} }
func (m *defaultPlantService) AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*AddCareRecordResp, error) { func (m *defaultPlantService) AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.AddCareRecord(ctx, in, opts...) return client.AddCareRecord(ctx, in, opts...)
} }
func (m *defaultPlantService) AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*AddGrowthRecordResp, error) { func (m *defaultPlantService) AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.AddGrowthRecord(ctx, in, opts...) return client.AddGrowthRecord(ctx, in, opts...)
} }
// 百科 // 百科
func (m *defaultPlantService) GetWikiList(ctx context.Context, in *GetWikiListReq, opts ...grpc.CallOption) (*GetWikiListResp, error) { func (m *defaultPlantService) GetWikiList(ctx context.Context, in *WikiListReq, opts ...grpc.CallOption) (*WikiListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetWikiList(ctx, in, opts...) return client.GetWikiList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetWikiDetail(ctx context.Context, in *GetWikiDetailReq, opts ...grpc.CallOption) (*GetWikiDetailResp, error) { func (m *defaultPlantService) GetWikiDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiDetailResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetWikiDetail(ctx, in, opts...) return client.GetWikiDetail(ctx, in, opts...)
} }
func (m *defaultPlantService) GetWikiClassList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GetWikiClassListResp, error) { func (m *defaultPlantService) GetWikiClassList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetWikiClassList(ctx, in, opts...) return client.GetWikiClassList(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateWikiClass(ctx context.Context, in *CreateWikiClassReq, opts ...grpc.CallOption) (*CreateWikiClassResp, error) { func (m *defaultPlantService) CreateWikiClass(ctx context.Context, in *CreateWikiClassReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateWikiClass(ctx, in, opts...) return client.CreateWikiClass(ctx, in, opts...)
} }
func (m *defaultPlantService) ToggleStar(ctx context.Context, in *ToggleStarReq, opts ...grpc.CallOption) (*ToggleStarResp, error) { func (m *defaultPlantService) ToggleWikiStar(ctx context.Context, in *ToggleStarReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.ToggleStar(ctx, in, opts...) return client.ToggleWikiStar(ctx, in, opts...)
} }
// 社区 // 社区
func (m *defaultPlantService) CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*CreatePostResp, error) { func (m *defaultPlantService) CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreatePost(ctx, in, opts...) return client.CreatePost(ctx, in, opts...)
} }
func (m *defaultPlantService) GetPostList(ctx context.Context, in *GetPostListReq, opts ...grpc.CallOption) (*GetPostListResp, error) { func (m *defaultPlantService) DeletePost(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPostList(ctx, in, opts...)
}
func (m *defaultPlantService) GetPostDetail(ctx context.Context, in *GetPostDetailReq, opts ...grpc.CallOption) (*GetPostDetailResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPostDetail(ctx, in, opts...)
}
func (m *defaultPlantService) DeletePost(ctx context.Context, in *DeletePostReq, opts ...grpc.CallOption) (*DeletePostResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeletePost(ctx, in, opts...) return client.DeletePost(ctx, in, opts...)
} }
func (m *defaultPlantService) CommentPost(ctx context.Context, in *CommentPostReq, opts ...grpc.CallOption) (*CommentPostResp, error) { func (m *defaultPlantService) GetPostList(ctx context.Context, in *PostListReq, opts ...grpc.CallOption) (*PostListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPostList(ctx, in, opts...)
}
func (m *defaultPlantService) GetPostDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PostDetailResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPostDetail(ctx, in, opts...)
}
func (m *defaultPlantService) CommentPost(ctx context.Context, in *CommentPostReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CommentPost(ctx, in, opts...) return client.CommentPost(ctx, in, opts...)
} }
func (m *defaultPlantService) LikePost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*LikePostResp, error) { func (m *defaultPlantService) LikePost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.LikePost(ctx, in, opts...) return client.LikePost(ctx, in, opts...)
} }
// 话题 // 话题
func (m *defaultPlantService) GetTopicList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GetTopicListResp, error) { func (m *defaultPlantService) GetTopicList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*TopicListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetTopicList(ctx, in, opts...) return client.GetTopicList(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateTopic(ctx context.Context, in *CreateTopicReq, opts ...grpc.CallOption) (*CreateTopicResp, error) { func (m *defaultPlantService) CreateTopic(ctx context.Context, in *CreateTopicReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateTopic(ctx, in, opts...) return client.CreateTopic(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteTopic(ctx context.Context, in *DeleteTopicReq, opts ...grpc.CallOption) (*DeleteTopicResp, error) { func (m *defaultPlantService) DeleteTopic(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteTopic(ctx, in, opts...) return client.DeleteTopic(ctx, in, opts...)
} }
// 配置
func (m *defaultPlantService) GetLevelConfigList(ctx context.Context, in *GetLevelConfigListReq, opts ...grpc.CallOption) (*GetLevelConfigListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetLevelConfigList(ctx, in, opts...)
}
func (m *defaultPlantService) GetBadgeConfigList(ctx context.Context, in *GetBadgeConfigListReq, opts ...grpc.CallOption) (*GetBadgeConfigListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetBadgeConfigList(ctx, in, opts...)
}
// 兑换 // 兑换
func (m *defaultPlantService) GetExchangeItemList(ctx context.Context, in *GetExchangeItemListReq, opts ...grpc.CallOption) (*GetExchangeItemListResp, error) { func (m *defaultPlantService) GetExchangeItemList(ctx context.Context, in *ExchangeItemListReq, opts ...grpc.CallOption) (*ExchangeItemListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetExchangeItemList(ctx, in, opts...) return client.GetExchangeItemList(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateExchangeOrder(ctx context.Context, in *CreateExchangeOrderReq, opts ...grpc.CallOption) (*CreateExchangeOrderResp, error) { func (m *defaultPlantService) CreateExchangeOrder(ctx context.Context, in *CreateExchangeOrderReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn()) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateExchangeOrder(ctx, in, opts...) return client.CreateExchangeOrder(ctx, in, opts...)
} }
// 配置
func (m *defaultPlantService) GetLevelConfigList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*LevelConfigListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetLevelConfigList(ctx, in, opts...)
}
func (m *defaultPlantService) GetBadgeConfigList(ctx context.Context, in *BadgeConfigListReq, opts ...grpc.CallOption) (*BadgeConfigListResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetBadgeConfigList(ctx, in, opts...)
}
+10 -27
View File
@@ -1,22 +1,20 @@
Name: radio-api Name: radio-api
Log:
Encoding: plain
Host: 0.0.0.0 Host: 0.0.0.0
Port: 9005 Port: 9005
Auth: Auth:
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872 AccessSecret: sundynix-jwt-secret-2024
AccessExpire: 7200 AccessExpire: 604800
# MySQL RadioRpc:
DB: Etcd:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local Hosts:
- 192.168.100.127:2379
Key: radio.rpc
# Redis
Cache:
- Host: 127.0.0.1:6379
Pass: sundynix
Type: node
# RPC 依赖
UserRpc: UserRpc:
Etcd: Etcd:
Hosts: Hosts:
@@ -28,18 +26,3 @@ FileRpc:
Hosts: Hosts:
- 192.168.100.127:2379 - 192.168.100.127:2379
Key: file.rpc Key: file.rpc
# TTS 火山引擎
Tts:
AppId: "9604175735"
ResourceId: "seed-tts-2.0"
AccessKey: "IMSrxDQgXWOwaJnuF-5G7uppRQutwBny"
# 微信支付
WechatPay:
MchId: "1735188493"
MchCertificateSerialNumber: "3725BFCA9CA3AF819AEC5D0CB7D3540BBC67F2CF"
MchApiV3Key: "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6"
PrivateKeyPath: "/Users/blizzard/privateFolder/cert/apiclient_key.pem"
PublicKeyPath: "/Users/blizzard/privateFolder/cert/pub_key.pem"
NotifyUrl: "https://radio.sundynix.cn/api/wechatpay/notify"
+1 -21
View File
@@ -14,27 +14,7 @@ type Config struct {
AccessSecret string AccessSecret string
AccessExpire int64 AccessExpire int64
} }
DB struct { RadioRpc zrpc.RpcClientConf
DataSource string
}
Cache []struct {
Host string
Pass string
Type string
}
UserRpc zrpc.RpcClientConf UserRpc zrpc.RpcClientConf
FileRpc zrpc.RpcClientConf FileRpc zrpc.RpcClientConf
Tts struct {
AppId string
ResourceId string
AccessKey string
}
WechatPay struct {
MchId string
MchCertificateSerialNumber string
MchApiV3Key string
PrivateKeyPath string
PublicKeyPath string
NotifyUrl string
}
} }
+3 -32
View File
@@ -6,52 +6,23 @@ package svc
import ( import (
"sundynix-micro-go/app/file/rpc/fileservice" "sundynix-micro-go/app/file/rpc/fileservice"
"sundynix-micro-go/app/radio/api/internal/config" "sundynix-micro-go/app/radio/api/internal/config"
radioModel "sundynix-micro-go/app/radio/model" "sundynix-micro-go/app/radio/rpc/radioservice"
"sundynix-micro-go/app/user/rpc/userservice" "sundynix-micro-go/app/user/rpc/userservice"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc" "github.com/zeromicro/go-zero/zrpc"
"gorm.io/driver/mysql"
"gorm.io/gorm"
) )
type ServiceContext struct { type ServiceContext struct {
Config config.Config Config config.Config
DB *gorm.DB RadioRpc radioservice.RadioService
UserRpc userservice.UserService UserRpc userservice.UserService
FileRpc fileservice.FileService FileRpc fileservice.FileService
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
if err != nil {
logx.Errorf("连接数据库失败: %v", err)
panic(err)
}
// 自动迁移
if err := db.AutoMigrate(
&radioModel.SundynixRadioUserProfile{},
&radioModel.SundynixRadioCategory{},
&radioModel.SundynixRadioChannel{},
&radioModel.SundynixRadioProgram{},
&radioModel.SundynixRadioVoice{},
&radioModel.SundynixRadioLike{},
&radioModel.SundynixRadioFavorite{},
&radioModel.SundynixRadioComment{},
&radioModel.SundynixRadioHistory{},
&radioModel.SundynixRadioSubscription{},
&radioModel.SundynixRadioSubscriptionOrder{},
&radioModel.SundynixRadioPayNotify{},
&radioModel.SundynixRadioVipConfig{},
&radioModel.SundynixRadioListenLog{},
); err != nil {
logx.Errorf("数据库迁移失败: %v", err)
}
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
DB: db, RadioRpc: radioservice.NewRadioService(zrpc.MustNewClient(c.RadioRpc)),
UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)), UserRpc: userservice.NewUserService(zrpc.MustNewClient(c.UserRpc)),
FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)), FileRpc: fileservice.NewFileService(zrpc.MustNewClient(c.FileRpc)),
} }
+8 -2
View File
@@ -1,6 +1,12 @@
Name: radio.rpc Name: radio.rpc
ListenOn: 0.0.0.0:8080
Log:
Encoding: plain
ListenOn: 0.0.0.0:9015
Etcd: Etcd:
Hosts: Hosts:
- 127.0.0.1:2379 - 192.168.100.127:2379
Key: radio.rpc Key: radio.rpc
DB:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
+3
View File
@@ -4,4 +4,7 @@ import "github.com/zeromicro/go-zero/zrpc"
type Config struct { type Config struct {
zrpc.RpcServerConf zrpc.RpcServerConf
DB struct {
DataSource string
}
} }
@@ -23,8 +23,8 @@ func NewCommentProgramLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Co
} }
} }
func (l *CommentProgramLogic) CommentProgram(in *radio.CommentReq) (*radio.CommentResp, error) { func (l *CommentProgramLogic) CommentProgram(in *radio.CommentReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.CommentResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewCreateCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cr
} }
// 分类 // 分类
func (l *CreateCategoryLogic) CreateCategory(in *radio.CreateCategoryReq) (*radio.CreateCategoryResp, error) { func (l *CreateCategoryLogic) CreateCategory(in *radio.CategoryReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.CreateCategoryResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewCreateChannelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
} }
// 频道 // 频道
func (l *CreateChannelLogic) CreateChannel(in *radio.CreateChannelReq) (*radio.CreateChannelResp, error) { func (l *CreateChannelLogic) CreateChannel(in *radio.CreateChannelReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.CreateChannelResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewCreateProgramLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
} }
// 节目 // 节目
func (l *CreateProgramLogic) CreateProgram(in *radio.CreateProgramReq) (*radio.CreateProgramResp, error) { func (l *CreateProgramLogic) CreateProgram(in *radio.CreateProgramReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.CreateProgramResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewCreateVoiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
} }
// 音色 // 音色
func (l *CreateVoiceLogic) CreateVoice(in *radio.CreateVoiceReq) (*radio.CreateVoiceResp, error) { func (l *CreateVoiceLogic) CreateVoice(in *radio.CreateVoiceReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.CreateVoiceResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeleteCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *De
} }
} }
func (l *DeleteCategoryLogic) DeleteCategory(in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (l *DeleteCategoryLogic) DeleteCategory(in *radio.IdsReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.DeleteResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeleteChannelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
} }
} }
func (l *DeleteChannelLogic) DeleteChannel(in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (l *DeleteChannelLogic) DeleteChannel(in *radio.IdsReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.DeleteResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeleteProgramLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
} }
} }
func (l *DeleteProgramLogic) DeleteProgram(in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (l *DeleteProgramLogic) DeleteProgram(in *radio.IdsReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.DeleteResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewDeleteVoiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
} }
} }
func (l *DeleteVoiceLogic) DeleteVoice(in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (l *DeleteVoiceLogic) DeleteVoice(in *radio.IdsReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.DeleteResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -0,0 +1,31 @@
package logic
import (
"context"
"sundynix-micro-go/app/radio/rpc/internal/svc"
"sundynix-micro-go/app/radio/rpc/radio"
"github.com/zeromicro/go-zero/core/logx"
)
type GetAnalyticsOverviewLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetAnalyticsOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAnalyticsOverviewLogic {
return &GetAnalyticsOverviewLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 数据分析
func (l *GetAnalyticsOverviewLogic) GetAnalyticsOverview(in *radio.AnalyticsReq) (*radio.AnalyticsOverviewResp, error) {
// todo: add your logic here and delete this line
return &radio.AnalyticsOverviewResp{}, nil
}
@@ -23,8 +23,8 @@ func NewGetCategoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
} }
} }
func (l *GetCategoryListLogic) GetCategoryList(in *radio.GetCategoryListReq) (*radio.GetCategoryListResp, error) { func (l *GetCategoryListLogic) GetCategoryList(in *radio.CategoryListReq) (*radio.CategoryListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetCategoryListResp{}, nil return &radio.CategoryListResp{}, nil
} }
@@ -0,0 +1,30 @@
package logic
import (
"context"
"sundynix-micro-go/app/radio/rpc/internal/svc"
"sundynix-micro-go/app/radio/rpc/radio"
"github.com/zeromicro/go-zero/core/logx"
)
type GetChannelAnalyticsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetChannelAnalyticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetChannelAnalyticsLogic {
return &GetChannelAnalyticsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetChannelAnalyticsLogic) GetChannelAnalytics(in *radio.AnalyticsReq) (*radio.ChannelAnalyticsResp, error) {
// todo: add your logic here and delete this line
return &radio.ChannelAnalyticsResp{}, nil
}
@@ -23,8 +23,8 @@ func NewGetChannelDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
} }
} }
func (l *GetChannelDetailLogic) GetChannelDetail(in *radio.GetChannelDetailReq) (*radio.GetChannelDetailResp, error) { func (l *GetChannelDetailLogic) GetChannelDetail(in *radio.IdReq) (*radio.ChannelInfo, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetChannelDetailResp{}, nil return &radio.ChannelInfo{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetChannelListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
} }
} }
func (l *GetChannelListLogic) GetChannelList(in *radio.GetChannelListReq) (*radio.GetChannelListResp, error) { func (l *GetChannelListLogic) GetChannelList(in *radio.ChannelListReq) (*radio.ChannelListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetChannelListResp{}, nil return &radio.ChannelListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetFavoriteListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
} }
} }
func (l *GetFavoriteListLogic) GetFavoriteList(in *radio.GetFavoriteListReq) (*radio.GetFavoriteListResp, error) { func (l *GetFavoriteListLogic) GetFavoriteList(in *radio.InteractionListReq) (*radio.FavoriteListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetFavoriteListResp{}, nil return &radio.FavoriteListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetHistoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
} }
} }
func (l *GetHistoryListLogic) GetHistoryList(in *radio.GetHistoryListReq) (*radio.GetHistoryListResp, error) { func (l *GetHistoryListLogic) GetHistoryList(in *radio.InteractionListReq) (*radio.HistoryListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetHistoryListResp{}, nil return &radio.HistoryListResp{}, nil
} }
@@ -23,9 +23,9 @@ func NewGetMySubscriptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
} }
} }
// 订阅 // 订阅/VIP
func (l *GetMySubscriptionsLogic) GetMySubscriptions(in *radio.GetMySubscriptionsReq) (*radio.GetMySubscriptionsResp, error) { func (l *GetMySubscriptionsLogic) GetMySubscriptions(in *radio.SubscriptionListReq) (*radio.SubscriptionListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetMySubscriptionsResp{}, nil return &radio.SubscriptionListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetMyVipInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetM
} }
} }
func (l *GetMyVipInfoLogic) GetMyVipInfo(in *radio.GetMyVipInfoReq) (*radio.GetMyVipInfoResp, error) { func (l *GetMyVipInfoLogic) GetMyVipInfo(in *radio.GetProfileReq) (*radio.RadioUserProfile, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetMyVipInfoResp{}, nil return &radio.RadioUserProfile{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetProgramDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
} }
} }
func (l *GetProgramDetailLogic) GetProgramDetail(in *radio.GetProgramDetailReq) (*radio.GetProgramDetailResp, error) { func (l *GetProgramDetailLogic) GetProgramDetail(in *radio.IdReq) (*radio.ProgramInfo, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetProgramDetailResp{}, nil return &radio.ProgramInfo{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetProgramListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
} }
} }
func (l *GetProgramListLogic) GetProgramList(in *radio.GetProgramListReq) (*radio.GetProgramListResp, error) { func (l *GetProgramListLogic) GetProgramList(in *radio.ProgramListReq) (*radio.ProgramListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetProgramListResp{}, nil return &radio.ProgramListResp{}, nil
} }
@@ -1,31 +0,0 @@
package logic
import (
"context"
"sundynix-micro-go/app/radio/rpc/internal/svc"
"sundynix-micro-go/app/radio/rpc/radio"
"github.com/zeromicro/go-zero/core/logx"
)
type GetRadioUserProfileLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetRadioUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRadioUserProfileLogic {
return &GetRadioUserProfileLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 用户
func (l *GetRadioUserProfileLogic) GetRadioUserProfile(in *radio.GetRadioUserProfileReq) (*radio.GetRadioUserProfileResp, error) {
// todo: add your logic here and delete this line
return &radio.GetRadioUserProfileResp{}, nil
}
@@ -0,0 +1,30 @@
package logic
import (
"context"
"sundynix-micro-go/app/radio/rpc/internal/svc"
"sundynix-micro-go/app/radio/rpc/radio"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserAnalyticsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserAnalyticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserAnalyticsLogic {
return &GetUserAnalyticsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetUserAnalyticsLogic) GetUserAnalytics(in *radio.AnalyticsReq) (*radio.UserAnalyticsResp, error) {
// todo: add your logic here and delete this line
return &radio.UserAnalyticsResp{}, nil
}
@@ -0,0 +1,31 @@
package logic
import (
"context"
"sundynix-micro-go/app/radio/rpc/internal/svc"
"sundynix-micro-go/app/radio/rpc/radio"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserProfileLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic {
return &GetUserProfileLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 用户Profile
func (l *GetUserProfileLogic) GetUserProfile(in *radio.GetProfileReq) (*radio.RadioUserProfile, error) {
// todo: add your logic here and delete this line
return &radio.RadioUserProfile{}, nil
}
@@ -23,9 +23,8 @@ func NewGetVipConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
} }
} }
// VIP func (l *GetVipConfigListLogic) GetVipConfigList(in *radio.IdReq) (*radio.VipConfigListResp, error) {
func (l *GetVipConfigListLogic) GetVipConfigList(in *radio.GetVipConfigListReq) (*radio.GetVipConfigListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetVipConfigListResp{}, nil return &radio.VipConfigListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewGetVoiceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetV
} }
} }
func (l *GetVoiceListLogic) GetVoiceList(in *radio.GetVoiceListReq) (*radio.GetVoiceListResp, error) { func (l *GetVoiceListLogic) GetVoiceList(in *radio.VoiceListReq) (*radio.VoiceListResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.GetVoiceListResp{}, nil return &radio.VoiceListResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewRecordHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rec
} }
} }
func (l *RecordHistoryLogic) RecordHistory(in *radio.RecordHistoryReq) (*radio.RecordHistoryResp, error) { func (l *RecordHistoryLogic) RecordHistory(in *radio.RecordHistoryReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.RecordHistoryResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewToggleFavoriteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *To
} }
} }
func (l *ToggleFavoriteLogic) ToggleFavorite(in *radio.ToggleFavoriteReq) (*radio.ToggleFavoriteResp, error) { func (l *ToggleFavoriteLogic) ToggleFavorite(in *radio.ToggleFavoriteReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.ToggleFavoriteResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -24,8 +24,8 @@ func NewToggleLikeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Toggle
} }
// 互动 // 互动
func (l *ToggleLikeLogic) ToggleLike(in *radio.ToggleLikeReq) (*radio.ToggleLikeResp, error) { func (l *ToggleLikeLogic) ToggleLike(in *radio.ToggleLikeReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.ToggleLikeResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewUpdateCategoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Up
} }
} }
func (l *UpdateCategoryLogic) UpdateCategory(in *radio.UpdateCategoryReq) (*radio.UpdateCategoryResp, error) { func (l *UpdateCategoryLogic) UpdateCategory(in *radio.CategoryUpdateReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.UpdateCategoryResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewUpdateChannelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
} }
} }
func (l *UpdateChannelLogic) UpdateChannel(in *radio.UpdateChannelReq) (*radio.UpdateChannelResp, error) { func (l *UpdateChannelLogic) UpdateChannel(in *radio.UpdateChannelReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.UpdateChannelResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewUpdateProgramLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
} }
} }
func (l *UpdateProgramLogic) UpdateProgram(in *radio.UpdateProgramReq) (*radio.UpdateProgramResp, error) { func (l *UpdateProgramLogic) UpdateProgram(in *radio.UpdateProgramReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.UpdateProgramResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,8 +23,8 @@ func NewUpdateVoiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
} }
} }
func (l *UpdateVoiceLogic) UpdateVoice(in *radio.UpdateVoiceReq) (*radio.UpdateVoiceResp, error) { func (l *UpdateVoiceLogic) UpdateVoice(in *radio.UpdateVoiceReq) (*radio.CommonResp, error) {
// todo: add your logic here and delete this line // todo: add your logic here and delete this line
return &radio.UpdateVoiceResp{}, nil return &radio.CommonResp{}, nil
} }
@@ -23,139 +23,139 @@ func NewRadioServiceServer(svcCtx *svc.ServiceContext) *RadioServiceServer {
} }
} }
// 用户 // 用户Profile
func (s *RadioServiceServer) GetRadioUserProfile(ctx context.Context, in *radio.GetRadioUserProfileReq) (*radio.GetRadioUserProfileResp, error) { func (s *RadioServiceServer) GetUserProfile(ctx context.Context, in *radio.GetProfileReq) (*radio.RadioUserProfile, error) {
l := logic.NewGetRadioUserProfileLogic(ctx, s.svcCtx) l := logic.NewGetUserProfileLogic(ctx, s.svcCtx)
return l.GetRadioUserProfile(in) return l.GetUserProfile(in)
} }
// 分类 // 分类
func (s *RadioServiceServer) CreateCategory(ctx context.Context, in *radio.CreateCategoryReq) (*radio.CreateCategoryResp, error) { func (s *RadioServiceServer) CreateCategory(ctx context.Context, in *radio.CategoryReq) (*radio.CommonResp, error) {
l := logic.NewCreateCategoryLogic(ctx, s.svcCtx) l := logic.NewCreateCategoryLogic(ctx, s.svcCtx)
return l.CreateCategory(in) return l.CreateCategory(in)
} }
func (s *RadioServiceServer) UpdateCategory(ctx context.Context, in *radio.UpdateCategoryReq) (*radio.UpdateCategoryResp, error) { func (s *RadioServiceServer) UpdateCategory(ctx context.Context, in *radio.CategoryUpdateReq) (*radio.CommonResp, error) {
l := logic.NewUpdateCategoryLogic(ctx, s.svcCtx) l := logic.NewUpdateCategoryLogic(ctx, s.svcCtx)
return l.UpdateCategory(in) return l.UpdateCategory(in)
} }
func (s *RadioServiceServer) DeleteCategory(ctx context.Context, in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (s *RadioServiceServer) DeleteCategory(ctx context.Context, in *radio.IdsReq) (*radio.CommonResp, error) {
l := logic.NewDeleteCategoryLogic(ctx, s.svcCtx) l := logic.NewDeleteCategoryLogic(ctx, s.svcCtx)
return l.DeleteCategory(in) return l.DeleteCategory(in)
} }
func (s *RadioServiceServer) GetCategoryList(ctx context.Context, in *radio.GetCategoryListReq) (*radio.GetCategoryListResp, error) { func (s *RadioServiceServer) GetCategoryList(ctx context.Context, in *radio.CategoryListReq) (*radio.CategoryListResp, error) {
l := logic.NewGetCategoryListLogic(ctx, s.svcCtx) l := logic.NewGetCategoryListLogic(ctx, s.svcCtx)
return l.GetCategoryList(in) return l.GetCategoryList(in)
} }
// 频道 // 频道
func (s *RadioServiceServer) CreateChannel(ctx context.Context, in *radio.CreateChannelReq) (*radio.CreateChannelResp, error) { func (s *RadioServiceServer) CreateChannel(ctx context.Context, in *radio.CreateChannelReq) (*radio.CommonResp, error) {
l := logic.NewCreateChannelLogic(ctx, s.svcCtx) l := logic.NewCreateChannelLogic(ctx, s.svcCtx)
return l.CreateChannel(in) return l.CreateChannel(in)
} }
func (s *RadioServiceServer) UpdateChannel(ctx context.Context, in *radio.UpdateChannelReq) (*radio.UpdateChannelResp, error) { func (s *RadioServiceServer) UpdateChannel(ctx context.Context, in *radio.UpdateChannelReq) (*radio.CommonResp, error) {
l := logic.NewUpdateChannelLogic(ctx, s.svcCtx) l := logic.NewUpdateChannelLogic(ctx, s.svcCtx)
return l.UpdateChannel(in) return l.UpdateChannel(in)
} }
func (s *RadioServiceServer) DeleteChannel(ctx context.Context, in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (s *RadioServiceServer) DeleteChannel(ctx context.Context, in *radio.IdsReq) (*radio.CommonResp, error) {
l := logic.NewDeleteChannelLogic(ctx, s.svcCtx) l := logic.NewDeleteChannelLogic(ctx, s.svcCtx)
return l.DeleteChannel(in) return l.DeleteChannel(in)
} }
func (s *RadioServiceServer) GetChannelList(ctx context.Context, in *radio.GetChannelListReq) (*radio.GetChannelListResp, error) { func (s *RadioServiceServer) GetChannelList(ctx context.Context, in *radio.ChannelListReq) (*radio.ChannelListResp, error) {
l := logic.NewGetChannelListLogic(ctx, s.svcCtx) l := logic.NewGetChannelListLogic(ctx, s.svcCtx)
return l.GetChannelList(in) return l.GetChannelList(in)
} }
func (s *RadioServiceServer) GetChannelDetail(ctx context.Context, in *radio.GetChannelDetailReq) (*radio.GetChannelDetailResp, error) { func (s *RadioServiceServer) GetChannelDetail(ctx context.Context, in *radio.IdReq) (*radio.ChannelInfo, error) {
l := logic.NewGetChannelDetailLogic(ctx, s.svcCtx) l := logic.NewGetChannelDetailLogic(ctx, s.svcCtx)
return l.GetChannelDetail(in) return l.GetChannelDetail(in)
} }
// 节目 // 节目
func (s *RadioServiceServer) CreateProgram(ctx context.Context, in *radio.CreateProgramReq) (*radio.CreateProgramResp, error) { func (s *RadioServiceServer) CreateProgram(ctx context.Context, in *radio.CreateProgramReq) (*radio.CommonResp, error) {
l := logic.NewCreateProgramLogic(ctx, s.svcCtx) l := logic.NewCreateProgramLogic(ctx, s.svcCtx)
return l.CreateProgram(in) return l.CreateProgram(in)
} }
func (s *RadioServiceServer) UpdateProgram(ctx context.Context, in *radio.UpdateProgramReq) (*radio.UpdateProgramResp, error) { func (s *RadioServiceServer) UpdateProgram(ctx context.Context, in *radio.UpdateProgramReq) (*radio.CommonResp, error) {
l := logic.NewUpdateProgramLogic(ctx, s.svcCtx) l := logic.NewUpdateProgramLogic(ctx, s.svcCtx)
return l.UpdateProgram(in) return l.UpdateProgram(in)
} }
func (s *RadioServiceServer) DeleteProgram(ctx context.Context, in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (s *RadioServiceServer) DeleteProgram(ctx context.Context, in *radio.IdsReq) (*radio.CommonResp, error) {
l := logic.NewDeleteProgramLogic(ctx, s.svcCtx) l := logic.NewDeleteProgramLogic(ctx, s.svcCtx)
return l.DeleteProgram(in) return l.DeleteProgram(in)
} }
func (s *RadioServiceServer) GetProgramList(ctx context.Context, in *radio.GetProgramListReq) (*radio.GetProgramListResp, error) { func (s *RadioServiceServer) GetProgramList(ctx context.Context, in *radio.ProgramListReq) (*radio.ProgramListResp, error) {
l := logic.NewGetProgramListLogic(ctx, s.svcCtx) l := logic.NewGetProgramListLogic(ctx, s.svcCtx)
return l.GetProgramList(in) return l.GetProgramList(in)
} }
func (s *RadioServiceServer) GetProgramDetail(ctx context.Context, in *radio.GetProgramDetailReq) (*radio.GetProgramDetailResp, error) { func (s *RadioServiceServer) GetProgramDetail(ctx context.Context, in *radio.IdReq) (*radio.ProgramInfo, error) {
l := logic.NewGetProgramDetailLogic(ctx, s.svcCtx) l := logic.NewGetProgramDetailLogic(ctx, s.svcCtx)
return l.GetProgramDetail(in) return l.GetProgramDetail(in)
} }
// 音色 // 音色
func (s *RadioServiceServer) CreateVoice(ctx context.Context, in *radio.CreateVoiceReq) (*radio.CreateVoiceResp, error) { func (s *RadioServiceServer) CreateVoice(ctx context.Context, in *radio.CreateVoiceReq) (*radio.CommonResp, error) {
l := logic.NewCreateVoiceLogic(ctx, s.svcCtx) l := logic.NewCreateVoiceLogic(ctx, s.svcCtx)
return l.CreateVoice(in) return l.CreateVoice(in)
} }
func (s *RadioServiceServer) UpdateVoice(ctx context.Context, in *radio.UpdateVoiceReq) (*radio.UpdateVoiceResp, error) { func (s *RadioServiceServer) UpdateVoice(ctx context.Context, in *radio.UpdateVoiceReq) (*radio.CommonResp, error) {
l := logic.NewUpdateVoiceLogic(ctx, s.svcCtx) l := logic.NewUpdateVoiceLogic(ctx, s.svcCtx)
return l.UpdateVoice(in) return l.UpdateVoice(in)
} }
func (s *RadioServiceServer) DeleteVoice(ctx context.Context, in *radio.DeleteByIdsReq) (*radio.DeleteResp, error) { func (s *RadioServiceServer) DeleteVoice(ctx context.Context, in *radio.IdsReq) (*radio.CommonResp, error) {
l := logic.NewDeleteVoiceLogic(ctx, s.svcCtx) l := logic.NewDeleteVoiceLogic(ctx, s.svcCtx)
return l.DeleteVoice(in) return l.DeleteVoice(in)
} }
func (s *RadioServiceServer) GetVoiceList(ctx context.Context, in *radio.GetVoiceListReq) (*radio.GetVoiceListResp, error) { func (s *RadioServiceServer) GetVoiceList(ctx context.Context, in *radio.VoiceListReq) (*radio.VoiceListResp, error) {
l := logic.NewGetVoiceListLogic(ctx, s.svcCtx) l := logic.NewGetVoiceListLogic(ctx, s.svcCtx)
return l.GetVoiceList(in) return l.GetVoiceList(in)
} }
// 互动 // 互动
func (s *RadioServiceServer) ToggleLike(ctx context.Context, in *radio.ToggleLikeReq) (*radio.ToggleLikeResp, error) { func (s *RadioServiceServer) ToggleLike(ctx context.Context, in *radio.ToggleLikeReq) (*radio.CommonResp, error) {
l := logic.NewToggleLikeLogic(ctx, s.svcCtx) l := logic.NewToggleLikeLogic(ctx, s.svcCtx)
return l.ToggleLike(in) return l.ToggleLike(in)
} }
func (s *RadioServiceServer) ToggleFavorite(ctx context.Context, in *radio.ToggleFavoriteReq) (*radio.ToggleFavoriteResp, error) { func (s *RadioServiceServer) ToggleFavorite(ctx context.Context, in *radio.ToggleFavoriteReq) (*radio.CommonResp, error) {
l := logic.NewToggleFavoriteLogic(ctx, s.svcCtx) l := logic.NewToggleFavoriteLogic(ctx, s.svcCtx)
return l.ToggleFavorite(in) return l.ToggleFavorite(in)
} }
func (s *RadioServiceServer) CommentProgram(ctx context.Context, in *radio.CommentReq) (*radio.CommentResp, error) { func (s *RadioServiceServer) CommentProgram(ctx context.Context, in *radio.CommentReq) (*radio.CommonResp, error) {
l := logic.NewCommentProgramLogic(ctx, s.svcCtx) l := logic.NewCommentProgramLogic(ctx, s.svcCtx)
return l.CommentProgram(in) return l.CommentProgram(in)
} }
func (s *RadioServiceServer) RecordHistory(ctx context.Context, in *radio.RecordHistoryReq) (*radio.RecordHistoryResp, error) { func (s *RadioServiceServer) RecordHistory(ctx context.Context, in *radio.RecordHistoryReq) (*radio.CommonResp, error) {
l := logic.NewRecordHistoryLogic(ctx, s.svcCtx) l := logic.NewRecordHistoryLogic(ctx, s.svcCtx)
return l.RecordHistory(in) return l.RecordHistory(in)
} }
func (s *RadioServiceServer) GetHistoryList(ctx context.Context, in *radio.GetHistoryListReq) (*radio.GetHistoryListResp, error) { func (s *RadioServiceServer) GetFavoriteList(ctx context.Context, in *radio.InteractionListReq) (*radio.FavoriteListResp, error) {
l := logic.NewGetHistoryListLogic(ctx, s.svcCtx)
return l.GetHistoryList(in)
}
func (s *RadioServiceServer) GetFavoriteList(ctx context.Context, in *radio.GetFavoriteListReq) (*radio.GetFavoriteListResp, error) {
l := logic.NewGetFavoriteListLogic(ctx, s.svcCtx) l := logic.NewGetFavoriteListLogic(ctx, s.svcCtx)
return l.GetFavoriteList(in) return l.GetFavoriteList(in)
} }
// 订阅 func (s *RadioServiceServer) GetHistoryList(ctx context.Context, in *radio.InteractionListReq) (*radio.HistoryListResp, error) {
func (s *RadioServiceServer) GetMySubscriptions(ctx context.Context, in *radio.GetMySubscriptionsReq) (*radio.GetMySubscriptionsResp, error) { l := logic.NewGetHistoryListLogic(ctx, s.svcCtx)
return l.GetHistoryList(in)
}
// 订阅/VIP
func (s *RadioServiceServer) GetMySubscriptions(ctx context.Context, in *radio.SubscriptionListReq) (*radio.SubscriptionListResp, error) {
l := logic.NewGetMySubscriptionsLogic(ctx, s.svcCtx) l := logic.NewGetMySubscriptionsLogic(ctx, s.svcCtx)
return l.GetMySubscriptions(in) return l.GetMySubscriptions(in)
} }
@@ -165,13 +165,28 @@ func (s *RadioServiceServer) CreatePayOrder(ctx context.Context, in *radio.Creat
return l.CreatePayOrder(in) return l.CreatePayOrder(in)
} }
// VIP func (s *RadioServiceServer) GetVipConfigList(ctx context.Context, in *radio.IdReq) (*radio.VipConfigListResp, error) {
func (s *RadioServiceServer) GetVipConfigList(ctx context.Context, in *radio.GetVipConfigListReq) (*radio.GetVipConfigListResp, error) {
l := logic.NewGetVipConfigListLogic(ctx, s.svcCtx) l := logic.NewGetVipConfigListLogic(ctx, s.svcCtx)
return l.GetVipConfigList(in) return l.GetVipConfigList(in)
} }
func (s *RadioServiceServer) GetMyVipInfo(ctx context.Context, in *radio.GetMyVipInfoReq) (*radio.GetMyVipInfoResp, error) { func (s *RadioServiceServer) GetMyVipInfo(ctx context.Context, in *radio.GetProfileReq) (*radio.RadioUserProfile, error) {
l := logic.NewGetMyVipInfoLogic(ctx, s.svcCtx) l := logic.NewGetMyVipInfoLogic(ctx, s.svcCtx)
return l.GetMyVipInfo(in) return l.GetMyVipInfo(in)
} }
// 数据分析
func (s *RadioServiceServer) GetAnalyticsOverview(ctx context.Context, in *radio.AnalyticsReq) (*radio.AnalyticsOverviewResp, error) {
l := logic.NewGetAnalyticsOverviewLogic(ctx, s.svcCtx)
return l.GetAnalyticsOverview(in)
}
func (s *RadioServiceServer) GetChannelAnalytics(ctx context.Context, in *radio.AnalyticsReq) (*radio.ChannelAnalyticsResp, error) {
l := logic.NewGetChannelAnalyticsLogic(ctx, s.svcCtx)
return l.GetChannelAnalytics(in)
}
func (s *RadioServiceServer) GetUserAnalytics(ctx context.Context, in *radio.AnalyticsReq) (*radio.UserAnalyticsResp, error) {
l := logic.NewGetUserAnalyticsLogic(ctx, s.svcCtx)
return l.GetUserAnalytics(in)
}
+34 -3
View File
@@ -1,13 +1,44 @@
package svc package svc
import "sundynix-micro-go/app/radio/rpc/internal/config" import (
radioModel "sundynix-micro-go/app/radio/model"
"sundynix-micro-go/app/radio/rpc/internal/config"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type ServiceContext struct { type ServiceContext struct {
Config config.Config Config config.Config
DB *gorm.DB
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{ db, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
Config: c, if err != nil {
logx.Errorf("连接数据库失败: %v", err)
panic(err)
} }
if err := db.AutoMigrate(
&radioModel.SundynixRadioUserProfile{},
&radioModel.SundynixRadioCategory{},
&radioModel.SundynixRadioChannel{},
&radioModel.SundynixRadioProgram{},
&radioModel.SundynixRadioVoice{},
&radioModel.SundynixRadioLike{},
&radioModel.SundynixRadioFavorite{},
&radioModel.SundynixRadioComment{},
&radioModel.SundynixRadioHistory{},
&radioModel.SundynixRadioSubscription{},
&radioModel.SundynixRadioSubscriptionOrder{},
&radioModel.SundynixRadioPayNotify{},
&radioModel.SundynixRadioVipConfig{},
&radioModel.SundynixRadioListenLog{},
); err != nil {
logx.Errorf("数据库迁移失败: %v", err)
}
return &ServiceContext{Config: c, DB: db}
} }
+308 -107
View File
@@ -4,7 +4,23 @@ package radio;
option go_package = "./radio"; option go_package = "./radio";
// ========== 通用 ==========
message CommonResp {
int64 code = 1;
string msg = 2;
}
message IdReq {
string id = 1;
}
message IdsReq {
repeated string ids = 1;
}
// ========== 用户Profile ========== // ========== 用户Profile ==========
message RadioUserProfile { message RadioUserProfile {
string id = 1; string id = 1;
string userId = 2; string userId = 2;
@@ -14,26 +30,45 @@ message RadioUserProfile {
int64 vipExpireAt = 6; int64 vipExpireAt = 6;
int32 vipLevel = 7; int32 vipLevel = 7;
} }
message GetRadioUserProfileReq { string userId = 1; }
message GetRadioUserProfileResp { RadioUserProfile profile = 1; } message GetProfileReq {
string userId = 1;
}
// ========== 分类 ========== // ========== 分类 ==========
message CategoryInfo { message CategoryInfo {
string id = 1; string id = 1;
string name = 2; string name = 2;
string icon = 3; string icon = 3;
int32 sort = 4; int32 sort = 4;
} }
message CreateCategoryReq { string name = 1; string icon = 2; int32 sort = 3; }
message CreateCategoryResp { string id = 1; } message CategoryReq {
message UpdateCategoryReq { string id = 1; string name = 2; string icon = 3; int32 sort = 4; } string name = 1;
message UpdateCategoryResp {} string icon = 2;
message DeleteByIdsReq { repeated string ids = 1; } int32 sort = 3;
message DeleteResp {} }
message GetCategoryListReq { int32 current = 1; int32 pageSize = 2; }
message GetCategoryListResp { repeated CategoryInfo list = 1; int64 total = 2; } message CategoryUpdateReq {
string id = 1;
string name = 2;
string icon = 3;
int32 sort = 4;
}
message CategoryListResp {
repeated CategoryInfo list = 1;
int64 total = 2;
}
message CategoryListReq {
int32 current = 1;
int32 pageSize = 2;
}
// ========== 频道 ========== // ========== 频道 ==========
message ChannelInfo { message ChannelInfo {
string id = 1; string id = 1;
string categoryId = 2; string categoryId = 2;
@@ -48,28 +83,52 @@ message ChannelInfo {
string tags = 11; string tags = 11;
int32 sort = 12; int32 sort = 12;
int32 status = 13; int32 status = 13;
int64 createdAt = 14;
} }
message CreateChannelReq { message CreateChannelReq {
string categoryId = 1; string name = 2; string description = 3; string categoryId = 1;
int32 isFree = 4; int32 isVipOnly = 5; string name = 2;
int32 monthlyPrice = 6; int32 quarterlyPrice = 7; int32 annualPrice = 8; string description = 3;
string cover = 9; string tags = 10; int32 sort = 11; int32 isFree = 4;
int32 isVipOnly = 5;
int32 monthlyPrice = 6;
int32 quarterlyPrice = 7;
int32 annualPrice = 8;
string cover = 9;
string tags = 10;
int32 sort = 11;
} }
message CreateChannelResp { string id = 1; }
message UpdateChannelReq { message UpdateChannelReq {
string id = 1; string name = 2; string description = 3; string id = 1;
int32 isFree = 4; int32 isVipOnly = 5; string categoryId = 2;
int32 monthlyPrice = 6; int32 quarterlyPrice = 7; int32 annualPrice = 8; string name = 3;
string cover = 9; string tags = 10; int32 sort = 11; int32 status = 12; string description = 4;
int32 isFree = 5;
int32 isVipOnly = 6;
int32 monthlyPrice = 7;
int32 quarterlyPrice = 8;
int32 annualPrice = 9;
string cover = 10;
string tags = 11;
int32 sort = 12;
int32 status = 13;
}
message ChannelListReq {
int32 current = 1;
int32 pageSize = 2;
string categoryId = 3;
string userId = 4;
}
message ChannelListResp {
repeated ChannelInfo list = 1;
int64 total = 2;
} }
message UpdateChannelResp {}
message GetChannelListReq { int32 current = 1; int32 pageSize = 2; string categoryId = 3; string userId = 4; }
message GetChannelListResp { repeated ChannelInfo list = 1; int64 total = 2; }
message GetChannelDetailReq { string id = 1; string userId = 2; }
message GetChannelDetailResp { ChannelInfo channel = 1; }
// ========== 节目 ========== // ========== 节目 ==========
message ProgramInfo { message ProgramInfo {
string id = 1; string id = 1;
string channelId = 2; string channelId = 2;
@@ -84,113 +143,255 @@ message ProgramInfo {
int32 playCount = 11; int32 playCount = 11;
int32 likeCount = 12; int32 likeCount = 12;
int32 status = 13; int32 status = 13;
int64 createdAt = 14;
} }
message CreateProgramReq { message CreateProgramReq {
string channelId = 1; string title = 2; string description = 3; string channelId = 1;
string content = 4; string cover = 5; string tags = 6; string title = 2;
string description = 3;
string content = 4;
string cover = 5;
string tags = 6;
} }
message CreateProgramResp { string id = 1; }
message UpdateProgramReq { message UpdateProgramReq {
string id = 1; string title = 2; string description = 3; string id = 1;
string content = 4; string cover = 5; string audioId = 6; string channelId = 2;
int32 audioStatus = 7; int32 duration = 8; string tags = 9; int32 status = 10; string title = 3;
string description = 4;
string content = 5;
string cover = 6;
string audioId = 7;
int32 audioStatus = 8;
int32 duration = 9;
string tags = 10;
int32 status = 11;
}
message ProgramListReq {
int32 current = 1;
int32 pageSize = 2;
string channelId = 3;
string userId = 4;
}
message ProgramListResp {
repeated ProgramInfo list = 1;
int64 total = 2;
} }
message UpdateProgramResp {}
message GetProgramListReq { int32 current = 1; int32 pageSize = 2; string channelId = 3; string userId = 4; }
message GetProgramListResp { repeated ProgramInfo list = 1; int64 total = 2; }
message GetProgramDetailReq { string id = 1; string userId = 2; }
message GetProgramDetailResp { ProgramInfo program = 1; }
// ========== 音色 ========== // ========== 音色 ==========
message VoiceInfo { message VoiceInfo {
string id = 1; string speakerId = 2; string name = 3; string id = 1;
string description = 4; string gender = 5; string icon = 6; string speakerId = 2;
string audioId = 7; int32 sort = 8; int32 status = 9; string name = 3;
int32 isDefault = 10; int32 useCount = 11; string description = 4;
string gender = 5;
string icon = 6;
string audioId = 7;
int32 sort = 8;
int32 status = 9;
int32 isDefault = 10;
}
message CreateVoiceReq {
string speakerId = 1;
string name = 2;
string description = 3;
string gender = 4;
string icon = 5;
string audioId = 6;
int32 sort = 7;
int32 isDefault = 8;
}
message UpdateVoiceReq {
string id = 1;
string speakerId = 2;
string name = 3;
string description = 4;
string gender = 5;
string icon = 6;
string audioId = 7;
int32 sort = 8;
int32 status = 9;
int32 isDefault = 10;
}
message VoiceListReq {
int32 current = 1;
int32 pageSize = 2;
}
message VoiceListResp {
repeated VoiceInfo list = 1;
int64 total = 2;
} }
message CreateVoiceReq { string speakerId = 1; string name = 2; string description = 3; string gender = 4; string icon = 5; string audioId = 6; int32 sort = 7; int32 isDefault = 8; }
message CreateVoiceResp { string id = 1; }
message UpdateVoiceReq { string id = 1; string name = 2; string description = 3; string icon = 4; string audioId = 5; int32 sort = 6; int32 status = 7; int32 isDefault = 8; }
message UpdateVoiceResp {}
message GetVoiceListReq { int32 current = 1; int32 pageSize = 2; }
message GetVoiceListResp { repeated VoiceInfo list = 1; int64 total = 2; }
// ========== 互动 ========== // ========== 互动 ==========
message ToggleLikeReq { string userId = 1; string programId = 2; }
message ToggleLikeResp { bool liked = 1; }
message ToggleFavoriteReq { string userId = 1; string programId = 2; }
message ToggleFavoriteResp { bool favorited = 1; }
message CommentReq { string userId = 1; string programId = 2; string content = 3; string parentId = 4; }
message CommentResp {}
message RecordHistoryReq { string userId = 1; string programId = 2; int32 duration = 3; }
message RecordHistoryResp {}
message GetHistoryListReq { string userId = 1; int32 current = 2; int32 pageSize = 3; }
message GetHistoryListResp { repeated ProgramInfo list = 1; int64 total = 2; }
message GetFavoriteListReq { string userId = 1; int32 current = 2; int32 pageSize = 3; }
message GetFavoriteListResp { repeated ProgramInfo list = 1; int64 total = 2; }
// ========== 订阅/支付 ========== message ToggleLikeReq {
message SubscriptionInfo { string userId = 1;
string id = 1; string userId = 2; string channelId = 3; string programId = 2;
int64 expiredAt = 4; int32 status = 5; }
message ToggleFavoriteReq {
string userId = 1;
string programId = 2;
}
message CommentReq {
string userId = 1;
string programId = 2;
string content = 3;
string parentId = 4;
}
message RecordHistoryReq {
string userId = 1;
string programId = 2;
int32 duration = 3;
}
message InteractionListReq {
string userId = 1;
int32 current = 2;
int32 pageSize = 3;
}
message FavoriteListResp {
repeated ProgramInfo list = 1;
int64 total = 2;
}
message HistoryListResp {
repeated ProgramInfo list = 1;
int64 total = 2;
}
// ========== 订阅/VIP ==========
message SubscriptionInfo {
string id = 1;
string channelId = 2;
int64 expiredAt = 3;
int32 status = 4;
}
message SubscriptionListReq {
string userId = 1;
}
message SubscriptionListResp {
repeated SubscriptionInfo list = 1;
}
message CreatePayOrderReq {
string userId = 1;
string channelId = 2;
string planType = 3;
}
message CreatePayOrderResp {
string orderNo = 1;
string prepayId = 2;
} }
message GetMySubscriptionsReq { string userId = 1; }
message GetMySubscriptionsResp { repeated SubscriptionInfo list = 1; }
message CreatePayOrderReq { string userId = 1; string channelId = 2; string planType = 3; }
message CreatePayOrderResp { string orderNo = 1; string prepayId = 2; }
// ========== VIP ==========
message VipConfigInfo { message VipConfigInfo {
string id = 1; string name = 2; string planType = 3; string id = 1;
int32 price = 4; int32 originalPrice = 5; int32 duration = 6; string name = 2;
string planType = 3;
int32 price = 4;
int32 originalPrice = 5;
int32 duration = 6;
string desc = 7; string desc = 7;
} }
message GetVipConfigListReq { int32 current = 1; int32 pageSize = 2; }
message GetVipConfigListResp { repeated VipConfigInfo list = 1; int64 total = 2; }
message GetMyVipInfoReq { string userId = 1; }
message GetMyVipInfoResp { RadioUserProfile profile = 1; }
// ========== 通用 ========== message VipConfigListResp {
message Empty {} repeated VipConfigInfo list = 1;
}
// ========== 数据分析 ==========
message AnalyticsReq {
string startDate = 1;
string endDate = 2;
}
message AnalyticsOverviewResp {
int64 totalUsers = 1;
int64 totalPlays = 2;
int64 totalChannels = 3;
int64 totalPrograms = 4;
}
message ChannelAnalyticsResp {
repeated ChannelAnalyticsItem list = 1;
}
message ChannelAnalyticsItem {
string channelId = 1;
string channelName = 2;
int64 playCount = 3;
int64 likeCount = 4;
int64 subscriberCount = 5;
}
message UserAnalyticsResp {
int64 newUsers = 1;
int64 activeUsers = 2;
int64 vipUsers = 3;
}
// ========== 服务定义 ========== // ========== 服务定义 ==========
service RadioService { service RadioService {
// 用户 // 用户Profile
rpc GetRadioUserProfile(GetRadioUserProfileReq) returns (GetRadioUserProfileResp); rpc GetUserProfile(GetProfileReq) returns (RadioUserProfile);
// 分类 // 分类
rpc CreateCategory(CreateCategoryReq) returns (CreateCategoryResp); rpc CreateCategory(CategoryReq) returns (CommonResp);
rpc UpdateCategory(UpdateCategoryReq) returns (UpdateCategoryResp); rpc UpdateCategory(CategoryUpdateReq) returns (CommonResp);
rpc DeleteCategory(DeleteByIdsReq) returns (DeleteResp); rpc DeleteCategory(IdsReq) returns (CommonResp);
rpc GetCategoryList(GetCategoryListReq) returns (GetCategoryListResp); rpc GetCategoryList(CategoryListReq) returns (CategoryListResp);
// 频道 // 频道
rpc CreateChannel(CreateChannelReq) returns (CreateChannelResp); rpc CreateChannel(CreateChannelReq) returns (CommonResp);
rpc UpdateChannel(UpdateChannelReq) returns (UpdateChannelResp); rpc UpdateChannel(UpdateChannelReq) returns (CommonResp);
rpc DeleteChannel(DeleteByIdsReq) returns (DeleteResp); rpc DeleteChannel(IdsReq) returns (CommonResp);
rpc GetChannelList(GetChannelListReq) returns (GetChannelListResp); rpc GetChannelList(ChannelListReq) returns (ChannelListResp);
rpc GetChannelDetail(GetChannelDetailReq) returns (GetChannelDetailResp); rpc GetChannelDetail(IdReq) returns (ChannelInfo);
// 节目 // 节目
rpc CreateProgram(CreateProgramReq) returns (CreateProgramResp); rpc CreateProgram(CreateProgramReq) returns (CommonResp);
rpc UpdateProgram(UpdateProgramReq) returns (UpdateProgramResp); rpc UpdateProgram(UpdateProgramReq) returns (CommonResp);
rpc DeleteProgram(DeleteByIdsReq) returns (DeleteResp); rpc DeleteProgram(IdsReq) returns (CommonResp);
rpc GetProgramList(GetProgramListReq) returns (GetProgramListResp); rpc GetProgramList(ProgramListReq) returns (ProgramListResp);
rpc GetProgramDetail(GetProgramDetailReq) returns (GetProgramDetailResp); rpc GetProgramDetail(IdReq) returns (ProgramInfo);
// 音色 // 音色
rpc CreateVoice(CreateVoiceReq) returns (CreateVoiceResp); rpc CreateVoice(CreateVoiceReq) returns (CommonResp);
rpc UpdateVoice(UpdateVoiceReq) returns (UpdateVoiceResp); rpc UpdateVoice(UpdateVoiceReq) returns (CommonResp);
rpc DeleteVoice(DeleteByIdsReq) returns (DeleteResp); rpc DeleteVoice(IdsReq) returns (CommonResp);
rpc GetVoiceList(GetVoiceListReq) returns (GetVoiceListResp); rpc GetVoiceList(VoiceListReq) returns (VoiceListResp);
// 互动 // 互动
rpc ToggleLike(ToggleLikeReq) returns (ToggleLikeResp); rpc ToggleLike(ToggleLikeReq) returns (CommonResp);
rpc ToggleFavorite(ToggleFavoriteReq) returns (ToggleFavoriteResp); rpc ToggleFavorite(ToggleFavoriteReq) returns (CommonResp);
rpc CommentProgram(CommentReq) returns (CommentResp); rpc CommentProgram(CommentReq) returns (CommonResp);
rpc RecordHistory(RecordHistoryReq) returns (RecordHistoryResp); rpc RecordHistory(RecordHistoryReq) returns (CommonResp);
rpc GetHistoryList(GetHistoryListReq) returns (GetHistoryListResp); rpc GetFavoriteList(InteractionListReq) returns (FavoriteListResp);
rpc GetFavoriteList(GetFavoriteListReq) returns (GetFavoriteListResp); rpc GetHistoryList(InteractionListReq) returns (HistoryListResp);
// 订阅
rpc GetMySubscriptions(GetMySubscriptionsReq) returns (GetMySubscriptionsResp); // 订阅/VIP
rpc GetMySubscriptions(SubscriptionListReq) returns (SubscriptionListResp);
rpc CreatePayOrder(CreatePayOrderReq) returns (CreatePayOrderResp); rpc CreatePayOrder(CreatePayOrderReq) returns (CreatePayOrderResp);
// VIP rpc GetVipConfigList(IdReq) returns (VipConfigListResp);
rpc GetVipConfigList(GetVipConfigListReq) returns (GetVipConfigListResp); rpc GetMyVipInfo(GetProfileReq) returns (RadioUserProfile);
rpc GetMyVipInfo(GetMyVipInfoReq) returns (GetMyVipInfoResp);
// 数据分析
rpc GetAnalyticsOverview(AnalyticsReq) returns (AnalyticsOverviewResp);
rpc GetChannelAnalytics(AnalyticsReq) returns (ChannelAnalyticsResp);
rpc GetUserAnalytics(AnalyticsReq) returns (UserAnalyticsResp);
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+110 -108
View File
@@ -14,105 +14,92 @@ import (
) )
type ( type (
AnalyticsOverviewResp = radio.AnalyticsOverviewResp
AnalyticsReq = radio.AnalyticsReq
CategoryInfo = radio.CategoryInfo CategoryInfo = radio.CategoryInfo
CategoryListReq = radio.CategoryListReq
CategoryListResp = radio.CategoryListResp
CategoryReq = radio.CategoryReq
CategoryUpdateReq = radio.CategoryUpdateReq
ChannelAnalyticsItem = radio.ChannelAnalyticsItem
ChannelAnalyticsResp = radio.ChannelAnalyticsResp
ChannelInfo = radio.ChannelInfo ChannelInfo = radio.ChannelInfo
ChannelListReq = radio.ChannelListReq
ChannelListResp = radio.ChannelListResp
CommentReq = radio.CommentReq CommentReq = radio.CommentReq
CommentResp = radio.CommentResp CommonResp = radio.CommonResp
CreateCategoryReq = radio.CreateCategoryReq
CreateCategoryResp = radio.CreateCategoryResp
CreateChannelReq = radio.CreateChannelReq CreateChannelReq = radio.CreateChannelReq
CreateChannelResp = radio.CreateChannelResp
CreatePayOrderReq = radio.CreatePayOrderReq CreatePayOrderReq = radio.CreatePayOrderReq
CreatePayOrderResp = radio.CreatePayOrderResp CreatePayOrderResp = radio.CreatePayOrderResp
CreateProgramReq = radio.CreateProgramReq CreateProgramReq = radio.CreateProgramReq
CreateProgramResp = radio.CreateProgramResp
CreateVoiceReq = radio.CreateVoiceReq CreateVoiceReq = radio.CreateVoiceReq
CreateVoiceResp = radio.CreateVoiceResp FavoriteListResp = radio.FavoriteListResp
DeleteByIdsReq = radio.DeleteByIdsReq GetProfileReq = radio.GetProfileReq
DeleteResp = radio.DeleteResp HistoryListResp = radio.HistoryListResp
Empty = radio.Empty IdReq = radio.IdReq
GetCategoryListReq = radio.GetCategoryListReq IdsReq = radio.IdsReq
GetCategoryListResp = radio.GetCategoryListResp InteractionListReq = radio.InteractionListReq
GetChannelDetailReq = radio.GetChannelDetailReq
GetChannelDetailResp = radio.GetChannelDetailResp
GetChannelListReq = radio.GetChannelListReq
GetChannelListResp = radio.GetChannelListResp
GetFavoriteListReq = radio.GetFavoriteListReq
GetFavoriteListResp = radio.GetFavoriteListResp
GetHistoryListReq = radio.GetHistoryListReq
GetHistoryListResp = radio.GetHistoryListResp
GetMySubscriptionsReq = radio.GetMySubscriptionsReq
GetMySubscriptionsResp = radio.GetMySubscriptionsResp
GetMyVipInfoReq = radio.GetMyVipInfoReq
GetMyVipInfoResp = radio.GetMyVipInfoResp
GetProgramDetailReq = radio.GetProgramDetailReq
GetProgramDetailResp = radio.GetProgramDetailResp
GetProgramListReq = radio.GetProgramListReq
GetProgramListResp = radio.GetProgramListResp
GetRadioUserProfileReq = radio.GetRadioUserProfileReq
GetRadioUserProfileResp = radio.GetRadioUserProfileResp
GetVipConfigListReq = radio.GetVipConfigListReq
GetVipConfigListResp = radio.GetVipConfigListResp
GetVoiceListReq = radio.GetVoiceListReq
GetVoiceListResp = radio.GetVoiceListResp
ProgramInfo = radio.ProgramInfo ProgramInfo = radio.ProgramInfo
ProgramListReq = radio.ProgramListReq
ProgramListResp = radio.ProgramListResp
RadioUserProfile = radio.RadioUserProfile RadioUserProfile = radio.RadioUserProfile
RecordHistoryReq = radio.RecordHistoryReq RecordHistoryReq = radio.RecordHistoryReq
RecordHistoryResp = radio.RecordHistoryResp
SubscriptionInfo = radio.SubscriptionInfo SubscriptionInfo = radio.SubscriptionInfo
SubscriptionListReq = radio.SubscriptionListReq
SubscriptionListResp = radio.SubscriptionListResp
ToggleFavoriteReq = radio.ToggleFavoriteReq ToggleFavoriteReq = radio.ToggleFavoriteReq
ToggleFavoriteResp = radio.ToggleFavoriteResp
ToggleLikeReq = radio.ToggleLikeReq ToggleLikeReq = radio.ToggleLikeReq
ToggleLikeResp = radio.ToggleLikeResp
UpdateCategoryReq = radio.UpdateCategoryReq
UpdateCategoryResp = radio.UpdateCategoryResp
UpdateChannelReq = radio.UpdateChannelReq UpdateChannelReq = radio.UpdateChannelReq
UpdateChannelResp = radio.UpdateChannelResp
UpdateProgramReq = radio.UpdateProgramReq UpdateProgramReq = radio.UpdateProgramReq
UpdateProgramResp = radio.UpdateProgramResp
UpdateVoiceReq = radio.UpdateVoiceReq UpdateVoiceReq = radio.UpdateVoiceReq
UpdateVoiceResp = radio.UpdateVoiceResp UserAnalyticsResp = radio.UserAnalyticsResp
VipConfigInfo = radio.VipConfigInfo VipConfigInfo = radio.VipConfigInfo
VipConfigListResp = radio.VipConfigListResp
VoiceInfo = radio.VoiceInfo VoiceInfo = radio.VoiceInfo
VoiceListReq = radio.VoiceListReq
VoiceListResp = radio.VoiceListResp
RadioService interface { RadioService interface {
// 用户 // 用户Profile
GetRadioUserProfile(ctx context.Context, in *GetRadioUserProfileReq, opts ...grpc.CallOption) (*GetRadioUserProfileResp, error) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*RadioUserProfile, error)
// 分类 // 分类
CreateCategory(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*CreateCategoryResp, error) CreateCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateCategory(ctx context.Context, in *UpdateCategoryReq, opts ...grpc.CallOption) (*UpdateCategoryResp, error) UpdateCategory(ctx context.Context, in *CategoryUpdateReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteCategory(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) DeleteCategory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetCategoryList(ctx context.Context, in *GetCategoryListReq, opts ...grpc.CallOption) (*GetCategoryListResp, error) GetCategoryList(ctx context.Context, in *CategoryListReq, opts ...grpc.CallOption) (*CategoryListResp, error)
// 频道 // 频道
CreateChannel(ctx context.Context, in *CreateChannelReq, opts ...grpc.CallOption) (*CreateChannelResp, error) CreateChannel(ctx context.Context, in *CreateChannelReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateChannel(ctx context.Context, in *UpdateChannelReq, opts ...grpc.CallOption) (*UpdateChannelResp, error) UpdateChannel(ctx context.Context, in *UpdateChannelReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteChannel(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) DeleteChannel(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetChannelList(ctx context.Context, in *GetChannelListReq, opts ...grpc.CallOption) (*GetChannelListResp, error) GetChannelList(ctx context.Context, in *ChannelListReq, opts ...grpc.CallOption) (*ChannelListResp, error)
GetChannelDetail(ctx context.Context, in *GetChannelDetailReq, opts ...grpc.CallOption) (*GetChannelDetailResp, error) GetChannelDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ChannelInfo, error)
// 节目 // 节目
CreateProgram(ctx context.Context, in *CreateProgramReq, opts ...grpc.CallOption) (*CreateProgramResp, error) CreateProgram(ctx context.Context, in *CreateProgramReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateProgram(ctx context.Context, in *UpdateProgramReq, opts ...grpc.CallOption) (*UpdateProgramResp, error) UpdateProgram(ctx context.Context, in *UpdateProgramReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteProgram(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) DeleteProgram(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetProgramList(ctx context.Context, in *GetProgramListReq, opts ...grpc.CallOption) (*GetProgramListResp, error) GetProgramList(ctx context.Context, in *ProgramListReq, opts ...grpc.CallOption) (*ProgramListResp, error)
GetProgramDetail(ctx context.Context, in *GetProgramDetailReq, opts ...grpc.CallOption) (*GetProgramDetailResp, error) GetProgramDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ProgramInfo, error)
// 音色 // 音色
CreateVoice(ctx context.Context, in *CreateVoiceReq, opts ...grpc.CallOption) (*CreateVoiceResp, error) CreateVoice(ctx context.Context, in *CreateVoiceReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateVoice(ctx context.Context, in *UpdateVoiceReq, opts ...grpc.CallOption) (*UpdateVoiceResp, error) UpdateVoice(ctx context.Context, in *UpdateVoiceReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteVoice(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) DeleteVoice(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetVoiceList(ctx context.Context, in *GetVoiceListReq, opts ...grpc.CallOption) (*GetVoiceListResp, error) GetVoiceList(ctx context.Context, in *VoiceListReq, opts ...grpc.CallOption) (*VoiceListResp, error)
// 互动 // 互动
ToggleLike(ctx context.Context, in *ToggleLikeReq, opts ...grpc.CallOption) (*ToggleLikeResp, error) ToggleLike(ctx context.Context, in *ToggleLikeReq, opts ...grpc.CallOption) (*CommonResp, error)
ToggleFavorite(ctx context.Context, in *ToggleFavoriteReq, opts ...grpc.CallOption) (*ToggleFavoriteResp, error) ToggleFavorite(ctx context.Context, in *ToggleFavoriteReq, opts ...grpc.CallOption) (*CommonResp, error)
CommentProgram(ctx context.Context, in *CommentReq, opts ...grpc.CallOption) (*CommentResp, error) CommentProgram(ctx context.Context, in *CommentReq, opts ...grpc.CallOption) (*CommonResp, error)
RecordHistory(ctx context.Context, in *RecordHistoryReq, opts ...grpc.CallOption) (*RecordHistoryResp, error) RecordHistory(ctx context.Context, in *RecordHistoryReq, opts ...grpc.CallOption) (*CommonResp, error)
GetHistoryList(ctx context.Context, in *GetHistoryListReq, opts ...grpc.CallOption) (*GetHistoryListResp, error) GetFavoriteList(ctx context.Context, in *InteractionListReq, opts ...grpc.CallOption) (*FavoriteListResp, error)
GetFavoriteList(ctx context.Context, in *GetFavoriteListReq, opts ...grpc.CallOption) (*GetFavoriteListResp, error) GetHistoryList(ctx context.Context, in *InteractionListReq, opts ...grpc.CallOption) (*HistoryListResp, error)
// 订阅 // 订阅/VIP
GetMySubscriptions(ctx context.Context, in *GetMySubscriptionsReq, opts ...grpc.CallOption) (*GetMySubscriptionsResp, error) GetMySubscriptions(ctx context.Context, in *SubscriptionListReq, opts ...grpc.CallOption) (*SubscriptionListResp, error)
CreatePayOrder(ctx context.Context, in *CreatePayOrderReq, opts ...grpc.CallOption) (*CreatePayOrderResp, error) CreatePayOrder(ctx context.Context, in *CreatePayOrderReq, opts ...grpc.CallOption) (*CreatePayOrderResp, error)
// VIP GetVipConfigList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*VipConfigListResp, error)
GetVipConfigList(ctx context.Context, in *GetVipConfigListReq, opts ...grpc.CallOption) (*GetVipConfigListResp, error) GetMyVipInfo(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*RadioUserProfile, error)
GetMyVipInfo(ctx context.Context, in *GetMyVipInfoReq, opts ...grpc.CallOption) (*GetMyVipInfoResp, error) // 数据分析
GetAnalyticsOverview(ctx context.Context, in *AnalyticsReq, opts ...grpc.CallOption) (*AnalyticsOverviewResp, error)
GetChannelAnalytics(ctx context.Context, in *AnalyticsReq, opts ...grpc.CallOption) (*ChannelAnalyticsResp, error)
GetUserAnalytics(ctx context.Context, in *AnalyticsReq, opts ...grpc.CallOption) (*UserAnalyticsResp, error)
} }
defaultRadioService struct { defaultRadioService struct {
@@ -126,139 +113,139 @@ func NewRadioService(cli zrpc.Client) RadioService {
} }
} }
// 用户 // 用户Profile
func (m *defaultRadioService) GetRadioUserProfile(ctx context.Context, in *GetRadioUserProfileReq, opts ...grpc.CallOption) (*GetRadioUserProfileResp, error) { func (m *defaultRadioService) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*RadioUserProfile, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetRadioUserProfile(ctx, in, opts...) return client.GetUserProfile(ctx, in, opts...)
} }
// 分类 // 分类
func (m *defaultRadioService) CreateCategory(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*CreateCategoryResp, error) { func (m *defaultRadioService) CreateCategory(ctx context.Context, in *CategoryReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.CreateCategory(ctx, in, opts...) return client.CreateCategory(ctx, in, opts...)
} }
func (m *defaultRadioService) UpdateCategory(ctx context.Context, in *UpdateCategoryReq, opts ...grpc.CallOption) (*UpdateCategoryResp, error) { func (m *defaultRadioService) UpdateCategory(ctx context.Context, in *CategoryUpdateReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.UpdateCategory(ctx, in, opts...) return client.UpdateCategory(ctx, in, opts...)
} }
func (m *defaultRadioService) DeleteCategory(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) { func (m *defaultRadioService) DeleteCategory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.DeleteCategory(ctx, in, opts...) return client.DeleteCategory(ctx, in, opts...)
} }
func (m *defaultRadioService) GetCategoryList(ctx context.Context, in *GetCategoryListReq, opts ...grpc.CallOption) (*GetCategoryListResp, error) { func (m *defaultRadioService) GetCategoryList(ctx context.Context, in *CategoryListReq, opts ...grpc.CallOption) (*CategoryListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetCategoryList(ctx, in, opts...) return client.GetCategoryList(ctx, in, opts...)
} }
// 频道 // 频道
func (m *defaultRadioService) CreateChannel(ctx context.Context, in *CreateChannelReq, opts ...grpc.CallOption) (*CreateChannelResp, error) { func (m *defaultRadioService) CreateChannel(ctx context.Context, in *CreateChannelReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.CreateChannel(ctx, in, opts...) return client.CreateChannel(ctx, in, opts...)
} }
func (m *defaultRadioService) UpdateChannel(ctx context.Context, in *UpdateChannelReq, opts ...grpc.CallOption) (*UpdateChannelResp, error) { func (m *defaultRadioService) UpdateChannel(ctx context.Context, in *UpdateChannelReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.UpdateChannel(ctx, in, opts...) return client.UpdateChannel(ctx, in, opts...)
} }
func (m *defaultRadioService) DeleteChannel(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) { func (m *defaultRadioService) DeleteChannel(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.DeleteChannel(ctx, in, opts...) return client.DeleteChannel(ctx, in, opts...)
} }
func (m *defaultRadioService) GetChannelList(ctx context.Context, in *GetChannelListReq, opts ...grpc.CallOption) (*GetChannelListResp, error) { func (m *defaultRadioService) GetChannelList(ctx context.Context, in *ChannelListReq, opts ...grpc.CallOption) (*ChannelListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetChannelList(ctx, in, opts...) return client.GetChannelList(ctx, in, opts...)
} }
func (m *defaultRadioService) GetChannelDetail(ctx context.Context, in *GetChannelDetailReq, opts ...grpc.CallOption) (*GetChannelDetailResp, error) { func (m *defaultRadioService) GetChannelDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ChannelInfo, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetChannelDetail(ctx, in, opts...) return client.GetChannelDetail(ctx, in, opts...)
} }
// 节目 // 节目
func (m *defaultRadioService) CreateProgram(ctx context.Context, in *CreateProgramReq, opts ...grpc.CallOption) (*CreateProgramResp, error) { func (m *defaultRadioService) CreateProgram(ctx context.Context, in *CreateProgramReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.CreateProgram(ctx, in, opts...) return client.CreateProgram(ctx, in, opts...)
} }
func (m *defaultRadioService) UpdateProgram(ctx context.Context, in *UpdateProgramReq, opts ...grpc.CallOption) (*UpdateProgramResp, error) { func (m *defaultRadioService) UpdateProgram(ctx context.Context, in *UpdateProgramReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.UpdateProgram(ctx, in, opts...) return client.UpdateProgram(ctx, in, opts...)
} }
func (m *defaultRadioService) DeleteProgram(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) { func (m *defaultRadioService) DeleteProgram(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.DeleteProgram(ctx, in, opts...) return client.DeleteProgram(ctx, in, opts...)
} }
func (m *defaultRadioService) GetProgramList(ctx context.Context, in *GetProgramListReq, opts ...grpc.CallOption) (*GetProgramListResp, error) { func (m *defaultRadioService) GetProgramList(ctx context.Context, in *ProgramListReq, opts ...grpc.CallOption) (*ProgramListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetProgramList(ctx, in, opts...) return client.GetProgramList(ctx, in, opts...)
} }
func (m *defaultRadioService) GetProgramDetail(ctx context.Context, in *GetProgramDetailReq, opts ...grpc.CallOption) (*GetProgramDetailResp, error) { func (m *defaultRadioService) GetProgramDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ProgramInfo, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetProgramDetail(ctx, in, opts...) return client.GetProgramDetail(ctx, in, opts...)
} }
// 音色 // 音色
func (m *defaultRadioService) CreateVoice(ctx context.Context, in *CreateVoiceReq, opts ...grpc.CallOption) (*CreateVoiceResp, error) { func (m *defaultRadioService) CreateVoice(ctx context.Context, in *CreateVoiceReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.CreateVoice(ctx, in, opts...) return client.CreateVoice(ctx, in, opts...)
} }
func (m *defaultRadioService) UpdateVoice(ctx context.Context, in *UpdateVoiceReq, opts ...grpc.CallOption) (*UpdateVoiceResp, error) { func (m *defaultRadioService) UpdateVoice(ctx context.Context, in *UpdateVoiceReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.UpdateVoice(ctx, in, opts...) return client.UpdateVoice(ctx, in, opts...)
} }
func (m *defaultRadioService) DeleteVoice(ctx context.Context, in *DeleteByIdsReq, opts ...grpc.CallOption) (*DeleteResp, error) { func (m *defaultRadioService) DeleteVoice(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.DeleteVoice(ctx, in, opts...) return client.DeleteVoice(ctx, in, opts...)
} }
func (m *defaultRadioService) GetVoiceList(ctx context.Context, in *GetVoiceListReq, opts ...grpc.CallOption) (*GetVoiceListResp, error) { func (m *defaultRadioService) GetVoiceList(ctx context.Context, in *VoiceListReq, opts ...grpc.CallOption) (*VoiceListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetVoiceList(ctx, in, opts...) return client.GetVoiceList(ctx, in, opts...)
} }
// 互动 // 互动
func (m *defaultRadioService) ToggleLike(ctx context.Context, in *ToggleLikeReq, opts ...grpc.CallOption) (*ToggleLikeResp, error) { func (m *defaultRadioService) ToggleLike(ctx context.Context, in *ToggleLikeReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.ToggleLike(ctx, in, opts...) return client.ToggleLike(ctx, in, opts...)
} }
func (m *defaultRadioService) ToggleFavorite(ctx context.Context, in *ToggleFavoriteReq, opts ...grpc.CallOption) (*ToggleFavoriteResp, error) { func (m *defaultRadioService) ToggleFavorite(ctx context.Context, in *ToggleFavoriteReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.ToggleFavorite(ctx, in, opts...) return client.ToggleFavorite(ctx, in, opts...)
} }
func (m *defaultRadioService) CommentProgram(ctx context.Context, in *CommentReq, opts ...grpc.CallOption) (*CommentResp, error) { func (m *defaultRadioService) CommentProgram(ctx context.Context, in *CommentReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.CommentProgram(ctx, in, opts...) return client.CommentProgram(ctx, in, opts...)
} }
func (m *defaultRadioService) RecordHistory(ctx context.Context, in *RecordHistoryReq, opts ...grpc.CallOption) (*RecordHistoryResp, error) { func (m *defaultRadioService) RecordHistory(ctx context.Context, in *RecordHistoryReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.RecordHistory(ctx, in, opts...) return client.RecordHistory(ctx, in, opts...)
} }
func (m *defaultRadioService) GetHistoryList(ctx context.Context, in *GetHistoryListReq, opts ...grpc.CallOption) (*GetHistoryListResp, error) { func (m *defaultRadioService) GetFavoriteList(ctx context.Context, in *InteractionListReq, opts ...grpc.CallOption) (*FavoriteListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetHistoryList(ctx, in, opts...)
}
func (m *defaultRadioService) GetFavoriteList(ctx context.Context, in *GetFavoriteListReq, opts ...grpc.CallOption) (*GetFavoriteListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetFavoriteList(ctx, in, opts...) return client.GetFavoriteList(ctx, in, opts...)
} }
// 订阅 func (m *defaultRadioService) GetHistoryList(ctx context.Context, in *InteractionListReq, opts ...grpc.CallOption) (*HistoryListResp, error) {
func (m *defaultRadioService) GetMySubscriptions(ctx context.Context, in *GetMySubscriptionsReq, opts ...grpc.CallOption) (*GetMySubscriptionsResp, error) { client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetHistoryList(ctx, in, opts...)
}
// 订阅/VIP
func (m *defaultRadioService) GetMySubscriptions(ctx context.Context, in *SubscriptionListReq, opts ...grpc.CallOption) (*SubscriptionListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetMySubscriptions(ctx, in, opts...) return client.GetMySubscriptions(ctx, in, opts...)
} }
@@ -268,13 +255,28 @@ func (m *defaultRadioService) CreatePayOrder(ctx context.Context, in *CreatePayO
return client.CreatePayOrder(ctx, in, opts...) return client.CreatePayOrder(ctx, in, opts...)
} }
// VIP func (m *defaultRadioService) GetVipConfigList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*VipConfigListResp, error) {
func (m *defaultRadioService) GetVipConfigList(ctx context.Context, in *GetVipConfigListReq, opts ...grpc.CallOption) (*GetVipConfigListResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetVipConfigList(ctx, in, opts...) return client.GetVipConfigList(ctx, in, opts...)
} }
func (m *defaultRadioService) GetMyVipInfo(ctx context.Context, in *GetMyVipInfoReq, opts ...grpc.CallOption) (*GetMyVipInfoResp, error) { func (m *defaultRadioService) GetMyVipInfo(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*RadioUserProfile, error) {
client := radio.NewRadioServiceClient(m.cli.Conn()) client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetMyVipInfo(ctx, in, opts...) return client.GetMyVipInfo(ctx, in, opts...)
} }
// 数据分析
func (m *defaultRadioService) GetAnalyticsOverview(ctx context.Context, in *AnalyticsReq, opts ...grpc.CallOption) (*AnalyticsOverviewResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetAnalyticsOverview(ctx, in, opts...)
}
func (m *defaultRadioService) GetChannelAnalytics(ctx context.Context, in *AnalyticsReq, opts ...grpc.CallOption) (*ChannelAnalyticsResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetChannelAnalytics(ctx, in, opts...)
}
func (m *defaultRadioService) GetUserAnalytics(ctx context.Context, in *AnalyticsReq, opts ...grpc.CallOption) (*UserAnalyticsResp, error) {
client := radio.NewRadioServiceClient(m.cli.Conn())
return client.GetUserAnalytics(ctx, in, opts...)
}
+5 -6
View File
@@ -1,15 +1,14 @@
Name: system-api Name: system-api
Log:
Encoding: plain
Host: 0.0.0.0 Host: 0.0.0.0
Port: 9003 Port: 9003
Auth: Auth:
AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872 AccessSecret: sundynix-jwt-secret-2024
AccessExpire: 7200 AccessExpire: 604800
DB:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
# system-rpc 服务配置
SystemRpc: SystemRpc:
Etcd: Etcd:
Hosts: Hosts:
-3
View File
@@ -15,7 +15,4 @@ type Config struct {
AccessExpire int64 AccessExpire int64
} }
SystemRpc zrpc.RpcClientConf SystemRpc zrpc.RpcClientConf
DB struct {
DataSource string
}
} }

Some files were not shown because too many files have changed in this diff Show More