feat: minilogin改造

This commit is contained in:
Blizzard
2026-05-24 23:04:09 +08:00
parent 076ed1509b
commit da02247794
36 changed files with 3523 additions and 11653 deletions
@@ -13,6 +13,7 @@ import (
"sundynix-micro-go/app/auth/api/internal/svc" "sundynix-micro-go/app/auth/api/internal/svc"
"sundynix-micro-go/app/auth/api/internal/types" "sundynix-micro-go/app/auth/api/internal/types"
plantPb "sundynix-micro-go/app/plant/rpc/plant"
sysPb "sundynix-micro-go/app/system/rpc/system" sysPb "sundynix-micro-go/app/system/rpc/system"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
@@ -54,9 +55,20 @@ func (l *LoginByPhoneLogic) LoginByPhone(req *types.LoginByPhoneReq) (resp *type
_ = jsonData _ = jsonData
_ = url.Values{} _ = url.Values{}
// 2. 通过 user-rpc 查询用户 // 2. 通过 plant-rpc 和 system-rpc 获取用户
userResp, err := l.svcCtx.SystemRpc.GetUserByOpenId(l.ctx, &sysPb.GetUserByOpenIdReq{ if l.svcCtx.PlantRpc == nil {
return nil, fmt.Errorf("植物服务不可用")
}
profileResp, err := l.svcCtx.PlantRpc.FindOrCreateUserByOpenId(l.ctx, &plantPb.FindOrCreateUserByOpenIdReq{
OpenId: req.OpenId, OpenId: req.OpenId,
ClientId: req.ClientId,
})
if err != nil {
return nil, fmt.Errorf("微信登录解析失败")
}
userResp, err := l.svcCtx.SystemRpc.GetUserById(l.ctx, &sysPb.GetUserByIdReq{
Id: profileResp.UserId,
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("用户不存在") return nil, fmt.Errorf("用户不存在")
@@ -112,46 +112,39 @@ func (l *MiniLoginLogic) MiniLogin(req *types.MiniLoginReq) (resp *types.LoginRe
return nil, fmt.Errorf("openid为空") return nil, fmt.Errorf("openid为空")
} }
// 4. 通过 system-rpc 创建或获取基础用户 // 4. 根据 clientId 路由到对应业务服务,获取或注册其扩展用户并得到 userId
createResp, err := l.svcCtx.SystemRpc.CreateUser(l.ctx, &sysPb.CreateUserReq{ var userId string
Name: "", switch req.ClientId {
case ClientIdPlant:
if l.svcCtx.PlantRpc == nil {
return nil, fmt.Errorf("植物小程序服务不可用")
}
profileResp, err := l.svcCtx.PlantRpc.FindOrCreateUserByOpenId(l.ctx, &plantPb.FindOrCreateUserByOpenIdReq{
OpenId: wxResp.Openid, OpenId: wxResp.Openid,
SessionKey: wxResp.SessionKey, SessionKey: wxResp.SessionKey,
UnionId: wxResp.Unionid,
ClientId: req.ClientId, ClientId: req.ClientId,
}) })
if err != nil { if err != nil {
l.Errorf("创建用户失败: %v", err) l.Errorf("微信登录失败(植物服务):%v", err)
return nil, fmt.Errorf("登录失败")
}
userId = profileResp.UserId
default:
return nil, fmt.Errorf("暂不支持该客户端: %s", req.ClientId)
}
// 5. 根据 userId 获取系统核心基础用户信息
userResp, err := l.svcCtx.SystemRpc.GetUserById(l.ctx, &sysPb.GetUserByIdReq{
Id: userId,
})
if err != nil {
l.Errorf("获取系统基础用户信息失败: userId=%s, err=%v", userId, err)
return nil, fmt.Errorf("登录失败") return nil, fmt.Errorf("登录失败")
} }
userId := createResp.User.Id
// 5. 异步初始化各业务服务的用户扩展表
// 新增小程序:在 switch 里加一个 case 即可
go func(uid, clientId string) {
bgCtx := context.Background()
switch clientId {
case ClientIdPlant:
if l.svcCtx.PlantRpc == nil {
l.Errorf("[MiniLogin] PlantRpc 未配置,跳过 plant profile 初始化")
return
}
if _, err := l.svcCtx.PlantRpc.GetUserProfile(bgCtx, &plantPb.GetProfileReq{
UserId: uid,
}); err != nil {
l.Errorf("[MiniLogin] 初始化 plant profile 失败: userId=%s, err=%v", uid, err)
} else {
l.Infof("[MiniLogin] plant profile 初始化成功: userId=%s", uid)
}
// case ClientIdRadio:
// l.svcCtx.RadioRpc.GetUserProfile(bgCtx, &radioPb.GetProfileReq{UserId: uid})
default:
// 未知 clientId 或无需扩展表的场景,跳过
}
}(userId, req.ClientId)
// 6. 生成JWT Token // 6. 生成JWT Token
token, err := generateToken(l.svcCtx.Config.Auth.AccessSecret, l.svcCtx.Config.Auth.AccessExpire, createResp.User) token, err := generateToken(l.svcCtx.Config.Auth.AccessSecret, l.svcCtx.Config.Auth.AccessExpire, userResp.User)
if err != nil { if err != nil {
l.Errorf("生成Token失败: %v", err) l.Errorf("生成Token失败: %v", err)
return nil, fmt.Errorf("登录失败") return nil, fmt.Errorf("登录失败")
@@ -159,6 +152,6 @@ func (l *MiniLoginLogic) MiniLogin(req *types.MiniLoginReq) (resp *types.LoginRe
return &types.LoginResp{ return &types.LoginResp{
Token: token, Token: token,
UserInfo: createResp.User, UserInfo: userResp.User,
}, nil }, nil
} }
-4
View File
@@ -15,10 +15,6 @@ type SundynixUser struct {
Password string `gorm:"size:100;column:password" json:"-"` Password string `gorm:"size:100;column:password" json:"-"`
NickName string `gorm:"size:100;column:nick_name" json:"nickName"` NickName string `gorm:"size:100;column:nick_name" json:"nickName"`
Phone string `gorm:"size:20;column:phone" json:"phone"` Phone string `gorm:"size:20;column:phone" json:"phone"`
SessionKey string `gorm:"size:80;column:session_key" json:"-"`
UnionID string `gorm:"size:80;column:union_id" json:"unionId"`
OpenID string `gorm:"size:80;column:open_id;index" json:"openId"`
SaOpenID string `gorm:"size:80;column:sa_open_id" json:"saOpenId"`
AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"` AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"`
Gender int `gorm:"default:0;column:gender" json:"gender"` Gender int `gorm:"default:0;column:gender" json:"gender"`
LastLoginIP string `gorm:"size:20;column:last_login_ip" json:"lastLoginIp"` LastLoginIP string `gorm:"size:20;column:last_login_ip" json:"lastLoginIp"`
@@ -18,9 +18,11 @@ func GetLevelConfigListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
var req types.LevelConfigListReq var req types.LevelConfigListReq
if err := httpx.Parse(r, &req); err != nil { if err := httpx.Parse(r, &req); err != nil {
if r.Method != http.MethodGet {
response.Fail(w, err.Error()) response.Fail(w, err.Error())
return return
} }
}
l := config.NewGetLevelConfigListLogic(r.Context(), svcCtx) l := config.NewGetLevelConfigListLogic(r.Context(), svcCtx)
resp, err := l.GetLevelConfigList(&req) resp, err := l.GetLevelConfigList(&req)
@@ -3,11 +3,15 @@ package complete
import ( import (
"context" "context"
"fmt" "fmt"
"time"
"github.com/zeromicro/go-zero/core/logx" filePb "sundynix-micro-go/app/file/rpc/file"
"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"
plantPb "sundynix-micro-go/app/plant/rpc/plant" plantPb "sundynix-micro-go/app/plant/rpc/plant"
"github.com/zeromicro/go-zero/core/logx"
) )
type CompleteTaskLogic struct { type CompleteTaskLogic struct {
@@ -20,9 +24,93 @@ func NewCompleteTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comp
return &CompleteTaskLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} return &CompleteTaskLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
} }
func (l *CompleteTaskLogic) CompleteTask(req *types.CompleteTaskApiReq) (*plantPb.TaskCompletionResult, error) { func (l *CompleteTaskLogic) CompleteTask(req *types.CompleteTaskApiReq) (interface{}, error) {
userId := fmt.Sprintf("%v", l.ctx.Value("userId")) userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
return l.svcCtx.PlantRpc.CompleteTask(l.ctx, &plantPb.CompleteTaskReq{ resp, err := l.svcCtx.PlantRpc.CompleteTask(l.ctx, &plantPb.CompleteTaskReq{
UserId: userId, TaskId: req.TaskId, Remark: req.Remark, UserId: userId, TaskId: req.TaskId, Remark: req.Remark,
}) })
if err != nil {
return nil, err
}
// 1. 拼装当前等级详情(在升级时包含 perks 等完整字段,完美渲染等级弹窗)
var currentLevelData map[string]interface{}
if resp.CurrentLevel != nil {
currentLevelData = map[string]interface{}{
"id": resp.CurrentLevel.Id,
"level": resp.CurrentLevel.Level,
"title": resp.CurrentLevel.Title,
"minSunlight": resp.CurrentLevel.MinSunlight,
"perks": "",
}
// 若发生升级,自动利用 GORM 提取等级的 Perks 描述
if resp.IsLevelUp {
var lvl plantModel.LevelConfig
if errLvl := l.svcCtx.DB.Where("id = ?", resp.CurrentLevel.Id).First(&lvl).Error; errLvl == nil {
currentLevelData["perks"] = lvl.Perks
}
}
}
// 2. 拼装新获得徽章详情(包含 description 和 icon.url,完美渲染新徽章弹窗)
var newBadgeData map[string]interface{}
if resp.IsGetBadge && resp.NewBadge != nil {
var bc plantModel.BadgeConfig
if errBc := l.svcCtx.DB.Where("id = ?", resp.NewBadge.Id).First(&bc).Error; errBc == nil {
newBadgeData = map[string]interface{}{
"id": bc.ID,
"name": bc.Name,
"description": bc.Description,
"iconId": bc.IconID,
"dimension": bc.Dimension,
"groupId": bc.GroupID,
"tier": bc.Tier,
"targetAction": bc.TargetAction,
"threshold": bc.Threshold,
"comparator": bc.Comparator,
"rewardSunlight": bc.RewardSunlight,
"sort": bc.Sort,
"icon": nil,
}
// 跨微服务请求获取 Icon 图片 URL 等元数据
if bc.IconID != "" {
fileResp, errFile := l.svcCtx.FileRpc.GetFilesByIds(l.ctx, &filePb.GetFilesByIdsReq{Ids: []string{bc.IconID}})
if errFile == nil && fileResp != nil && len(fileResp.Files) > 0 {
f := fileResp.Files[0]
newBadgeData["icon"] = map[string]interface{}{
"id": f.Id,
"name": f.Name,
"url": f.Url,
"tag": f.Tag,
"key": f.Key,
"suffix": f.Suffix,
"md5": f.Md5,
"createdAt": time.Unix(f.CreatedAt, 0).Format(time.RFC3339),
}
}
}
} else {
// 兜底映射
newBadgeData = map[string]interface{}{
"id": resp.NewBadge.Id,
"name": resp.NewBadge.Name,
"dimension": resp.NewBadge.Dimension,
"tier": resp.NewBadge.Tier,
"rewardSunlight": resp.NewBadge.RewardSunlight,
"icon": nil,
}
}
}
// 3. 构建高度兼容的 JSON 响应,同时适配大小写驼峰字段
res := map[string]interface{}{
"isLevelUp": resp.IsLevelUp,
"currentLevel": currentLevelData,
"isGetBadge": resp.IsGetBadge,
"IsGetBadge": resp.IsGetBadge, // 兼容前端多处命名差异
"newBadge": newBadgeData,
"rewardSunlight": resp.RewardSunlight,
}
return res, nil
} }
@@ -2,10 +2,13 @@ package complete
import ( import (
"context" "context"
"time"
filePb "sundynix-micro-go/app/file/rpc/file"
"sundynix-micro-go/app/plant/api/internal/svc"
plantModel "sundynix-micro-go/app/plant/model"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"sundynix-micro-go/app/plant/api/internal/svc"
plantPb "sundynix-micro-go/app/plant/rpc/plant"
) )
type GetBadgeConfigTreeLogic struct { type GetBadgeConfigTreeLogic struct {
@@ -18,6 +21,142 @@ func NewGetBadgeConfigTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext)
return &GetBadgeConfigTreeLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} return &GetBadgeConfigTreeLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
} }
func (l *GetBadgeConfigTreeLogic) GetBadgeConfigTree() (*plantPb.BadgeConfigTreeResp, error) { func (l *GetBadgeConfigTreeLogic) GetBadgeConfigTree() (interface{}, error) {
return l.svcCtx.PlantRpc.GetBadgeConfigTree(l.ctx, &plantPb.IdReq{}) var allBadges []plantModel.BadgeConfig
err := l.svcCtx.DB.Order("dimension desc, group_id asc, tier asc, sort asc").Find(&allBadges).Error
if err != nil {
return nil, err
}
iconIds := make([]string, 0)
iconIdMap := make(map[string]bool)
for _, b := range allBadges {
if b.IconID != "" && !iconIdMap[b.IconID] {
iconIdMap[b.IconID] = true
iconIds = append(iconIds, b.IconID)
}
}
fileMap := make(map[string]map[string]interface{})
if len(iconIds) > 0 {
resp, err := l.svcCtx.FileRpc.GetFilesByIds(l.ctx, &filePb.GetFilesByIdsReq{Ids: iconIds})
if err == nil && resp != nil {
for _, f := range resp.Files {
fileMap[f.Id] = map[string]interface{}{
"id": f.Id,
"name": f.Name,
"url": f.Url,
"tag": f.Tag,
"key": f.Key,
"suffix": f.Suffix,
"md5": f.Md5,
"createdAt": time.Unix(f.CreatedAt, 0).Format(time.RFC3339),
}
}
}
}
dimLabelMap := map[string]string{
"PERSISTENCE": "勤勉成就",
"EXPERTISE": "专家成就",
"JOURNAL": "岁月记录",
"DISCOVERY": "探索发现",
}
groupLabelMap := map[string]string{
"water_master": "雨露均沾",
"alive_master": "长情陪伴",
"fert_master": "炼金术士",
"prune_master": "园艺理发师",
"repot_master": "乔迁之喜",
"doctor_master": "植物医生",
"photo_master": "光影捕手",
"night_owl": "守夜人",
}
dimOrder := []string{"PERSISTENCE", "EXPERTISE", "JOURNAL", "DISCOVERY"}
// Build dimension -> groupId -> badge list
tempMap := make(map[string]map[string][]map[string]interface{})
for _, b := range allBadges {
dim := b.Dimension
group := b.GroupID
badgeData := map[string]interface{}{
"id": b.ID,
"name": b.Name,
"description": b.Description,
"iconId": b.IconID,
"dimension": b.Dimension,
"groupId": b.GroupID,
"tier": b.Tier,
"targetAction": b.TargetAction,
"threshold": b.Threshold,
"comparator": b.Comparator,
"rewardSunlight": b.RewardSunlight,
"sort": b.Sort,
"createdAt": b.CreatedAt.Format("2006-01-02 15:04:05"),
}
if iconData, ok := fileMap[b.IconID]; ok {
badgeData["icon"] = iconData
} else {
badgeData["icon"] = nil
}
if tempMap[dim] == nil {
tempMap[dim] = make(map[string][]map[string]interface{})
}
tempMap[dim][group] = append(tempMap[dim][group], badgeData)
}
var tree []map[string]interface{}
for _, dimKey := range dimOrder {
if groupMap, exists := tempMap[dimKey]; exists {
var groupNodes []map[string]interface{}
for groupKey, badges := range groupMap {
gLabel := groupLabelMap[groupKey]
if gLabel == "" {
gLabel = groupKey
}
groupNodes = append(groupNodes, map[string]interface{}{
"groupId": groupKey,
"groupLabel": gLabel,
"badges": badges,
})
}
dLabel := dimLabelMap[dimKey]
if dLabel == "" {
dLabel = dimKey
}
tree = append(tree, map[string]interface{}{
"dimension": dimKey,
"label": dLabel,
"groups": groupNodes,
})
delete(tempMap, dimKey)
}
}
// Handle leftover dimensions
for dimKey, groupMap := range tempMap {
var groupNodes []map[string]interface{}
for groupKey, badges := range groupMap {
gLabel := groupLabelMap[groupKey]
if gLabel == "" {
gLabel = groupKey
}
groupNodes = append(groupNodes, map[string]interface{}{
"groupId": groupKey,
"groupLabel": gLabel,
"badges": badges,
})
}
tree = append(tree, map[string]interface{}{
"dimension": dimKey,
"label": dimKey,
"groups": groupNodes,
})
}
return tree, nil
} }
@@ -36,7 +36,18 @@ func (l *GetLevelConfigListLogic) GetLevelConfigList(req *types.LevelConfigListR
if err != nil { if err != nil {
return nil, err return nil, err
} }
resList := make([]map[string]interface{}, 0, len(result.List))
for _, item := range result.List {
resList = append(resList, map[string]interface{}{
"id": item.Id,
"level": item.Level,
"title": item.Title,
"minSunlight": item.MinSunlight, // Explicitly keep 0 values in JSON
"perks": item.Perks,
})
}
return map[string]interface{}{ return map[string]interface{}{
"list": result.List, "list": resList,
}, nil }, nil
} }
@@ -1,15 +1,16 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1
package userProfile package userProfile
import ( import (
"context" "context"
"fmt" "fmt"
"time"
filePb "sundynix-micro-go/app/file/rpc/file"
"sundynix-micro-go/app/plant/api/internal/svc"
plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/plant"
"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/rpc/plant"
) )
type GetUserProfileLogic struct { type GetUserProfileLogic struct {
@@ -33,5 +34,98 @@ func (l *GetUserProfileLogic) GetUserProfile() (interface{}, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result, nil
// 1. 获取 Avatar 详情
var avatarData map[string]interface{}
if result.AvatarId != "" {
avatarData = l.fetchAvatar(result.AvatarId)
}
// 2. 获取 Level 详情
var levelData map[string]interface{}
var lvl plantModel.LevelConfig
levelFound := false
if result.LevelId != "" {
if errLvl := l.svcCtx.DB.Where("id = ?", result.LevelId).First(&lvl).Error; errLvl == nil {
levelFound = true
}
}
// 如果没有在数据库中找到 level_id,或者 level_id 为空,根据用户 totalSunlight 动态查找最匹配的等级
if !levelFound {
var matchedLvl plantModel.LevelConfig
// 查找最匹配的等级:total_sunlight >= min_sunlight 中 level 最大的那一个
errLvl := l.svcCtx.DB.Order("level desc").Where("min_sunlight <= ?", result.TotalSunlight).First(&matchedLvl).Error
if errLvl == nil {
lvl = matchedLvl
levelFound = true
// 自动更新用户资料表的 level_id,保证后续一致性
l.svcCtx.DB.Model(&plantModel.UserProfile{}).Where("id = ?", result.Id).Update("level_id", matchedLvl.ID)
} else {
// 如果没有等级配置,使用 level = 1 的配置作为默认
var firstLvl plantModel.LevelConfig
if l.svcCtx.DB.Order("level asc").First(&firstLvl).Error == nil {
lvl = firstLvl
levelFound = true
l.svcCtx.DB.Model(&plantModel.UserProfile{}).Where("id = ?", result.Id).Update("level_id", firstLvl.ID)
}
}
}
if levelFound {
levelData = map[string]interface{}{
"id": lvl.ID,
"level": lvl.Level,
"title": lvl.Title,
"minSunlight": lvl.MinSunlight,
"perks": lvl.Perks,
"createdAt": lvl.CreatedAt.Format("2006-01-02 15:04:05"),
}
}
// 3. 构造兼容新旧版本的复合 JSON 数据
res := map[string]interface{}{
"id": result.Id,
"userId": result.UserId,
"nickName": result.NickName,
"nickname": result.NickName, // 兼容旧版 json tag
"avatarId": result.AvatarId,
"levelId": result.LevelId,
"currentSunlight": result.CurrentSunlight,
"totalSunlight": result.TotalSunlight,
"plantCount": result.PlantCount,
"careCount": result.CareCount,
"postCount": result.PostCount,
"waterCount": result.WaterCount,
"fertilizeCount": result.FertilizeCount,
"repotCount": result.RepotCount,
"pruneCount": result.PruneCount,
"photoCount": result.PhotoCount,
"avatar": avatarData,
"level": levelData,
}
return res, nil
}
func (l *GetUserProfileLogic) fetchAvatar(avatarId string) map[string]interface{} {
if avatarId == "" {
return nil
}
resp, err := l.svcCtx.FileRpc.GetFilesByIds(l.ctx, &filePb.GetFilesByIdsReq{Ids: []string{avatarId}})
if err != nil || resp == nil || len(resp.Files) == 0 {
return nil
}
f := resp.Files[0]
return map[string]interface{}{
"id": f.Id,
"name": f.Name,
"url": f.Url,
"tag": f.Tag,
"key": f.Key,
"suffix": f.Suffix,
"md5": f.Md5,
"createdAt": time.Unix(f.CreatedAt, 0).Format(time.RFC3339),
}
} }
+4
View File
@@ -14,6 +14,9 @@ type UserProfile struct {
model.BaseModel model.BaseModel
UserID string `gorm:"size:50;uniqueIndex;column:user_id" json:"userId"` UserID string `gorm:"size:50;uniqueIndex;column:user_id" json:"userId"`
MiniOpenID string `gorm:"size:80;column:mini_open_id" json:"miniOpenId"` MiniOpenID string `gorm:"size:80;column:mini_open_id" json:"miniOpenId"`
SessionKey string `gorm:"size:80;column:session_key" json:"sessionKey"`
UnionID string `gorm:"size:80;column:union_id" json:"unionId"`
SaOpenID string `gorm:"size:80;column:sa_open_id" json:"saOpenId"`
NickName string `gorm:"size:100;column:nick_name" json:"nickName"` NickName string `gorm:"size:100;column:nick_name" json:"nickName"`
AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"` AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"`
LevelID string `gorm:"size:50;column:level_id" json:"levelId"` LevelID string `gorm:"size:50;column:level_id" json:"levelId"`
@@ -302,6 +305,7 @@ type LevelConfig struct {
Title string `gorm:"size:50;column:title" json:"title"` Title string `gorm:"size:50;column:title" json:"title"`
MinSunlight int64 `gorm:"column:min_sunlight" json:"minSunlight"` MinSunlight int64 `gorm:"column:min_sunlight" json:"minSunlight"`
Perks string `gorm:"size:200;column:perks" json:"perks"` Perks string `gorm:"size:200;column:perks" json:"perks"`
Preserve string `gorm:"column:preserve" json:"preserve"`
} }
func (LevelConfig) TableName() string { return "sundynix_plant_level_config" } func (LevelConfig) TableName() string { return "sundynix_plant_level_config" }
+6
View File
@@ -10,3 +10,9 @@ Etcd:
DB: DB:
DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local DataSource: root:root@tcp(192.168.100.127:3307)/sundynix_micro_go?charset=utf8mb4&parseTime=True&loc=Local
SystemRpc:
Etcd:
Hosts:
- 192.168.100.127:2379
Key: system.rpc
+1
View File
@@ -7,4 +7,5 @@ type Config struct {
DB struct { DB struct {
DataSource string DataSource string
} }
SystemRpc zrpc.RpcClientConf
} }
@@ -0,0 +1,31 @@
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 CreateBannerLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateBannerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateBannerLogic {
return &CreateBannerLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// Banner
func (l *CreateBannerLogic) CreateBanner(in *plant.CreateBannerReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line
return &plant.CommonResp{}, nil
}
@@ -0,0 +1,30 @@
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 DeleteBannerLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeleteBannerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteBannerLogic {
return &DeleteBannerLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DeleteBannerLogic) DeleteBanner(in *plant.IdsReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line
return &plant.CommonResp{}, nil
}
@@ -0,0 +1,136 @@
package logic
import (
"context"
"errors"
"fmt"
plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/internal/svc"
"sundynix-micro-go/app/plant/rpc/plant"
sysPb "sundynix-micro-go/app/system/rpc/system"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
type FindOrCreateUserByOpenIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewFindOrCreateUserByOpenIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindOrCreateUserByOpenIdLogic {
return &FindOrCreateUserByOpenIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *FindOrCreateUserByOpenIdLogic) FindOrCreateUserByOpenId(in *plant.FindOrCreateUserByOpenIdReq) (*plant.PlantUserProfile, error) {
if in.OpenId == "" {
return nil, fmt.Errorf("openid 不能为空")
}
// 1. 根据 mini_open_id 查询植物用户扩展表
var profile plantModel.UserProfile
err := l.svcCtx.DB.Where("mini_open_id = ?", in.OpenId).First(&profile).Error
if err == nil {
// 1.1 用户已存在:如果 session_key 发生变化则进行更新
if in.SessionKey != "" && (in.SessionKey != profile.SessionKey || in.UnionId != profile.UnionID || in.SaOpenId != profile.SaOpenID) {
l.svcCtx.DB.Model(&profile).Updates(map[string]interface{}{
"session_key": in.SessionKey,
"union_id": in.UnionId,
"sa_open_id": in.SaOpenId,
})
}
return profileToProto(&profile), nil
}
// 2. 用户不存在:分步创建(先 System RPC 创建基础用户,再本地创建扩展用户)
if !errors.Is(err, gorm.ErrRecordNotFound) {
l.Errorf("[FindOrCreateUserByOpenId] 查询扩展表失败: openid=%s, err=%v", in.OpenId, err)
return nil, fmt.Errorf("系统繁忙,请稍后再试")
}
// 2.1 调用 System RPC 创建基础用户(遵守服务边界,不直接写 system 表)
createResp, err := l.svcCtx.SystemRpc.CreateUser(l.ctx, &sysPb.CreateUserReq{
ClientId: in.ClientId,
NickName: "园艺新手",
})
if err != nil {
l.Errorf("[FindOrCreateUserByOpenId] 调用 System RPC 创建基础用户失败: err=%v", err)
return nil, fmt.Errorf("注册用户失败")
}
userId := createResp.User.Id
l.Infof("[FindOrCreateUserByOpenId] ✅ System 基础用户创建成功: userId=%s", userId)
// 2.2 自动匹配初始等级 ID (获取首个等级,一般是 Level 1)
var firstLevel plantModel.LevelConfig
levelErr := l.svcCtx.DB.Order("level asc").First(&firstLevel).Error
levelID := ""
if levelErr == nil {
levelID = firstLevel.ID
}
// 2.3 本地事务创建应用专属扩展表
profile = plantModel.UserProfile{
UserID: userId,
MiniOpenID: in.OpenId,
SessionKey: in.SessionKey,
UnionID: in.UnionId,
SaOpenID: in.SaOpenId,
NickName: "园艺新手",
LevelID: levelID,
CurrentSunlight: 0,
TotalSunlight: 0,
}
if err = l.svcCtx.DB.Create(&profile).Error; err != nil {
l.Errorf("[FindOrCreateUserByOpenId] 创建用户扩展表失败: err=%v", err)
// 2.4 补偿回滚:删除已创建的 System 基础用户,避免孤儿记录
_, delErr := l.svcCtx.SystemRpc.DeleteUser(l.ctx, &sysPb.DeleteUserReq{
Ids: []string{userId},
})
if delErr != nil {
l.Errorf("[FindOrCreateUserByOpenId] ⚠️ 补偿删除基础用户失败: userId=%s, err=%v", userId, delErr)
// 即使补偿失败也返回原始错误,孤儿记录可通过后台定期清理
} else {
l.Infof("[FindOrCreateUserByOpenId] 补偿删除基础用户成功: userId=%s", userId)
}
return nil, fmt.Errorf("注册应用扩展失败")
}
l.Infof("[FindOrCreateUserByOpenId] ✅ 成功创建游客账户: userId=%s, openid=%s", userId, in.OpenId)
return profileToProto(&profile), nil
}
// profileToProto 将 model 转为 proto 响应
func profileToProto(p *plantModel.UserProfile) *plant.PlantUserProfile {
return &plant.PlantUserProfile{
Id: p.ID,
UserId: p.UserID,
NickName: p.NickName,
AvatarId: p.AvatarID,
LevelId: p.LevelID,
CurrentSunlight: p.CurrentSunlight,
TotalSunlight: p.TotalSunlight,
PlantCount: p.PlantCount,
CareCount: p.CareCount,
PostCount: p.PostCount,
WaterCount: p.WaterCount,
FertilizeCount: p.FertilizeCount,
RepotCount: p.RepotCount,
PruneCount: p.PruneCount,
PhotoCount: p.PhotoCount,
MiniOpenId: p.MiniOpenID,
SessionKey: p.SessionKey,
UnionId: p.UnionID,
SaOpenId: p.SaOpenID,
}
}
@@ -0,0 +1,30 @@
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 GetActiveBannerListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetActiveBannerListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetActiveBannerListLogic {
return &GetActiveBannerListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetActiveBannerListLogic) GetActiveBannerList(in *plant.PageReq) (*plant.BannerListResp, error) {
// todo: add your logic here and delete this line
return &plant.BannerListResp{}, nil
}
@@ -0,0 +1,30 @@
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 GetBannerListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetBannerListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetBannerListLogic {
return &GetBannerListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetBannerListLogic) GetBannerList(in *plant.BannerListReq) (*plant.BannerListResp, error) {
// todo: add your logic here and delete this line
return &plant.BannerListResp{}, nil
}
@@ -0,0 +1,31 @@
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 QuickCareLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewQuickCareLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QuickCareLogic {
return &QuickCareLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 快捷养护
func (l *QuickCareLogic) QuickCare(in *plant.QuickCareReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line
return &plant.CommonResp{}, nil
}
@@ -0,0 +1,30 @@
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 UpdateBannerLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateBannerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBannerLogic {
return &UpdateBannerLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *UpdateBannerLogic) UpdateBanner(in *plant.UpdateBannerReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line
return &plant.CommonResp{}, nil
}
@@ -18,244 +18,399 @@ type PlantServiceServer struct {
} }
func NewPlantServiceServer(svcCtx *svc.ServiceContext) *PlantServiceServer { func NewPlantServiceServer(svcCtx *svc.ServiceContext) *PlantServiceServer {
return &PlantServiceServer{svcCtx: svcCtx} return &PlantServiceServer{
svcCtx: svcCtx,
}
} }
// ---- 用户Profile ---- // 用户Profile
func (s *PlantServiceServer) GetUserProfile(ctx context.Context, in *plant.GetProfileReq) (*plant.PlantUserProfile, error) { func (s *PlantServiceServer) GetUserProfile(ctx context.Context, in *plant.GetProfileReq) (*plant.PlantUserProfile, error) {
return logic.NewGetUserProfileLogic(ctx, s.svcCtx).GetUserProfile(in) l := logic.NewGetUserProfileLogic(ctx, s.svcCtx)
return l.GetUserProfile(in)
} }
func (s *PlantServiceServer) FindOrCreateUserByOpenId(ctx context.Context, in *plant.FindOrCreateUserByOpenIdReq) (*plant.PlantUserProfile, error) {
l := logic.NewFindOrCreateUserByOpenIdLogic(ctx, s.svcCtx)
return l.FindOrCreateUserByOpenId(in)
}
func (s *PlantServiceServer) UpdateUserProfile(ctx context.Context, in *plant.UpdateProfileReq) (*plant.CommonResp, error) { func (s *PlantServiceServer) UpdateUserProfile(ctx context.Context, in *plant.UpdateProfileReq) (*plant.CommonResp, error) {
return logic.NewUpdateUserProfileLogic(ctx, s.svcCtx).UpdateUserProfile(in) l := logic.NewUpdateUserProfileLogic(ctx, s.svcCtx)
return l.UpdateUserProfile(in)
} }
func (s *PlantServiceServer) GetMyBadges(ctx context.Context, in *plant.GetProfileReq) (*plant.UserBadgeListResp, error) { func (s *PlantServiceServer) GetMyBadges(ctx context.Context, in *plant.GetProfileReq) (*plant.UserBadgeListResp, error) {
return logic.NewGetMyBadgesLogic(ctx, s.svcCtx).GetMyBadges(in) l := logic.NewGetMyBadgesLogic(ctx, s.svcCtx)
return l.GetMyBadges(in)
} }
func (s *PlantServiceServer) GetMyStars(ctx context.Context, in *plant.GetProfileReq) (*plant.UserStarListResp, error) { func (s *PlantServiceServer) GetMyStars(ctx context.Context, in *plant.GetProfileReq) (*plant.UserStarListResp, error) {
return logic.NewGetMyStarsLogic(ctx, s.svcCtx).GetMyStars(in) l := logic.NewGetMyStarsLogic(ctx, s.svcCtx)
return l.GetMyStars(in)
} }
// ---- 我的植物 ---- // 我的植物
func (s *PlantServiceServer) CreatePlant(ctx context.Context, in *plant.CreatePlantReq) (*plant.CommonResp, error) { func (s *PlantServiceServer) CreatePlant(ctx context.Context, in *plant.CreatePlantReq) (*plant.CommonResp, error) {
return logic.NewCreatePlantLogic(ctx, s.svcCtx).CreatePlant(in) l := logic.NewCreatePlantLogic(ctx, s.svcCtx)
return l.CreatePlant(in)
} }
func (s *PlantServiceServer) UpdatePlant(ctx context.Context, in *plant.UpdatePlantReq) (*plant.CommonResp, error) { func (s *PlantServiceServer) UpdatePlant(ctx context.Context, in *plant.UpdatePlantReq) (*plant.CommonResp, error) {
return logic.NewUpdatePlantLogic(ctx, s.svcCtx).UpdatePlant(in) l := logic.NewUpdatePlantLogic(ctx, s.svcCtx)
return l.UpdatePlant(in)
} }
func (s *PlantServiceServer) DeletePlant(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) { func (s *PlantServiceServer) DeletePlant(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeletePlantLogic(ctx, s.svcCtx).DeletePlant(in) l := logic.NewDeletePlantLogic(ctx, s.svcCtx)
return l.DeletePlant(in)
} }
func (s *PlantServiceServer) GetPlantList(ctx context.Context, in *plant.PlantListReq) (*plant.PlantListResp, error) { func (s *PlantServiceServer) GetPlantList(ctx context.Context, in *plant.PlantListReq) (*plant.PlantListResp, error) {
return logic.NewGetPlantListLogic(ctx, s.svcCtx).GetPlantList(in) l := logic.NewGetPlantListLogic(ctx, s.svcCtx)
return l.GetPlantList(in)
} }
func (s *PlantServiceServer) GetPlantDetail(ctx context.Context, in *plant.IdReq) (*plant.PlantDetailResp, error) { func (s *PlantServiceServer) GetPlantDetail(ctx context.Context, in *plant.IdReq) (*plant.PlantDetailResp, error) {
return logic.NewGetPlantDetailLogic(ctx, s.svcCtx).GetPlantDetail(in) l := logic.NewGetPlantDetailLogic(ctx, s.svcCtx)
return l.GetPlantDetail(in)
} }
// ---- 养护 ---- // 养护
func (s *PlantServiceServer) AddCarePlan(ctx context.Context, in *plant.AddCarePlanReq) (*plant.CommonResp, error) { func (s *PlantServiceServer) AddCarePlan(ctx context.Context, in *plant.AddCarePlanReq) (*plant.CommonResp, error) {
return logic.NewAddCarePlanLogic(ctx, s.svcCtx).AddCarePlan(in) l := logic.NewAddCarePlanLogic(ctx, s.svcCtx)
return l.AddCarePlan(in)
} }
func (s *PlantServiceServer) DeleteCarePlan(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) { func (s *PlantServiceServer) DeleteCarePlan(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteCarePlanLogic(ctx, s.svcCtx).DeleteCarePlan(in) l := logic.NewDeleteCarePlanLogic(ctx, s.svcCtx)
return l.DeleteCarePlan(in)
} }
func (s *PlantServiceServer) GetTodayTaskList(ctx context.Context, in *plant.GetProfileReq) (*plant.CareTaskListResp, error) { func (s *PlantServiceServer) GetTodayTaskList(ctx context.Context, in *plant.GetProfileReq) (*plant.CareTaskListResp, error) {
return logic.NewGetTodayTaskListLogic(ctx, s.svcCtx).GetTodayTaskList(in) l := logic.NewGetTodayTaskListLogic(ctx, s.svcCtx)
} return l.GetTodayTaskList(in)
func (s *PlantServiceServer) AddCareRecord(ctx context.Context, in *plant.AddCareRecordReq) (*plant.CommonResp, error) {
return logic.NewAddCareRecordLogic(ctx, s.svcCtx).AddCareRecord(in)
}
func (s *PlantServiceServer) AddGrowthRecord(ctx context.Context, in *plant.AddGrowthRecordReq) (*plant.CommonResp, error) {
return logic.NewAddGrowthRecordLogic(ctx, s.svcCtx).AddGrowthRecord(in)
} }
// ---- 百科 ----
func (s *PlantServiceServer) GetWikiList(ctx context.Context, in *plant.WikiListReq) (*plant.WikiListResp, error) {
return logic.NewGetWikiListLogic(ctx, s.svcCtx).GetWikiList(in)
}
func (s *PlantServiceServer) GetWikiDetail(ctx context.Context, in *plant.IdReq) (*plant.WikiDetailResp, error) {
return logic.NewGetWikiDetailLogic(ctx, s.svcCtx).GetWikiDetail(in)
}
func (s *PlantServiceServer) CreateWiki(ctx context.Context, in *plant.CreateWikiReq) (*plant.CommonResp, error) {
return logic.NewCreateWikiLogic(ctx, s.svcCtx).CreateWiki(in)
}
func (s *PlantServiceServer) UpdateWiki(ctx context.Context, in *plant.UpdateWikiReq) (*plant.CommonResp, error) {
return logic.NewUpdateWikiLogic(ctx, s.svcCtx).UpdateWiki(in)
}
func (s *PlantServiceServer) DeleteWiki(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteWikiLogic(ctx, s.svcCtx).DeleteWiki(in)
}
func (s *PlantServiceServer) SyncWikiVector(ctx context.Context, in *plant.SyncWikiVectorReq) (*plant.CommonResp, error) {
return logic.NewSyncWikiVectorLogic(ctx, s.svcCtx).SyncWikiVector(in)
}
func (s *PlantServiceServer) DeleteWikiVector(ctx context.Context, in *plant.SyncWikiVectorReq) (*plant.CommonResp, error) {
return logic.NewDeleteWikiVectorLogic(ctx, s.svcCtx).DeleteWikiVector(in)
}
func (s *PlantServiceServer) SyncAllWikiVector(ctx context.Context, in *plant.PageReq) (*plant.CommonResp, error) {
return logic.NewSyncAllWikiVectorLogic(ctx, s.svcCtx).SyncAllWikiVector(in)
}
func (s *PlantServiceServer) GetWikiClassList(ctx context.Context, in *plant.IdReq) (*plant.WikiClassListResp, error) {
return logic.NewGetWikiClassListLogic(ctx, s.svcCtx).GetWikiClassList(in)
}
func (s *PlantServiceServer) CreateWikiClass(ctx context.Context, in *plant.CreateWikiClassReq) (*plant.CommonResp, error) {
return logic.NewCreateWikiClassLogic(ctx, s.svcCtx).CreateWikiClass(in)
}
func (s *PlantServiceServer) UpdateWikiClass(ctx context.Context, in *plant.UpdateWikiClassReq) (*plant.CommonResp, error) {
return logic.NewUpdateWikiClassLogic(ctx, s.svcCtx).UpdateWikiClass(in)
}
func (s *PlantServiceServer) DeleteWikiClass(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteWikiClassLogic(ctx, s.svcCtx).DeleteWikiClass(in)
}
func (s *PlantServiceServer) ToggleWikiStar(ctx context.Context, in *plant.ToggleStarReq) (*plant.CommonResp, error) {
return logic.NewToggleWikiStarLogic(ctx, s.svcCtx).ToggleWikiStar(in)
}
// ---- OCR ----
func (s *PlantServiceServer) GetMyClassifyLog(ctx context.Context, in *plant.GetProfileReq) (*plant.ClassifyLogListResp, error) {
return logic.NewGetMyClassifyLogLogic(ctx, s.svcCtx).GetMyClassifyLog(in)
}
func (s *PlantServiceServer) DeleteClassifyLog(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteClassifyLogLogic(ctx, s.svcCtx).DeleteClassifyLog(in)
}
// ---- 社区 ----
func (s *PlantServiceServer) CreatePost(ctx context.Context, in *plant.CreatePostReq) (*plant.CommonResp, error) {
return logic.NewCreatePostLogic(ctx, s.svcCtx).CreatePost(in)
}
func (s *PlantServiceServer) DeletePost(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeletePostLogic(ctx, s.svcCtx).DeletePost(in)
}
func (s *PlantServiceServer) GetPostList(ctx context.Context, in *plant.PostListReq) (*plant.PostListResp, error) {
return logic.NewGetPostListLogic(ctx, s.svcCtx).GetPostList(in)
}
func (s *PlantServiceServer) GetPostDetail(ctx context.Context, in *plant.IdReq) (*plant.PostDetailResp, error) {
return logic.NewGetPostDetailLogic(ctx, s.svcCtx).GetPostDetail(in)
}
func (s *PlantServiceServer) CommentPost(ctx context.Context, in *plant.CommentPostReq) (*plant.CommonResp, error) {
return logic.NewCommentPostLogic(ctx, s.svcCtx).CommentPost(in)
}
func (s *PlantServiceServer) LikePost(ctx context.Context, in *plant.LikePostReq) (*plant.CommonResp, error) {
return logic.NewLikePostLogic(ctx, s.svcCtx).LikePost(in)
}
func (s *PlantServiceServer) StarPost(ctx context.Context, in *plant.LikePostReq) (*plant.CommonResp, error) {
return logic.NewStarPostLogic(ctx, s.svcCtx).StarPost(in)
}
func (s *PlantServiceServer) MediaCheckCallback(ctx context.Context, in *plant.MediaCheckCallbackReq) (*plant.CommonResp, error) {
return logic.NewMediaCheckCallbackLogic(ctx, s.svcCtx).MediaCheckCallback(in)
}
// ---- 话题 ----
func (s *PlantServiceServer) GetTopicList(ctx context.Context, in *plant.IdReq) (*plant.TopicListResp, error) {
return logic.NewGetTopicListLogic(ctx, s.svcCtx).GetTopicList(in)
}
func (s *PlantServiceServer) GetTopicDetail(ctx context.Context, in *plant.IdReq) (*plant.TopicInfo, error) {
return logic.NewGetTopicDetailLogic(ctx, s.svcCtx).GetTopicDetail(in)
}
func (s *PlantServiceServer) CreateTopic(ctx context.Context, in *plant.CreateTopicReq) (*plant.CommonResp, error) {
return logic.NewCreateTopicLogic(ctx, s.svcCtx).CreateTopic(in)
}
func (s *PlantServiceServer) UpdateTopic(ctx context.Context, in *plant.UpdateTopicReq) (*plant.CommonResp, error) {
return logic.NewUpdateTopicLogic(ctx, s.svcCtx).UpdateTopic(in)
}
func (s *PlantServiceServer) DeleteTopic(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteTopicLogic(ctx, s.svcCtx).DeleteTopic(in)
}
// ---- 兑换 ----
func (s *PlantServiceServer) GetExchangeItemList(ctx context.Context, in *plant.ExchangeItemListReq) (*plant.ExchangeItemListResp, error) {
return logic.NewGetExchangeItemListLogic(ctx, s.svcCtx).GetExchangeItemList(in)
}
func (s *PlantServiceServer) CreateExchangeItem(ctx context.Context, in *plant.CreateExchangeItemReq) (*plant.CommonResp, error) {
return logic.NewCreateExchangeItemLogic(ctx, s.svcCtx).CreateExchangeItem(in)
}
func (s *PlantServiceServer) UpdateExchangeItem(ctx context.Context, in *plant.UpdateExchangeItemReq) (*plant.CommonResp, error) {
return logic.NewUpdateExchangeItemLogic(ctx, s.svcCtx).UpdateExchangeItem(in)
}
func (s *PlantServiceServer) DeleteExchangeItem(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteExchangeItemLogic(ctx, s.svcCtx).DeleteExchangeItem(in)
}
func (s *PlantServiceServer) CreateExchangeOrder(ctx context.Context, in *plant.CreateExchangeOrderReq) (*plant.CommonResp, error) {
return logic.NewCreateExchangeOrderLogic(ctx, s.svcCtx).CreateExchangeOrder(in)
}
func (s *PlantServiceServer) GetMyExchangeOrders(ctx context.Context, in *plant.ExchangeOrderListReq) (*plant.ExchangeOrderListResp, error) {
return logic.NewGetMyExchangeOrdersLogic(ctx, s.svcCtx).GetMyExchangeOrders(in)
}
func (s *PlantServiceServer) GetExchangeOrderList(ctx context.Context, in *plant.ExchangeOrderListReq) (*plant.ExchangeOrderListResp, error) {
return logic.NewGetExchangeOrderListLogic(ctx, s.svcCtx).GetExchangeOrderList(in)
}
func (s *PlantServiceServer) UpdateExchangeOrder(ctx context.Context, in *plant.UpdateExchangeOrderReq) (*plant.CommonResp, error) {
return logic.NewUpdateExchangeOrderLogic(ctx, s.svcCtx).UpdateExchangeOrder(in)
}
// ---- 配置 ----
func (s *PlantServiceServer) GetLevelConfigList(ctx context.Context, in *plant.PageReq) (*plant.LevelConfigListResp, error) {
return logic.NewGetLevelConfigListLogic(ctx, s.svcCtx).GetLevelConfigList(in)
}
func (s *PlantServiceServer) CreateLevelConfig(ctx context.Context, in *plant.CreateLevelConfigReq) (*plant.CommonResp, error) {
return logic.NewCreateLevelConfigLogic(ctx, s.svcCtx).CreateLevelConfig(in)
}
func (s *PlantServiceServer) UpdateLevelConfig(ctx context.Context, in *plant.UpdateLevelConfigReq) (*plant.CommonResp, error) {
return logic.NewUpdateLevelConfigLogic(ctx, s.svcCtx).UpdateLevelConfig(in)
}
func (s *PlantServiceServer) DeleteLevelConfig(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteLevelConfigLogic(ctx, s.svcCtx).DeleteLevelConfig(in)
}
func (s *PlantServiceServer) GetBadgeConfigList(ctx context.Context, in *plant.BadgeConfigListReq) (*plant.BadgeConfigListResp, error) {
return logic.NewGetBadgeConfigListLogic(ctx, s.svcCtx).GetBadgeConfigList(in)
}
func (s *PlantServiceServer) GetBadgeConfigDetail(ctx context.Context, in *plant.IdReq) (*plant.BadgeConfigInfo, error) {
return logic.NewGetBadgeConfigDetailLogic(ctx, s.svcCtx).GetBadgeConfigDetail(in)
}
func (s *PlantServiceServer) CreateBadgeConfig(ctx context.Context, in *plant.CreateBadgeConfigReq) (*plant.CommonResp, error) {
return logic.NewCreateBadgeConfigLogic(ctx, s.svcCtx).CreateBadgeConfig(in)
}
func (s *PlantServiceServer) UpdateBadgeConfig(ctx context.Context, in *plant.UpdateBadgeConfigReq) (*plant.CommonResp, error) {
return logic.NewUpdateBadgeConfigLogic(ctx, s.svcCtx).UpdateBadgeConfig(in)
}
func (s *PlantServiceServer) DeleteBadgeConfig(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteBadgeConfigLogic(ctx, s.svcCtx).DeleteBadgeConfig(in)
}
// ---- AI ----
func (s *PlantServiceServer) DeleteAiChatHistory(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
return logic.NewDeleteAiChatHistoryLogic(ctx, s.svcCtx).DeleteAiChatHistory(in)
}
func (s *PlantServiceServer) SaveAiChatHistory(ctx context.Context, in *plant.SaveAiChatHistoryReq) (*plant.CommonResp, error) {
return logic.NewSaveAiChatHistoryLogic(ctx, s.svcCtx).SaveAiChatHistory(in)
}
func (s *PlantServiceServer) ClearAiChatHistory(ctx context.Context, in *plant.GetProfileReq) (*plant.CommonResp, error) {
return logic.NewClearAiChatHistoryLogic(ctx, s.svcCtx).ClearAiChatHistory(in)
}
func (s *PlantServiceServer) GetAiChatQuota(ctx context.Context, in *plant.GetProfileReq) (*plant.AiQuotaResp, error) {
return logic.NewGetAiChatQuotaLogic(ctx, s.svcCtx).GetAiChatQuota(in)
}
// ---- 完成任务 ----
func (s *PlantServiceServer) CompleteTask(ctx context.Context, in *plant.CompleteTaskReq) (*plant.TaskCompletionResult, error) { func (s *PlantServiceServer) CompleteTask(ctx context.Context, in *plant.CompleteTaskReq) (*plant.TaskCompletionResult, error) {
return logic.NewCompleteTaskLogic(ctx, s.svcCtx).CompleteTask(in) l := logic.NewCompleteTaskLogic(ctx, s.svcCtx)
return l.CompleteTask(in)
}
func (s *PlantServiceServer) AddCareRecord(ctx context.Context, in *plant.AddCareRecordReq) (*plant.CommonResp, error) {
l := logic.NewAddCareRecordLogic(ctx, s.svcCtx)
return l.AddCareRecord(in)
}
func (s *PlantServiceServer) AddGrowthRecord(ctx context.Context, in *plant.AddGrowthRecordReq) (*plant.CommonResp, error) {
l := logic.NewAddGrowthRecordLogic(ctx, s.svcCtx)
return l.AddGrowthRecord(in)
}
// 百科
func (s *PlantServiceServer) GetWikiList(ctx context.Context, in *plant.WikiListReq) (*plant.WikiListResp, error) {
l := logic.NewGetWikiListLogic(ctx, s.svcCtx)
return l.GetWikiList(in)
}
func (s *PlantServiceServer) GetWikiDetail(ctx context.Context, in *plant.IdReq) (*plant.WikiDetailResp, error) {
l := logic.NewGetWikiDetailLogic(ctx, s.svcCtx)
return l.GetWikiDetail(in)
}
func (s *PlantServiceServer) CreateWiki(ctx context.Context, in *plant.CreateWikiReq) (*plant.CommonResp, error) {
l := logic.NewCreateWikiLogic(ctx, s.svcCtx)
return l.CreateWiki(in)
}
func (s *PlantServiceServer) UpdateWiki(ctx context.Context, in *plant.UpdateWikiReq) (*plant.CommonResp, error) {
l := logic.NewUpdateWikiLogic(ctx, s.svcCtx)
return l.UpdateWiki(in)
}
func (s *PlantServiceServer) DeleteWiki(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteWikiLogic(ctx, s.svcCtx)
return l.DeleteWiki(in)
}
func (s *PlantServiceServer) SyncWikiVector(ctx context.Context, in *plant.SyncWikiVectorReq) (*plant.CommonResp, error) {
l := logic.NewSyncWikiVectorLogic(ctx, s.svcCtx)
return l.SyncWikiVector(in)
}
func (s *PlantServiceServer) DeleteWikiVector(ctx context.Context, in *plant.SyncWikiVectorReq) (*plant.CommonResp, error) {
l := logic.NewDeleteWikiVectorLogic(ctx, s.svcCtx)
return l.DeleteWikiVector(in)
}
func (s *PlantServiceServer) SyncAllWikiVector(ctx context.Context, in *plant.PageReq) (*plant.CommonResp, error) {
l := logic.NewSyncAllWikiVectorLogic(ctx, s.svcCtx)
return l.SyncAllWikiVector(in)
}
func (s *PlantServiceServer) GetWikiClassList(ctx context.Context, in *plant.IdReq) (*plant.WikiClassListResp, error) {
l := logic.NewGetWikiClassListLogic(ctx, s.svcCtx)
return l.GetWikiClassList(in)
}
func (s *PlantServiceServer) CreateWikiClass(ctx context.Context, in *plant.CreateWikiClassReq) (*plant.CommonResp, error) {
l := logic.NewCreateWikiClassLogic(ctx, s.svcCtx)
return l.CreateWikiClass(in)
}
func (s *PlantServiceServer) UpdateWikiClass(ctx context.Context, in *plant.UpdateWikiClassReq) (*plant.CommonResp, error) {
l := logic.NewUpdateWikiClassLogic(ctx, s.svcCtx)
return l.UpdateWikiClass(in)
}
func (s *PlantServiceServer) DeleteWikiClass(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteWikiClassLogic(ctx, s.svcCtx)
return l.DeleteWikiClass(in)
}
func (s *PlantServiceServer) ToggleWikiStar(ctx context.Context, in *plant.ToggleStarReq) (*plant.CommonResp, error) {
l := logic.NewToggleWikiStarLogic(ctx, s.svcCtx)
return l.ToggleWikiStar(in)
}
// OCR
func (s *PlantServiceServer) GetMyClassifyLog(ctx context.Context, in *plant.GetProfileReq) (*plant.ClassifyLogListResp, error) {
l := logic.NewGetMyClassifyLogLogic(ctx, s.svcCtx)
return l.GetMyClassifyLog(in)
}
func (s *PlantServiceServer) DeleteClassifyLog(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteClassifyLogLogic(ctx, s.svcCtx)
return l.DeleteClassifyLog(in)
}
// 社区
func (s *PlantServiceServer) CreatePost(ctx context.Context, in *plant.CreatePostReq) (*plant.CommonResp, error) {
l := logic.NewCreatePostLogic(ctx, s.svcCtx)
return l.CreatePost(in)
}
func (s *PlantServiceServer) DeletePost(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeletePostLogic(ctx, s.svcCtx)
return l.DeletePost(in)
}
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)
return l.CommentPost(in)
}
func (s *PlantServiceServer) LikePost(ctx context.Context, in *plant.LikePostReq) (*plant.CommonResp, error) {
l := logic.NewLikePostLogic(ctx, s.svcCtx)
return l.LikePost(in)
}
func (s *PlantServiceServer) StarPost(ctx context.Context, in *plant.LikePostReq) (*plant.CommonResp, error) {
l := logic.NewStarPostLogic(ctx, s.svcCtx)
return l.StarPost(in)
}
func (s *PlantServiceServer) MediaCheckCallback(ctx context.Context, in *plant.MediaCheckCallbackReq) (*plant.CommonResp, error) {
l := logic.NewMediaCheckCallbackLogic(ctx, s.svcCtx)
return l.MediaCheckCallback(in)
}
// 话题
func (s *PlantServiceServer) GetTopicList(ctx context.Context, in *plant.IdReq) (*plant.TopicListResp, error) {
l := logic.NewGetTopicListLogic(ctx, s.svcCtx)
return l.GetTopicList(in)
}
func (s *PlantServiceServer) GetTopicDetail(ctx context.Context, in *plant.IdReq) (*plant.TopicInfo, error) {
l := logic.NewGetTopicDetailLogic(ctx, s.svcCtx)
return l.GetTopicDetail(in)
}
func (s *PlantServiceServer) CreateTopic(ctx context.Context, in *plant.CreateTopicReq) (*plant.CommonResp, error) {
l := logic.NewCreateTopicLogic(ctx, s.svcCtx)
return l.CreateTopic(in)
}
func (s *PlantServiceServer) UpdateTopic(ctx context.Context, in *plant.UpdateTopicReq) (*plant.CommonResp, error) {
l := logic.NewUpdateTopicLogic(ctx, s.svcCtx)
return l.UpdateTopic(in)
}
func (s *PlantServiceServer) DeleteTopic(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteTopicLogic(ctx, s.svcCtx)
return l.DeleteTopic(in)
}
// 兑换
func (s *PlantServiceServer) GetExchangeItemList(ctx context.Context, in *plant.ExchangeItemListReq) (*plant.ExchangeItemListResp, error) {
l := logic.NewGetExchangeItemListLogic(ctx, s.svcCtx)
return l.GetExchangeItemList(in)
} }
// ---- 兑换详情 ----
func (s *PlantServiceServer) GetExchangeItemDetail(ctx context.Context, in *plant.IdReq) (*plant.ExchangeItemInfo, error) { func (s *PlantServiceServer) GetExchangeItemDetail(ctx context.Context, in *plant.IdReq) (*plant.ExchangeItemInfo, error) {
return logic.NewGetExchangeItemDetailLogic(ctx, s.svcCtx).GetExchangeItemDetail(in) l := logic.NewGetExchangeItemDetailLogic(ctx, s.svcCtx)
return l.GetExchangeItemDetail(in)
} }
// ---- 百科分类详情 ---- func (s *PlantServiceServer) CreateExchangeItem(ctx context.Context, in *plant.CreateExchangeItemReq) (*plant.CommonResp, error) {
func (s *PlantServiceServer) GetWikiClassDetail(ctx context.Context, in *plant.IdReq) (*plant.WikiClassInfo, error) { l := logic.NewCreateExchangeItemLogic(ctx, s.svcCtx)
return logic.NewGetWikiClassDetailLogic(ctx, s.svcCtx).GetWikiClassDetail(in) return l.CreateExchangeItem(in)
}
func (s *PlantServiceServer) UpdateExchangeItem(ctx context.Context, in *plant.UpdateExchangeItemReq) (*plant.CommonResp, error) {
l := logic.NewUpdateExchangeItemLogic(ctx, s.svcCtx)
return l.UpdateExchangeItem(in)
}
func (s *PlantServiceServer) DeleteExchangeItem(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteExchangeItemLogic(ctx, s.svcCtx)
return l.DeleteExchangeItem(in)
}
func (s *PlantServiceServer) CreateExchangeOrder(ctx context.Context, in *plant.CreateExchangeOrderReq) (*plant.CommonResp, error) {
l := logic.NewCreateExchangeOrderLogic(ctx, s.svcCtx)
return l.CreateExchangeOrder(in)
}
func (s *PlantServiceServer) GetMyExchangeOrders(ctx context.Context, in *plant.ExchangeOrderListReq) (*plant.ExchangeOrderListResp, error) {
l := logic.NewGetMyExchangeOrdersLogic(ctx, s.svcCtx)
return l.GetMyExchangeOrders(in)
}
func (s *PlantServiceServer) GetExchangeOrderList(ctx context.Context, in *plant.ExchangeOrderListReq) (*plant.ExchangeOrderListResp, error) {
l := logic.NewGetExchangeOrderListLogic(ctx, s.svcCtx)
return l.GetExchangeOrderList(in)
}
func (s *PlantServiceServer) UpdateExchangeOrder(ctx context.Context, in *plant.UpdateExchangeOrderReq) (*plant.CommonResp, error) {
l := logic.NewUpdateExchangeOrderLogic(ctx, s.svcCtx)
return l.UpdateExchangeOrder(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) GetLevelConfigDetail(ctx context.Context, in *plant.IdReq) (*plant.LevelConfigInfo, error) { func (s *PlantServiceServer) GetLevelConfigDetail(ctx context.Context, in *plant.IdReq) (*plant.LevelConfigInfo, error) {
return logic.NewGetLevelConfigDetailLogic(ctx, s.svcCtx).GetLevelConfigDetail(in) l := logic.NewGetLevelConfigDetailLogic(ctx, s.svcCtx)
return l.GetLevelConfigDetail(in)
}
func (s *PlantServiceServer) CreateLevelConfig(ctx context.Context, in *plant.CreateLevelConfigReq) (*plant.CommonResp, error) {
l := logic.NewCreateLevelConfigLogic(ctx, s.svcCtx)
return l.CreateLevelConfig(in)
}
func (s *PlantServiceServer) UpdateLevelConfig(ctx context.Context, in *plant.UpdateLevelConfigReq) (*plant.CommonResp, error) {
l := logic.NewUpdateLevelConfigLogic(ctx, s.svcCtx)
return l.UpdateLevelConfig(in)
}
func (s *PlantServiceServer) DeleteLevelConfig(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteLevelConfigLogic(ctx, s.svcCtx)
return l.DeleteLevelConfig(in)
}
func (s *PlantServiceServer) GetBadgeConfigList(ctx context.Context, in *plant.BadgeConfigListReq) (*plant.BadgeConfigListResp, error) {
l := logic.NewGetBadgeConfigListLogic(ctx, s.svcCtx)
return l.GetBadgeConfigList(in)
}
func (s *PlantServiceServer) GetBadgeConfigDetail(ctx context.Context, in *plant.IdReq) (*plant.BadgeConfigInfo, error) {
l := logic.NewGetBadgeConfigDetailLogic(ctx, s.svcCtx)
return l.GetBadgeConfigDetail(in)
} }
// ---- 徽章配置树 ----
func (s *PlantServiceServer) GetBadgeConfigTree(ctx context.Context, in *plant.IdReq) (*plant.BadgeConfigTreeResp, error) { func (s *PlantServiceServer) GetBadgeConfigTree(ctx context.Context, in *plant.IdReq) (*plant.BadgeConfigTreeResp, error) {
return logic.NewGetBadgeConfigTreeLogic(ctx, s.svcCtx).GetBadgeConfigTree(in) l := logic.NewGetBadgeConfigTreeLogic(ctx, s.svcCtx)
return l.GetBadgeConfigTree(in)
} }
// ---- AI 历史 ---- func (s *PlantServiceServer) CreateBadgeConfig(ctx context.Context, in *plant.CreateBadgeConfigReq) (*plant.CommonResp, error) {
func (s *PlantServiceServer) GetAiChatHistory(ctx context.Context, in *plant.AiChatHistoryReq) (*plant.AiChatHistoryResp, error) { l := logic.NewCreateBadgeConfigLogic(ctx, s.svcCtx)
return logic.NewGetAiChatHistoryLogic(ctx, s.svcCtx).GetAiChatHistory(in) return l.CreateBadgeConfig(in)
}
func (s *PlantServiceServer) UpdateBadgeConfig(ctx context.Context, in *plant.UpdateBadgeConfigReq) (*plant.CommonResp, error) {
l := logic.NewUpdateBadgeConfigLogic(ctx, s.svcCtx)
return l.UpdateBadgeConfig(in)
}
func (s *PlantServiceServer) DeleteBadgeConfig(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteBadgeConfigLogic(ctx, s.svcCtx)
return l.DeleteBadgeConfig(in)
}
func (s *PlantServiceServer) GetWikiClassDetail(ctx context.Context, in *plant.IdReq) (*plant.WikiClassInfo, error) {
l := logic.NewGetWikiClassDetailLogic(ctx, s.svcCtx)
return l.GetWikiClassDetail(in)
}
// AI
func (s *PlantServiceServer) GetAiChatHistory(ctx context.Context, in *plant.AiChatHistoryReq) (*plant.AiChatHistoryResp, error) {
l := logic.NewGetAiChatHistoryLogic(ctx, s.svcCtx)
return l.GetAiChatHistory(in)
}
func (s *PlantServiceServer) SaveAiChatHistory(ctx context.Context, in *plant.SaveAiChatHistoryReq) (*plant.CommonResp, error) {
l := logic.NewSaveAiChatHistoryLogic(ctx, s.svcCtx)
return l.SaveAiChatHistory(in)
}
func (s *PlantServiceServer) DeleteAiChatHistory(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteAiChatHistoryLogic(ctx, s.svcCtx)
return l.DeleteAiChatHistory(in)
}
func (s *PlantServiceServer) ClearAiChatHistory(ctx context.Context, in *plant.GetProfileReq) (*plant.CommonResp, error) {
l := logic.NewClearAiChatHistoryLogic(ctx, s.svcCtx)
return l.ClearAiChatHistory(in)
}
func (s *PlantServiceServer) GetAiChatQuota(ctx context.Context, in *plant.GetProfileReq) (*plant.AiQuotaResp, error) {
l := logic.NewGetAiChatQuotaLogic(ctx, s.svcCtx)
return l.GetAiChatQuota(in)
}
// 快捷养护
func (s *PlantServiceServer) QuickCare(ctx context.Context, in *plant.QuickCareReq) (*plant.CommonResp, error) {
l := logic.NewQuickCareLogic(ctx, s.svcCtx)
return l.QuickCare(in)
}
// Banner
func (s *PlantServiceServer) CreateBanner(ctx context.Context, in *plant.CreateBannerReq) (*plant.CommonResp, error) {
l := logic.NewCreateBannerLogic(ctx, s.svcCtx)
return l.CreateBanner(in)
}
func (s *PlantServiceServer) UpdateBanner(ctx context.Context, in *plant.UpdateBannerReq) (*plant.CommonResp, error) {
l := logic.NewUpdateBannerLogic(ctx, s.svcCtx)
return l.UpdateBanner(in)
}
func (s *PlantServiceServer) DeleteBanner(ctx context.Context, in *plant.IdsReq) (*plant.CommonResp, error) {
l := logic.NewDeleteBannerLogic(ctx, s.svcCtx)
return l.DeleteBanner(in)
}
func (s *PlantServiceServer) GetBannerList(ctx context.Context, in *plant.BannerListReq) (*plant.BannerListResp, error) {
l := logic.NewGetBannerListLogic(ctx, s.svcCtx)
return l.GetBannerList(in)
}
func (s *PlantServiceServer) GetActiveBannerList(ctx context.Context, in *plant.PageReq) (*plant.BannerListResp, error) {
l := logic.NewGetActiveBannerListLogic(ctx, s.svcCtx)
return l.GetActiveBannerList(in)
} }
+8 -1
View File
@@ -3,8 +3,10 @@ package svc
import ( import (
plantModel "sundynix-micro-go/app/plant/model" plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/internal/config" "sundynix-micro-go/app/plant/rpc/internal/config"
"sundynix-micro-go/app/system/rpc/systemservice"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/zrpc"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
) )
@@ -12,6 +14,7 @@ import (
type ServiceContext struct { type ServiceContext struct {
Config config.Config Config config.Config
DB *gorm.DB DB *gorm.DB
SystemRpc systemservice.SystemService
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
@@ -55,5 +58,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
logx.Errorf("数据库迁移失败: %v", err) logx.Errorf("数据库迁移失败: %v", err)
} }
return &ServiceContext{Config: c, DB: db} // 初始化 System RPC 客户端
sysRpc := systemservice.NewSystemService(zrpc.MustNewClient(c.SystemRpc))
logx.Info("[plant-rpc] ✅ SystemRpc 已连接")
return &ServiceContext{Config: c, DB: db, SystemRpc: sysRpc}
} }
File diff suppressed because it is too large Load Diff
+13
View File
@@ -42,6 +42,18 @@ message PlantUserProfile {
int64 repotCount = 13; int64 repotCount = 13;
int64 pruneCount = 14; int64 pruneCount = 14;
int64 photoCount = 15; int64 photoCount = 15;
string miniOpenId = 16;
string sessionKey = 17;
string unionId = 18;
string saOpenId = 19;
}
message FindOrCreateUserByOpenIdReq {
string openId = 1;
string sessionKey = 2;
string clientId = 3;
string unionId = 4;
string saOpenId = 5;
} }
message GetProfileReq { message GetProfileReq {
@@ -778,6 +790,7 @@ message AiChatHistoryResp {
service PlantService { service PlantService {
// 用户Profile // 用户Profile
rpc GetUserProfile(GetProfileReq) returns (PlantUserProfile); rpc GetUserProfile(GetProfileReq) returns (PlantUserProfile);
rpc FindOrCreateUserByOpenId(FindOrCreateUserByOpenIdReq) returns (PlantUserProfile);
rpc UpdateUserProfile(UpdateProfileReq) returns (CommonResp); rpc UpdateUserProfile(UpdateProfileReq) returns (CommonResp);
rpc GetMyBadges(GetProfileReq) returns (UserBadgeListResp); rpc GetMyBadges(GetProfileReq) returns (UserBadgeListResp);
rpc GetMyStars(GetProfileReq) returns (UserStarListResp); rpc GetMyStars(GetProfileReq) returns (UserStarListResp);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+270
View File
@@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion9
const ( const (
PlantService_GetUserProfile_FullMethodName = "/plant.PlantService/GetUserProfile" PlantService_GetUserProfile_FullMethodName = "/plant.PlantService/GetUserProfile"
PlantService_FindOrCreateUserByOpenId_FullMethodName = "/plant.PlantService/FindOrCreateUserByOpenId"
PlantService_UpdateUserProfile_FullMethodName = "/plant.PlantService/UpdateUserProfile" PlantService_UpdateUserProfile_FullMethodName = "/plant.PlantService/UpdateUserProfile"
PlantService_GetMyBadges_FullMethodName = "/plant.PlantService/GetMyBadges" PlantService_GetMyBadges_FullMethodName = "/plant.PlantService/GetMyBadges"
PlantService_GetMyStars_FullMethodName = "/plant.PlantService/GetMyStars" PlantService_GetMyStars_FullMethodName = "/plant.PlantService/GetMyStars"
@@ -88,6 +89,12 @@ const (
PlantService_DeleteAiChatHistory_FullMethodName = "/plant.PlantService/DeleteAiChatHistory" PlantService_DeleteAiChatHistory_FullMethodName = "/plant.PlantService/DeleteAiChatHistory"
PlantService_ClearAiChatHistory_FullMethodName = "/plant.PlantService/ClearAiChatHistory" PlantService_ClearAiChatHistory_FullMethodName = "/plant.PlantService/ClearAiChatHistory"
PlantService_GetAiChatQuota_FullMethodName = "/plant.PlantService/GetAiChatQuota" PlantService_GetAiChatQuota_FullMethodName = "/plant.PlantService/GetAiChatQuota"
PlantService_QuickCare_FullMethodName = "/plant.PlantService/QuickCare"
PlantService_CreateBanner_FullMethodName = "/plant.PlantService/CreateBanner"
PlantService_UpdateBanner_FullMethodName = "/plant.PlantService/UpdateBanner"
PlantService_DeleteBanner_FullMethodName = "/plant.PlantService/DeleteBanner"
PlantService_GetBannerList_FullMethodName = "/plant.PlantService/GetBannerList"
PlantService_GetActiveBannerList_FullMethodName = "/plant.PlantService/GetActiveBannerList"
) )
// PlantServiceClient is the client API for PlantService service. // PlantServiceClient is the client API for PlantService service.
@@ -96,6 +103,7 @@ const (
type PlantServiceClient interface { type PlantServiceClient interface {
// 用户Profile // 用户Profile
GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error)
FindOrCreateUserByOpenId(ctx context.Context, in *FindOrCreateUserByOpenIdReq, opts ...grpc.CallOption) (*PlantUserProfile, error)
UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error)
GetMyBadges(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserBadgeListResp, error) GetMyBadges(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserBadgeListResp, error)
GetMyStars(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserStarListResp, error) GetMyStars(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserStarListResp, error)
@@ -173,6 +181,14 @@ type PlantServiceClient interface {
DeleteAiChatHistory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteAiChatHistory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
ClearAiChatHistory(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CommonResp, error) ClearAiChatHistory(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CommonResp, error)
GetAiChatQuota(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*AiQuotaResp, error) GetAiChatQuota(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*AiQuotaResp, error)
// 快捷养护
QuickCare(ctx context.Context, in *QuickCareReq, opts ...grpc.CallOption) (*CommonResp, error)
// Banner
CreateBanner(ctx context.Context, in *CreateBannerReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateBanner(ctx context.Context, in *UpdateBannerReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteBanner(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetBannerList(ctx context.Context, in *BannerListReq, opts ...grpc.CallOption) (*BannerListResp, error)
GetActiveBannerList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*BannerListResp, error)
} }
type plantServiceClient struct { type plantServiceClient struct {
@@ -193,6 +209,16 @@ func (c *plantServiceClient) GetUserProfile(ctx context.Context, in *GetProfileR
return out, nil return out, nil
} }
func (c *plantServiceClient) FindOrCreateUserByOpenId(ctx context.Context, in *FindOrCreateUserByOpenIdReq, opts ...grpc.CallOption) (*PlantUserProfile, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PlantUserProfile)
err := c.cc.Invoke(ctx, PlantService_FindOrCreateUserByOpenId_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *plantServiceClient) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) { func (c *plantServiceClient) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommonResp) out := new(CommonResp)
@@ -873,12 +899,73 @@ func (c *plantServiceClient) GetAiChatQuota(ctx context.Context, in *GetProfileR
return out, nil return out, nil
} }
func (c *plantServiceClient) QuickCare(ctx context.Context, in *QuickCareReq, opts ...grpc.CallOption) (*CommonResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommonResp)
err := c.cc.Invoke(ctx, PlantService_QuickCare_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *plantServiceClient) CreateBanner(ctx context.Context, in *CreateBannerReq, opts ...grpc.CallOption) (*CommonResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommonResp)
err := c.cc.Invoke(ctx, PlantService_CreateBanner_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *plantServiceClient) UpdateBanner(ctx context.Context, in *UpdateBannerReq, opts ...grpc.CallOption) (*CommonResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommonResp)
err := c.cc.Invoke(ctx, PlantService_UpdateBanner_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *plantServiceClient) DeleteBanner(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommonResp)
err := c.cc.Invoke(ctx, PlantService_DeleteBanner_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *plantServiceClient) GetBannerList(ctx context.Context, in *BannerListReq, opts ...grpc.CallOption) (*BannerListResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(BannerListResp)
err := c.cc.Invoke(ctx, PlantService_GetBannerList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *plantServiceClient) GetActiveBannerList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*BannerListResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(BannerListResp)
err := c.cc.Invoke(ctx, PlantService_GetActiveBannerList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// PlantServiceServer is the server API for PlantService service. // PlantServiceServer is the server API for PlantService service.
// All implementations must embed UnimplementedPlantServiceServer // All implementations must embed UnimplementedPlantServiceServer
// for forward compatibility. // for forward compatibility.
type PlantServiceServer interface { type PlantServiceServer interface {
// 用户Profile // 用户Profile
GetUserProfile(context.Context, *GetProfileReq) (*PlantUserProfile, error) GetUserProfile(context.Context, *GetProfileReq) (*PlantUserProfile, error)
FindOrCreateUserByOpenId(context.Context, *FindOrCreateUserByOpenIdReq) (*PlantUserProfile, error)
UpdateUserProfile(context.Context, *UpdateProfileReq) (*CommonResp, error) UpdateUserProfile(context.Context, *UpdateProfileReq) (*CommonResp, error)
GetMyBadges(context.Context, *GetProfileReq) (*UserBadgeListResp, error) GetMyBadges(context.Context, *GetProfileReq) (*UserBadgeListResp, error)
GetMyStars(context.Context, *GetProfileReq) (*UserStarListResp, error) GetMyStars(context.Context, *GetProfileReq) (*UserStarListResp, error)
@@ -956,6 +1043,14 @@ type PlantServiceServer interface {
DeleteAiChatHistory(context.Context, *IdsReq) (*CommonResp, error) DeleteAiChatHistory(context.Context, *IdsReq) (*CommonResp, error)
ClearAiChatHistory(context.Context, *GetProfileReq) (*CommonResp, error) ClearAiChatHistory(context.Context, *GetProfileReq) (*CommonResp, error)
GetAiChatQuota(context.Context, *GetProfileReq) (*AiQuotaResp, error) GetAiChatQuota(context.Context, *GetProfileReq) (*AiQuotaResp, error)
// 快捷养护
QuickCare(context.Context, *QuickCareReq) (*CommonResp, error)
// Banner
CreateBanner(context.Context, *CreateBannerReq) (*CommonResp, error)
UpdateBanner(context.Context, *UpdateBannerReq) (*CommonResp, error)
DeleteBanner(context.Context, *IdsReq) (*CommonResp, error)
GetBannerList(context.Context, *BannerListReq) (*BannerListResp, error)
GetActiveBannerList(context.Context, *PageReq) (*BannerListResp, error)
mustEmbedUnimplementedPlantServiceServer() mustEmbedUnimplementedPlantServiceServer()
} }
@@ -969,6 +1064,9 @@ type UnimplementedPlantServiceServer struct{}
func (UnimplementedPlantServiceServer) GetUserProfile(context.Context, *GetProfileReq) (*PlantUserProfile, error) { func (UnimplementedPlantServiceServer) GetUserProfile(context.Context, *GetProfileReq) (*PlantUserProfile, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserProfile not implemented") return nil, status.Error(codes.Unimplemented, "method GetUserProfile not implemented")
} }
func (UnimplementedPlantServiceServer) FindOrCreateUserByOpenId(context.Context, *FindOrCreateUserByOpenIdReq) (*PlantUserProfile, error) {
return nil, status.Error(codes.Unimplemented, "method FindOrCreateUserByOpenId not implemented")
}
func (UnimplementedPlantServiceServer) UpdateUserProfile(context.Context, *UpdateProfileReq) (*CommonResp, error) { func (UnimplementedPlantServiceServer) UpdateUserProfile(context.Context, *UpdateProfileReq) (*CommonResp, error) {
return nil, status.Error(codes.Unimplemented, "method UpdateUserProfile not implemented") return nil, status.Error(codes.Unimplemented, "method UpdateUserProfile not implemented")
} }
@@ -1173,6 +1271,24 @@ func (UnimplementedPlantServiceServer) ClearAiChatHistory(context.Context, *GetP
func (UnimplementedPlantServiceServer) GetAiChatQuota(context.Context, *GetProfileReq) (*AiQuotaResp, error) { func (UnimplementedPlantServiceServer) GetAiChatQuota(context.Context, *GetProfileReq) (*AiQuotaResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetAiChatQuota not implemented") return nil, status.Error(codes.Unimplemented, "method GetAiChatQuota not implemented")
} }
func (UnimplementedPlantServiceServer) QuickCare(context.Context, *QuickCareReq) (*CommonResp, error) {
return nil, status.Error(codes.Unimplemented, "method QuickCare not implemented")
}
func (UnimplementedPlantServiceServer) CreateBanner(context.Context, *CreateBannerReq) (*CommonResp, error) {
return nil, status.Error(codes.Unimplemented, "method CreateBanner not implemented")
}
func (UnimplementedPlantServiceServer) UpdateBanner(context.Context, *UpdateBannerReq) (*CommonResp, error) {
return nil, status.Error(codes.Unimplemented, "method UpdateBanner not implemented")
}
func (UnimplementedPlantServiceServer) DeleteBanner(context.Context, *IdsReq) (*CommonResp, error) {
return nil, status.Error(codes.Unimplemented, "method DeleteBanner not implemented")
}
func (UnimplementedPlantServiceServer) GetBannerList(context.Context, *BannerListReq) (*BannerListResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetBannerList not implemented")
}
func (UnimplementedPlantServiceServer) GetActiveBannerList(context.Context, *PageReq) (*BannerListResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetActiveBannerList not implemented")
}
func (UnimplementedPlantServiceServer) mustEmbedUnimplementedPlantServiceServer() {} func (UnimplementedPlantServiceServer) mustEmbedUnimplementedPlantServiceServer() {}
func (UnimplementedPlantServiceServer) testEmbeddedByValue() {} func (UnimplementedPlantServiceServer) testEmbeddedByValue() {}
@@ -1212,6 +1328,24 @@ func _PlantService_GetUserProfile_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _PlantService_FindOrCreateUserByOpenId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FindOrCreateUserByOpenIdReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).FindOrCreateUserByOpenId(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_FindOrCreateUserByOpenId_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).FindOrCreateUserByOpenId(ctx, req.(*FindOrCreateUserByOpenIdReq))
}
return interceptor(ctx, in, info, handler)
}
func _PlantService_UpdateUserProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _PlantService_UpdateUserProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateProfileReq) in := new(UpdateProfileReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@@ -2436,6 +2570,114 @@ func _PlantService_GetAiChatQuota_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _PlantService_QuickCare_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuickCareReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).QuickCare(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_QuickCare_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).QuickCare(ctx, req.(*QuickCareReq))
}
return interceptor(ctx, in, info, handler)
}
func _PlantService_CreateBanner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateBannerReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).CreateBanner(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_CreateBanner_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).CreateBanner(ctx, req.(*CreateBannerReq))
}
return interceptor(ctx, in, info, handler)
}
func _PlantService_UpdateBanner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateBannerReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).UpdateBanner(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_UpdateBanner_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).UpdateBanner(ctx, req.(*UpdateBannerReq))
}
return interceptor(ctx, in, info, handler)
}
func _PlantService_DeleteBanner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdsReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).DeleteBanner(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_DeleteBanner_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).DeleteBanner(ctx, req.(*IdsReq))
}
return interceptor(ctx, in, info, handler)
}
func _PlantService_GetBannerList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(BannerListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).GetBannerList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_GetBannerList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).GetBannerList(ctx, req.(*BannerListReq))
}
return interceptor(ctx, in, info, handler)
}
func _PlantService_GetActiveBannerList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PageReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PlantServiceServer).GetActiveBannerList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PlantService_GetActiveBannerList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PlantServiceServer).GetActiveBannerList(ctx, req.(*PageReq))
}
return interceptor(ctx, in, info, handler)
}
// PlantService_ServiceDesc is the grpc.ServiceDesc for PlantService service. // PlantService_ServiceDesc is the grpc.ServiceDesc for PlantService service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@@ -2447,6 +2689,10 @@ var PlantService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetUserProfile", MethodName: "GetUserProfile",
Handler: _PlantService_GetUserProfile_Handler, Handler: _PlantService_GetUserProfile_Handler,
}, },
{
MethodName: "FindOrCreateUserByOpenId",
Handler: _PlantService_FindOrCreateUserByOpenId_Handler,
},
{ {
MethodName: "UpdateUserProfile", MethodName: "UpdateUserProfile",
Handler: _PlantService_UpdateUserProfile_Handler, Handler: _PlantService_UpdateUserProfile_Handler,
@@ -2719,6 +2965,30 @@ var PlantService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetAiChatQuota", MethodName: "GetAiChatQuota",
Handler: _PlantService_GetAiChatQuota_Handler, Handler: _PlantService_GetAiChatQuota_Handler,
}, },
{
MethodName: "QuickCare",
Handler: _PlantService_QuickCare_Handler,
},
{
MethodName: "CreateBanner",
Handler: _PlantService_CreateBanner_Handler,
},
{
MethodName: "UpdateBanner",
Handler: _PlantService_UpdateBanner_Handler,
},
{
MethodName: "DeleteBanner",
Handler: _PlantService_DeleteBanner_Handler,
},
{
MethodName: "GetBannerList",
Handler: _PlantService_GetBannerList_Handler,
},
{
MethodName: "GetActiveBannerList",
Handler: _PlantService_GetActiveBannerList_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "pb/plant.proto", Metadata: "pb/plant.proto",
+275 -101
View File
@@ -17,10 +17,18 @@ type (
AddCarePlanReq = plant.AddCarePlanReq AddCarePlanReq = plant.AddCarePlanReq
AddCareRecordReq = plant.AddCareRecordReq AddCareRecordReq = plant.AddCareRecordReq
AddGrowthRecordReq = plant.AddGrowthRecordReq AddGrowthRecordReq = plant.AddGrowthRecordReq
AiChatHistoryInfo = plant.AiChatHistoryInfo
AiChatHistoryReq = plant.AiChatHistoryReq
AiChatHistoryResp = plant.AiChatHistoryResp
AiQuotaResp = plant.AiQuotaResp AiQuotaResp = plant.AiQuotaResp
BadgeConfigInfo = plant.BadgeConfigInfo BadgeConfigInfo = plant.BadgeConfigInfo
BadgeConfigListReq = plant.BadgeConfigListReq BadgeConfigListReq = plant.BadgeConfigListReq
BadgeConfigListResp = plant.BadgeConfigListResp BadgeConfigListResp = plant.BadgeConfigListResp
BadgeConfigTreeResp = plant.BadgeConfigTreeResp
BadgeGroupInfo = plant.BadgeGroupInfo
BannerInfo = plant.BannerInfo
BannerListReq = plant.BannerListReq
BannerListResp = plant.BannerListResp
CarePlanInfo = plant.CarePlanInfo CarePlanInfo = plant.CarePlanInfo
CareTaskInfo = plant.CareTaskInfo CareTaskInfo = plant.CareTaskInfo
CareTaskListResp = plant.CareTaskListResp CareTaskListResp = plant.CareTaskListResp
@@ -28,7 +36,9 @@ type (
ClassifyLogListResp = plant.ClassifyLogListResp ClassifyLogListResp = plant.ClassifyLogListResp
CommentPostReq = plant.CommentPostReq CommentPostReq = plant.CommentPostReq
CommonResp = plant.CommonResp CommonResp = plant.CommonResp
CompleteTaskReq = plant.CompleteTaskReq
CreateBadgeConfigReq = plant.CreateBadgeConfigReq CreateBadgeConfigReq = plant.CreateBadgeConfigReq
CreateBannerReq = plant.CreateBannerReq
CreateExchangeItemReq = plant.CreateExchangeItemReq CreateExchangeItemReq = plant.CreateExchangeItemReq
CreateExchangeOrderReq = plant.CreateExchangeOrderReq CreateExchangeOrderReq = plant.CreateExchangeOrderReq
CreateLevelConfigReq = plant.CreateLevelConfigReq CreateLevelConfigReq = plant.CreateLevelConfigReq
@@ -43,6 +53,7 @@ type (
ExchangeOrderInfo = plant.ExchangeOrderInfo ExchangeOrderInfo = plant.ExchangeOrderInfo
ExchangeOrderListReq = plant.ExchangeOrderListReq ExchangeOrderListReq = plant.ExchangeOrderListReq
ExchangeOrderListResp = plant.ExchangeOrderListResp ExchangeOrderListResp = plant.ExchangeOrderListResp
FindOrCreateUserByOpenIdReq = plant.FindOrCreateUserByOpenIdReq
GetProfileReq = plant.GetProfileReq GetProfileReq = plant.GetProfileReq
GrowthRecordInfo = plant.GrowthRecordInfo GrowthRecordInfo = plant.GrowthRecordInfo
IdReq = plant.IdReq IdReq = plant.IdReq
@@ -62,10 +73,15 @@ type (
PostInfo = plant.PostInfo PostInfo = plant.PostInfo
PostListReq = plant.PostListReq PostListReq = plant.PostListReq
PostListResp = plant.PostListResp PostListResp = plant.PostListResp
QuickCareReq = plant.QuickCareReq
SaveAiChatHistoryReq = plant.SaveAiChatHistoryReq
SyncWikiVectorReq = plant.SyncWikiVectorReq
TaskCompletionResult = plant.TaskCompletionResult
ToggleStarReq = plant.ToggleStarReq ToggleStarReq = plant.ToggleStarReq
TopicInfo = plant.TopicInfo TopicInfo = plant.TopicInfo
TopicListResp = plant.TopicListResp TopicListResp = plant.TopicListResp
UpdateBadgeConfigReq = plant.UpdateBadgeConfigReq UpdateBadgeConfigReq = plant.UpdateBadgeConfigReq
UpdateBannerReq = plant.UpdateBannerReq
UpdateExchangeItemReq = plant.UpdateExchangeItemReq UpdateExchangeItemReq = plant.UpdateExchangeItemReq
UpdateExchangeOrderReq = plant.UpdateExchangeOrderReq UpdateExchangeOrderReq = plant.UpdateExchangeOrderReq
UpdateLevelConfigReq = plant.UpdateLevelConfigReq UpdateLevelConfigReq = plant.UpdateLevelConfigReq
@@ -84,20 +100,11 @@ type (
WikiInfo = plant.WikiInfo WikiInfo = plant.WikiInfo
WikiListReq = plant.WikiListReq WikiListReq = plant.WikiListReq
WikiListResp = plant.WikiListResp WikiListResp = plant.WikiListResp
// new types
AiChatHistoryInfo = plant.AiChatHistoryInfo
AiChatHistoryReq = plant.AiChatHistoryReq
AiChatHistoryResp = plant.AiChatHistoryResp
BadgeGroupInfo = plant.BadgeGroupInfo
BadgeConfigTreeResp = plant.BadgeConfigTreeResp
CompleteTaskReq = plant.CompleteTaskReq
TaskCompletionResult = plant.TaskCompletionResult
SaveAiChatHistoryReq = plant.SaveAiChatHistoryReq
SyncWikiVectorReq = plant.SyncWikiVectorReq
PlantService interface { PlantService interface {
// 用户Profile // 用户Profile
GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error)
FindOrCreateUserByOpenId(ctx context.Context, in *FindOrCreateUserByOpenIdReq, opts ...grpc.CallOption) (*PlantUserProfile, error)
UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error)
GetMyBadges(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserBadgeListResp, error) GetMyBadges(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserBadgeListResp, error)
GetMyStars(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserStarListResp, error) GetMyStars(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserStarListResp, error)
@@ -111,6 +118,7 @@ type (
AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*CommonResp, error) AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteCarePlan(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteCarePlan(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetTodayTaskList(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CareTaskListResp, error) GetTodayTaskList(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CareTaskListResp, error)
CompleteTask(ctx context.Context, in *CompleteTaskReq, opts ...grpc.CallOption) (*TaskCompletionResult, error)
AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*CommonResp, error) AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*CommonResp, error)
AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*CommonResp, error) AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*CommonResp, error)
// 百科 // 百科
@@ -147,6 +155,7 @@ type (
DeleteTopic(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteTopic(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
// 兑换 // 兑换
GetExchangeItemList(ctx context.Context, in *ExchangeItemListReq, opts ...grpc.CallOption) (*ExchangeItemListResp, error) GetExchangeItemList(ctx context.Context, in *ExchangeItemListReq, opts ...grpc.CallOption) (*ExchangeItemListResp, error)
GetExchangeItemDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ExchangeItemInfo, error)
CreateExchangeItem(ctx context.Context, in *CreateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error) CreateExchangeItem(ctx context.Context, in *CreateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateExchangeItem(ctx context.Context, in *UpdateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error) UpdateExchangeItem(ctx context.Context, in *UpdateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteExchangeItem(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteExchangeItem(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
@@ -167,16 +176,20 @@ type (
UpdateBadgeConfig(ctx context.Context, in *UpdateBadgeConfigReq, opts ...grpc.CallOption) (*CommonResp, error) UpdateBadgeConfig(ctx context.Context, in *UpdateBadgeConfigReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteBadgeConfig(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteBadgeConfig(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetWikiClassDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassInfo, error) GetWikiClassDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassInfo, error)
// 兑换详情
GetExchangeItemDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ExchangeItemInfo, error)
// 养护完成任务
CompleteTask(ctx context.Context, in *CompleteTaskReq, opts ...grpc.CallOption) (*TaskCompletionResult, error)
// AI // AI
GetAiChatHistory(ctx context.Context, in *AiChatHistoryReq, opts ...grpc.CallOption) (*AiChatHistoryResp, error) GetAiChatHistory(ctx context.Context, in *AiChatHistoryReq, opts ...grpc.CallOption) (*AiChatHistoryResp, error)
SaveAiChatHistory(ctx context.Context, in *SaveAiChatHistoryReq, opts ...grpc.CallOption) (*CommonResp, error) SaveAiChatHistory(ctx context.Context, in *SaveAiChatHistoryReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteAiChatHistory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteAiChatHistory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
ClearAiChatHistory(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CommonResp, error) ClearAiChatHistory(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CommonResp, error)
GetAiChatQuota(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*AiQuotaResp, error) GetAiChatQuota(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*AiQuotaResp, error)
// 快捷养护
QuickCare(ctx context.Context, in *QuickCareReq, opts ...grpc.CallOption) (*CommonResp, error)
// Banner
CreateBanner(ctx context.Context, in *CreateBannerReq, opts ...grpc.CallOption) (*CommonResp, error)
UpdateBanner(ctx context.Context, in *UpdateBannerReq, opts ...grpc.CallOption) (*CommonResp, error)
DeleteBanner(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error)
GetBannerList(ctx context.Context, in *BannerListReq, opts ...grpc.CallOption) (*BannerListResp, error)
GetActiveBannerList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*BannerListResp, error)
} }
defaultPlantService struct { defaultPlantService struct {
@@ -185,238 +198,399 @@ type (
) )
func NewPlantService(cli zrpc.Client) PlantService { func NewPlantService(cli zrpc.Client) PlantService {
return &defaultPlantService{cli: cli} return &defaultPlantService{
cli: cli,
}
} }
// ---- 用户Profile ---- // 用户Profile
func (m *defaultPlantService) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error) { func (m *defaultPlantService) GetUserProfile(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*PlantUserProfile, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetUserProfile(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetUserProfile(ctx, in, opts...)
} }
func (m *defaultPlantService) FindOrCreateUserByOpenId(ctx context.Context, in *FindOrCreateUserByOpenIdReq, opts ...grpc.CallOption) (*PlantUserProfile, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.FindOrCreateUserByOpenId(ctx, in, opts...)
}
func (m *defaultPlantService) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateUserProfile(ctx context.Context, in *UpdateProfileReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateUserProfile(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateUserProfile(ctx, in, opts...)
} }
func (m *defaultPlantService) GetMyBadges(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserBadgeListResp, error) { func (m *defaultPlantService) GetMyBadges(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserBadgeListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetMyBadges(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetMyBadges(ctx, in, opts...)
} }
func (m *defaultPlantService) GetMyStars(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserStarListResp, error) { func (m *defaultPlantService) GetMyStars(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*UserStarListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetMyStars(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetMyStars(ctx, in, opts...)
} }
// ---- 我的植物 ---- // 我的植物
func (m *defaultPlantService) CreatePlant(ctx context.Context, in *CreatePlantReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreatePlant(ctx context.Context, in *CreatePlantReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreatePlant(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreatePlant(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdatePlant(ctx context.Context, in *UpdatePlantReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdatePlant(ctx context.Context, in *UpdatePlantReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdatePlant(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdatePlant(ctx, in, opts...)
} }
func (m *defaultPlantService) DeletePlant(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeletePlant(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeletePlant(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeletePlant(ctx, in, opts...)
} }
func (m *defaultPlantService) GetPlantList(ctx context.Context, in *PlantListReq, opts ...grpc.CallOption) (*PlantListResp, error) { func (m *defaultPlantService) GetPlantList(ctx context.Context, in *PlantListReq, opts ...grpc.CallOption) (*PlantListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetPlantList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPlantList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetPlantDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PlantDetailResp, error) { func (m *defaultPlantService) GetPlantDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PlantDetailResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetPlantDetail(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetPlantDetail(ctx, in, opts...)
} }
// ---- 养护 ---- // 养护
func (m *defaultPlantService) AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) AddCarePlan(ctx context.Context, in *AddCarePlanReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).AddCarePlan(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.AddCarePlan(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteCarePlan(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteCarePlan(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteCarePlan(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteCarePlan(ctx, in, opts...)
} }
func (m *defaultPlantService) GetTodayTaskList(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CareTaskListResp, error) { func (m *defaultPlantService) GetTodayTaskList(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CareTaskListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetTodayTaskList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetTodayTaskList(ctx, in, opts...)
} }
func (m *defaultPlantService) CompleteTask(ctx context.Context, in *CompleteTaskReq, opts ...grpc.CallOption) (*TaskCompletionResult, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CompleteTask(ctx, in, opts...)
}
func (m *defaultPlantService) AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) AddCareRecord(ctx context.Context, in *AddCareRecordReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).AddCareRecord(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.AddCareRecord(ctx, in, opts...)
} }
func (m *defaultPlantService) AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) AddGrowthRecord(ctx context.Context, in *AddGrowthRecordReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).AddGrowthRecord(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.AddGrowthRecord(ctx, in, opts...)
} }
// ---- 百科 ---- // 百科
func (m *defaultPlantService) GetWikiList(ctx context.Context, in *WikiListReq, opts ...grpc.CallOption) (*WikiListResp, error) { func (m *defaultPlantService) GetWikiList(ctx context.Context, in *WikiListReq, opts ...grpc.CallOption) (*WikiListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetWikiList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetWikiList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetWikiDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiDetailResp, error) { func (m *defaultPlantService) GetWikiDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiDetailResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetWikiDetail(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetWikiDetail(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateWiki(ctx context.Context, in *CreateWikiReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateWiki(ctx context.Context, in *CreateWikiReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateWiki(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateWiki(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateWiki(ctx context.Context, in *UpdateWikiReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateWiki(ctx context.Context, in *UpdateWikiReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateWiki(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateWiki(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteWiki(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteWiki(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteWiki(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteWiki(ctx, in, opts...)
} }
func (m *defaultPlantService) SyncWikiVector(ctx context.Context, in *SyncWikiVectorReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) SyncWikiVector(ctx context.Context, in *SyncWikiVectorReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).SyncWikiVector(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.SyncWikiVector(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteWikiVector(ctx context.Context, in *SyncWikiVectorReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteWikiVector(ctx context.Context, in *SyncWikiVectorReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteWikiVector(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteWikiVector(ctx, in, opts...)
} }
func (m *defaultPlantService) SyncAllWikiVector(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) SyncAllWikiVector(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).SyncAllWikiVector(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.SyncAllWikiVector(ctx, in, opts...)
} }
func (m *defaultPlantService) GetWikiClassList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassListResp, error) { func (m *defaultPlantService) GetWikiClassList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetWikiClassList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetWikiClassList(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateWikiClass(ctx context.Context, in *CreateWikiClassReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateWikiClass(ctx context.Context, in *CreateWikiClassReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateWikiClass(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateWikiClass(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateWikiClass(ctx context.Context, in *UpdateWikiClassReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateWikiClass(ctx context.Context, in *UpdateWikiClassReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateWikiClass(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateWikiClass(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteWikiClass(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteWikiClass(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteWikiClass(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteWikiClass(ctx, in, opts...)
} }
func (m *defaultPlantService) ToggleWikiStar(ctx context.Context, in *ToggleStarReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) ToggleWikiStar(ctx context.Context, in *ToggleStarReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).ToggleWikiStar(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.ToggleWikiStar(ctx, in, opts...)
} }
// ---- OCR ---- // OCR
func (m *defaultPlantService) GetMyClassifyLog(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*ClassifyLogListResp, error) { func (m *defaultPlantService) GetMyClassifyLog(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*ClassifyLogListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetMyClassifyLog(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetMyClassifyLog(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteClassifyLog(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteClassifyLog(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteClassifyLog(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteClassifyLog(ctx, in, opts...)
} }
// ---- 社区 ---- // 社区
func (m *defaultPlantService) CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreatePost(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreatePost(ctx, in, opts...)
} }
func (m *defaultPlantService) DeletePost(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeletePost(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeletePost(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeletePost(ctx, in, opts...)
} }
func (m *defaultPlantService) GetPostList(ctx context.Context, in *PostListReq, opts ...grpc.CallOption) (*PostListResp, error) { func (m *defaultPlantService) GetPostList(ctx context.Context, in *PostListReq, opts ...grpc.CallOption) (*PostListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetPostList(ctx, in, opts...) 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) { func (m *defaultPlantService) GetPostDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*PostDetailResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetPostDetail(ctx, in, opts...) 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) { func (m *defaultPlantService) CommentPost(ctx context.Context, in *CommentPostReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CommentPost(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CommentPost(ctx, in, opts...)
} }
func (m *defaultPlantService) LikePost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) LikePost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).LikePost(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.LikePost(ctx, in, opts...)
} }
func (m *defaultPlantService) StarPost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) StarPost(ctx context.Context, in *LikePostReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).StarPost(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.StarPost(ctx, in, opts...)
} }
func (m *defaultPlantService) MediaCheckCallback(ctx context.Context, in *MediaCheckCallbackReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) MediaCheckCallback(ctx context.Context, in *MediaCheckCallbackReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).MediaCheckCallback(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.MediaCheckCallback(ctx, in, opts...)
} }
// ---- 话题 ---- // 话题
func (m *defaultPlantService) GetTopicList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*TopicListResp, error) { func (m *defaultPlantService) GetTopicList(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*TopicListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetTopicList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetTopicList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetTopicDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*TopicInfo, error) { func (m *defaultPlantService) GetTopicDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*TopicInfo, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetTopicDetail(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetTopicDetail(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateTopic(ctx context.Context, in *CreateTopicReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateTopic(ctx context.Context, in *CreateTopicReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateTopic(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateTopic(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateTopic(ctx context.Context, in *UpdateTopicReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateTopic(ctx context.Context, in *UpdateTopicReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateTopic(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateTopic(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteTopic(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteTopic(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteTopic(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteTopic(ctx, in, opts...)
} }
// ---- 兑换 ---- // 兑换
func (m *defaultPlantService) GetExchangeItemList(ctx context.Context, in *ExchangeItemListReq, opts ...grpc.CallOption) (*ExchangeItemListResp, error) { func (m *defaultPlantService) GetExchangeItemList(ctx context.Context, in *ExchangeItemListReq, opts ...grpc.CallOption) (*ExchangeItemListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetExchangeItemList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetExchangeItemList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetExchangeItemDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*ExchangeItemInfo, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetExchangeItemDetail(ctx, in, opts...)
}
func (m *defaultPlantService) CreateExchangeItem(ctx context.Context, in *CreateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateExchangeItem(ctx context.Context, in *CreateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateExchangeItem(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateExchangeItem(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateExchangeItem(ctx context.Context, in *UpdateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateExchangeItem(ctx context.Context, in *UpdateExchangeItemReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateExchangeItem(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateExchangeItem(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteExchangeItem(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteExchangeItem(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteExchangeItem(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteExchangeItem(ctx, in, opts...)
} }
func (m *defaultPlantService) CreateExchangeOrder(ctx context.Context, in *CreateExchangeOrderReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateExchangeOrder(ctx context.Context, in *CreateExchangeOrderReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateExchangeOrder(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateExchangeOrder(ctx, in, opts...)
} }
func (m *defaultPlantService) GetMyExchangeOrders(ctx context.Context, in *ExchangeOrderListReq, opts ...grpc.CallOption) (*ExchangeOrderListResp, error) { func (m *defaultPlantService) GetMyExchangeOrders(ctx context.Context, in *ExchangeOrderListReq, opts ...grpc.CallOption) (*ExchangeOrderListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetMyExchangeOrders(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetMyExchangeOrders(ctx, in, opts...)
} }
func (m *defaultPlantService) GetExchangeOrderList(ctx context.Context, in *ExchangeOrderListReq, opts ...grpc.CallOption) (*ExchangeOrderListResp, error) { func (m *defaultPlantService) GetExchangeOrderList(ctx context.Context, in *ExchangeOrderListReq, opts ...grpc.CallOption) (*ExchangeOrderListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetExchangeOrderList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetExchangeOrderList(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateExchangeOrder(ctx context.Context, in *UpdateExchangeOrderReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateExchangeOrder(ctx context.Context, in *UpdateExchangeOrderReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateExchangeOrder(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateExchangeOrder(ctx, in, opts...)
} }
// ---- 配置 ---- // 配置
func (m *defaultPlantService) GetLevelConfigList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*LevelConfigListResp, error) { func (m *defaultPlantService) GetLevelConfigList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*LevelConfigListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetLevelConfigList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetLevelConfigList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetLevelConfigDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*LevelConfigInfo, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetLevelConfigDetail(ctx, in, opts...)
}
func (m *defaultPlantService) CreateLevelConfig(ctx context.Context, in *CreateLevelConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateLevelConfig(ctx context.Context, in *CreateLevelConfigReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateLevelConfig(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateLevelConfig(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateLevelConfig(ctx context.Context, in *UpdateLevelConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateLevelConfig(ctx context.Context, in *UpdateLevelConfigReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateLevelConfig(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateLevelConfig(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteLevelConfig(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteLevelConfig(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteLevelConfig(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteLevelConfig(ctx, in, opts...)
} }
func (m *defaultPlantService) GetBadgeConfigList(ctx context.Context, in *BadgeConfigListReq, opts ...grpc.CallOption) (*BadgeConfigListResp, error) { func (m *defaultPlantService) GetBadgeConfigList(ctx context.Context, in *BadgeConfigListReq, opts ...grpc.CallOption) (*BadgeConfigListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetBadgeConfigList(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetBadgeConfigList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetBadgeConfigDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*BadgeConfigInfo, error) { func (m *defaultPlantService) GetBadgeConfigDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*BadgeConfigInfo, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetBadgeConfigDetail(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetBadgeConfigDetail(ctx, in, opts...)
} }
func (m *defaultPlantService) GetBadgeConfigTree(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*BadgeConfigTreeResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetBadgeConfigTree(ctx, in, opts...)
}
func (m *defaultPlantService) CreateBadgeConfig(ctx context.Context, in *CreateBadgeConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) CreateBadgeConfig(ctx context.Context, in *CreateBadgeConfigReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).CreateBadgeConfig(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateBadgeConfig(ctx, in, opts...)
} }
func (m *defaultPlantService) UpdateBadgeConfig(ctx context.Context, in *UpdateBadgeConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) UpdateBadgeConfig(ctx context.Context, in *UpdateBadgeConfigReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).UpdateBadgeConfig(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateBadgeConfig(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteBadgeConfig(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) DeleteBadgeConfig(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteBadgeConfig(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteBadgeConfig(ctx, in, opts...)
} }
// ---- AI ---- func (m *defaultPlantService) GetWikiClassDetail(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*WikiClassInfo, error) {
func (m *defaultPlantService) DeleteAiChatHistory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) { client := plant.NewPlantServiceClient(m.cli.Conn())
return plant.NewPlantServiceClient(m.cli.Conn()).DeleteAiChatHistory(ctx, in, opts...) return client.GetWikiClassDetail(ctx, in, opts...)
} }
// AI
func (m *defaultPlantService) GetAiChatHistory(ctx context.Context, in *AiChatHistoryReq, opts ...grpc.CallOption) (*AiChatHistoryResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetAiChatHistory(ctx, in, opts...)
}
func (m *defaultPlantService) SaveAiChatHistory(ctx context.Context, in *SaveAiChatHistoryReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) SaveAiChatHistory(ctx context.Context, in *SaveAiChatHistoryReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).SaveAiChatHistory(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.SaveAiChatHistory(ctx, in, opts...)
} }
func (m *defaultPlantService) DeleteAiChatHistory(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteAiChatHistory(ctx, in, opts...)
}
func (m *defaultPlantService) ClearAiChatHistory(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CommonResp, error) { func (m *defaultPlantService) ClearAiChatHistory(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).ClearAiChatHistory(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.ClearAiChatHistory(ctx, in, opts...)
} }
func (m *defaultPlantService) GetAiChatQuota(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*AiQuotaResp, error) { func (m *defaultPlantService) GetAiChatQuota(ctx context.Context, in *GetProfileReq, opts ...grpc.CallOption) (*AiQuotaResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetAiChatQuota(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetAiChatQuota(ctx, in, opts...)
} }
func (m *defaultPlantService) CompleteTask(ctx context.Context, in *plant.CompleteTaskReq, opts ...grpc.CallOption) (*plant.TaskCompletionResult, error) { // 快捷养护
return plant.NewPlantServiceClient(m.cli.Conn()).CompleteTask(ctx, in, opts...) func (m *defaultPlantService) QuickCare(ctx context.Context, in *QuickCareReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.QuickCare(ctx, in, opts...)
} }
func (m *defaultPlantService) GetExchangeItemDetail(ctx context.Context, in *plant.IdReq, opts ...grpc.CallOption) (*plant.ExchangeItemInfo, error) { // Banner
return plant.NewPlantServiceClient(m.cli.Conn()).GetExchangeItemDetail(ctx, in, opts...) func (m *defaultPlantService) CreateBanner(ctx context.Context, in *CreateBannerReq, opts ...grpc.CallOption) (*CommonResp, error) {
client := plant.NewPlantServiceClient(m.cli.Conn())
return client.CreateBanner(ctx, in, opts...)
} }
func (m *defaultPlantService) GetWikiClassDetail(ctx context.Context, in *plant.IdReq, opts ...grpc.CallOption) (*plant.WikiClassInfo, error) { func (m *defaultPlantService) UpdateBanner(ctx context.Context, in *UpdateBannerReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetWikiClassDetail(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.UpdateBanner(ctx, in, opts...)
} }
func (m *defaultPlantService) GetLevelConfigDetail(ctx context.Context, in *plant.IdReq, opts ...grpc.CallOption) (*plant.LevelConfigInfo, error) { func (m *defaultPlantService) DeleteBanner(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetLevelConfigDetail(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.DeleteBanner(ctx, in, opts...)
} }
func (m *defaultPlantService) GetBadgeConfigTree(ctx context.Context, in *plant.IdReq, opts ...grpc.CallOption) (*plant.BadgeConfigTreeResp, error) { func (m *defaultPlantService) GetBannerList(ctx context.Context, in *BannerListReq, opts ...grpc.CallOption) (*BannerListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetBadgeConfigTree(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetBannerList(ctx, in, opts...)
} }
func (m *defaultPlantService) GetAiChatHistory(ctx context.Context, in *plant.AiChatHistoryReq, opts ...grpc.CallOption) (*plant.AiChatHistoryResp, error) { func (m *defaultPlantService) GetActiveBannerList(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*BannerListResp, error) {
return plant.NewPlantServiceClient(m.cli.Conn()).GetAiChatHistory(ctx, in, opts...) client := plant.NewPlantServiceClient(m.cli.Conn())
return client.GetActiveBannerList(ctx, in, opts...)
} }
-4
View File
@@ -106,10 +106,6 @@ type SundynixUser struct {
Password string `gorm:"size:100;column:password" json:"-"` Password string `gorm:"size:100;column:password" json:"-"`
NickName string `gorm:"size:100;column:nick_name" json:"nickName"` NickName string `gorm:"size:100;column:nick_name" json:"nickName"`
Phone string `gorm:"size:20;column:phone" json:"phone"` Phone string `gorm:"size:20;column:phone" json:"phone"`
SessionKey string `gorm:"size:80;column:session_key" json:"-"`
UnionID string `gorm:"size:80;column:union_id" json:"unionId"`
OpenID string `gorm:"size:80;column:open_id;index" json:"openId"`
SaOpenID string `gorm:"size:80;column:sa_open_id" json:"saOpenId"`
AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"` AvatarID string `gorm:"size:50;column:avatar_id" json:"avatarId"`
Gender int `gorm:"default:0;column:gender" json:"gender"` Gender int `gorm:"default:0;column:gender" json:"gender"`
LastLoginIP string `gorm:"size:20;column:last_login_ip" json:"lastLoginIp"` LastLoginIP string `gorm:"size:20;column:last_login_ip" json:"lastLoginIp"`
@@ -23,18 +23,6 @@ func NewCreateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
} }
func (l *CreateUserLogic) CreateUser(in *system.CreateUserReq) (*system.CreateUserResp, error) { func (l *CreateUserLogic) CreateUser(in *system.CreateUserReq) (*system.CreateUserResp, error) {
// 如果有 OpenId,先查是否已存在(社交登录场景:已有用户直接返回)
if in.OpenId != "" {
var existing sysModel.SundynixUser
if err := l.svcCtx.DB.Where("open_id = ?", in.OpenId).First(&existing).Error; err == nil {
// 用户已存在,更新 session_key 后直接返回
if in.SessionKey != "" {
l.svcCtx.DB.Model(&existing).Update("session_key", in.SessionKey)
}
return &system.CreateUserResp{User: convertUserToProto(&existing)}, nil
}
}
// 如果有 Account,检查是否重复(后台创建用户场景:禁止重复) // 如果有 Account,检查是否重复(后台创建用户场景:禁止重复)
if in.Account != "" { if in.Account != "" {
var count int64 var count int64
@@ -48,8 +36,7 @@ func (l *CreateUserLogic) CreateUser(in *system.CreateUserReq) (*system.CreateUs
Name: in.Name, Name: in.Name,
Account: in.Account, Account: in.Account,
Phone: in.Phone, Phone: in.Phone,
OpenID: in.OpenId, NickName: in.NickName,
SessionKey: in.SessionKey,
ClientID: in.ClientId, ClientID: in.ClientId,
} }
if in.Password != "" { if in.Password != "" {
@@ -1,36 +0,0 @@
package logic
import (
"context"
"errors"
sysModel "sundynix-micro-go/app/system/model"
"sundynix-micro-go/app/system/rpc/internal/svc"
"sundynix-micro-go/app/system/rpc/system"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"gorm.io/gorm"
)
type GetUserByOpenIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserByOpenIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserByOpenIdLogic {
return &GetUserByOpenIdLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
}
func (l *GetUserByOpenIdLogic) GetUserByOpenId(in *system.GetUserByOpenIdReq) (*system.GetUserByOpenIdResp, error) {
var u sysModel.SundynixUser
if err := l.svcCtx.DB.Where("open_id = ?", in.OpenId).First(&u).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, status.Error(codes.NotFound, "用户不存在")
}
return nil, status.Error(codes.Internal, "查询失败")
}
return &system.GetUserByOpenIdResp{User: convertUserToProto(&u)}, nil
}
@@ -15,10 +15,6 @@ func convertUserToProto(u *sysModel.SundynixUser) *system.UserInfo {
Account: u.Account, Account: u.Account,
NickName: u.NickName, NickName: u.NickName,
Phone: u.Phone, Phone: u.Phone,
SessionKey: u.SessionKey,
UnionId: u.UnionID,
OpenId: u.OpenID,
SaOpenId: u.SaOpenID,
AvatarId: u.AvatarID, AvatarId: u.AvatarID,
Gender: int32(u.Gender), Gender: int32(u.Gender),
CreatedAt: u.CreatedAt.Unix(), CreatedAt: u.CreatedAt.Unix(),
@@ -29,11 +29,6 @@ func (s *SystemServiceServer) GetUserById(ctx context.Context, in *system.GetUse
return l.GetUserById(in) return l.GetUserById(in)
} }
func (s *SystemServiceServer) GetUserByOpenId(ctx context.Context, in *system.GetUserByOpenIdReq) (*system.GetUserByOpenIdResp, error) {
l := logic.NewGetUserByOpenIdLogic(ctx, s.svcCtx)
return l.GetUserByOpenId(in)
}
func (s *SystemServiceServer) LoginByAccount(ctx context.Context, in *system.LoginByAccountReq) (*system.LoginByAccountResp, error) { func (s *SystemServiceServer) LoginByAccount(ctx context.Context, in *system.LoginByAccountReq) (*system.LoginByAccountResp, error) {
l := logic.NewLoginByAccountLogic(ctx, s.svcCtx) l := logic.NewLoginByAccountLogic(ctx, s.svcCtx)
return l.LoginByAccount(in) return l.LoginByAccount(in)
+1 -15
View File
@@ -259,10 +259,6 @@ message UserInfo {
string account = 5; string account = 5;
string nickName = 6; string nickName = 6;
string phone = 7; string phone = 7;
string sessionKey = 8;
string unionId = 9;
string openId = 10;
string saOpenId = 11;
string avatarId = 12; string avatarId = 12;
int32 gender = 13; int32 gender = 13;
string country = 14; string country = 14;
@@ -287,20 +283,11 @@ message GetUserByIdResp {
UserInfo user = 1; UserInfo user = 1;
} }
message GetUserByOpenIdReq {
string openId = 1;
}
message GetUserByOpenIdResp {
UserInfo user = 1;
}
message CreateUserReq { message CreateUserReq {
string name = 1; string name = 1;
string account = 2; string account = 2;
string password = 3; string password = 3;
string openId = 4; string nickName = 4;
string sessionKey = 5;
string clientId = 6; string clientId = 6;
string phone = 7; string phone = 7;
} }
@@ -392,7 +379,6 @@ message GetClientByIdResp {
service SystemService { service SystemService {
// --- --- // --- ---
rpc GetUserById(GetUserByIdReq) returns (GetUserByIdResp); rpc GetUserById(GetUserByIdReq) returns (GetUserByIdResp);
rpc GetUserByOpenId(GetUserByOpenIdReq) returns (GetUserByOpenIdResp);
rpc LoginByAccount(LoginByAccountReq) returns (LoginByAccountResp); rpc LoginByAccount(LoginByAccountReq) returns (LoginByAccountResp);
rpc CreateUser(CreateUserReq) returns (CreateUserResp); rpc CreateUser(CreateUserReq) returns (CreateUserResp);
rpc UpdateUser(UpdateUserReq) returns (CommonResp); rpc UpdateUser(UpdateUserReq) returns (CommonResp);
File diff suppressed because it is too large Load Diff
+2 -40
View File
@@ -2,7 +2,7 @@
// versions: // versions:
// - protoc-gen-go-grpc v1.6.1 // - protoc-gen-go-grpc v1.6.1
// - protoc v7.34.1 // - protoc v7.34.1
// source: pb/system.proto // source: app/system/rpc/pb/system.proto
package system package system
@@ -20,7 +20,6 @@ const _ = grpc.SupportPackageIsVersion9
const ( const (
SystemService_GetUserById_FullMethodName = "/system.SystemService/GetUserById" SystemService_GetUserById_FullMethodName = "/system.SystemService/GetUserById"
SystemService_GetUserByOpenId_FullMethodName = "/system.SystemService/GetUserByOpenId"
SystemService_LoginByAccount_FullMethodName = "/system.SystemService/LoginByAccount" SystemService_LoginByAccount_FullMethodName = "/system.SystemService/LoginByAccount"
SystemService_CreateUser_FullMethodName = "/system.SystemService/CreateUser" SystemService_CreateUser_FullMethodName = "/system.SystemService/CreateUser"
SystemService_UpdateUser_FullMethodName = "/system.SystemService/UpdateUser" SystemService_UpdateUser_FullMethodName = "/system.SystemService/UpdateUser"
@@ -61,7 +60,6 @@ const (
type SystemServiceClient interface { type SystemServiceClient interface {
// --- 用户 --- // --- 用户 ---
GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error) GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error)
GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error)
LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error) LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error)
CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error) CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error)
UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error) UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error)
@@ -120,16 +118,6 @@ func (c *systemServiceClient) GetUserById(ctx context.Context, in *GetUserByIdRe
return out, nil return out, nil
} }
func (c *systemServiceClient) GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserByOpenIdResp)
err := c.cc.Invoke(ctx, SystemService_GetUserByOpenId_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *systemServiceClient) LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error) { func (c *systemServiceClient) LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(LoginByAccountResp) out := new(LoginByAccountResp)
@@ -456,7 +444,6 @@ func (c *systemServiceClient) GetOperationRecordList(ctx context.Context, in *Op
type SystemServiceServer interface { type SystemServiceServer interface {
// --- 用户 --- // --- 用户 ---
GetUserById(context.Context, *GetUserByIdReq) (*GetUserByIdResp, error) GetUserById(context.Context, *GetUserByIdReq) (*GetUserByIdResp, error)
GetUserByOpenId(context.Context, *GetUserByOpenIdReq) (*GetUserByOpenIdResp, error)
LoginByAccount(context.Context, *LoginByAccountReq) (*LoginByAccountResp, error) LoginByAccount(context.Context, *LoginByAccountReq) (*LoginByAccountResp, error)
CreateUser(context.Context, *CreateUserReq) (*CreateUserResp, error) CreateUser(context.Context, *CreateUserReq) (*CreateUserResp, error)
UpdateUser(context.Context, *UpdateUserReq) (*CommonResp, error) UpdateUser(context.Context, *UpdateUserReq) (*CommonResp, error)
@@ -508,9 +495,6 @@ type UnimplementedSystemServiceServer struct{}
func (UnimplementedSystemServiceServer) GetUserById(context.Context, *GetUserByIdReq) (*GetUserByIdResp, error) { func (UnimplementedSystemServiceServer) GetUserById(context.Context, *GetUserByIdReq) (*GetUserByIdResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserById not implemented") return nil, status.Error(codes.Unimplemented, "method GetUserById not implemented")
} }
func (UnimplementedSystemServiceServer) GetUserByOpenId(context.Context, *GetUserByOpenIdReq) (*GetUserByOpenIdResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserByOpenId not implemented")
}
func (UnimplementedSystemServiceServer) LoginByAccount(context.Context, *LoginByAccountReq) (*LoginByAccountResp, error) { func (UnimplementedSystemServiceServer) LoginByAccount(context.Context, *LoginByAccountReq) (*LoginByAccountResp, error) {
return nil, status.Error(codes.Unimplemented, "method LoginByAccount not implemented") return nil, status.Error(codes.Unimplemented, "method LoginByAccount not implemented")
} }
@@ -646,24 +630,6 @@ func _SystemService_GetUserById_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _SystemService_GetUserByOpenId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByOpenIdReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SystemServiceServer).GetUserByOpenId(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: SystemService_GetUserByOpenId_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SystemServiceServer).GetUserByOpenId(ctx, req.(*GetUserByOpenIdReq))
}
return interceptor(ctx, in, info, handler)
}
func _SystemService_LoginByAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _SystemService_LoginByAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginByAccountReq) in := new(LoginByAccountReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@@ -1251,10 +1217,6 @@ var SystemService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetUserById", MethodName: "GetUserById",
Handler: _SystemService_GetUserById_Handler, Handler: _SystemService_GetUserById_Handler,
}, },
{
MethodName: "GetUserByOpenId",
Handler: _SystemService_GetUserByOpenId_Handler,
},
{ {
MethodName: "LoginByAccount", MethodName: "LoginByAccount",
Handler: _SystemService_LoginByAccount_Handler, Handler: _SystemService_LoginByAccount_Handler,
@@ -1385,5 +1347,5 @@ var SystemService_ServiceDesc = grpc.ServiceDesc{
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "pb/system.proto", Metadata: "app/system/rpc/pb/system.proto",
} }
@@ -36,14 +36,10 @@ type (
GetMenusByRoleIdReq = system.GetMenusByRoleIdReq GetMenusByRoleIdReq = system.GetMenusByRoleIdReq
GetMenusByRoleIdResp = system.GetMenusByRoleIdResp GetMenusByRoleIdResp = system.GetMenusByRoleIdResp
GetRoleDetailReq = system.GetRoleDetailReq GetRoleDetailReq = system.GetRoleDetailReq
GetRoleListReq = system.RoleListReq
GetRoleListResp = system.RoleListResp
GetRolesByUserIdReq = system.GetRolesByUserIdReq GetRolesByUserIdReq = system.GetRolesByUserIdReq
GetRolesByUserIdResp = system.GetRolesByUserIdResp GetRolesByUserIdResp = system.GetRolesByUserIdResp
GetUserByIdReq = system.GetUserByIdReq GetUserByIdReq = system.GetUserByIdReq
GetUserByIdResp = system.GetUserByIdResp GetUserByIdResp = system.GetUserByIdResp
GetUserByOpenIdReq = system.GetUserByOpenIdReq
GetUserByOpenIdResp = system.GetUserByOpenIdResp
GetUserDetailReq = system.GetUserDetailReq GetUserDetailReq = system.GetUserDetailReq
GetUserListReq = system.GetUserListReq GetUserListReq = system.GetUserListReq
GetUserListResp = system.GetUserListResp GetUserListResp = system.GetUserListResp
@@ -72,7 +68,6 @@ type (
SystemService interface { SystemService interface {
// --- 用户 --- // --- 用户 ---
GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error) GetUserById(ctx context.Context, in *GetUserByIdReq, opts ...grpc.CallOption) (*GetUserByIdResp, error)
GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error)
LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error) LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error)
CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error) CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error)
UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error) UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error)
@@ -130,11 +125,6 @@ func (m *defaultSystemService) GetUserById(ctx context.Context, in *GetUserByIdR
return client.GetUserById(ctx, in, opts...) return client.GetUserById(ctx, in, opts...)
} }
func (m *defaultSystemService) GetUserByOpenId(ctx context.Context, in *GetUserByOpenIdReq, opts ...grpc.CallOption) (*GetUserByOpenIdResp, error) {
client := system.NewSystemServiceClient(m.cli.Conn())
return client.GetUserByOpenId(ctx, in, opts...)
}
func (m *defaultSystemService) LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error) { func (m *defaultSystemService) LoginByAccount(ctx context.Context, in *LoginByAccountReq, opts ...grpc.CallOption) (*LoginByAccountResp, error) {
client := system.NewSystemServiceClient(m.cli.Conn()) client := system.NewSystemServiceClient(m.cli.Conn())
return client.LoginByAccount(ctx, in, opts...) return client.LoginByAccount(ctx, in, opts...)
@@ -0,0 +1,332 @@
# DTM Saga 分布式事务改造 — 用户注册流程
## 背景
当前 [findorcreateuserbyopenidlogic.go](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/plant/rpc/internal/logic/findorcreateuserbyopenidlogic.go) 中,Plant RPC 直接跨服务边界操作 System 的 `sundynix_user` 表,使用本地事务一次性创建基础用户和扩展用户。这违反了微服务自治原则,**一旦分库部署将导致数据不一致**。
本方案引入 **DTM (Distributed Transaction Manager)****Saga 模式**,将跨服务的用户注册拆分为两个独立的子事务,由 DTM 协调保证强一致性。
---
## User Review Required
> [!IMPORTANT]
> **基础设施依赖**:本方案需要部署一个 DTM 服务实例(Docker 容器),并且 DTM 依赖 MySQL 存储事务状态。请确认你的 `192.168.100.127` 服务器上可以运行新的 Docker 容器。
> [!WARNING]
> **DTM 维护状态**`dtm-driver-gozero` 项目近两年更新较少,但核心功能稳定且被广泛使用。与 go-zero v1.10.1 兼容性需要验证,如果有兼容性问题我会做适配。
## Open Questions
> [!IMPORTANT]
> 1. **DTM 部署方式**:你希望 DTM 服务部署在 `192.168.100.127` 上(推荐,和 etcd/MySQL 同机器),还是本地开发环境?
> 2. **DTM 存储**:DTM 需要一个 MySQL 数据库来存储事务状态。是新建一个 `dtm` 数据库,还是在现有的 `sundynix_micro_go` 中加表?推荐新建独立数据库。
> 3. **Saga vs TCC 选择**:对于用户注册场景,Saga 更合适(逻辑简单、不需要资源预留),TCC 适合需要"冻结"资源的场景(如扣款)。你确定要用 Saga 还是 TCC?下面默认按 **Saga** 设计。
---
## 架构设计
### 改造前 vs 改造后
```mermaid
graph TB
subgraph "改造前 ❌"
A1[Plant RPC] -->|"直接 tx.Create"| B1[sundynix_user 表]
A1 -->|"直接 tx.Create"| C1[plant_user_profile 表]
style B1 fill:#ff6b6b,color:#fff
end
subgraph "改造后 ✅"
DTM[DTM Server] -->|"Step 1: CreateUserByMini"| SYS[System RPC]
DTM -->|"Step 2: CreateProfile"| PLT[Plant RPC]
SYS -->|"本地事务"| B2[sundynix_user 表]
PLT -->|"本地事务"| C2[plant_user_profile 表]
DTM -.->|"失败补偿"| SYS2[System: CompensateCreateUser]
DTM -.->|"失败补偿"| PLT2[Plant: CompensateCreateProfile]
style DTM fill:#4ecdc4,color:#fff
end
```
### Saga 事务流程
```mermaid
sequenceDiagram
participant Plant as Plant RPC<br>(事务发起者)
participant DTM as DTM Server
participant Sys as System RPC
participant PlantSub as Plant RPC<br>(子事务)
Plant->>DTM: 提交 Saga 全局事务 (gid)
DTM->>Sys: Step1: CreateUserByMini(openId, clientId, nickName)
Sys->>Sys: barrier.Call → INSERT sundynix_user → 返回 userId
Sys-->>DTM: 返回 {userId}
DTM->>PlantSub: Step2: CreateProfile(userId, openId, sessionKey...)
PlantSub->>PlantSub: barrier.Call → INSERT plant_user_profile
PlantSub-->>DTM: 返回 success
DTM-->>Plant: Saga 完成
Note over DTM,PlantSub: 如果 Step2 失败:
DTM->>PlantSub: CompensateCreateProfile(userId)
DTM->>Sys: CompensateCreateUserByMini(userId)
```
---
## Proposed Changes
### 1. 基础设施 — DTM 服务部署
`192.168.100.127` 上通过 Docker 部署 DTM
```bash
docker run -d --name dtm \
-p 36789:36789 \
-p 36790:36790 \
-e STORE_DRIVER=mysql \
-e STORE_HOST=192.168.100.127 \
-e STORE_PORT=3307 \
-e STORE_USER=root \
-e STORE_PASSWORD=root \
-e MICRO_SERVICE_DRIVER=dtm-driver-gozero \
-e MICRO_SERVICE_TARGET=etcd://192.168.100.127:2379/dtmservice \
yedf/dtm:latest
```
同时需要在数据库中创建 `dtm_barrier` 表(DTM 子事务屏障所需),分别在 System 和 Plant 连接的数据库中建表:
```sql
CREATE TABLE IF NOT EXISTS dtm_barrier (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
trans_type VARCHAR(45) DEFAULT '',
gid VARCHAR(128) DEFAULT '',
branch_id VARCHAR(128) DEFAULT '',
op VARCHAR(45) DEFAULT '',
barrier_id VARCHAR(45) DEFAULT '',
reason VARCHAR(45) DEFAULT '',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
update_time DATETIME DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY uk_barrier (gid, branch_id, op, barrier_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```
---
### 2. 依赖管理
#### [MODIFY] [go.mod](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/go.mod)
新增 DTM 相关依赖:
```
github.com/dtm-labs/dtmgrpc
github.com/dtm-labs/dtmdriver-gozero
```
---
### 3. System RPC — 新增子事务方法
#### [MODIFY] [system.proto](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/system/rpc/pb/system.proto)
新增消息和 RPC 方法:
```protobuf
// DTM Saga 子事务:小程序注册基础用户
message CreateUserByMiniReq {
string openId = 1; // 用于幂等判断
string clientId = 2;
string nickName = 3;
}
message CreateUserByMiniResp {
string userId = 1;
}
// Service 新增:
rpc CreateUserByMini(CreateUserByMiniReq) returns (CreateUserByMiniResp);
rpc CreateUserByMiniCompensate(CreateUserByMiniReq) returns (CommonResp);
```
#### [NEW] createUserByMiniLogic.go
- 使用 `dtmgrpc.BarrierFromGrpc(ctx)` 创建子事务屏障
- `barrier.CallWithDB(db, func(tx *sql.Tx) error { ... })` 内执行 INSERT
- 自动处理幂等、空补偿、悬挂问题
#### [NEW] createUserByMiniCompensateLogic.go
- 同样使用子事务屏障
- 补偿逻辑:`DELETE FROM sundynix_user WHERE id = ? AND client_id = ?`
---
### 4. Plant RPC — 新增子事务方法 + 重构编排
#### [MODIFY] [plant.proto](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/plant/rpc/pb/plant.proto)
新增消息和 RPC 方法:
```protobuf
// DTM Saga 子事务:创建 Plant 用户扩展表
message CreateProfileReq {
string userId = 1;
string openId = 2;
string sessionKey = 3;
string unionId = 4;
string saOpenId = 5;
string clientId = 6;
string nickName = 7;
}
message CreateProfileResp {
string profileId = 1;
}
// Service 新增:
rpc CreateProfile(CreateProfileReq) returns (CreateProfileResp);
rpc CreateProfileCompensate(CreateProfileReq) returns (CommonResp);
```
#### [NEW] createProfileLogic.go
- 子事务屏障内执行:查找初始等级 + INSERT `plant_user_profile`
#### [NEW] createProfileCompensateLogic.go
- 子事务屏障内执行:`DELETE FROM sundynix_plant_user_profile WHERE user_id = ?`
#### [MODIFY] [findorcreateuserbyopenidlogic.go](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/plant/rpc/internal/logic/findorcreateuserbyopenidlogic.go)
**核心改造**:从直接操作数据库改为 **DTM Saga 编排者**
```go
func (l *FindOrCreateUserByOpenIdLogic) FindOrCreateUserByOpenId(in *plant.FindOrCreateUserByOpenIdReq) (*plant.PlantUserProfile, error) {
// 1. 先查询是否已存在(不变)
var profile plantModel.UserProfile
err := l.svcCtx.DB.Where("mini_open_id = ?", in.OpenId).First(&profile).Error
if err == nil {
// 已存在:更新 session_key,直接返回(不变)
...
return &plant.PlantUserProfile{...}, nil
}
// 2. 新用户 → 发起 DTM Saga 分布式事务
dtmServer := "etcd://192.168.100.127:2379/dtmservice"
systemTarget := "etcd://192.168.100.127:2379/system.rpc"
plantTarget := "etcd://192.168.100.127:2379/plant.rpc"
gid := dtmgrpc.MustGenGid(dtmServer)
sysReq := &sysPb.CreateUserByMiniReq{
OpenId: in.OpenId,
ClientId: in.ClientId,
NickName: "园艺新手",
}
plantReq := &plantPb.CreateProfileReq{
UserId: "", // 由 DTM 传递(见下方说明)
OpenId: in.OpenId,
SessionKey: in.SessionKey,
UnionId: in.UnionId,
SaOpenId: in.SaOpenId,
ClientId: in.ClientId,
NickName: "园艺新手",
}
saga := dtmgrpc.NewSagaGrpc(dtmServer, gid).
Add(systemTarget+"/system.SystemService/CreateUserByMini",
systemTarget+"/system.SystemService/CreateUserByMiniCompensate",
sysReq).
Add(plantTarget+"/plant.PlantService/CreateProfile",
plantTarget+"/plant.PlantService/CreateProfileCompensate",
plantReq)
saga.WaitResult = true // 等待事务结果
err = saga.Submit()
if err != nil {
return nil, fmt.Errorf("注册用户失败: %w", err)
}
// 3. 事务完成后查询完整 profile
l.svcCtx.DB.Where("mini_open_id = ?", in.OpenId).First(&profile)
return &plant.PlantUserProfile{...}, nil
}
```
> [!IMPORTANT]
> **关于 userId 传递问题**:Saga 模式下各步骤是独立的,Step2 无法直接获取 Step1 返回的 userId。解决方案是:**CreateProfile 内部根据 openId 查询刚创建的 sundynix_user 获取 userId**(两步在同一个 gid 内是顺序执行的,Step1 完成后 Step2 才会执行)。或者使用 DTM 的 **Workflow 模式** 代替 Saga,支持步骤间传值。
---
### 5. 配置更新
#### [MODIFY] [plant.yaml](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/plant/rpc/etc/plant.yaml)
```yaml
# 新增 DTM 和 System RPC 配置
DtmServer: "etcd://192.168.100.127:2379/dtmservice"
SystemRpc:
Etcd:
Hosts:
- 192.168.100.127:2379
Key: system.rpc
```
#### [MODIFY] Plant RPC config.go, serviceContext.go
- Config 增加 `DtmServer string``SystemRpc zrpc.RpcClientConf`
- ServiceContext 增加 SystemRpc 客户端(仅用于非 DTM 场景的备用查询)
---
### 6. 删除旧的跨服务代码
#### [MODIFY] [findorcreateuserbyopenidlogic.go](file:///Users/zhangjianmin/sourceCode/GolandProjects/src/sundynix-micro-go/app/plant/rpc/internal/logic/findorcreateuserbyopenidlogic.go)
- 移除对 `sysModel.SundynixUser` 的直接引用和 import
- 移除 `tx.Create(&sysUser)` 这段跨服务写入代码
---
## 文件变更总结
| 服务 | 文件 | 操作 | 说明 |
|---|---|---|---|
| **根目录** | `go.mod` | MODIFY | 添加 dtmgrpc、dtm-driver-gozero 依赖 |
| **System RPC** | `system.proto` | MODIFY | 新增 CreateUserByMini + Compensate RPC |
| **System RPC** | `createUserByMiniLogic.go` | NEW | 子事务:创建基础用户 (barrier) |
| **System RPC** | `createUserByMiniCompensateLogic.go` | NEW | 补偿:删除基础用户 (barrier) |
| **Plant RPC** | `plant.proto` | MODIFY | 新增 CreateProfile + Compensate RPC |
| **Plant RPC** | `createProfileLogic.go` | NEW | 子事务:创建扩展用户 (barrier) |
| **Plant RPC** | `createProfileCompensateLogic.go` | NEW | 补偿:删除扩展用户 (barrier) |
| **Plant RPC** | `findorcreateuserbyopenidlogic.go` | MODIFY | 重构为 Saga 编排者 |
| **Plant RPC** | `config.go` | MODIFY | 添加 DtmServer 配置 |
| **Plant RPC** | `serviceContext.go` | MODIFY | 初始化 DTM driver |
| **Plant RPC** | `plant.yaml` | MODIFY | 添加 DTM 连接配置 |
| **Database** | SQL | EXECUTE | 创建 dtm_barrier 屏障表 |
---
## Verification Plan
### Automated Tests
```bash
# 1. 编译验证
go build ./app/system/rpc/...
go build ./app/plant/rpc/...
go build ./app/auth/api/...
# 2. 确认 DTM 服务健康
curl http://192.168.100.127:36789/api/dtmsvr/version
```
### Manual Verification
1. 启动 DTM + System RPC + Plant RPC + Auth API
2. 小程序端发起 miniLogin → 验证新用户同时出现在 `sundynix_user``plant_user_profile`
3. 模拟 Plant CreateProfile 失败 → 验证 System 的 CompensateCreateUserByMini 被调用,`sundynix_user` 中无孤儿记录
4. 通过 DTM 管理台 (`http://192.168.100.127:36789`) 查看事务状态