feat: 迁移plant

This commit is contained in:
Blizzard
2026-05-23 13:55:05 +08:00
parent a93477ea8e
commit ae6d03d351
228 changed files with 25296 additions and 917 deletions
@@ -3,10 +3,12 @@ package logic
import (
"context"
plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/internal/svc"
"sundynix-micro-go/app/plant/rpc/plant"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
type CommentPostLogic struct {
@@ -23,8 +25,23 @@ func NewCommentPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comme
}
}
// 评论帖子
func (l *CommentPostLogic) CommentPost(in *plant.CommentPostReq) (*plant.CommonResp, error) {
// todo: add your logic here and delete this line
return &plant.CommonResp{}, nil
err := l.svcCtx.DB.Transaction(func(tx *gorm.DB) error {
comment := plantModel.PostComment{
PostID: in.PostId,
UserID: in.UserId,
Content: in.Content,
ParentID: in.ParentId,
}
if err := tx.Create(&comment).Error; err != nil {
return err
}
return tx.Model(&plantModel.Post{}).Where("id = ?", in.PostId).
Update("comment_count", gorm.Expr("comment_count + 1")).Error
})
if err != nil {
return nil, err
}
return &plant.CommonResp{Code: 0, Msg: "ok"}, nil
}