From 5e7d77a66b1e7a2347a88af2b9cc2383640fd48f Mon Sep 17 00:00:00 2001 From: zhengshilong <1725838433@qq.com> Date: Wed, 23 Jul 2025 18:35:17 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9&=E6=9C=8B=E5=8F=8B?= =?UTF-8?q?=E5=9C=88=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- acquaintances/biz/dal/mysql/friend_moments.go | 394 ++++- acquaintances/biz/dal/mysql/init.go | 2 +- acquaintances/biz/dal/mysql/user.go | 3 - .../biz/handler/user/moments_service.go | 79 +- acquaintances/biz/model/friend_moments.go | 17 +- acquaintances/biz/model/user.go | 3 + acquaintances/biz/model/user/user.go | 1474 +++-------------- acquaintances/biz/router/user/user.go | 19 - acquaintances/config.ini | 4 +- acquaintances/idl/user.thrift | 158 +- 10 files changed, 637 insertions(+), 1516 deletions(-) diff --git a/acquaintances/biz/dal/mysql/friend_moments.go b/acquaintances/biz/dal/mysql/friend_moments.go index 2e23476..413c7ae 100644 --- a/acquaintances/biz/dal/mysql/friend_moments.go +++ b/acquaintances/biz/dal/mysql/friend_moments.go @@ -3,8 +3,10 @@ package mysql import ( "acquaintances/biz/model" "acquaintances/biz/model/user" + "errors" + "fmt" + "github.com/cloudwego/hertz/pkg/common/hlog" "gorm.io/gorm" - "time" ) // SaveMomentWithImages 新建动态 @@ -20,11 +22,10 @@ func SaveMomentWithImages(moment *model.Moment, imageURLs []string) error { // 保存图片(如果有) if len(imageURLs) > 0 { images := make([]model.MomentImage, 0, len(imageURLs)) - for i, url := range imageURLs { + for _, url := range imageURLs { images = append(images, model.MomentImage{ - MomentID: moment.ID, - ImageURL: url, - SortOrder: uint8(i), // 按URL顺序排序 + MomentID: moment.ID, + ImageURL: url, }) } if err := tx.Create(&images).Error; err != nil { @@ -48,100 +49,36 @@ func CheckUserExists(userID string) (bool, error) { return count > 0, nil } -// 构建可见性查询条件 -func buildVisibilityCondition(currentUserID string) func(db *gorm.DB) *gorm.DB { - return func(db *gorm.DB) *gorm.DB { - // 可见性条件:公开 或者 仅自己可见(且是当前用户) 或者 仅好友可见(需要查询好友关系) - return db.Where("(visibility = ?) OR (visibility = ? AND user_id = ?) OR (visibility = ? AND user_id IN (?))", - model.VisibilityPublic, - model.VisibilitySelfOnly, - currentUserID, - model.VisibilityFriendsOnly, - getFriendUserIDs(currentUserID), // 需要实现好友关系查询 - ) - } -} - // 获取当前用户的好友ID列表 -func getFriendUserIDs(userID string) []string { - // 实际项目中需要查询好友关系表 - // 这里简化处理,返回空列表 - return []string{} -} - -// ConvertMomentsToDTOs 将数据库模型转换为API响应DTO -func ConvertMomentsToDTOs(moments []model.Moment, currentUserID string) ([]user.Moment, error) { - db := DB - var result []user.Moment - - // 提取所有用户ID用于批量查询 - userIDs := make([]string, 0, len(moments)) - for _, m := range moments { - userIDs = append(userIDs, m.UserID) - } - - // 批量查询用户信息 - userMap, err := batchGetUserInfo(userIDs) +// 获取当前用户的好友ID列表 +func getFriendUserIDs(userID string) ([]string, error) { + var friends []model.FriendRelationship + // 一次查询所有与当前用户相关的已通过好友关系 + err := DB.Model(model.FriendRelationship{}). + Where("(applicant_id = ? OR target_user_id = ?) AND status = 1", userID, userID). + Find(&friends).Error if err != nil { - return nil, err + return nil, fmt.Errorf("查询好友列表失败: %w", err) } - // 处理每条动态 - for _, m := range moments { - // 获取用户信息 - userInfo := convertUserModelToDTO(userMap[m.UserID]) - - // 查询动态图片 - var images []model.MomentImage - if err := db.Where("moment_id = ?", m.ID). - Order("sort_order ASC"). - Find(&images).Error; err != nil { - return nil, err + // 使用map去重 + friendMap := make(map[string]struct{}) + for _, rel := range friends { + // 根据关系方向添加对应的好友ID + if rel.ApplicantID == userID { + friendMap[rel.TargetUserID] = struct{}{} + } else { + friendMap[rel.ApplicantID] = struct{}{} } - - // 转换图片列表 - momentImages := make([]*user.MomentImage, 0, len(images)) - for _, img := range images { - momentImages = append(momentImages, &user.MomentImage{ - ID: int64(img.ID), - MomentID: int64(img.MomentID), - ImageURL: img.ImageURL, - }) - } - - // 构建动态DTO - result = append(result, user.Moment{ - ID: int64(m.ID), - UserID: m.UserID, - User: &userInfo, - Content: m.Content, - Visibility: user.MomentVisibility(m.Visibility), - Location: m.Location, - Status: user.ContentStatus(m.Status), - LikeCount: int32(m.LikeCount), - CommentCount: int32(m.CommentCount), - Images: momentImages, - CreatedAt: m.CreatedAt.Format(time.RFC3339), - UpdatedAt: m.UpdatedAt.Format(time.RFC3339), - }) } - return result, nil -} - -// 批量获取用户信息 -func batchGetUserInfo(userIDs []string) (map[string]model.User, error) { - db := DB - var users []model.User - if err := db.Where("user_id IN (?)", userIDs).Find(&users).Error; err != nil { - return nil, err + // 转换map为切片 + friendUserIDs := make([]string, 0, len(friendMap)) + for id := range friendMap { + friendUserIDs = append(friendUserIDs, id) } - userMap := make(map[string]model.User) - for _, u := range users { - userMap[u.UserID] = u - } - return userMap, nil + return friendUserIDs, nil } // 将用户模型转换为DTO @@ -162,3 +99,280 @@ func convertUserModelToDTO(u model.User) user.UserInfoReq { return userInfo } + +// GetMomentsImage 获取指定动态的图像列表 +func GetMomentsImage(ids uint) ([]*user.MomentImage, error) { + db := DB + var images []model.MomentImage + var data []*user.MomentImage + err := db.Model(&model.MomentImage{}).Where("moment_id = ?", ids).Find(&images).Error + if err != nil { + return nil, err + } + for _, v := range images { + data = append(data, &user.MomentImage{ + ID: int64(v.ID), + MomentID: int64(v.MomentID), + ImageURL: v.ImageURL, + }) + } + return data, nil +} + +// GetFriendsMoments 获取好友动态 +func GetFriendsMoments(req user.ListMomentsRequest) ([]*user.Moment, int32, error) { + db := DB + //获取好友id列表 + friends, err := getFriendUserIDs(req.UserID) + if err != nil { + return nil, 0, err + } + + // 校验分页参数 + if req.Page < 1 { + req.Page = 1 + } + if req.PageSize < 1 { + req.PageSize = 10 + } + + // 查询总数 + var total int64 + query := db.Model(&model.Moment{}).Where("user_id = ?", req.UserID) + if len(friends) > 0 { + query = query.Or("user_id IN (?) AND visibility != ?", friends, model.VisibilitySelfOnly) + } + if err := query.Count(&total).Error; err != nil { + return nil, 0, err + } + + //获取朋友圈内容信息 + var moments []model.Moment + query = db.Model(&model.Moment{}).Where("user_id = ?", req.UserID) + if len(friends) > 0 { + query = query.Or("user_id IN (?) AND visibility != ?", friends, model.VisibilitySelfOnly) + } + err = query.Limit(int(req.PageSize)).Offset(int(req.PageSize * (req.Page - 1))).Find(&moments).Error + if err != nil { + return nil, 0, err + } + + //批量查询用户信息 + var userIDs []string + for _, v := range moments { + userIDs = append(userIDs, v.UserID) + } + userInfo, err := GetUsersById(userIDs...) // 自定义批量查询函数 + if err != nil { + hlog.Errorf("批量查询用户失败: %v", err) + return nil, 0, err + } + + var data []*user.Moment + query = db.Model(&model.Moment{}).Where("user_id = ?", req.UserID) + if len(friends) > 0 { + query = query.Or("user_id IN (?) AND visibility != ?", friends, model.VisibilitySelfOnly) + } + err = query.Limit(int(req.PageSize)).Offset(int(req.PageSize * (req.Page - 1))).Find(&moments).Error + if err != nil { + return nil, 0, err + } + + for k, v := range moments { + images, err := GetMomentsImage(v.ID) + if err != nil { + continue + } + data = append(data, &user.Moment{ + ID: int64(v.ID), + UserID: v.UserID, + User: userInfo[k], + Content: v.Content, + Location: v.Location, + Status: user.ContentStatus(int64(v.Status)), + LikeCount: int32(v.LikeCount), + CommentCount: int32(v.CommentCount), + Images: images, + CreatedAt: v.CreatedAt.Format("2006-01-02 15:04"), + }) + } + return data, int32(total), nil +} + +// GetMomentsAppoint 获取指定好友动态 +func GetMomentsAppoint(req user.ListMomentsAppointRequest) ([]*user.Moment, int32, error) { + db := DB + // 校验分页参数 + if req.Page < 1 { + req.Page = 1 + } + if req.PageSize < 1 { + req.PageSize = 10 + } + + // 查询总数 + var total int64 + query := db.Model(&model.Moment{}).Where("user_id = ?", req.UserID) + if err := query.Count(&total).Error; err != nil { + return nil, 0, err + } + + //获取朋友圈内容信息 + var moments []model.Moment + query = db.Model(&model.Moment{}).Where("user_id = ?", req.UserID) + err := query.Limit(int(req.PageSize)).Offset(int(req.PageSize * (req.Page - 1))).Find(&moments).Error + if err != nil { + return nil, 0, err + } + + //查询用户信息 + userInfo, err := GetUsersById(req.UserID) // 自定义批量查询函数 + if err != nil || len(userInfo) != 1 { + hlog.Errorf("批量查询用户失败: %v", err) + return nil, 0, err + } + + var data []*user.Moment + query = db.Model(&model.Moment{}).Where("user_id = ?", req.UserID).Limit(int(req.PageSize)).Offset(int(req.PageSize * (req.Page - 1))).Find(&moments) + if db.Error != nil { + return nil, 0, err + } + for _, v := range moments { + images, err := GetMomentsImage(v.ID) + if err != nil { + continue + } + data = append(data, &user.Moment{ + ID: int64(v.ID), + UserID: v.UserID, + User: userInfo[0], + Content: v.Content, + Location: v.Location, + Status: user.ContentStatus(int64(v.Status)), + LikeCount: int32(v.LikeCount), + CommentCount: int32(v.CommentCount), + Images: images, + CreatedAt: v.CreatedAt.Format("2006-01-02 15:04"), + }) + } + return data, int32(total), nil +} + +// DeleteMoment 删除朋友圈动态 +func DeleteMoment(req user.DeleteMomentRequest) error { + db := DB + // 使用事务确保数据一致性 + return db.Transaction(func(tx *gorm.DB) error { + // 保存动态 + if err := tx.Model(&model.Moment{}).Where("id = ?", req.MomentID).Delete(&model.Moment{}).Error; err != nil { + return err + } + + // 删除图片 + if err := tx.Model(model.MomentImage{}).Where("moment_id = ?", req.MomentID).Delete(&model.MomentImage{}).Error; err != nil { + return err + } + + //删除评论 + //TODO + + //删除点赞 + //TODO + + return nil + }) + +} + +// LikeMoment 点赞朋友圈动态 +func LikeMoment(req user.LikeMomentRequest) error { + db := DB + // 使用事务确保数据一致性 + return db.Transaction(func(tx *gorm.DB) error { + // 检查是否已经点赞 + var existingLike model.MomentLike + err := tx.Model(&model.MomentLike{}). + Where("user_id = ? AND moment_id = ?", req.UserID, req.MomentID). + First(&existingLike).Error + + // 如果不是"未找到"错误,说明查询异常 + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return fmt.Errorf("检查点赞记录失败: %w", err) + } + + // 如果已经点赞,返回错误 + if err == nil { + return errors.New("已经点赞过该动态") + } + + // 新增点赞记录 + if err := tx.Model(&model.MomentLike{}).Create(&model.MomentLike{ + UserID: req.UserID, + MomentID: uint(req.MomentID), + }).Error; err != nil { + return fmt.Errorf("创建点赞记录失败: %w", err) + } + + // 点赞数原子增加1,避免并发问题 + result := tx.Model(model.Moment{}). + Where("moment_id = ?", req.MomentID). + Update("like_count", gorm.Expr("like_count + 1")) + + if result.Error != nil { + return fmt.Errorf("更新点赞数失败: %w", result.Error) + } + + // 检查动态是否存在 + if result.RowsAffected == 0 { + return errors.New("动态不存在") + } + + return nil + }) +} + +// UnlikeMoment 取消点赞朋友圈动态 +func UnlikeMoment(req user.UnlikeMomentRequest) error { + db := DB + // 使用事务确保数据一致性 + return db.Transaction(func(tx *gorm.DB) error { + // 检查是否存在点赞记录 + var like model.MomentLike + err := tx.Model(&model.MomentLike{}). + Where("user_id = ? AND moment_id = ?", req.UserID, req.MomentID). + First(&like).Error + + // 如果不是"未找到"错误,说明查询异常 + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return fmt.Errorf("检查点赞记录失败: %w", err) + } + + // 如果没有点赞记录,返回错误 + if errors.Is(err, gorm.ErrRecordNotFound) { + return errors.New("未点赞该动态,无法取消") + } + + // 删除点赞记录 + if err := tx.Model(&model.MomentLike{}). + Where("user_id = ? AND moment_id = ?", req.UserID, req.MomentID). + Delete(&model.MomentLike{}).Error; err != nil { + return fmt.Errorf("删除点赞记录失败: %w", err) + } + + // 点赞数原子减少1 + result := tx.Model(model.Moment{}). + Where("moment_id = ? AND like_count > 0", req.MomentID). // 确保点赞数不会小于0 + Update("like_count", gorm.Expr("like_count - 1")) + + if result.Error != nil { + return fmt.Errorf("更新点赞数失败: %w", result.Error) + } + + // 检查动态是否存在 + if result.RowsAffected == 0 { + return errors.New("动态不存在或点赞数已为0") + } + + return nil + }) +} diff --git a/acquaintances/biz/dal/mysql/init.go b/acquaintances/biz/dal/mysql/init.go index f00cf5c..75e5a15 100644 --- a/acquaintances/biz/dal/mysql/init.go +++ b/acquaintances/biz/dal/mysql/init.go @@ -33,7 +33,7 @@ func Init() { panic(err) } // 自动迁移 - err = DB.AutoMigrate(model.User{}, model.Country{}, model.UserRelations{}, model.FriendRelationship{}, model.ChatGroupInfo{}, model.GroupUserRelation{}) + err = DB.AutoMigrate(model.User{}, model.Country{}, model.UserRelations{}, model.FriendRelationship{}, model.ChatGroupInfo{}, model.GroupUserRelation{}, model.Moment{}, model.MomentImage{}, model.MomentLike{}, model.MomentComment{}) if err != nil { hlog.Error("AutoMigrate failed: " + err.Error()) return diff --git a/acquaintances/biz/dal/mysql/user.go b/acquaintances/biz/dal/mysql/user.go index 243d567..e5e8bc1 100644 --- a/acquaintances/biz/dal/mysql/user.go +++ b/acquaintances/biz/dal/mysql/user.go @@ -45,9 +45,6 @@ func DeleteUser(userId string) error { return errTransaction } -func UpdateUser(user *user.User) error { - return DB.Updates(user).Error -} func UpdatesUser(user *user.UpdateUserRequest) error { db := DB.Model(&model.User{}) maps := make(map[string]interface{}) diff --git a/acquaintances/biz/handler/user/moments_service.go b/acquaintances/biz/handler/user/moments_service.go index 9a0802f..af60352 100644 --- a/acquaintances/biz/handler/user/moments_service.go +++ b/acquaintances/biz/handler/user/moments_service.go @@ -6,6 +6,7 @@ import ( "acquaintances/biz/dal/mysql" "acquaintances/biz/model" "context" + "github.com/cloudwego/hertz/pkg/common/hlog" user "acquaintances/biz/model/user" "github.com/cloudwego/hertz/pkg/app" @@ -20,18 +21,18 @@ func CreateMoment(ctx context.Context, c *app.RequestContext) { // 绑定并验证请求参数 if err = c.BindAndValidate(&req); err != nil { - c.String(consts.StatusBadRequest, "请求参数错误: %v", err) + c.JSON(consts.StatusBadRequest, "请求参数错误") return } - + hlog.Errorf("+++++++") // 验证用户是否存在(实际项目中应通过token获取用户ID并验证) exists, err := mysql.CheckUserExists(req.UserID) if err != nil { - c.String(consts.StatusInternalServerError, "查询用户信息失败: %v", err) + c.JSON(consts.StatusInternalServerError, "查询用户信息失败") return } if !exists { - c.String(consts.StatusForbidden, "用户不存在") + c.JSON(consts.StatusForbidden, "用户不存在") return } @@ -45,7 +46,7 @@ func CreateMoment(ctx context.Context, c *app.RequestContext) { } // 保存动态到数据库 - if err = mysql.SaveMomentWithImages(&moment, req.ImageURLs); err != nil { + if err = mysql.SaveMomentWithImages(&moment, req.ImageUrls); err != nil { c.JSON(consts.StatusInternalServerError, &user.CreateMomentResponse{Code: user.Code_DBErr, Msg: err.Error()}) return } @@ -56,50 +57,46 @@ func CreateMoment(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusOK, resp) } -// ListMoments . +// ListMoments 获取朋友圈动态 // @router /v1/Moments/list/ [GET] func ListMoments(ctx context.Context, c *app.RequestContext) { var err error var req user.ListMomentsRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + data, total, err := mysql.GetFriendsMoments(req) + if err != nil { + c.JSON(consts.StatusInternalServerError, err.Error()) return } - resp := new(user.ListMomentsResponse) + resp.Moments = data + resp.Total = total c.JSON(consts.StatusOK, resp) } -// ListMomentsAppoint . +// ListMomentsAppoint 获取指定用户朋友圈动态 // @router /v1/Moments/user/list/ [GET] func ListMomentsAppoint(ctx context.Context, c *app.RequestContext) { var err error var req user.ListMomentsAppointRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } - - resp := new(user.ListMomentsAppointResponse) - - c.JSON(consts.StatusOK, resp) -} - -// GetMoment . -// @router /v1/Moments/info/ [GET] -func GetMoment(ctx context.Context, c *app.RequestContext) { - var err error - var req user.GetMomentRequest - err = c.BindAndValidate(&req) + data, total, err := mysql.GetMomentsAppoint(req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusInternalServerError, err.Error()) return } - - resp := new(user.GetMomentResponse) + resp := new(user.ListMomentsAppointResponse) + resp.Moments = data + resp.Total = total c.JSON(consts.StatusOK, resp) } @@ -111,10 +108,14 @@ func DeleteMoment(ctx context.Context, c *app.RequestContext) { var req user.DeleteMomentRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + err = mysql.DeleteMoment(req) + if err != nil { + c.JSON(consts.StatusInternalServerError, err.Error()) return } - resp := new(user.DeleteMomentResponse) c.JSON(consts.StatusOK, resp) @@ -127,10 +128,14 @@ func LikeMoment(ctx context.Context, c *app.RequestContext) { var req user.LikeMomentRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + err = mysql.LikeMoment(req) + if err != nil { + c.JSON(consts.StatusInternalServerError, err.Error()) return } - resp := new(user.LikeMomentResponse) c.JSON(consts.StatusOK, resp) @@ -143,10 +148,14 @@ func UnlikeMoment(ctx context.Context, c *app.RequestContext) { var req user.UnlikeMomentRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + err = mysql.UnlikeMoment(req) + if err != nil { + c.JSON(consts.StatusInternalServerError, err.Error()) return } - resp := new(user.UnlikeMomentResponse) c.JSON(consts.StatusOK, resp) @@ -159,7 +168,7 @@ func ListMomentLikes(ctx context.Context, c *app.RequestContext) { var req user.ListMomentLikesRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } @@ -175,7 +184,7 @@ func CommentMoment(ctx context.Context, c *app.RequestContext) { var req user.CommentMomentRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } @@ -191,7 +200,7 @@ func ListMomentComments(ctx context.Context, c *app.RequestContext) { var req user.ListMomentCommentsRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } @@ -207,7 +216,7 @@ func DeleteComment(ctx context.Context, c *app.RequestContext) { var req user.DeleteCommentRequest err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } diff --git a/acquaintances/biz/model/friend_moments.go b/acquaintances/biz/model/friend_moments.go index cc80735..2256910 100644 --- a/acquaintances/biz/model/friend_moments.go +++ b/acquaintances/biz/model/friend_moments.go @@ -20,35 +20,28 @@ type Moment struct { Status uint8 `gorm:"column:status;type:tinyint unsigned;default:1;comment:'状态;0:删除,1:正常'"` LikeCount uint32 `gorm:"column:like_count;type:int unsigned;default:0;comment:'点赞数'"` CommentCount uint32 `gorm:"column:comment_count;type:int unsigned;default:0;comment:'评论数'"` - // 关联 - Images []MomentImage `gorm:"foreignKey:MomentID"` - Likes []MomentLike `gorm:"foreignKey:MomentID"` - Comments []MomentComment `gorm:"foreignKey:MomentID"` } // 朋友圈图片表 type MomentImage struct { gorm.Model - MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;index:idx_moment_id;comment:'朋友圈动态ID'"` - ImageURL string `gorm:"column:image_url;type:varchar(255);not null;comment:'图片URL'"` - SortOrder uint8 `gorm:"column:sort_order;type:tinyint unsigned;default:0;comment:'排序序号'"` + MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;comment:'朋友圈动态ID'"` + ImageURL string `gorm:"column:image_url;type:varchar(255);not null;comment:'图片URL'"` } // 朋友圈点赞表 type MomentLike struct { gorm.Model - MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;index:idx_moment_id;comment:'朋友圈动态ID'"` + MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;comment:'朋友圈动态ID'"` UserID string `gorm:"column:user_id;type:varchar(32);not null;comment:'点赞用户ID'"` - // 联合唯一索引,确保一个用户只能给一条动态点一次赞 - gorm.Index `gorm:"uniqueIndex:idx_moment_user,comment:'动态ID和用户ID的联合索引'"` } // 朋友圈评论表 type MomentComment struct { gorm.Model - MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;index:idx_moment_id;comment:'朋友圈动态ID'"` + MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;comment:'朋友圈动态ID'"` UserID string `gorm:"column:user_id;type:varchar(32);not null;comment:'评论用户ID'"` Content string `gorm:"column:content;type:text;not null;comment:'评论内容'"` - ParentID *uint `gorm:"column:parent_id;type:int unsigned;index:idx_parent_id;comment:'父评论ID,用于回复功能'"` + ParentID uint `gorm:"column:parent_id;type:int unsigned;index:idx_parent_id;comment:'父评论ID,用于回复功能'"` Status uint8 `gorm:"column:status;type:tinyint unsigned;default:1;comment:'状态;0:删除,1:正常'"` } diff --git a/acquaintances/biz/model/user.go b/acquaintances/biz/model/user.go index 6b50d50..8f419bb 100644 --- a/acquaintances/biz/model/user.go +++ b/acquaintances/biz/model/user.go @@ -5,9 +5,12 @@ import ( "acquaintances/biz/utils" "encoding/json" "gorm.io/gorm" + "sync" "time" ) +var UserSync *sync.Mutex + type User struct { gorm.Model UserID string `gorm:"column:user_id;type:varchar(32);uniqueIndex:idx_user_id;not null;comment:'用户唯一标识'"` diff --git a/acquaintances/biz/model/user/user.go b/acquaintances/biz/model/user/user.go index ed42c1d..b378275 100644 --- a/acquaintances/biz/model/user/user.go +++ b/acquaintances/biz/model/user/user.go @@ -1780,7 +1780,7 @@ type CreateUserRequest struct { Gender Gender `thrift:"gender,2" form:"gender" form:"gender" json:"gender" vd:"($ == 1||$ == 2)"` Age int64 `thrift:"age,3" form:"age" json:"age" vd:"$>0"` Mobile string `thrift:"mobile,4" form:"mobile" form:"mobile" json:"mobile" vd:"(len($) > 0 && len($) < 12)"` - Area int64 `thrift:"area,5" form:"area" json:"area" vd:"$>0"` + Area int64 `thrift:"area,5" form:"area" form:"area" json:"area" vd:"$>0"` UserPassword string `thrift:"user_password,6" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"` } @@ -11319,11 +11319,11 @@ func (p *ListUserChatGroupRes) String() string { // 朋友圈图片结构体 type MomentImage struct { // ID - ID int64 `thrift:"ID,1" form:"ID" json:"ID" query:"ID"` + ID int64 `thrift:"id,1" form:"id" json:"id" query:"id"` // 所属动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` // 图片URL - ImageURL string `thrift:"ImageURL,3" form:"ImageURL" json:"ImageURL" query:"ImageURL"` + ImageURL string `thrift:"image_url,3" form:"image_url" json:"image_url" query:"image_url"` } func NewMomentImage() *MomentImage { @@ -11346,9 +11346,9 @@ func (p *MomentImage) GetImageURL() (v string) { } var fieldIDToName_MomentImage = map[int16]string{ - 1: "ID", - 2: "MomentID", - 3: "ImageURL", + 1: "id", + 2: "moment_id", + 3: "image_url", } func (p *MomentImage) Read(iprot thrift.TProtocol) (err error) { @@ -11493,7 +11493,7 @@ WriteStructEndError: } func (p *MomentImage) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ID", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ID); err != nil { @@ -11509,7 +11509,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *MomentImage) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -11525,7 +11525,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *MomentImage) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ImageURL", thrift.STRING, 3); err != nil { + if err = oprot.WriteFieldBegin("image_url", thrift.STRING, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.ImageURL); err != nil { @@ -11552,13 +11552,13 @@ func (p *MomentImage) String() string { // 朋友圈点赞结构体 type MomentLike struct { // 点赞ID - ID int64 `thrift:"ID,1" form:"ID" json:"ID" query:"ID"` + ID int64 `thrift:"id,1" form:"id" json:"id" query:"id"` // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` // 点赞用户ID - UserID string `thrift:"UserID,3" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,3" form:"user_id" json:"user_id" query:"user_id"` // 点赞时间 - CreatedAt string `thrift:"CreatedAt,4" form:"CreatedAt" json:"CreatedAt" query:"CreatedAt"` + CreatedAt string `thrift:"created_at,4" form:"created_at" json:"created_at" query:"created_at"` } func NewMomentLike() *MomentLike { @@ -11585,10 +11585,10 @@ func (p *MomentLike) GetCreatedAt() (v string) { } var fieldIDToName_MomentLike = map[int16]string{ - 1: "ID", - 2: "MomentID", - 3: "UserID", - 4: "CreatedAt", + 1: "id", + 2: "moment_id", + 3: "user_id", + 4: "created_at", } func (p *MomentLike) Read(iprot thrift.TProtocol) (err error) { @@ -11756,7 +11756,7 @@ WriteStructEndError: } func (p *MomentLike) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ID", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ID); err != nil { @@ -11772,7 +11772,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *MomentLike) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -11788,7 +11788,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *MomentLike) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 3); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -11804,7 +11804,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *MomentLike) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("CreatedAt", thrift.STRING, 4); err != nil { + if err = oprot.WriteFieldBegin("created_at", thrift.STRING, 4); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.CreatedAt); err != nil { @@ -11831,25 +11831,25 @@ func (p *MomentLike) String() string { // 朋友圈评论结构体 type MomentComment struct { // 评论ID - ID int64 `thrift:"ID,1" form:"ID" json:"ID" query:"ID"` + ID int64 `thrift:"id,1" form:"id" json:"id" query:"id"` // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` // 评论用户ID - UserID string `thrift:"UserID,3" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,3" form:"user_id" json:"user_id" query:"user_id"` // 评论用户信息 - User *UserInfoReq `thrift:"User,4" form:"User" json:"User" query:"User"` + User *UserInfoReq `thrift:"user,4" form:"user" json:"user" query:"user"` // 评论内容 - Content string `thrift:"Content,5" form:"Content" json:"Content" query:"Content"` + Content string `thrift:"content,5" form:"content" json:"content" query:"content"` // 父评论ID,用于回复 - ParentID int64 `thrift:"ParentID,6" form:"ParentID" json:"ParentID" query:"ParentID"` + ParentID int64 `thrift:"parent_id,6" form:"parent_id" json:"parent_id" query:"parent_id"` // 父评论信息 - ParentComment *MomentComment `thrift:"ParentComment,7" form:"ParentComment" json:"ParentComment" query:"ParentComment"` + ParentComment *MomentComment `thrift:"parent_comment,7" form:"parent_comment" json:"parent_comment" query:"parent_comment"` // 状态 - Status ContentStatus `thrift:"Status,8" form:"Status" json:"Status" query:"Status"` + Status ContentStatus `thrift:"status,8" form:"status" json:"status" query:"status"` // 创建时间 - CreatedAt string `thrift:"CreatedAt,9" form:"CreatedAt" json:"CreatedAt" query:"CreatedAt"` + CreatedAt string `thrift:"created_at,9" form:"created_at" json:"created_at" query:"created_at"` // 更新时间 - UpdatedAt string `thrift:"UpdatedAt,10" form:"UpdatedAt" json:"UpdatedAt" query:"UpdatedAt"` + UpdatedAt string `thrift:"updated_at,10" form:"updated_at" json:"updated_at" query:"updated_at"` } func NewMomentComment() *MomentComment { @@ -11910,16 +11910,16 @@ func (p *MomentComment) GetUpdatedAt() (v string) { } var fieldIDToName_MomentComment = map[int16]string{ - 1: "ID", - 2: "MomentID", - 3: "UserID", - 4: "User", - 5: "Content", - 6: "ParentID", - 7: "ParentComment", - 8: "Status", - 9: "CreatedAt", - 10: "UpdatedAt", + 1: "id", + 2: "moment_id", + 3: "user_id", + 4: "user", + 5: "content", + 6: "parent_id", + 7: "parent_comment", + 8: "status", + 9: "created_at", + 10: "updated_at", } func (p *MomentComment) IsSetUser() bool { @@ -12227,7 +12227,7 @@ WriteStructEndError: } func (p *MomentComment) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ID", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ID); err != nil { @@ -12243,7 +12243,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *MomentComment) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -12259,7 +12259,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *MomentComment) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 3); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -12275,7 +12275,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *MomentComment) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("User", thrift.STRUCT, 4); err != nil { + if err = oprot.WriteFieldBegin("user", thrift.STRUCT, 4); err != nil { goto WriteFieldBeginError } if err := p.User.Write(oprot); err != nil { @@ -12291,7 +12291,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) } func (p *MomentComment) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Content", thrift.STRING, 5); err != nil { + if err = oprot.WriteFieldBegin("content", thrift.STRING, 5); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Content); err != nil { @@ -12307,7 +12307,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) } func (p *MomentComment) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ParentID", thrift.I64, 6); err != nil { + if err = oprot.WriteFieldBegin("parent_id", thrift.I64, 6); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ParentID); err != nil { @@ -12323,7 +12323,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) } func (p *MomentComment) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ParentComment", thrift.STRUCT, 7); err != nil { + if err = oprot.WriteFieldBegin("parent_comment", thrift.STRUCT, 7); err != nil { goto WriteFieldBeginError } if err := p.ParentComment.Write(oprot); err != nil { @@ -12339,7 +12339,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) } func (p *MomentComment) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Status", thrift.I32, 8); err != nil { + if err = oprot.WriteFieldBegin("status", thrift.I32, 8); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(int32(p.Status)); err != nil { @@ -12355,7 +12355,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) } func (p *MomentComment) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("CreatedAt", thrift.STRING, 9); err != nil { + if err = oprot.WriteFieldBegin("created_at", thrift.STRING, 9); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.CreatedAt); err != nil { @@ -12371,7 +12371,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) } func (p *MomentComment) writeField10(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UpdatedAt", thrift.STRING, 10); err != nil { + if err = oprot.WriteFieldBegin("updated_at", thrift.STRING, 10); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UpdatedAt); err != nil { @@ -12398,29 +12398,29 @@ func (p *MomentComment) String() string { // 朋友圈动态结构体 type Moment struct { // 动态ID - ID int64 `thrift:"ID,1" form:"ID" json:"ID" query:"ID"` + ID int64 `thrift:"id,1" form:"id" json:"id" query:"id"` // 发布者用户ID - UserID string `thrift:"UserID,2" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,2" form:"user_id" json:"user_id" query:"user_id"` // 发布者信息 - User *UserInfoReq `thrift:"User,3" form:"User" json:"User" query:"User"` + User *UserInfoReq `thrift:"user,3" form:"user" json:"user" query:"user"` // 动态内容 - Content string `thrift:"Content,4" form:"Content" json:"Content" query:"Content"` + Content string `thrift:"content,4" form:"content" json:"content" query:"content"` // 可见性 - Visibility MomentVisibility `thrift:"Visibility,5" form:"Visibility" json:"Visibility" query:"Visibility"` + Visibility MomentVisibility `thrift:"visibility,5" form:"visibility" json:"visibility" query:"visibility"` // 发布地点 - Location string `thrift:"Location,6" form:"Location" json:"Location" query:"Location"` + Location string `thrift:"location,6" form:"location" json:"location" query:"location"` // 状态 - Status ContentStatus `thrift:"Status,7" form:"Status" json:"Status" query:"Status"` + Status ContentStatus `thrift:"status,7" form:"status" json:"status" query:"status"` // 点赞数 - LikeCount int32 `thrift:"LikeCount,8" form:"LikeCount" json:"LikeCount" query:"LikeCount"` + LikeCount int32 `thrift:"like_count,8" form:"like_count" json:"like_count" query:"like_count"` // 评论数 - CommentCount int32 `thrift:"CommentCount,9" form:"CommentCount" json:"CommentCount" query:"CommentCount"` + CommentCount int32 `thrift:"comment_count,9" form:"comment_count" json:"comment_count" query:"comment_count"` // 动态图片列表 - Images []*MomentImage `thrift:"Images,10" form:"Images" json:"Images" query:"Images"` + Images []*MomentImage `thrift:"images,10" form:"images" json:"images" query:"images"` // 创建时间 - CreatedAt string `thrift:"CreatedAt,11" form:"CreatedAt" json:"CreatedAt" query:"CreatedAt"` + CreatedAt string `thrift:"created_at,11" form:"created_at" json:"created_at" query:"created_at"` // 更新时间 - UpdatedAt string `thrift:"UpdatedAt,12" form:"UpdatedAt" json:"UpdatedAt" query:"UpdatedAt"` + UpdatedAt string `thrift:"updated_at,12" form:"updated_at" json:"updated_at" query:"updated_at"` } func NewMoment() *Moment { @@ -12484,18 +12484,18 @@ func (p *Moment) GetUpdatedAt() (v string) { } var fieldIDToName_Moment = map[int16]string{ - 1: "ID", - 2: "UserID", - 3: "User", - 4: "Content", - 5: "Visibility", - 6: "Location", - 7: "Status", - 8: "LikeCount", - 9: "CommentCount", - 10: "Images", - 11: "CreatedAt", - 12: "UpdatedAt", + 1: "id", + 2: "user_id", + 3: "user", + 4: "content", + 5: "visibility", + 6: "location", + 7: "status", + 8: "like_count", + 9: "comment_count", + 10: "images", + 11: "created_at", + 12: "updated_at", } func (p *Moment) IsSetUser() bool { @@ -12860,7 +12860,7 @@ WriteStructEndError: } func (p *Moment) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ID", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("id", thrift.I64, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ID); err != nil { @@ -12876,7 +12876,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *Moment) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 2); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -12892,7 +12892,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *Moment) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("User", thrift.STRUCT, 3); err != nil { + if err = oprot.WriteFieldBegin("user", thrift.STRUCT, 3); err != nil { goto WriteFieldBeginError } if err := p.User.Write(oprot); err != nil { @@ -12908,7 +12908,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *Moment) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Content", thrift.STRING, 4); err != nil { + if err = oprot.WriteFieldBegin("content", thrift.STRING, 4); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Content); err != nil { @@ -12924,7 +12924,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) } func (p *Moment) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Visibility", thrift.I32, 5); err != nil { + if err = oprot.WriteFieldBegin("visibility", thrift.I32, 5); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(int32(p.Visibility)); err != nil { @@ -12940,7 +12940,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) } func (p *Moment) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Location", thrift.STRING, 6); err != nil { + if err = oprot.WriteFieldBegin("location", thrift.STRING, 6); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Location); err != nil { @@ -12956,7 +12956,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) } func (p *Moment) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Status", thrift.I32, 7); err != nil { + if err = oprot.WriteFieldBegin("status", thrift.I32, 7); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(int32(p.Status)); err != nil { @@ -12972,7 +12972,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) } func (p *Moment) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("LikeCount", thrift.I32, 8); err != nil { + if err = oprot.WriteFieldBegin("like_count", thrift.I32, 8); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.LikeCount); err != nil { @@ -12988,7 +12988,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) } func (p *Moment) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("CommentCount", thrift.I32, 9); err != nil { + if err = oprot.WriteFieldBegin("comment_count", thrift.I32, 9); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.CommentCount); err != nil { @@ -13004,7 +13004,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) } func (p *Moment) writeField10(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Images", thrift.LIST, 10); err != nil { + if err = oprot.WriteFieldBegin("images", thrift.LIST, 10); err != nil { goto WriteFieldBeginError } if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Images)); err != nil { @@ -13028,7 +13028,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) } func (p *Moment) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("CreatedAt", thrift.STRING, 11); err != nil { + if err = oprot.WriteFieldBegin("created_at", thrift.STRING, 11); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.CreatedAt); err != nil { @@ -13044,7 +13044,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) } func (p *Moment) writeField12(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UpdatedAt", thrift.STRING, 12); err != nil { + if err = oprot.WriteFieldBegin("updated_at", thrift.STRING, 12); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UpdatedAt); err != nil { @@ -13071,15 +13071,15 @@ func (p *Moment) String() string { // 发布动态请求 type CreateMomentRequest struct { // 发布者用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 动态内容 - Content string `thrift:"Content,2" form:"Content" json:"Content" query:"Content"` + Content string `thrift:"content,2" form:"content" json:"content" query:"content"` // 可见性,默认公开 - Visibility MomentVisibility `thrift:"Visibility,3" form:"Visibility" json:"Visibility" query:"Visibility"` + Visibility MomentVisibility `thrift:"visibility,3" form:"visibility" json:"visibility" query:"visibility"` // 发布地点 - Location string `thrift:"Location,4" form:"Location" json:"Location" query:"Location"` + Location string `thrift:"location,4" form:"location" json:"location" query:"location"` // 图片URL列表 - ImageURLs []string `thrift:"ImageURLs,5" form:"ImageURLs" json:"ImageURLs" query:"ImageURLs"` + ImageUrls []string `thrift:"image_urls,5" form:"image_urls" json:"image_urls" query:"image_urls"` } func NewCreateMomentRequest() *CreateMomentRequest { @@ -13105,16 +13105,16 @@ func (p *CreateMomentRequest) GetLocation() (v string) { return p.Location } -func (p *CreateMomentRequest) GetImageURLs() (v []string) { - return p.ImageURLs +func (p *CreateMomentRequest) GetImageUrls() (v []string) { + return p.ImageUrls } var fieldIDToName_CreateMomentRequest = map[int16]string{ - 1: "UserID", - 2: "Content", - 3: "Visibility", - 4: "Location", - 5: "ImageURLs", + 1: "user_id", + 2: "content", + 3: "visibility", + 4: "location", + 5: "image_urls", } func (p *CreateMomentRequest) Read(iprot thrift.TProtocol) (err error) { @@ -13268,7 +13268,7 @@ func (p *CreateMomentRequest) ReadField5(iprot thrift.TProtocol) error { if err := iprot.ReadListEnd(); err != nil { return err } - p.ImageURLs = _field + p.ImageUrls = _field return nil } @@ -13317,7 +13317,7 @@ WriteStructEndError: } func (p *CreateMomentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -13333,7 +13333,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *CreateMomentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Content", thrift.STRING, 2); err != nil { + if err = oprot.WriteFieldBegin("content", thrift.STRING, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Content); err != nil { @@ -13349,7 +13349,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *CreateMomentRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Visibility", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("visibility", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(int32(p.Visibility)); err != nil { @@ -13365,7 +13365,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *CreateMomentRequest) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Location", thrift.STRING, 4); err != nil { + if err = oprot.WriteFieldBegin("location", thrift.STRING, 4); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Location); err != nil { @@ -13381,13 +13381,13 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) } func (p *CreateMomentRequest) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ImageURLs", thrift.LIST, 5); err != nil { + if err = oprot.WriteFieldBegin("image_urls", thrift.LIST, 5); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteListBegin(thrift.STRING, len(p.ImageURLs)); err != nil { + if err := oprot.WriteListBegin(thrift.STRING, len(p.ImageUrls)); err != nil { return err } - for _, v := range p.ImageURLs { + for _, v := range p.ImageUrls { if err := oprot.WriteString(v); err != nil { return err } @@ -13601,11 +13601,11 @@ func (p *CreateMomentResponse) String() string { // 获取动态列表请求 type ListMomentsRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 页码,默认1 - Page int32 `thrift:"Page,2" form:"Page" json:"Page" query:"Page"` + Page int32 `thrift:"page,2" form:"page" json:"page" query:"page"` // 每页数量,默认10 - PageSize int32 `thrift:"PageSize,3" form:"PageSize" json:"PageSize" query:"PageSize"` + PageSize int32 `thrift:"pageSize,3" form:"pageSize" json:"pageSize" query:"pageSize"` } func NewListMomentsRequest() *ListMomentsRequest { @@ -13628,9 +13628,9 @@ func (p *ListMomentsRequest) GetPageSize() (v int32) { } var fieldIDToName_ListMomentsRequest = map[int16]string{ - 1: "UserID", - 2: "Page", - 3: "PageSize", + 1: "user_id", + 2: "page", + 3: "pageSize", } func (p *ListMomentsRequest) Read(iprot thrift.TProtocol) (err error) { @@ -13775,7 +13775,7 @@ WriteStructEndError: } func (p *ListMomentsRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -13791,7 +13791,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentsRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Page", thrift.I32, 2); err != nil { + if err = oprot.WriteFieldBegin("page", thrift.I32, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Page); err != nil { @@ -13807,7 +13807,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentsRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("pageSize", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.PageSize); err != nil { @@ -13835,15 +13835,9 @@ func (p *ListMomentsRequest) String() string { type ListMomentsResponse struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` // 动态列表 - Moments []*Moment `thrift:"Moments,2" form:"Moments" json:"Moments" query:"Moments"` + Moments []*Moment `thrift:"moments,2" form:"moments" json:"moments" query:"moments"` // 总数量 - Total int32 `thrift:"Total,3" form:"Total" json:"Total" query:"Total"` - // 当前页码 - Page int32 `thrift:"Page,4" form:"Page" json:"Page" query:"Page"` - // 每页数量 - PageSize int32 `thrift:"PageSize,5" form:"PageSize" json:"PageSize" query:"PageSize"` - // 提示信息 - Message string `thrift:"Message,6" form:"Message" json:"Message" query:"Message"` + Total int32 `thrift:"total,3" form:"total" json:"total" query:"total"` } func NewListMomentsResponse() *ListMomentsResponse { @@ -13865,25 +13859,10 @@ func (p *ListMomentsResponse) GetTotal() (v int32) { return p.Total } -func (p *ListMomentsResponse) GetPage() (v int32) { - return p.Page -} - -func (p *ListMomentsResponse) GetPageSize() (v int32) { - return p.PageSize -} - -func (p *ListMomentsResponse) GetMessage() (v string) { - return p.Message -} - var fieldIDToName_ListMomentsResponse = map[int16]string{ 1: "code", - 2: "Moments", - 3: "Total", - 4: "Page", - 5: "PageSize", - 6: "Message", + 2: "moments", + 3: "total", } func (p *ListMomentsResponse) Read(iprot thrift.TProtocol) (err error) { @@ -13928,30 +13907,6 @@ func (p *ListMomentsResponse) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } - case 4: - if fieldTypeId == thrift.I32 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.I32 { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.STRING { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -14026,39 +13981,6 @@ func (p *ListMomentsResponse) ReadField3(iprot thrift.TProtocol) error { p.Total = _field return nil } -func (p *ListMomentsResponse) ReadField4(iprot thrift.TProtocol) error { - - var _field int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _field = v - } - p.Page = _field - return nil -} -func (p *ListMomentsResponse) ReadField5(iprot thrift.TProtocol) error { - - var _field int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _field = v - } - p.PageSize = _field - return nil -} -func (p *ListMomentsResponse) ReadField6(iprot thrift.TProtocol) error { - - var _field string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _field = v - } - p.Message = _field - return nil -} func (p *ListMomentsResponse) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -14078,18 +14000,6 @@ func (p *ListMomentsResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -14125,7 +14035,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentsResponse) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Moments", thrift.LIST, 2); err != nil { + if err = oprot.WriteFieldBegin("moments", thrift.LIST, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Moments)); err != nil { @@ -14149,7 +14059,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentsResponse) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Total", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("total", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Total); err != nil { @@ -14164,54 +14074,6 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } -func (p *ListMomentsResponse) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Page", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Page); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} -func (p *ListMomentsResponse) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.PageSize); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} -func (p *ListMomentsResponse) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Message", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} func (p *ListMomentsResponse) String() string { if p == nil { @@ -14221,438 +14083,12 @@ func (p *ListMomentsResponse) String() string { } -// 获取单条动态请求 -type GetMomentRequest struct { - // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` - // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` -} - -func NewGetMomentRequest() *GetMomentRequest { - return &GetMomentRequest{} -} - -func (p *GetMomentRequest) InitDefault() { -} - -func (p *GetMomentRequest) GetUserID() (v string) { - return p.UserID -} - -func (p *GetMomentRequest) GetMomentID() (v int64) { - return p.MomentID -} - -var fieldIDToName_GetMomentRequest = map[int16]string{ - 1: "UserID", - 2: "MomentID", -} - -func (p *GetMomentRequest) Read(iprot thrift.TProtocol) (err error) { - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.I64 { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetMomentRequest[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *GetMomentRequest) ReadField1(iprot thrift.TProtocol) error { - - var _field string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _field = v - } - p.UserID = _field - return nil -} -func (p *GetMomentRequest) ReadField2(iprot thrift.TProtocol) error { - - var _field int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _field = v - } - p.MomentID = _field - return nil -} - -func (p *GetMomentRequest) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("GetMomentRequest"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *GetMomentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.UserID); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} -func (p *GetMomentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.MomentID); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *GetMomentRequest) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetMomentRequest(%+v)", *p) - -} - -// 获取单条动态响应 -type GetMomentResponse struct { - // 是否成功 - Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` - // 动态详情 - Moment *Moment `thrift:"Moment,2" form:"Moment" json:"Moment" query:"Moment"` - // 提示信息 - Msg string `thrift:"msg,3" form:"msg" json:"msg" query:"msg"` -} - -func NewGetMomentResponse() *GetMomentResponse { - return &GetMomentResponse{} -} - -func (p *GetMomentResponse) InitDefault() { -} - -func (p *GetMomentResponse) GetCode() (v Code) { - return p.Code -} - -var GetMomentResponse_Moment_DEFAULT *Moment - -func (p *GetMomentResponse) GetMoment() (v *Moment) { - if !p.IsSetMoment() { - return GetMomentResponse_Moment_DEFAULT - } - return p.Moment -} - -func (p *GetMomentResponse) GetMsg() (v string) { - return p.Msg -} - -var fieldIDToName_GetMomentResponse = map[int16]string{ - 1: "code", - 2: "Moment", - 3: "msg", -} - -func (p *GetMomentResponse) IsSetMoment() bool { - return p.Moment != nil -} - -func (p *GetMomentResponse) Read(iprot thrift.TProtocol) (err error) { - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.I32 { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.STRING { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetMomentResponse[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *GetMomentResponse) ReadField1(iprot thrift.TProtocol) error { - - var _field Code - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _field = Code(v) - } - p.Code = _field - return nil -} -func (p *GetMomentResponse) ReadField2(iprot thrift.TProtocol) error { - _field := NewMoment() - if err := _field.Read(iprot); err != nil { - return err - } - p.Moment = _field - return nil -} -func (p *GetMomentResponse) ReadField3(iprot thrift.TProtocol) error { - - var _field string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _field = v - } - p.Msg = _field - return nil -} - -func (p *GetMomentResponse) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("GetMomentResponse"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *GetMomentResponse) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(int32(p.Code)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} -func (p *GetMomentResponse) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Moment", thrift.STRUCT, 2); err != nil { - goto WriteFieldBeginError - } - if err := p.Moment.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} -func (p *GetMomentResponse) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("msg", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Msg); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} - -func (p *GetMomentResponse) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetMomentResponse(%+v)", *p) - -} - // 删除动态请求 type DeleteMomentRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` } func NewDeleteMomentRequest() *DeleteMomentRequest { @@ -14671,8 +14107,8 @@ func (p *DeleteMomentRequest) GetMomentID() (v int64) { } var fieldIDToName_DeleteMomentRequest = map[int16]string{ - 1: "UserID", - 2: "MomentID", + 1: "user_id", + 2: "moment_id", } func (p *DeleteMomentRequest) Read(iprot thrift.TProtocol) (err error) { @@ -14794,7 +14230,7 @@ WriteStructEndError: } func (p *DeleteMomentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -14810,7 +14246,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *DeleteMomentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -15022,9 +14458,9 @@ func (p *DeleteMomentResponse) String() string { // 点赞动态请求 type LikeMomentRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` } func NewLikeMomentRequest() *LikeMomentRequest { @@ -15043,8 +14479,8 @@ func (p *LikeMomentRequest) GetMomentID() (v int64) { } var fieldIDToName_LikeMomentRequest = map[int16]string{ - 1: "UserID", - 2: "MomentID", + 1: "user_id", + 2: "moment_id", } func (p *LikeMomentRequest) Read(iprot thrift.TProtocol) (err error) { @@ -15166,7 +14602,7 @@ WriteStructEndError: } func (p *LikeMomentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -15182,7 +14618,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *LikeMomentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -15395,9 +14831,9 @@ func (p *LikeMomentResponse) String() string { // 取消点赞请求 type UnlikeMomentRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` } func NewUnlikeMomentRequest() *UnlikeMomentRequest { @@ -15416,8 +14852,8 @@ func (p *UnlikeMomentRequest) GetMomentID() (v int64) { } var fieldIDToName_UnlikeMomentRequest = map[int16]string{ - 1: "UserID", - 2: "MomentID", + 1: "user_id", + 2: "moment_id", } func (p *UnlikeMomentRequest) Read(iprot thrift.TProtocol) (err error) { @@ -15539,7 +14975,7 @@ WriteStructEndError: } func (p *UnlikeMomentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -15555,7 +14991,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *UnlikeMomentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -15767,11 +15203,11 @@ func (p *UnlikeMomentResponse) String() string { // 获取动态点赞列表请求 type ListMomentLikesRequest struct { // 动态ID - MomentID int64 `thrift:"MomentID,1" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,1" form:"moment_id" json:"moment_id" query:"moment_id"` // 页码,默认1 - Page int32 `thrift:"Page,2" form:"Page" json:"Page" query:"Page"` + Page int32 `thrift:"page,2" form:"page" json:"page" query:"page"` // 每页数量,默认20 - PageSize int32 `thrift:"PageSize,3" form:"PageSize" json:"PageSize" query:"PageSize"` + PageSize int32 `thrift:"page_size,3" form:"page_size" json:"page_size" query:"page_size"` } func NewListMomentLikesRequest() *ListMomentLikesRequest { @@ -15794,9 +15230,9 @@ func (p *ListMomentLikesRequest) GetPageSize() (v int32) { } var fieldIDToName_ListMomentLikesRequest = map[int16]string{ - 1: "MomentID", - 2: "Page", - 3: "PageSize", + 1: "moment_id", + 2: "page", + 3: "page_size", } func (p *ListMomentLikesRequest) Read(iprot thrift.TProtocol) (err error) { @@ -15941,7 +15377,7 @@ WriteStructEndError: } func (p *ListMomentLikesRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -15957,7 +15393,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentLikesRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Page", thrift.I32, 2); err != nil { + if err = oprot.WriteFieldBegin("page", thrift.I32, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Page); err != nil { @@ -15973,7 +15409,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentLikesRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("page_size", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.PageSize); err != nil { @@ -16001,11 +15437,11 @@ func (p *ListMomentLikesRequest) String() string { type ListMomentLikesResponse struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` // 点赞列表 - Likes []*MomentLike `thrift:"Likes,2" form:"Likes" json:"Likes" query:"Likes"` + Likes []*MomentLike `thrift:"likes,2" form:"likes" json:"likes" query:"likes"` // 总数量 - Total int32 `thrift:"Total,3" form:"Total" json:"Total" query:"Total"` + Total int32 `thrift:"total,3" form:"total" json:"total" query:"total"` // 提示信息 - Message string `thrift:"Message,4" form:"Message" json:"Message" query:"Message"` + Message string `thrift:"message,4" form:"message" json:"message" query:"message"` } func NewListMomentLikesResponse() *ListMomentLikesResponse { @@ -16033,9 +15469,9 @@ func (p *ListMomentLikesResponse) GetMessage() (v string) { var fieldIDToName_ListMomentLikesResponse = map[int16]string{ 1: "code", - 2: "Likes", - 3: "Total", - 4: "Message", + 2: "likes", + 3: "total", + 4: "message", } func (p *ListMomentLikesResponse) Read(iprot thrift.TProtocol) (err error) { @@ -16231,7 +15667,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentLikesResponse) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Likes", thrift.LIST, 2); err != nil { + if err = oprot.WriteFieldBegin("likes", thrift.LIST, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Likes)); err != nil { @@ -16255,7 +15691,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentLikesResponse) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Total", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("total", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Total); err != nil { @@ -16271,7 +15707,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *ListMomentLikesResponse) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Message", thrift.STRING, 4); err != nil { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 4); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Message); err != nil { @@ -16298,13 +15734,13 @@ func (p *ListMomentLikesResponse) String() string { // 评论动态请求 type CommentMomentRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 动态ID - MomentID int64 `thrift:"MomentID,2" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,2" form:"moment_id" json:"moment_id" query:"moment_id"` // 评论内容 - Content string `thrift:"Content,3" form:"Content" json:"Content" query:"Content"` + Content string `thrift:"content,3" form:"content" json:"content" query:"content"` // 父评论ID,用于回复 - ParentID int64 `thrift:"ParentID,4" form:"ParentID" json:"ParentID" query:"ParentID"` + ParentID int64 `thrift:"parent_id,4" form:"parent_id" json:"parent_id" query:"parent_id"` } func NewCommentMomentRequest() *CommentMomentRequest { @@ -16331,10 +15767,10 @@ func (p *CommentMomentRequest) GetParentID() (v int64) { } var fieldIDToName_CommentMomentRequest = map[int16]string{ - 1: "UserID", - 2: "MomentID", - 3: "Content", - 4: "ParentID", + 1: "user_id", + 2: "moment_id", + 3: "content", + 4: "parent_id", } func (p *CommentMomentRequest) Read(iprot thrift.TProtocol) (err error) { @@ -16502,7 +15938,7 @@ WriteStructEndError: } func (p *CommentMomentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -16518,7 +15954,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *CommentMomentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -16534,7 +15970,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *CommentMomentRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Content", thrift.STRING, 3); err != nil { + if err = oprot.WriteFieldBegin("content", thrift.STRING, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.Content); err != nil { @@ -16550,7 +15986,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *CommentMomentRequest) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ParentID", thrift.I64, 4); err != nil { + if err = oprot.WriteFieldBegin("parent_id", thrift.I64, 4); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ParentID); err != nil { @@ -16764,13 +16200,13 @@ func (p *CommentMomentResponse) String() string { // 获取动态评论列表请求 type ListMomentCommentsRequest struct { // 动态ID - MomentID int64 `thrift:"MomentID,1" form:"MomentID" json:"MomentID" query:"MomentID"` + MomentID int64 `thrift:"moment_id,1" form:"moment_id" json:"moment_id" query:"moment_id"` // 父评论ID,用于获取回复 - ParentID int64 `thrift:"ParentID,2" form:"ParentID" json:"ParentID" query:"ParentID"` + ParentID int64 `thrift:"parent_id,2" form:"parent_id" json:"parent_id" query:"parent_id"` // 页码,默认1 - Page int32 `thrift:"Page,3" form:"Page" json:"Page" query:"Page"` + Page int32 `thrift:"page,3" form:"page" json:"page" query:"page"` // 每页数量,默认20 - PageSize int32 `thrift:"PageSize,4" form:"PageSize" json:"PageSize" query:"PageSize"` + PageSize int32 `thrift:"page_size,4" form:"page_size" json:"page_size" query:"page_size"` } func NewListMomentCommentsRequest() *ListMomentCommentsRequest { @@ -16797,10 +16233,10 @@ func (p *ListMomentCommentsRequest) GetPageSize() (v int32) { } var fieldIDToName_ListMomentCommentsRequest = map[int16]string{ - 1: "MomentID", - 2: "ParentID", - 3: "Page", - 4: "PageSize", + 1: "moment_id", + 2: "parent_id", + 3: "page", + 4: "page_size", } func (p *ListMomentCommentsRequest) Read(iprot thrift.TProtocol) (err error) { @@ -16968,7 +16404,7 @@ WriteStructEndError: } func (p *ListMomentCommentsRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("MomentID", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("moment_id", thrift.I64, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.MomentID); err != nil { @@ -16984,7 +16420,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentCommentsRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ParentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("parent_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.ParentID); err != nil { @@ -17000,7 +16436,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentCommentsRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Page", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("page", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Page); err != nil { @@ -17016,7 +16452,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *ListMomentCommentsRequest) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 4); err != nil { + if err = oprot.WriteFieldBegin("page_size", thrift.I32, 4); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.PageSize); err != nil { @@ -17044,9 +16480,9 @@ func (p *ListMomentCommentsRequest) String() string { type ListMomentCommentsResponse struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` // 评论列表 - Comments []*MomentComment `thrift:"Comments,2" form:"Comments" json:"Comments" query:"Comments"` + Comments []*MomentComment `thrift:"comments,2" form:"comments" json:"comments" query:"comments"` // 总数量 - Total int32 `thrift:"Total,3" form:"Total" json:"Total" query:"Total"` + Total int32 `thrift:"total,3" form:"total" json:"total" query:"total"` // 提示信息 Msg string `thrift:"msg,4" form:"msg" json:"msg" query:"msg"` } @@ -17076,8 +16512,8 @@ func (p *ListMomentCommentsResponse) GetMsg() (v string) { var fieldIDToName_ListMomentCommentsResponse = map[int16]string{ 1: "code", - 2: "Comments", - 3: "Total", + 2: "comments", + 3: "total", 4: "msg", } @@ -17274,7 +16710,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentCommentsResponse) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Comments", thrift.LIST, 2); err != nil { + if err = oprot.WriteFieldBegin("comments", thrift.LIST, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Comments)); err != nil { @@ -17298,7 +16734,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentCommentsResponse) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Total", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("total", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Total); err != nil { @@ -17341,9 +16777,9 @@ func (p *ListMomentCommentsResponse) String() string { // 删除评论请求 type DeleteCommentRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 评论ID - CommentID int64 `thrift:"CommentID,2" form:"CommentID" json:"CommentID" query:"CommentID"` + CommentID int64 `thrift:"comment_id,2" form:"comment_id" json:"comment_id" query:"comment_id"` } func NewDeleteCommentRequest() *DeleteCommentRequest { @@ -17362,8 +16798,8 @@ func (p *DeleteCommentRequest) GetCommentID() (v int64) { } var fieldIDToName_DeleteCommentRequest = map[int16]string{ - 1: "UserID", - 2: "CommentID", + 1: "user_id", + 2: "comment_id", } func (p *DeleteCommentRequest) Read(iprot thrift.TProtocol) (err error) { @@ -17485,7 +16921,7 @@ WriteStructEndError: } func (p *DeleteCommentRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -17501,7 +16937,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *DeleteCommentRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("CommentID", thrift.I64, 2); err != nil { + if err = oprot.WriteFieldBegin("comment_id", thrift.I64, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI64(p.CommentID); err != nil { @@ -17712,11 +17148,11 @@ func (p *DeleteCommentResponse) String() string { type ListMomentsAppointRequest struct { // 当前用户ID - UserID string `thrift:"UserID,1" form:"UserID" json:"UserID" query:"UserID"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` // 页码,默认1 - Page int32 `thrift:"Page,2" form:"Page" json:"Page" query:"Page"` + Page int32 `thrift:"page,2" form:"page" json:"page" query:"page"` // 每页数量,默认10 - PageSize int32 `thrift:"PageSize,3" form:"PageSize" json:"PageSize" query:"PageSize"` + PageSize int32 `thrift:"page_size,3" form:"page_size" json:"page_size" query:"page_size"` } func NewListMomentsAppointRequest() *ListMomentsAppointRequest { @@ -17739,9 +17175,9 @@ func (p *ListMomentsAppointRequest) GetPageSize() (v int32) { } var fieldIDToName_ListMomentsAppointRequest = map[int16]string{ - 1: "UserID", - 2: "Page", - 3: "PageSize", + 1: "user_id", + 2: "page", + 3: "page_size", } func (p *ListMomentsAppointRequest) Read(iprot thrift.TProtocol) (err error) { @@ -17886,7 +17322,7 @@ WriteStructEndError: } func (p *ListMomentsAppointRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("UserID", thrift.STRING, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(p.UserID); err != nil { @@ -17902,7 +17338,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentsAppointRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Page", thrift.I32, 2); err != nil { + if err = oprot.WriteFieldBegin("page", thrift.I32, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Page); err != nil { @@ -17918,7 +17354,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentsAppointRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("page_size", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.PageSize); err != nil { @@ -17946,15 +17382,9 @@ func (p *ListMomentsAppointRequest) String() string { type ListMomentsAppointResponse struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` // 动态列表 - Moments []*Moment `thrift:"Moments,2" form:"Moments" json:"Moments" query:"Moments"` + Moments []*Moment `thrift:"moments,2" form:"moments" json:"moments" query:"moments"` // 总数量 - Total int32 `thrift:"Total,3" form:"Total" json:"Total" query:"Total"` - // 当前页码 - Page int32 `thrift:"Page,4" form:"Page" json:"Page" query:"Page"` - // 每页数量 - PageSize int32 `thrift:"PageSize,5" form:"PageSize" json:"PageSize" query:"PageSize"` - // 提示信息 - Message string `thrift:"Message,6" form:"Message" json:"Message" query:"Message"` + Total int32 `thrift:"total,3" form:"total" json:"total" query:"total"` } func NewListMomentsAppointResponse() *ListMomentsAppointResponse { @@ -17976,25 +17406,10 @@ func (p *ListMomentsAppointResponse) GetTotal() (v int32) { return p.Total } -func (p *ListMomentsAppointResponse) GetPage() (v int32) { - return p.Page -} - -func (p *ListMomentsAppointResponse) GetPageSize() (v int32) { - return p.PageSize -} - -func (p *ListMomentsAppointResponse) GetMessage() (v string) { - return p.Message -} - var fieldIDToName_ListMomentsAppointResponse = map[int16]string{ 1: "code", - 2: "Moments", - 3: "Total", - 4: "Page", - 5: "PageSize", - 6: "Message", + 2: "moments", + 3: "total", } func (p *ListMomentsAppointResponse) Read(iprot thrift.TProtocol) (err error) { @@ -18039,30 +17454,6 @@ func (p *ListMomentsAppointResponse) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } - case 4: - if fieldTypeId == thrift.I32 { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.I32 { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.STRING { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -18137,39 +17528,6 @@ func (p *ListMomentsAppointResponse) ReadField3(iprot thrift.TProtocol) error { p.Total = _field return nil } -func (p *ListMomentsAppointResponse) ReadField4(iprot thrift.TProtocol) error { - - var _field int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _field = v - } - p.Page = _field - return nil -} -func (p *ListMomentsAppointResponse) ReadField5(iprot thrift.TProtocol) error { - - var _field int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _field = v - } - p.PageSize = _field - return nil -} -func (p *ListMomentsAppointResponse) ReadField6(iprot thrift.TProtocol) error { - - var _field string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _field = v - } - p.Message = _field - return nil -} func (p *ListMomentsAppointResponse) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -18189,18 +17547,6 @@ func (p *ListMomentsAppointResponse) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -18236,7 +17582,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *ListMomentsAppointResponse) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Moments", thrift.LIST, 2); err != nil { + if err = oprot.WriteFieldBegin("moments", thrift.LIST, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Moments)); err != nil { @@ -18260,7 +17606,7 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *ListMomentsAppointResponse) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Total", thrift.I32, 3); err != nil { + if err = oprot.WriteFieldBegin("total", thrift.I32, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(p.Total); err != nil { @@ -18275,54 +17621,6 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } -func (p *ListMomentsAppointResponse) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Page", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.Page); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} -func (p *ListMomentsAppointResponse) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.PageSize); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} -func (p *ListMomentsAppointResponse) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Message", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} func (p *ListMomentsAppointResponse) String() string { if p == nil { @@ -18676,8 +17974,6 @@ type MomentsService interface { ListMoments(ctx context.Context, req *ListMomentsRequest) (r *ListMomentsResponse, err error) //获取指定用户动态列表 ListMomentsAppoint(ctx context.Context, req *ListMomentsAppointRequest) (r *ListMomentsAppointResponse, err error) - // 获取单条动态详情 - GetMoment(ctx context.Context, req *GetMomentRequest) (r *GetMomentResponse, err error) // 删除动态 DeleteMoment(ctx context.Context, req *DeleteMomentRequest) (r *DeleteMomentResponse, err error) // 点赞动态 @@ -18747,15 +18043,6 @@ func (p *MomentsServiceClient) ListMomentsAppoint(ctx context.Context, req *List } return _result.GetSuccess(), nil } -func (p *MomentsServiceClient) GetMoment(ctx context.Context, req *GetMomentRequest) (r *GetMomentResponse, err error) { - var _args MomentsServiceGetMomentArgs - _args.Req = req - var _result MomentsServiceGetMomentResult - if err = p.Client_().Call(ctx, "GetMoment", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} func (p *MomentsServiceClient) DeleteMoment(ctx context.Context, req *DeleteMomentRequest) (r *DeleteMomentResponse, err error) { var _args MomentsServiceDeleteMomentArgs _args.Req = req @@ -25823,7 +25110,6 @@ func NewMomentsServiceProcessor(handler MomentsService) *MomentsServiceProcessor self.AddToProcessorMap("CreateMoment", &momentsServiceProcessorCreateMoment{handler: handler}) self.AddToProcessorMap("ListMoments", &momentsServiceProcessorListMoments{handler: handler}) self.AddToProcessorMap("ListMomentsAppoint", &momentsServiceProcessorListMomentsAppoint{handler: handler}) - self.AddToProcessorMap("GetMoment", &momentsServiceProcessorGetMoment{handler: handler}) self.AddToProcessorMap("DeleteMoment", &momentsServiceProcessorDeleteMoment{handler: handler}) self.AddToProcessorMap("LikeMoment", &momentsServiceProcessorLikeMoment{handler: handler}) self.AddToProcessorMap("UnlikeMoment", &momentsServiceProcessorUnlikeMoment{handler: handler}) @@ -25995,54 +25281,6 @@ func (p *momentsServiceProcessorListMomentsAppoint) Process(ctx context.Context, return true, err } -type momentsServiceProcessorGetMoment struct { - handler MomentsService -} - -func (p *momentsServiceProcessorGetMoment) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := MomentsServiceGetMomentArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("GetMoment", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := MomentsServiceGetMomentResult{} - var retval *GetMomentResponse - if retval, err2 = p.handler.GetMoment(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing GetMoment: "+err2.Error()) - oprot.WriteMessageBegin("GetMoment", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("GetMoment", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - type momentsServiceProcessorDeleteMoment struct { handler MomentsService } @@ -27255,298 +26493,6 @@ func (p *MomentsServiceListMomentsAppointResult) String() string { } -type MomentsServiceGetMomentArgs struct { - Req *GetMomentRequest `thrift:"req,1"` -} - -func NewMomentsServiceGetMomentArgs() *MomentsServiceGetMomentArgs { - return &MomentsServiceGetMomentArgs{} -} - -func (p *MomentsServiceGetMomentArgs) InitDefault() { -} - -var MomentsServiceGetMomentArgs_Req_DEFAULT *GetMomentRequest - -func (p *MomentsServiceGetMomentArgs) GetReq() (v *GetMomentRequest) { - if !p.IsSetReq() { - return MomentsServiceGetMomentArgs_Req_DEFAULT - } - return p.Req -} - -var fieldIDToName_MomentsServiceGetMomentArgs = map[int16]string{ - 1: "req", -} - -func (p *MomentsServiceGetMomentArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *MomentsServiceGetMomentArgs) Read(iprot thrift.TProtocol) (err error) { - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MomentsServiceGetMomentArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *MomentsServiceGetMomentArgs) ReadField1(iprot thrift.TProtocol) error { - _field := NewGetMomentRequest() - if err := _field.Read(iprot); err != nil { - return err - } - p.Req = _field - return nil -} - -func (p *MomentsServiceGetMomentArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("GetMoment_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *MomentsServiceGetMomentArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *MomentsServiceGetMomentArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MomentsServiceGetMomentArgs(%+v)", *p) - -} - -type MomentsServiceGetMomentResult struct { - Success *GetMomentResponse `thrift:"success,0,optional"` -} - -func NewMomentsServiceGetMomentResult() *MomentsServiceGetMomentResult { - return &MomentsServiceGetMomentResult{} -} - -func (p *MomentsServiceGetMomentResult) InitDefault() { -} - -var MomentsServiceGetMomentResult_Success_DEFAULT *GetMomentResponse - -func (p *MomentsServiceGetMomentResult) GetSuccess() (v *GetMomentResponse) { - if !p.IsSetSuccess() { - return MomentsServiceGetMomentResult_Success_DEFAULT - } - return p.Success -} - -var fieldIDToName_MomentsServiceGetMomentResult = map[int16]string{ - 0: "success", -} - -func (p *MomentsServiceGetMomentResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *MomentsServiceGetMomentResult) Read(iprot thrift.TProtocol) (err error) { - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MomentsServiceGetMomentResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *MomentsServiceGetMomentResult) ReadField0(iprot thrift.TProtocol) error { - _field := NewGetMomentResponse() - if err := _field.Read(iprot); err != nil { - return err - } - p.Success = _field - return nil -} - -func (p *MomentsServiceGetMomentResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("GetMoment_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *MomentsServiceGetMomentResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *MomentsServiceGetMomentResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MomentsServiceGetMomentResult(%+v)", *p) - -} - type MomentsServiceDeleteMomentArgs struct { Req *DeleteMomentRequest `thrift:"req,1"` } diff --git a/acquaintances/biz/router/user/user.go b/acquaintances/biz/router/user/user.go index a64c2ae..74b7145 100644 --- a/acquaintances/biz/router/user/user.go +++ b/acquaintances/biz/router/user/user.go @@ -5,7 +5,6 @@ package user import ( user "acquaintances/biz/handler/user" "github.com/cloudwego/hertz/pkg/app/server" - "github.com/hertz-contrib/cors" ) /* @@ -20,20 +19,6 @@ func Register(r *server.Hertz) { root := r.Group("/", rootMw()...) { _v1 := root.Group("/v1", _v1Mw()...) - _v1.Use(cors.New(cors.Config{ - // 允许的源( origins ),* 表示允许所有源(生产环境建议指定具体域名) - AllowOrigins: []string{"*"}, - // 允许的请求方法 - AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, - // 允许的请求头 - AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization"}, - // 是否允许发送 Cookie - AllowCredentials: true, - // 预检请求的有效期(秒),在此期间不需要重复发送预检请求 - MaxAge: 12 * 3600, - // 允许暴露的响应头(前端通过 XMLHttpRequest 可以访问的头信息) - ExposeHeaders: []string{"Content-Length"}, - })) { _moments := _v1.Group("/Moments", _momentsMw()...) _moments.DELETE("/", append(_deletemomentMw(), user.DeleteMoment)...) @@ -51,10 +36,6 @@ func Register(r *server.Hertz) { _dislike := _moments.Group("/dislike", _dislikeMw()...) _dislike.POST("/", append(_unlikemomentMw(), user.UnlikeMoment)...) } - { - _info := _moments.Group("/info", _infoMw()...) - _info.GET("/", append(_getmomentMw(), user.GetMoment)...) - } { _like := _moments.Group("/like", _likeMw()...) _like.POST("/", append(_likemomentMw(), user.LikeMoment)...) diff --git a/acquaintances/config.ini b/acquaintances/config.ini index 13966de..32196e6 100644 --- a/acquaintances/config.ini +++ b/acquaintances/config.ini @@ -11,8 +11,8 @@ WorkerIDBits = 3 Db = mysql DbHost = 127.0.0.1 DbPort = 3306 -DbUser = iuqtRoot -DbPassWord = mN3x4diYX6NzmC5a +DbUser = root +DbPassWord = 123456 DbName = iuqt_acquaintances #ETCD参数 diff --git a/acquaintances/idl/user.thrift b/acquaintances/idl/user.thrift index 54b890d..062f790 100644 --- a/acquaintances/idl/user.thrift +++ b/acquaintances/idl/user.thrift @@ -378,56 +378,56 @@ enum ContentStatus { // 朋友圈图片结构体 struct MomentImage { - 1: i64 ID // ID - 2: i64 MomentID // 所属动态ID - 3: string ImageURL // 图片URL + 1: i64 id // ID + 2: i64 moment_id // 所属动态ID + 3: string image_url // 图片URL } // 朋友圈点赞结构体 struct MomentLike { - 1: i64 ID // 点赞ID - 2: i64 MomentID // 动态ID - 3: string UserID // 点赞用户ID - 4: string CreatedAt // 点赞时间 + 1: i64 id // 点赞ID + 2: i64 moment_id // 动态ID + 3: string user_id // 点赞用户ID + 4: string created_at // 点赞时间 } // 朋友圈评论结构体 struct MomentComment { - 1: i64 ID // 评论ID - 2: i64 MomentID // 动态ID - 3: string UserID // 评论用户ID - 4: UserInfoReq User // 评论用户信息 - 5: string Content // 评论内容 - 6: i64 ParentID // 父评论ID,用于回复 - 7: MomentComment ParentComment // 父评论信息 - 8: ContentStatus Status // 状态 - 9: string CreatedAt // 创建时间 - 10: string UpdatedAt // 更新时间 + 1: i64 id // 评论ID + 2: i64 moment_id // 动态ID + 3: string user_id // 评论用户ID + 4: UserInfoReq user // 评论用户信息 + 5: string content // 评论内容 + 6: i64 parent_id // 父评论ID,用于回复 + 7: MomentComment parent_comment // 父评论信息 + 8: ContentStatus status // 状态 + 9: string created_at // 创建时间 + 10: string updated_at // 更新时间 } // 朋友圈动态结构体 struct Moment { - 1: i64 ID // 动态ID - 2: string UserID // 发布者用户ID - 3: UserInfoReq User // 发布者信息 - 4: string Content // 动态内容 - 5: MomentVisibility Visibility // 可见性 - 6: string Location // 发布地点 - 7: ContentStatus Status // 状态 - 8: i32 LikeCount // 点赞数 - 9: i32 CommentCount // 评论数 - 10: list Images // 动态图片列表 - 11: string CreatedAt // 创建时间 - 12: string UpdatedAt // 更新时间 + 1: i64 id // 动态ID + 2: string user_id // 发布者用户ID + 3: UserInfoReq user // 发布者信息 + 4: string content // 动态内容 + 5: MomentVisibility visibility // 可见性 + 6: string location // 发布地点 + 7: ContentStatus status // 状态 + 8: i32 like_count // 点赞数 + 9: i32 comment_count // 评论数 + 10: list images // 动态图片列表 + 11: string created_at // 创建时间 + 12: string updated_at // 更新时间 } // 发布动态请求 struct CreateMomentRequest { - 1: string UserID // 发布者用户ID - 2: string Content // 动态内容 - 3: MomentVisibility Visibility // 可见性,默认公开 - 4: string Location // 发布地点 - 5: list ImageURLs // 图片URL列表 + 1: string user_id // 发布者用户ID + 2: string content // 动态内容 + 3: MomentVisibility visibility // 可见性,默认公开 + 4: string location // 发布地点 + 5: list image_urls // 图片URL列表 } // 发布动态响应 @@ -438,38 +438,22 @@ struct CreateMomentResponse { // 获取动态列表请求 struct ListMomentsRequest { - 1: string UserID // 当前用户ID - 2: i32 Page // 页码,默认1 - 3: i32 PageSize // 每页数量,默认10 + 1: string user_id // 当前用户ID + 2: i32 page // 页码,默认1 + 3: i32 pageSize // 每页数量,默认10 } // 获取动态列表响应 struct ListMomentsResponse { 1: Code code - 2: list Moments // 动态列表 - 3: i32 Total // 总数量 - 4: i32 Page // 当前页码 - 5: i32 PageSize // 每页数量 - 6: string Message // 提示信息 -} - -// 获取单条动态请求 -struct GetMomentRequest { - 1: string UserID // 当前用户ID - 2: i64 MomentID // 动态ID -} - -// 获取单条动态响应 -struct GetMomentResponse { - 1: Code code // 是否成功 - 2: Moment Moment // 动态详情 - 3: string msg // 提示信息 + 2: list moments // 动态列表 + 3: i32 total // 总数量 } // 删除动态请求 struct DeleteMomentRequest { - 1: string UserID // 当前用户ID - 2: i64 MomentID // 动态ID + 1: string user_id // 当前用户ID + 2: i64 moment_id // 动态ID } // 删除动态响应 @@ -480,8 +464,8 @@ struct DeleteMomentResponse { // 点赞动态请求 struct LikeMomentRequest { - 1: string UserID // 当前用户ID - 2: i64 MomentID // 动态ID + 1: string user_id // 当前用户ID + 2: i64 moment_id // 动态ID } // 点赞动态响应 @@ -492,8 +476,8 @@ struct LikeMomentResponse { // 取消点赞请求 struct UnlikeMomentRequest { - 1: string UserID // 当前用户ID - 2: i64 MomentID // 动态ID + 1: string user_id // 当前用户ID + 2: i64 moment_id // 动态ID } // 取消点赞响应 @@ -504,25 +488,25 @@ struct UnlikeMomentResponse { // 获取动态点赞列表请求 struct ListMomentLikesRequest { - 1: i64 MomentID // 动态ID - 2: i32 Page // 页码,默认1 - 3: i32 PageSize // 每页数量,默认20 + 1: i64 moment_id // 动态ID + 2: i32 page // 页码,默认1 + 3: i32 page_size // 每页数量,默认20 } // 获取动态点赞列表响应 struct ListMomentLikesResponse { 1: Code code - 2: list Likes // 点赞列表 - 3: i32 Total // 总数量 - 4: string Message // 提示信息 + 2: list likes // 点赞列表 + 3: i32 total // 总数量 + 4: string message // 提示信息 } // 评论动态请求 struct CommentMomentRequest { - 1: string UserID // 当前用户ID - 2: i64 MomentID // 动态ID - 3: string Content // 评论内容 - 4: i64 ParentID // 父评论ID,用于回复 + 1: string user_id // 当前用户ID + 2: i64 moment_id // 动态ID + 3: string content // 评论内容 + 4: i64 parent_id // 父评论ID,用于回复 } // 评论动态响应 @@ -533,24 +517,24 @@ struct CommentMomentResponse { // 获取动态评论列表请求 struct ListMomentCommentsRequest { - 1: i64 MomentID // 动态ID - 2: i64 ParentID // 父评论ID,用于获取回复 - 3: i32 Page // 页码,默认1 - 4: i32 PageSize // 每页数量,默认20 + 1: i64 moment_id // 动态ID + 2: i64 parent_id // 父评论ID,用于获取回复 + 3: i32 page // 页码,默认1 + 4: i32 page_size // 每页数量,默认20 } // 获取动态评论列表响应 struct ListMomentCommentsResponse { 1: Code code - 2: list Comments // 评论列表 - 3: i32 Total // 总数量 + 2: list comments // 评论列表 + 3: i32 total // 总数量 4: string msg // 提示信息 } // 删除评论请求 struct DeleteCommentRequest { - 1: string UserID // 当前用户ID - 2: i64 CommentID // 评论ID + 1: string user_id // 当前用户ID + 2: i64 comment_id // 评论ID } // 删除评论响应 @@ -560,19 +544,16 @@ struct DeleteCommentResponse { } struct ListMomentsAppointRequest { - 1: string UserID // 当前用户ID - 2: i32 Page // 页码,默认1 - 3: i32 PageSize // 每页数量,默认10 + 1: string user_id // 当前用户ID + 2: i32 page // 页码,默认1 + 3: i32 page_size // 每页数量,默认10 } // 获取动态列表响应 struct ListMomentsAppointResponse { 1: Code code - 2: list Moments // 动态列表 - 3: i32 Total // 总数量 - 4: i32 Page // 当前页码 - 5: i32 PageSize // 每页数量 - 6: string Message // 提示信息 + 2: list moments // 动态列表 + 3: i32 total // 总数量 } // 朋友圈服务接口 @@ -586,9 +567,6 @@ service MomentsService { //获取指定用户动态列表 ListMomentsAppointResponse ListMomentsAppoint(1: ListMomentsAppointRequest req)(api.get="/v1/Moments/user/list/") - // 获取单条动态详情 - GetMomentResponse GetMoment(1: GetMomentRequest req)(api.get="/v1/Moments/info/") - // 删除动态 DeleteMomentResponse DeleteMoment(1: DeleteMomentRequest req)(api.delete="/v1/Moments/")