refactor: reorganize modules and add Linux build tooling
This commit is contained in:
62
module/social/feed/internal/config/config.go
Normal file
62
module/social/feed/internal/config/config.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/conf"
|
||||
"git.apinb.com/bsm-sdk/core/crypto/encipher"
|
||||
"git.apinb.com/bsm-sdk/core/env"
|
||||
)
|
||||
|
||||
var (
|
||||
Spec SrvConfig
|
||||
)
|
||||
|
||||
type SrvConfig struct {
|
||||
conf.Base `yaml:",inline"`
|
||||
Databases *conf.DBConf `yaml:"Databases"`
|
||||
MicroService *conf.MicroServiceConf `yaml:"MicroService"`
|
||||
Rpc map[string]conf.RpcConf `yaml:"Rpc"`
|
||||
Gateway *conf.GatewayConf `yaml:"Gateway"`
|
||||
Apm *conf.ApmConf `yaml:"APM"`
|
||||
Etcd *conf.EtcdConf `yaml:"Etcd"`
|
||||
WeChat *WeChatConf `yaml:"WeChatConf"`
|
||||
Token *TokenConf `yaml:"Token"`
|
||||
Kyc *KycConf `yaml:"Kyc"`
|
||||
}
|
||||
|
||||
type KycConf struct {
|
||||
Provider string `yaml:"Provider"`
|
||||
BaseUrl string `yaml:"BaseUrl"`
|
||||
ApiSecret string `yaml:"ApiSecret"`
|
||||
ApiToken string `yaml:"ApiToken"`
|
||||
ApiArgs string `yaml:"ApiArgs"`
|
||||
}
|
||||
|
||||
type TokenConf struct {
|
||||
Prefix string `yaml:"Prefix"`
|
||||
Expire int `yaml:"Expire"`
|
||||
}
|
||||
|
||||
type WeChatConf struct {
|
||||
AppID string `json:"app_id"`
|
||||
AppSecret string `json:"app_secret"`
|
||||
}
|
||||
|
||||
func New(srvKey string) {
|
||||
// 初始化配置 创建一个新的配置实例,用于服务配置
|
||||
conf.New(srvKey, &Spec)
|
||||
|
||||
// 配置校验 服务IP,端口; 端口如果不合规,则随机分配端口
|
||||
Spec.Port = conf.CheckPort(Spec.Port)
|
||||
Spec.BindIP = conf.CheckIP(Spec.BindIP)
|
||||
Spec.Addr = net.JoinHostPort(Spec.BindIP, Spec.Port)
|
||||
|
||||
// 配置校验 服务名称地址及监听地址不能为空
|
||||
conf.NotNil(Spec.Service, Spec.Cache)
|
||||
|
||||
// 初始化加密SecretKey
|
||||
encipher.New(env.Runtime.JwtSecretKey)
|
||||
|
||||
conf.PrintInfo(Spec.Addr)
|
||||
}
|
||||
25
module/social/feed/internal/impl/impl.go
Normal file
25
module/social/feed/internal/impl/impl.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package impl
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/cache/redis"
|
||||
"git.apinb.com/bsm-sdk/core/with"
|
||||
"bsm/full/module/social/feed/internal/config"
|
||||
cache "github.com/patrickmn/go-cache"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
RedisService *redis.RedisClient
|
||||
EtcdService *clientv3.Client
|
||||
DBService *gorm.DB
|
||||
MemorySerice *cache.Cache
|
||||
)
|
||||
|
||||
func NewImpl() {
|
||||
// with activating
|
||||
MemorySerice = with.Memory(nil)
|
||||
RedisService = with.RedisCache(config.Spec.Cache) // redis cache
|
||||
DBService = with.Databases(config.Spec.Databases, nil) // model
|
||||
EtcdService = with.Etcd(config.Spec.Etcd) // etcd
|
||||
}
|
||||
34
module/social/feed/internal/logic/post/action.go
Normal file
34
module/social/feed/internal/logic/post/action.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 计数操作
|
||||
func Action(ctx context.Context, in *pb.PostActionRequest) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetActionOp() == "" || in.GetActionType() == "" || in.GetIdentity() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
if err := models.LikeAction(in.ActionOp, in.ActionType, in.Identity); err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: vars.OK,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
40
module/social/feed/internal/logic/post/add_comment.go
Normal file
40
module/social/feed/internal/logic/post/add_comment.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 新建评论
|
||||
func AddComment(ctx context.Context, in *pb.CommentItem) (reply *pb.StatusReply, err error) {
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var data = &models.FeedComment{
|
||||
Std_IICUDS: types.Std_IICUDS{Identity: utils.UUID()},
|
||||
PostIdentity: in.PostIdentity,
|
||||
Content: in.Content,
|
||||
}
|
||||
if in.Identity != "" {
|
||||
data.ParentIdentity = in.Identity
|
||||
}
|
||||
if err := models.AddComment(data, auth.Identity); err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: data.Identity,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
50
module/social/feed/internal/logic/post/change.go
Normal file
50
module/social/feed/internal/logic/post/change.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 修改推文
|
||||
func Change(ctx context.Context, in *pb.PostItem) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetContent() == "" || in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
var postData = models.FeedPost{
|
||||
Std_IICUDS: types.Std_IICUDS{Identity: in.Identity},
|
||||
Content: in.Content,
|
||||
IsOpen: in.IsOpen,
|
||||
}
|
||||
|
||||
if len(in.GetAttachs()) != 0 {
|
||||
for _, val := range in.Attachs {
|
||||
postData.Attachs = append(postData.Attachs, models.FeedRelateAttach{
|
||||
Identity: utils.UUID(),
|
||||
AttachType: val.AttachType,
|
||||
Url: val.Url,
|
||||
})
|
||||
}
|
||||
}
|
||||
err = models.ChargePost(&postData)
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: postData.Identity,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
29
module/social/feed/internal/logic/post/comment_list.go
Normal file
29
module/social/feed/internal/logic/post/comment_list.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 评论列表
|
||||
func CommentList(ctx context.Context, in *pb.FetchRequest) (reply *pb.CommentListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
62
module/social/feed/internal/logic/post/create.go
Normal file
62
module/social/feed/internal/logic/post/create.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 新建推文
|
||||
func Create(ctx context.Context, in *pb.PostItem) (reply *pb.StatusReply, err error) {
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetContent() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
var postData = models.FeedPost{
|
||||
Std_IICUDS: types.Std_IICUDS{Identity: utils.UUID()},
|
||||
Std_Passport: types.Std_Passport{PassportID: auth.ID, PassportIdentity: auth.Identity},
|
||||
Content: in.Content,
|
||||
IsOpen: in.IsOpen,
|
||||
}
|
||||
|
||||
if len(in.GetAttachs()) > 0 {
|
||||
for _, val := range in.Attachs {
|
||||
postData.Attachs = append(postData.Attachs, models.FeedRelateAttach{
|
||||
PostIdentity: postData.Std_IICUDS.Identity,
|
||||
Identity: utils.UUID(),
|
||||
AttachType: val.AttachType,
|
||||
Url: val.Url,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(in.GetTags()) > 0 {
|
||||
for _, val := range in.Tags {
|
||||
postData.Tags = append(postData.Tags, models.FeedRelateTags{
|
||||
PostIdentity: postData.Std_IICUDS.Identity,
|
||||
Content: val.Content,
|
||||
Key: val.Key,
|
||||
})
|
||||
}
|
||||
}
|
||||
err = models.CreatePost(&postData)
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
return &pb.StatusReply{
|
||||
Data: postData.Identity,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
34
module/social/feed/internal/logic/post/delete_comment.go
Normal file
34
module/social/feed/internal/logic/post/delete_comment.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 删除评论
|
||||
func DeleteComment(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetId() == 0 && in.GetIdentity() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
err = models.DeleteComment(in.Identity)
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: vars.OK,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
67
module/social/feed/internal/logic/post/fetch.go
Normal file
67
module/social/feed/internal/logic/post/fetch.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 推文列表
|
||||
func Fetch(ctx context.Context, in *pb.FetchRequest) (reply *pb.PostListReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetPageNo() <= 0 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() <= 0 {
|
||||
in.PageSize = 10
|
||||
}
|
||||
|
||||
data, cnt, err := models.PostList(in.PageNo, in.PageSize, in.Params["key"])
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
var res = &pb.PostListReply{Cnt: cnt}
|
||||
if cnt > 0 {
|
||||
res.List = AssembleList(data)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func AssembleList(data []*models.FeedPost) (res []*pb.PostItem) {
|
||||
for _, val := range data {
|
||||
post := &pb.PostItem{
|
||||
Identity: val.Identity,
|
||||
Content: val.Content,
|
||||
FeedIdentity: val.Identity,
|
||||
FeedId: int64(val.ID),
|
||||
IsOpen: val.IsOpen,
|
||||
CntUnlike: val.CntUnlike,
|
||||
CntLike: val.CntLike,
|
||||
CntComment: val.CntComment,
|
||||
}
|
||||
for _, tag := range val.Tags {
|
||||
post.Tags = append(post.Tags, &pb.TagItem{
|
||||
Key: tag.Key,
|
||||
Content: tag.Content,
|
||||
})
|
||||
}
|
||||
for _, attachs := range val.Attachs {
|
||||
post.Attachs = append(post.Attachs, &pb.AttachItem{
|
||||
Identity: attachs.Identity,
|
||||
AttachType: attachs.AttachType,
|
||||
Url: attachs.Url,
|
||||
})
|
||||
}
|
||||
res = append(res, post)
|
||||
}
|
||||
return
|
||||
}
|
||||
36
module/social/feed/internal/logic/post/remove.go
Normal file
36
module/social/feed/internal/logic/post/remove.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 删除推文
|
||||
func Remove(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetIdentity() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
err = models.DeletePost(in.Identity)
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
return &pb.StatusReply{
|
||||
Data: vars.OK,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
23
module/social/feed/internal/logic/setting/info.go
Normal file
23
module/social/feed/internal/logic/setting/info.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 修改个人信息
|
||||
func Info(ctx context.Context, in *pb.Empty) (reply *pb.Empty, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: valid code
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
23
module/social/feed/internal/logic/setting/rights.go
Normal file
23
module/social/feed/internal/logic/setting/rights.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 修改权限信息
|
||||
func Rights(ctx context.Context, in *pb.Empty) (reply *pb.Empty, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: valid code
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
37
module/social/feed/internal/logic/tag/create.go
Normal file
37
module/social/feed/internal/logic/tag/create.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package tag
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 新建标签
|
||||
func Create(ctx context.Context, in *pb.AddTagRequest) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(in.GetTags()) == 0 {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
var tags = &[]models.FeedTags{}
|
||||
for _, val := range in.Tags {
|
||||
*tags = append(*tags, models.FeedTags{
|
||||
Key: utils.UUID(),
|
||||
Content: val,
|
||||
})
|
||||
}
|
||||
if err := models.AddTags(tags); err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
return &pb.StatusReply{}, nil
|
||||
|
||||
}
|
||||
33
module/social/feed/internal/logic/tag/list.go
Normal file
33
module/social/feed/internal/logic/tag/list.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package tag
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 标签列表
|
||||
func List(ctx context.Context, in *pb.FetchRequest) (reply *pb.TagListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tags, cnt, err := models.TagsList()
|
||||
if err != nil {
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
var res = &pb.TagListReply{Total: cnt}
|
||||
for _, v := range tags {
|
||||
res.Tags = append(res.Tags, &pb.TagItem{
|
||||
Key: v.Key,
|
||||
Content: v.Content,
|
||||
})
|
||||
}
|
||||
return &pb.TagListReply{}, nil
|
||||
}
|
||||
29
module/social/feed/internal/logic/tag/post_list.go
Normal file
29
module/social/feed/internal/logic/tag/post_list.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package tag
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 话题相关的文章
|
||||
func PostList(ctx context.Context, in *pb.FetchRequest) (reply *pb.PostListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
29
module/social/feed/internal/logic/timeline/follow.go
Normal file
29
module/social/feed/internal/logic/timeline/follow.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package timeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 关注的动态
|
||||
func Follow(ctx context.Context, in *pb.FetchRequest) (reply *pb.PostListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
29
module/social/feed/internal/logic/timeline/friend.go
Normal file
29
module/social/feed/internal/logic/timeline/friend.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package timeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 好友动态
|
||||
func Friend(ctx context.Context, in *pb.FetchRequest) (reply *pb.PostListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
29
module/social/feed/internal/logic/timeline/hot.go
Normal file
29
module/social/feed/internal/logic/timeline/hot.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package timeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 热门
|
||||
func Hot(ctx context.Context, in *pb.FetchRequest) (reply *pb.PostListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
29
module/social/feed/internal/logic/timeline/recommend.go
Normal file
29
module/social/feed/internal/logic/timeline/recommend.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package timeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 推荐
|
||||
func Recommend(ctx context.Context, in *pb.FetchRequest) (reply *pb.PostListReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request page_no,page_size.
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
|
||||
// TODO: add your logic code & delete this line.
|
||||
|
||||
return
|
||||
}
|
||||
20
module/social/feed/internal/models/feed_comment.go
Normal file
20
module/social/feed/internal/models/feed_comment.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/types"
|
||||
|
||||
// feed评论表
|
||||
type FeedComment struct {
|
||||
types.Std_IICUDS
|
||||
types.Std_Passport
|
||||
PostIdentity string `gorm:"column:post_identity;type:varchar(36);index;" json:"post_identity"` // 推文唯一码
|
||||
ParentIdentity string `gorm:"column:parent_identity;type:varchar(36);index;" json:"parent_identity"` // 上级评论唯一码
|
||||
Content string `gorm:"column:content;type:text;default:'';" json:"content"` // 正文
|
||||
SubComment []FeedComment `gorm:"foreignkey:parent_identity;"` // 子评论唯一码
|
||||
CntLike int64 `gorm:"column:cnt_like;type:int;default:0" json:"cnt_like"` // 点赞数
|
||||
CntUnlike int64 `gorm:"column:cnt_unlike;type:int;default:0" json:"cnt_unlike"` // 点踩数
|
||||
CntComment int64 `gorm:"column:cnt_comment;type:int;default:0" json:"cnt_comment"` // 评论数
|
||||
}
|
||||
|
||||
func (table *FeedComment) TableName() string {
|
||||
return "feed_comment"
|
||||
}
|
||||
22
module/social/feed/internal/models/feed_post.go
Normal file
22
module/social/feed/internal/models/feed_post.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
)
|
||||
|
||||
// feed推文表
|
||||
type FeedPost struct {
|
||||
types.Std_IICUDS
|
||||
types.Std_Passport
|
||||
Content string `gorm:"column:content;type:text;default:'';" json:"content"` // 正文
|
||||
IsOpen bool `gorm:"column:is_open;default:true;" json:"is_open"` // 默认为true-公开,false-不公开
|
||||
CntLike int64 `gorm:"column:cnt_like;type:int;default:0;" json:"cnt_like"` // 点赞数
|
||||
CntUnlike int64 `gorm:"column:cnt_unlike;type:int;default:0;" json:"cnt_unlike"` // 点踩数
|
||||
CntComment int64 `gorm:"column:cnt_comment;type:int;default:0;" json:"cnt_comment"` // 评论数
|
||||
Attachs []FeedRelateAttach `gorm:"-"`
|
||||
Tags []FeedRelateTags `gorm:"-"`
|
||||
}
|
||||
|
||||
func (c *FeedPost) TableName() string {
|
||||
return "feed_post"
|
||||
}
|
||||
16
module/social/feed/internal/models/feed_relate_attachs.go
Normal file
16
module/social/feed/internal/models/feed_relate_attachs.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/types"
|
||||
|
||||
// feed 关联附件表
|
||||
type FeedRelateAttach struct {
|
||||
types.Std_IDIdentity
|
||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;"`
|
||||
PostIdentity string `gorm:"column:post_identity;type:varchar(36);index;" json:"post_identity"` // 推文唯一码
|
||||
AttachType string `gorm:"column:attach_type;type:varchar(36);index;" json:"attach_type"` // 附件类型
|
||||
Url string `gorm:"column:url;type:varchar(255);index;" json:"url"` // 附件地址
|
||||
}
|
||||
|
||||
func (table *FeedRelateAttach) TableName() string {
|
||||
return "feed_relate_attach"
|
||||
}
|
||||
15
module/social/feed/internal/models/feed_relate_tags.go
Normal file
15
module/social/feed/internal/models/feed_relate_tags.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package models
|
||||
|
||||
import "git.apinb.com/bsm-sdk/core/types"
|
||||
|
||||
// feed 关联标签表
|
||||
type FeedRelateTags struct {
|
||||
types.Std_IDIdentity
|
||||
PostIdentity string `gorm:"column:post_identity;type:varchar(36);index;" json:"post_identity"`
|
||||
Key string `gorm:"column:key;type:varchar(36);index;" json:"key"`
|
||||
Content string `gorm:"-"`
|
||||
}
|
||||
|
||||
func (table *FeedRelateTags) TableName() string {
|
||||
return "feed_relate_tags"
|
||||
}
|
||||
16
module/social/feed/internal/models/feed_tags.go
Normal file
16
module/social/feed/internal/models/feed_tags.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// feed标签表
|
||||
type FeedTags struct {
|
||||
gorm.Model
|
||||
Key string `gorm:"column:key;type:varchar(36);not null" json:"key"`
|
||||
Content string `gorm:"column:content;type:varchar(255);not null" json:"content"`
|
||||
}
|
||||
|
||||
func (c *FeedTags) TableName() string {
|
||||
return "feed_tags"
|
||||
}
|
||||
125
module/social/feed/internal/models/query.go
Normal file
125
module/social/feed/internal/models/query.go
Normal file
@@ -0,0 +1,125 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"bsm/full/module/social/feed/internal/impl"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func InitData() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreatePost(data *FeedPost) error {
|
||||
err := impl.DBService.Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Create(&data).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Create(&data.Attachs).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Create(&data.Tags).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
func ChargePost(data *FeedPost) error {
|
||||
err := impl.DBService.Where("identity = ?", data.Identity).Updates(&data).Error
|
||||
return err
|
||||
}
|
||||
func DeletePost(identity string) error {
|
||||
err := impl.DBService.Where("identity = ?", identity).Delete(&FeedPost{}).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// 点赞/踩操作
|
||||
func LikeAction(action_op, action_type, identity string) (err error) {
|
||||
var column string
|
||||
tx := impl.DBService
|
||||
if action_type == "post" {
|
||||
tx = tx.Model(&FeedPost{})
|
||||
} else if action_type == "comment" {
|
||||
tx = tx.Model(&FeedComment{})
|
||||
}
|
||||
if action_op == "ilike" {
|
||||
column = "cnt_like"
|
||||
} else if action_type == "unlike" {
|
||||
column = "cnt_unlike"
|
||||
}
|
||||
if err = tx.Where("identity = ?", identity).UpdateColumn(column, gorm.Expr(fmt.Sprintf("%s + ?", column), 1)).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// PostList
|
||||
func PostList(page, size int64, tag string) (list []*FeedPost, cnt int64, err error) {
|
||||
tx := impl.DBService.Order("created_at desc")
|
||||
if tag != "" {
|
||||
tx = tx.Joins("join feed_relate_tags on feed_relate_tags.post_identity = feed_post.identity", impl.DBService.Where(&FeedRelateTags{Key: tag}))
|
||||
tx = tx.Where("key = ?", tag)
|
||||
}
|
||||
|
||||
tx.Limit(int(page)).Offset(int((page - 1) * size))
|
||||
err = tx.Find(&list).Count(&cnt).Error
|
||||
fmt.Print("posts", list)
|
||||
return
|
||||
}
|
||||
|
||||
func AddTags(data *[]FeedTags) (err error) {
|
||||
err = impl.DBService.Create(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
func ModifyTags(data *FeedTags) (err error) {
|
||||
err = impl.DBService.Where("identity = ?", data.Key).Save(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func DeleteTags(key string) (err error) {
|
||||
err = impl.DBService.Where("identity = ?", key).Delete(&FeedTags{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func TagsList() (list []*FeedTags, cnt int64, err error) {
|
||||
tags := make([]*FeedTags, 0)
|
||||
tx := impl.DBService.Order("created_at desc")
|
||||
err = tx.Find(&tags).Count(&cnt).Error
|
||||
return tags, cnt, err
|
||||
}
|
||||
|
||||
func AddComment(comment *FeedComment, authorIdentity string) (err error) {
|
||||
err = impl.DBService.Transaction(func(tx *gorm.DB) error {
|
||||
// 添加评论,更新文章评论量
|
||||
err := tx.Create(comment).Table("feed_post").Where("identity = ?", comment.PostIdentity).UpdateColumn("cnt_comment", gorm.Expr("cnt_comment + ?", 1)).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if comment.ParentIdentity != "" {
|
||||
//更新被评论的评论数
|
||||
err = tx.Where("identity = ?", comment.ParentIdentity).UpdateColumn("cnt_comment", gorm.Expr("cnt_comment + ?", 1)).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func DeleteComment(identity string) (err error) {
|
||||
|
||||
return
|
||||
}
|
||||
77
module/social/feed/internal/server/new.go
Normal file
77
module/social/feed/internal/server/new.go
Normal file
@@ -0,0 +1,77 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Grpc *grpc.Server
|
||||
Ctx context.Context
|
||||
Mux *gwRuntime.ServeMux
|
||||
}
|
||||
|
||||
func New(addr string) *Server {
|
||||
srv := &Server{Ctx: context.Background(), Grpc: grpc.NewServer(), Mux: gwRuntime.NewServeMux(
|
||||
gwRuntime.WithForwardResponseRewriter(responseEnvelope),
|
||||
)}
|
||||
|
||||
// register service to grpc.Server
|
||||
pb.RegisterPostServer(srv.Grpc, NewPostServer())
|
||||
pb.RegisterSettingServer(srv.Grpc, NewSettingServer())
|
||||
pb.RegisterTagServer(srv.Grpc, NewTagServer())
|
||||
pb.RegisterTimelineServer(srv.Grpc, NewTimelineServer())
|
||||
|
||||
reflection.Register(srv.Grpc)
|
||||
|
||||
// 将服务注册到Gateway
|
||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
pb.RegisterPostHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
pb.RegisterSettingHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
pb.RegisterTagHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
pb.RegisterTimelineHandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)
|
||||
|
||||
// Register services swagger
|
||||
srv.RegisterSwagger()
|
||||
|
||||
return srv
|
||||
}
|
||||
|
||||
// RegisterSwagger 注册swagger
|
||||
func (s *Server) RegisterSwagger() {
|
||||
srvKey := strings.ToLower(vars.ServiceKey)
|
||||
s.Mux.HandlePath("GET", "/"+srvKey+".swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
bytes, err := os.ReadFile("./swagger/" + srvKey + ".swagger.json")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
w.Write(bytes)
|
||||
return
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// response envelope
|
||||
func responseEnvelope(_ context.Context, response proto.Message) (interface{}, error) {
|
||||
name := string(response.ProtoReflect().Descriptor().Name())
|
||||
if name == "Status" || name == "Error" || name == "StatusReply" {
|
||||
return response, nil
|
||||
}
|
||||
return map[string]any{
|
||||
"code": 0,
|
||||
"message": "OK",
|
||||
"result": response,
|
||||
}, nil
|
||||
}
|
||||
56
module/social/feed/internal/server/post_server.go
Normal file
56
module/social/feed/internal/server/post_server.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"bsm/full/module/social/feed/internal/logic/post"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
type PostServer struct {
|
||||
pb.UnimplementedPostServer
|
||||
}
|
||||
|
||||
func NewPostServer() *PostServer {
|
||||
return &PostServer{}
|
||||
}
|
||||
|
||||
// 推文列表
|
||||
func (s *PostServer) Fetch(ctx context.Context, in *pb.FetchRequest) (*pb.PostListReply, error) {
|
||||
return post.Fetch(ctx, in)
|
||||
}
|
||||
|
||||
// 新建推文
|
||||
func (s *PostServer) Create(ctx context.Context, in *pb.PostItem) (*pb.StatusReply, error) {
|
||||
return post.Create(ctx, in)
|
||||
}
|
||||
|
||||
// 修改推文
|
||||
func (s *PostServer) Change(ctx context.Context, in *pb.PostItem) (*pb.StatusReply, error) {
|
||||
return post.Change(ctx, in)
|
||||
}
|
||||
|
||||
// 删除推文
|
||||
func (s *PostServer) Remove(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return post.Remove(ctx, in)
|
||||
}
|
||||
|
||||
// 评论列表
|
||||
func (s *PostServer) CommentList(ctx context.Context, in *pb.FetchRequest) (*pb.CommentListReply, error) {
|
||||
return post.CommentList(ctx, in)
|
||||
}
|
||||
|
||||
// 新建评论
|
||||
func (s *PostServer) AddComment(ctx context.Context, in *pb.CommentItem) (*pb.StatusReply, error) {
|
||||
return post.AddComment(ctx, in)
|
||||
}
|
||||
|
||||
// 删除评论
|
||||
func (s *PostServer) DeleteComment(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
|
||||
return post.DeleteComment(ctx, in)
|
||||
}
|
||||
|
||||
// 计数操作
|
||||
func (s *PostServer) Action(ctx context.Context, in *pb.PostActionRequest) (*pb.StatusReply, error) {
|
||||
return post.Action(ctx, in)
|
||||
}
|
||||
26
module/social/feed/internal/server/setting_server.go
Normal file
26
module/social/feed/internal/server/setting_server.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"bsm/full/module/social/feed/internal/logic/setting"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
type SettingServer struct {
|
||||
pb.UnimplementedSettingServer
|
||||
}
|
||||
|
||||
func NewSettingServer() *SettingServer {
|
||||
return &SettingServer{}
|
||||
}
|
||||
|
||||
// 修改个人信息
|
||||
func (s *SettingServer) Info(ctx context.Context, in *pb.Empty) (*pb.Empty, error) {
|
||||
return setting.Info(ctx, in)
|
||||
}
|
||||
|
||||
// 修改权限信息
|
||||
func (s *SettingServer) Rights(ctx context.Context, in *pb.Empty) (*pb.Empty, error) {
|
||||
return setting.Rights(ctx, in)
|
||||
}
|
||||
31
module/social/feed/internal/server/tag_server.go
Normal file
31
module/social/feed/internal/server/tag_server.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"bsm/full/module/social/feed/internal/logic/tag"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
type TagServer struct {
|
||||
pb.UnimplementedTagServer
|
||||
}
|
||||
|
||||
func NewTagServer() *TagServer {
|
||||
return &TagServer{}
|
||||
}
|
||||
|
||||
// 标签列表
|
||||
func (s *TagServer) List(ctx context.Context, in *pb.FetchRequest) (*pb.TagListReply, error) {
|
||||
return tag.List(ctx, in)
|
||||
}
|
||||
|
||||
// 新建标签
|
||||
func (s *TagServer) Create(ctx context.Context, in *pb.AddTagRequest) (*pb.StatusReply, error) {
|
||||
return tag.Create(ctx, in)
|
||||
}
|
||||
|
||||
// 话题相关的文章
|
||||
func (s *TagServer) PostList(ctx context.Context, in *pb.FetchRequest) (*pb.PostListReply, error) {
|
||||
return tag.PostList(ctx, in)
|
||||
}
|
||||
36
module/social/feed/internal/server/timeline_server.go
Normal file
36
module/social/feed/internal/server/timeline_server.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"bsm/full/module/social/feed/internal/logic/timeline"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
type TimelineServer struct {
|
||||
pb.UnimplementedTimelineServer
|
||||
}
|
||||
|
||||
func NewTimelineServer() *TimelineServer {
|
||||
return &TimelineServer{}
|
||||
}
|
||||
|
||||
// 推荐
|
||||
func (s *TimelineServer) Recommend(ctx context.Context, in *pb.FetchRequest) (*pb.PostListReply, error) {
|
||||
return timeline.Recommend(ctx, in)
|
||||
}
|
||||
|
||||
// 好友动态
|
||||
func (s *TimelineServer) Friend(ctx context.Context, in *pb.FetchRequest) (*pb.PostListReply, error) {
|
||||
return timeline.Friend(ctx, in)
|
||||
}
|
||||
|
||||
// 关注的动态
|
||||
func (s *TimelineServer) Follow(ctx context.Context, in *pb.FetchRequest) (*pb.PostListReply, error) {
|
||||
return timeline.Follow(ctx, in)
|
||||
}
|
||||
|
||||
// 热门
|
||||
func (s *TimelineServer) Hot(ctx context.Context, in *pb.FetchRequest) (*pb.PostListReply, error) {
|
||||
return timeline.Hot(ctx, in)
|
||||
}
|
||||
Reference in New Issue
Block a user