diff --git a/acquaintances/biz/dal/mysql/chat_group.go b/acquaintances/biz/dal/mysql/chat_group.go index a6464fa..63efc63 100644 --- a/acquaintances/biz/dal/mysql/chat_group.go +++ b/acquaintances/biz/dal/mysql/chat_group.go @@ -9,7 +9,7 @@ import ( ) // 创建群 -func CreateChatGroupInfo(userId string, data *user.ChatGroupInfo) error { +func CreateChatGroupInfo(userId string, data *model.ChatGroupInfo) error { // 参数校验 if userId == "" { return errors.New("用户ID不能为空") @@ -66,7 +66,7 @@ func DeleteChatGroupInfo(chatGroupId, userId string) error { } // 检查用户是否为群主(只有群主可以解散群) - var role model.ChatGroupRole + var role int err := DB.Model(&model.GroupUserRelation{}). Where("chat_group_id = ? AND user_id = ?", chatGroupId, userId). Pluck("role", &role).Error @@ -76,7 +76,7 @@ func DeleteChatGroupInfo(chatGroupId, userId string) error { return errors.New("查询用户权限失败") } - if role != model.GroupLeader { + if role != int(model.GroupLeader) { hlog.Warn("非群主尝试解散群", "user_id", userId, "group_id", chatGroupId, "role", role) return errors.New("只有群主可以解散群") } @@ -361,7 +361,7 @@ func GetUserListByChatGroup(req *user.ListUserChatGroupReq) ([]*user.UserInfoReq } // 批量获取用户信息 - users, err := GetUsersById(userIDs) + users, err := GetUsersById(userIDs...) if err != nil { hlog.Error("批量获取用户信息失败", err, "user_ids_count", len(userIDs)) return nil, errors.New("获取用户信息失败") diff --git a/acquaintances/biz/dal/mysql/friend_relationship.go b/acquaintances/biz/dal/mysql/friend_relationship.go index 5b2ac64..7e19241 100644 --- a/acquaintances/biz/dal/mysql/friend_relationship.go +++ b/acquaintances/biz/dal/mysql/friend_relationship.go @@ -3,6 +3,7 @@ package mysql import ( "acquaintances/biz/model" "acquaintances/biz/model/user" + "github.com/cloudwego/hertz/pkg/common/hlog" "gorm.io/gorm" ) @@ -37,7 +38,7 @@ func CreateFriendApplication(applicantID, targetUserID, message string) error { } // HandleFriendApplication 处理好友申请(接受/拒绝) -func HandleFriendApplication(applicationID uint64, status model.FriendApplicationStatus) error { +func HandleFriendApplication(applicationID int64, status model.FriendApplicationStatus) error { tx := DB if !status.IsValid() { return gorm.ErrInvalidData @@ -59,11 +60,11 @@ func HandleFriendApplication(applicationID uint64, status model.FriendApplicatio } // GetApplications 获取收到的好友申请/获取发出的好友申请 -func GetApplications(req user.ListFriendRelationshipReq, status ...model.FriendApplicationStatus) ([]*user.FriendRelationshipInfo, error) { +func GetApplications(req user.ListFriendRelationshipReq, status ...model.FriendApplicationStatus) ([]*user.FriendRelationshipListInfo, error) { tx := DB - var applications []*user.FriendRelationshipInfo - query := tx.Where("target_user_id = ? and applicant_id = ?", req.UserID, req.UserID) + var applications []*model.FriendRelationship + query := tx.Where("target_user_id = ? or applicant_id = ?", req.UserID, req.UserID) if len(status) > 0 { query = query.Where("status IN (?)", status) @@ -72,6 +73,29 @@ func GetApplications(req user.ListFriendRelationshipReq, status ...model.FriendA if err := query.Order("created_at DESC").Find(&applications).Error; err != nil { return nil, err } + var result []*user.FriendRelationshipListInfo + for _, v := range applications { + var tmp user.FriendRelationshipListInfo - return applications, nil + if v.ApplicantID == req.UserID { + data, err := GetUsersById(v.TargetUserID) + if err != nil || len(data) != 1 { + hlog.Errorf("GetApplications err:%v", err) + continue + } + tmp.UserName = data[0].UserName + tmp.AvatarImageURL = data[0].AvatarImageURL + } + tmp.ApplicationMessage = v.ApplicationMessage + tmp.Status = int8(v.Status) + result = append(result, &user.FriendRelationshipListInfo{ + UserName: tmp.UserName, + AvatarImageURL: tmp.AvatarImageURL, + UserID: tmp.UserID, + Status: tmp.Status, + ApplicationMessage: tmp.ApplicationMessage, + }) + } + + return result, nil } diff --git a/acquaintances/biz/dal/mysql/init.go b/acquaintances/biz/dal/mysql/init.go index efd4782..f00cf5c 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{}) + err = DB.AutoMigrate(model.User{}, model.Country{}, model.UserRelations{}, model.FriendRelationship{}, model.ChatGroupInfo{}, model.GroupUserRelation{}) 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 eb2171e..5cb65f0 100644 --- a/acquaintances/biz/dal/mysql/user.go +++ b/acquaintances/biz/dal/mysql/user.go @@ -4,16 +4,41 @@ import ( "acquaintances/biz/model" "acquaintances/biz/model/user" "errors" + "gorm.io/gorm" "github.com/cloudwego/hertz/pkg/common/hlog" ) func CreateUser(users []*model.User) error { - return DB.Create(users).Error + errTransaction := DB.Transaction(func(tx *gorm.DB) error { + //创建用户信息表记录 + err := tx.Create(users).Error + if err != nil { + return err + } + //创建用户关系表记录 + var rel model.UserRelations + rel.UserID = users[0].UserID + err = tx.Model(&model.UserRelations{}).Create(&rel).Error + if err != nil { + return err + } + + return nil + }) + return errTransaction } -func DeleteUser(userId int64) error { - return DB.Model(&model.User{}).Where("user_id = ?", userId).Delete(&model.User{}).Error +func DeleteUser(userId string) error { + errTransaction := DB.Transaction(func(tx *gorm.DB) error { + err := tx.Model(&model.User{}).Where("user_id = ?", userId).Delete(&model.User{}).Error + if err != nil { + return err + } + + return nil + }) + return errTransaction } func UpdateUser(user *user.User) error { @@ -55,12 +80,11 @@ func UpdatesUser(user *user.UpdateUserRequest) error { // InfoUser 查询单个用户 // 参数:用户ID -// 返回:用户信息指针,错误 -func InfoUser(id int64) (*user.UserInfoReq, error) { - db := DB.Model(&model.User{}) - db.Where("user_id = ?", id) - var res *user.UserInfoReq - if err := db.Find(&res).Error; err != nil { +// 返回:用户信息,错误 +func InfoUser(id string) (*model.User, error) { + res := new(model.User) + db := DB.Model(&model.User{}).Where("user_id = ?", id).First(res) + if err := db.Error; err != nil { return nil, err } return res, nil @@ -69,7 +93,7 @@ func InfoUser(id int64) (*user.UserInfoReq, error) { // GetUsersById 批量查询用户信息 // 参数:用户ID切片 // 返回:用户信息切片指针,错误 -func GetUsersById(ids []string) ([]*user.UserInfoReq, error) { +func GetUsersById(ids ...string) ([]*user.UserInfoReq, error) { db := DB.Model(&model.User{}) // 参数校验 if len(ids) == 0 { @@ -85,3 +109,17 @@ func GetUsersById(ids []string) ([]*user.UserInfoReq, error) { return users, nil } + +func FindUser(keyword *string) (*user.UserInfoReq, error) { + db := DB.Model(model.User{}) + if keyword != nil && len(*keyword) != 0 { + db = db.Where(DB.Or("user_id = ?", keyword). + Or("user_name = ?", keyword). + Or("mobile = ?", keyword)) + } + var res *user.UserInfoReq + if err := db.First(&res).Error; err != nil { + return nil, err + } + return res, nil +} diff --git a/acquaintances/biz/dal/mysql/user_relations.go b/acquaintances/biz/dal/mysql/user_relations.go index 23e5a1b..78c562c 100644 --- a/acquaintances/biz/dal/mysql/user_relations.go +++ b/acquaintances/biz/dal/mysql/user_relations.go @@ -5,12 +5,13 @@ import ( "acquaintances/biz/model/user" "encoding/json" "errors" + "gorm.io/gorm" "time" "github.com/cloudwego/hertz/pkg/common/hlog" ) -// 发起好申请 +// 添加好友 func CreateUserRelations(relations user.CreateUserRelationsReq) error { // 参数校验 if relations.UserID == "" || relations.FriendID == "" { @@ -19,33 +20,83 @@ func CreateUserRelations(relations user.CreateUserRelationsReq) error { if relations.UserID == relations.FriendID { return errors.New("不能添加自己为好友") } - db := DB.Model(&model.UserRelations{}) - var data model.UserRelations - friends, err := getFriend(relations.UserID) + var me model.UserRelations + meFriends, err := getFriend(relations.UserID) if err != nil { hlog.Error("CreateUserRelations:", err) return err } - // 检查是否已存在 - for _, friend := range friends { - if friend.FriendID == relations.FriendID { - return nil + if meFriends != nil { + hlog.Info("CreateUserRelations friends exist", meFriends) + // 检查是否已存在 + for _, friend := range meFriends { + if friend.FriendID == relations.FriendID { + return errors.New("已经是好友") + } } + } else { + hlog.Info("CreateUserRelations friends not exist") + meFriends = make([]*model.Friend, 0) } // 不存在 - newFriend := model.Friend{ + newMeFriends := model.Friend{ FriendID: relations.FriendID, - Remark: relations.Remark, + Remark: "", CreateTime: time.Now().Unix(), } - friends = append(friends, newFriend) - data.FriendList, err = json.Marshal(friends) + meFriends = append(meFriends, &newMeFriends) + me.FriendList, err = json.Marshal(&meFriends) if err != nil { hlog.Error("CreateUserRelations:", err) return err } - data.FriendCount = int64(len(friends)) - return db.Create(data).Error + me.FriendCount = int64(len(meFriends)) + + var you model.UserRelations + youFriends, err := getFriend(relations.FriendID) + if err != nil { + hlog.Error("CreateUserRelations:", err) + return err + } + + if youFriends != nil { + hlog.Info("CreateUserRelations friends exist", meFriends) + // 检查是否已存在 + for _, friend := range youFriends { + if friend.FriendID == relations.UserID { + return errors.New("已经是好友") + } + } + } else { + hlog.Info("CreateUserRelations friends not exist") + youFriends = make([]*model.Friend, 0) + } + + newYouFriends := &model.Friend{ + FriendID: relations.UserID, + Remark: "", + CreateTime: time.Now().Unix(), + } + youFriends = append(youFriends, newYouFriends) + you.FriendList, err = json.Marshal(&youFriends) + if err != nil { + hlog.Error("CreateUserRelations:", err) + return err + } + you.FriendCount = int64(len(meFriends)) + errTransaction := DB.Transaction(func(tx *gorm.DB) error { + err := tx.Where("user_id = ?", relations.UserID).Updates(&me).Error + if err != nil { + return err + } + err = tx.Where("user_id = ?", relations.FriendID).Updates(&you).Error + if err != nil { + return err + } + + return nil + }) + return errTransaction } // 删除好友 @@ -54,13 +105,12 @@ func DeleteUserRelations(relations user.DeleteUserRelationsReq) error { if relations.UserID == "" || relations.FriendID == "" { return errors.New("用户ID和好友ID不能为空") } - db := DB.Model(&model.UserRelations{}) friends, err := getFriend(relations.UserID) if err != nil { hlog.Error("DeleteUserRelations:", err) return err } - var newFriends []model.Friend + var newFriends []*model.Friend for _, friend := range friends { if friend.FriendID != relations.FriendID { newFriends = append(newFriends, friend) @@ -74,7 +124,20 @@ func DeleteUserRelations(relations user.DeleteUserRelationsReq) error { hlog.Error("DeleteUserRelations:", err) return err } - return db.Where("user_id = ?", relations.UserID).Updates(maps).Error + del := make(map[string]interface{}) + del["status"] = model.RelationshipBreakdown + errTransaction := DB.Transaction(func(tx *gorm.DB) error { + err := tx.Model(&model.UserRelations{}).Where("user_id = ?", relations.UserID).Updates(maps).Error + if err != nil { + return err + } + err = tx.Model(&model.FriendRelationship{}).Where("(applicant_id = ? and target_user_id = ?) or (applicant_id = ? and target_user_id = ?)", relations.UserID, relations.FriendID, relations.FriendID, relations.UserID).Updates(del).Error + if err != nil { + return err + } + return nil + }) + return errTransaction } // 更新好友备注 @@ -98,7 +161,7 @@ func UpdateUserRelations(relations user.UpdateUserRelationsReq) error { } } maps := make(map[string]interface{}) - maps["friend_list"], err = json.Marshal(friends) + maps["friend_list"], err = json.Marshal(&friends) if err != nil { hlog.Error("UpdateUserRelations:", err) return err @@ -118,7 +181,7 @@ func GetUserListRelations(relations user.ListUserRelationsReq) (*user.ListUserRe for _, v := range friends { ids = append(ids, v.FriendID) } - res.Users, err = GetUsersById(ids) + res.Users, err = GetUsersById(ids...) if err != nil { hlog.Error("GetUserListRelations:", err) return nil, err @@ -127,14 +190,17 @@ func GetUserListRelations(relations user.ListUserRelationsReq) (*user.ListUserRe return res, nil } -func getFriend(userId string) ([]model.Friend, error) { +func getFriend(userId string) ([]*model.Friend, error) { db := DB.Model(&model.UserRelations{}) var beforeRes model.UserRelations if err := db.Where("user_id = ?", userId).Find(&beforeRes).Error; err != nil { hlog.Error("getFriend:", err) return nil, err } - var friends []model.Friend + if beforeRes.FriendList == nil { + return nil, nil + } + var friends []*model.Friend if err := json.Unmarshal(beforeRes.FriendList, &friends); err != nil { hlog.Error("getFriend:", err) return nil, err diff --git a/acquaintances/biz/handler/ping.go b/acquaintances/biz/handler/ping.go index cdbeaba..950d476 100644 --- a/acquaintances/biz/handler/ping.go +++ b/acquaintances/biz/handler/ping.go @@ -13,6 +13,6 @@ import ( // Ping . func Ping(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusOK, utils.H{ - "message": "acquaintances pong", + "message": "pong", }) } diff --git a/acquaintances/biz/handler/user/chat_group_service.go b/acquaintances/biz/handler/user/chat_group_service.go index e98d8ef..6a129a5 100644 --- a/acquaintances/biz/handler/user/chat_group_service.go +++ b/acquaintances/biz/handler/user/chat_group_service.go @@ -4,10 +4,10 @@ package user import ( "acquaintances/biz/dal/mysql" + "acquaintances/biz/model" + user "acquaintances/biz/model/user" "acquaintances/biz/utils" "context" - - user "acquaintances/biz/model/user" "github.com/cloudwego/hertz/pkg/app" "github.com/cloudwego/hertz/pkg/protocol/consts" ) @@ -22,7 +22,7 @@ func CreateChatGroup(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusBadRequest, err.Error()) return } - data := &user.ChatGroupInfo{ChatGroupID: utils.GenerateChatGroupID(), ChatGroupName: req.ChatGroupName} + data := &model.ChatGroupInfo{ChatGroupID: utils.GenerateChatGroupID(), ChatGroupName: req.ChatGroupName} err = mysql.CreateChatGroupInfo(req.UserID, data) if err != nil { c.JSON(consts.StatusInternalServerError, err.Error()) diff --git a/acquaintances/biz/handler/user/friend_relationship_service.go b/acquaintances/biz/handler/user/friend_relationship_service.go index b402b88..956ffaf 100644 --- a/acquaintances/biz/handler/user/friend_relationship_service.go +++ b/acquaintances/biz/handler/user/friend_relationship_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" @@ -19,12 +20,12 @@ func CreateFriendRelationship(ctx context.Context, c *app.RequestContext) { var req user.CreateFriendRelationshipReq err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } err = mysql.CreateFriendApplication(req.ApplicantID, req.TargetUserID, req.ApplicationMessage) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } resp := new(user.CreateFriendRelationshipRes) @@ -39,7 +40,36 @@ func UpdateFriendRelationship(ctx context.Context, c *app.RequestContext) { var req user.UpdateFriendRelationshipReq err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + + if req.Status == 1 { + //接受 + err = mysql.HandleFriendApplication(req.ID, model.ApplicationAccepted) + if err != nil { + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + //添加好友 + var reqC user.CreateUserRelationsReq + reqC.UserID = req.ApplicantID + reqC.FriendID = req.TargetUserID + err := mysql.CreateUserRelations(reqC) + if err != nil { + hlog.Errorf("CreateUserRelations err=%s", err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + } else if req.Status == 2 { + //拒绝 + err = mysql.HandleFriendApplication(req.ID, model.ApplicationRejected) + if err != nil { + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + } else { + c.JSON(consts.StatusBadRequest, "invalid status") return } @@ -55,12 +85,12 @@ func ListFriendRelationship(ctx context.Context, c *app.RequestContext) { var req user.ListFriendRelationshipReq err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } data, err := mysql.GetApplications(req, model.ApplicationPending, model.ApplicationAccepted, model.ApplicationRejected) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } resp := new(user.ListFriendRelationshipRes) diff --git a/acquaintances/biz/handler/user/user_relations_service.go b/acquaintances/biz/handler/user/user_relations_service.go index edc5fc1..4b07ac3 100644 --- a/acquaintances/biz/handler/user/user_relations_service.go +++ b/acquaintances/biz/handler/user/user_relations_service.go @@ -27,7 +27,7 @@ func DeleteUserRelations(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusInternalServerError, err.Error()) return } - resp := new(user.DeleteUserRelationsReq) + resp := new(user.DeleteUserRelationsRes) c.JSON(consts.StatusOK, resp) } @@ -42,10 +42,10 @@ func CreateUserRelations(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusBadRequest, err.Error()) return } - if err = mysql.CreateUserRelations(req); err != nil { - c.JSON(consts.StatusInternalServerError, err.Error()) - return - } + //if err = mysql.CreateUserRelations(req); err != nil { + // c.JSON(consts.StatusInternalServerError, err.Error()) + // return + //} resp := new(user.CreateUserRelationsReq) c.JSON(consts.StatusOK, resp) @@ -79,7 +79,7 @@ func UpdateUserRelations(ctx context.Context, c *app.RequestContext) { var req user.UpdateUserRelationsReq err = c.BindAndValidate(&req) if err != nil { - c.String(consts.StatusBadRequest, err.Error()) + c.JSON(consts.StatusBadRequest, err.Error()) return } resp := new(user.UpdateUserRelationsRes) diff --git a/acquaintances/biz/handler/user/user_service.go b/acquaintances/biz/handler/user/user_service.go index 760329e..0986683 100644 --- a/acquaintances/biz/handler/user/user_service.go +++ b/acquaintances/biz/handler/user/user_service.go @@ -54,7 +54,7 @@ func DeleteUser(ctx context.Context, c *app.RequestContext) { } // QueryUser . -// @router /v1/user/info/ [GET] +// @router /v1/user/[GET] func InfoUser(ctx context.Context, c *app.RequestContext) { var err error var req user.InfoUserRequest @@ -63,13 +63,31 @@ func InfoUser(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusBadRequest, err.Error()) return } + hlog.Infof("InfoUser(%+v)", req) data, err := mysql.InfoUser(req.UserID) if err != nil { c.JSON(consts.StatusInternalServerError, err.Error()) return } + resData := new(user.UserInfoReq) + resData.UserName = data.UserName + resData.Gender = data.Gender + resData.Age = int64(data.Age) + resData.Introduce = data.Introduce + resData.AvatarImageURL = data.AvatarImageURL + if data.Birthday != nil { + resData.Birthday = data.Birthday.String() + } + + resData.Area = int64(data.Area) + resData.Mobile = data.Mobile + resData.Email = data.UserEmail + resData.Alias = data.Alias + resData.Address = data.Address + resData.UserID = data.UserID + resp := new(user.QueryUserResponse) - resp.UserInfo = data + resp.UserInfo = resData c.JSON(consts.StatusOK, resp) } @@ -107,3 +125,23 @@ func CreateUser(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusOK, resp) } + +// FindUser . +// @router /v1/user/find/ [GET] +func FindUser(ctx context.Context, c *app.RequestContext) { + var err error + var req user.FindUserRequest + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + data, err := mysql.FindUser(&req.Keyword) + if err != nil { + c.JSON(consts.StatusInternalServerError, err.Error()) + return + } + resp := new(user.FindUserResponse) + resp.UserInfo = data + c.JSON(consts.StatusOK, resp) +} diff --git a/acquaintances/biz/model/area/area.go b/acquaintances/biz/model/area/area.go index 566929e..9c2eaf3 100644 --- a/acquaintances/biz/model/area/area.go +++ b/acquaintances/biz/model/area/area.go @@ -70,6 +70,7 @@ type Area struct { NumCode string `thrift:"NumCode,5" form:"NumCode" json:"NumCode" query:"NumCode"` PhoneCode string `thrift:"PhoneCode,6" form:"PhoneCode" json:"PhoneCode" query:"PhoneCode"` DomainSuffix string `thrift:"DomainSuffix,7" form:"DomainSuffix" json:"DomainSuffix" query:"DomainSuffix"` + Id int64 `thrift:"Id,8" form:"Id" json:"Id" query:"Id"` } func NewArea() *Area { @@ -107,6 +108,10 @@ func (p *Area) GetDomainSuffix() (v string) { return p.DomainSuffix } +func (p *Area) GetId() (v int64) { + return p.Id +} + var fieldIDToName_Area = map[int16]string{ 1: "ChineseName", 2: "EnglishName", @@ -115,6 +120,7 @@ var fieldIDToName_Area = map[int16]string{ 5: "NumCode", 6: "PhoneCode", 7: "DomainSuffix", + 8: "Id", } func (p *Area) Read(iprot thrift.TProtocol) (err error) { @@ -191,6 +197,14 @@ func (p *Area) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 8: + if fieldTypeId == thrift.I64 { + if err = p.ReadField8(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 @@ -297,6 +311,17 @@ func (p *Area) ReadField7(iprot thrift.TProtocol) error { p.DomainSuffix = _field return nil } +func (p *Area) ReadField8(iprot thrift.TProtocol) error { + + var _field int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = v + } + p.Id = _field + return nil +} func (p *Area) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -332,6 +357,10 @@ func (p *Area) Write(oprot thrift.TProtocol) (err error) { fieldId = 7 goto WriteFieldError } + if err = p.writeField8(oprot); err != nil { + fieldId = 8 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -462,6 +491,22 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) } +func (p *Area) writeField8(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Id", thrift.I64, 8); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.Id); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) +} func (p *Area) String() string { if p == nil { diff --git a/acquaintances/biz/model/user/user.go b/acquaintances/biz/model/user/user.go index 5c408dd..9fd9003 100644 --- a/acquaintances/biz/model/user/user.go +++ b/acquaintances/biz/model/user/user.go @@ -156,7 +156,7 @@ func (p *UserStatus) Value() (driver.Value, error) { type User struct { //id - UserID int64 `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` //用户名 UserName string `thrift:"user_name,2" form:"user_name" json:"user_name" query:"user_name"` //性别 @@ -178,7 +178,7 @@ type User struct { //用户状态 UserStatus UserStatus `thrift:"user_status,11" form:"user_status" json:"user_status" query:"user_status"` //用户邮箱 - UserEmail string `thrift:"user_email,12" form:"user_email" json:"user_email" query:"user_email"` + Email string `thrift:"email,12" form:"email" json:"email" query:"email"` //别名 Alias string `thrift:"alias,13" form:"alias" json:"alias" query:"alias"` //详细地址 @@ -198,7 +198,7 @@ func NewUser() *User { func (p *User) InitDefault() { } -func (p *User) GetUserID() (v int64) { +func (p *User) GetUserID() (v string) { return p.UserID } @@ -242,8 +242,8 @@ func (p *User) GetUserStatus() (v UserStatus) { return p.UserStatus } -func (p *User) GetUserEmail() (v string) { - return p.UserEmail +func (p *User) GetEmail() (v string) { + return p.Email } func (p *User) GetAlias() (v string) { @@ -278,7 +278,7 @@ var fieldIDToName_User = map[int16]string{ 9: "mobile", 10: "user_password", 11: "user_status", - 12: "user_email", + 12: "email", 13: "alias", 14: "address", 15: "last_login_ip", @@ -305,7 +305,7 @@ func (p *User) Read(iprot thrift.TProtocol) (err error) { switch fieldId { case 1: - if fieldTypeId == thrift.I64 { + if fieldTypeId == thrift.STRING { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } @@ -471,8 +471,8 @@ ReadStructEndError: func (p *User) ReadField1(iprot thrift.TProtocol) error { - var _field int64 - if v, err := iprot.ReadI64(); err != nil { + var _field string + if v, err := iprot.ReadString(); err != nil { return err } else { _field = v @@ -598,7 +598,7 @@ func (p *User) ReadField12(iprot thrift.TProtocol) error { } else { _field = v } - p.UserEmail = _field + p.Email = _field return nil } func (p *User) ReadField13(iprot thrift.TProtocol) error { @@ -750,10 +750,10 @@ WriteStructEndError: } func (p *User) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("user_id", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteI64(p.UserID); err != nil { + if err := oprot.WriteString(p.UserID); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -926,10 +926,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) } func (p *User) writeField12(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("user_email", thrift.STRING, 12); err != nil { + if err = oprot.WriteFieldBegin("email", thrift.STRING, 12); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.UserEmail); err != nil { + if err := oprot.WriteString(p.Email); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -1048,11 +1048,13 @@ type UserInfoReq struct { //手机号 Mobile string `thrift:"mobile,8" form:"mobile" json:"mobile" query:"mobile"` //用户邮箱 - UserEmail string `thrift:"user_email,9" form:"user_email" json:"user_email" query:"user_email"` + Email string `thrift:"email,9" form:"email" json:"email" query:"email"` //别名 Alias string `thrift:"alias,10" form:"alias" json:"alias" query:"alias"` //详细地址 Address string `thrift:"address,11" form:"address" json:"address" query:"address"` + //id + UserID string `thrift:"user_id,12" form:"user_id" json:"user_id" query:"user_id"` } func NewUserInfoReq() *UserInfoReq { @@ -1094,8 +1096,8 @@ func (p *UserInfoReq) GetMobile() (v string) { return p.Mobile } -func (p *UserInfoReq) GetUserEmail() (v string) { - return p.UserEmail +func (p *UserInfoReq) GetEmail() (v string) { + return p.Email } func (p *UserInfoReq) GetAlias() (v string) { @@ -1106,6 +1108,10 @@ func (p *UserInfoReq) GetAddress() (v string) { return p.Address } +func (p *UserInfoReq) GetUserID() (v string) { + return p.UserID +} + var fieldIDToName_UserInfoReq = map[int16]string{ 1: "user_name", 2: "gender", @@ -1115,9 +1121,10 @@ var fieldIDToName_UserInfoReq = map[int16]string{ 6: "birthday", 7: "area", 8: "mobile", - 9: "user_email", + 9: "email", 10: "alias", 11: "address", + 12: "user_id", } func (p *UserInfoReq) Read(iprot thrift.TProtocol) (err error) { @@ -1226,6 +1233,14 @@ func (p *UserInfoReq) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 12: + if fieldTypeId == thrift.STRING { + if err = p.ReadField12(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 @@ -1351,7 +1366,7 @@ func (p *UserInfoReq) ReadField9(iprot thrift.TProtocol) error { } else { _field = v } - p.UserEmail = _field + p.Email = _field return nil } func (p *UserInfoReq) ReadField10(iprot thrift.TProtocol) error { @@ -1376,6 +1391,17 @@ func (p *UserInfoReq) ReadField11(iprot thrift.TProtocol) error { p.Address = _field return nil } +func (p *UserInfoReq) ReadField12(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 *UserInfoReq) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -1427,6 +1453,10 @@ func (p *UserInfoReq) Write(oprot thrift.TProtocol) (err error) { fieldId = 11 goto WriteFieldError } + if err = p.writeField12(oprot); err != nil { + fieldId = 12 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1574,10 +1604,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) } func (p *UserInfoReq) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("user_email", thrift.STRING, 9); err != nil { + if err = oprot.WriteFieldBegin("email", thrift.STRING, 9); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.UserEmail); err != nil { + if err := oprot.WriteString(p.Email); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -1621,6 +1651,22 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) } +func (p *UserInfoReq) writeField12(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 12); 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 12 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) +} func (p *UserInfoReq) String() string { if p == nil { @@ -1632,11 +1678,11 @@ func (p *UserInfoReq) String() string { type CreateUserRequest struct { Name string `thrift:"name,1" form:"name" json:"name" vd:"(len($) > 0 && len($) < 100)"` - Gender Gender `thrift:"gender,2" 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)"` + Gender Gender `thrift:"gender,2" form:"gender" form:"gender" json:"gender" vd:"($ == 1||$ == 2)"` + Age int64 `thrift:"age,3" form:"age" form:"age" json:"age" vd:"$>0"` + Mobile string `thrift:"mobile,4" form:"mobile" json:"mobile" vd:"(len($) > 0 && len($) < 12)"` Area int64 `thrift:"area,5" form:"area" json:"area" vd:"$>0"` - UserPassword string `thrift:"user_password,6" form:"user_password" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"` + UserPassword string `thrift:"user_password,6" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"` } func NewCreateUserRequest() *CreateUserRequest { @@ -2179,7 +2225,7 @@ func (p *CreateUserResponse) String() string { } type InfoUserRequest struct { - UserID int64 `thrift:"user_id,1" json:"user_id" path:"user_id" vd:"$>0"` + UserID string `thrift:"user_id,1" json:"user_id" path:"user_id" query:"user_id"` } func NewInfoUserRequest() *InfoUserRequest { @@ -2189,7 +2235,7 @@ func NewInfoUserRequest() *InfoUserRequest { func (p *InfoUserRequest) InitDefault() { } -func (p *InfoUserRequest) GetUserID() (v int64) { +func (p *InfoUserRequest) GetUserID() (v string) { return p.UserID } @@ -2216,7 +2262,7 @@ func (p *InfoUserRequest) Read(iprot thrift.TProtocol) (err error) { switch fieldId { case 1: - if fieldTypeId == thrift.I64 { + if fieldTypeId == thrift.STRING { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } @@ -2254,8 +2300,8 @@ ReadStructEndError: func (p *InfoUserRequest) ReadField1(iprot thrift.TProtocol) error { - var _field int64 - if v, err := iprot.ReadI64(); err != nil { + var _field string + if v, err := iprot.ReadString(); err != nil { return err } else { _field = v @@ -2293,10 +2339,10 @@ WriteStructEndError: } func (p *InfoUserRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("user_id", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteI64(p.UserID); err != nil { + if err := oprot.WriteString(p.UserID); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -2553,7 +2599,7 @@ func (p *QueryUserResponse) String() string { } type DeleteUserRequest struct { - UserID int64 `thrift:"user_id,1" json:"user_id" path:"user_id" vd:"$>0"` + UserID string `thrift:"user_id,1" json:"user_id" path:"user_id"` } func NewDeleteUserRequest() *DeleteUserRequest { @@ -2563,7 +2609,7 @@ func NewDeleteUserRequest() *DeleteUserRequest { func (p *DeleteUserRequest) InitDefault() { } -func (p *DeleteUserRequest) GetUserID() (v int64) { +func (p *DeleteUserRequest) GetUserID() (v string) { return p.UserID } @@ -2590,7 +2636,7 @@ func (p *DeleteUserRequest) Read(iprot thrift.TProtocol) (err error) { switch fieldId { case 1: - if fieldTypeId == thrift.I64 { + if fieldTypeId == thrift.STRING { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } @@ -2628,8 +2674,8 @@ ReadStructEndError: func (p *DeleteUserRequest) ReadField1(iprot thrift.TProtocol) error { - var _field int64 - if v, err := iprot.ReadI64(); err != nil { + var _field string + if v, err := iprot.ReadString(); err != nil { return err } else { _field = v @@ -2667,10 +2713,10 @@ WriteStructEndError: } func (p *DeleteUserRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("user_id", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteI64(p.UserID); err != nil { + if err := oprot.WriteString(p.UserID); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -2876,7 +2922,7 @@ func (p *DeleteUserResponse) String() string { } type UpdateUserRequest struct { - UserID int64 `thrift:"user_id,1" json:"user_id" path:"user_id"` + UserID string `thrift:"user_id,1" json:"user_id" path:"user_id"` Name string `thrift:"name,2" form:"name" json:"name"` Gender Gender `thrift:"gender,3" form:"gender" json:"gender"` Age int64 `thrift:"age,4" form:"age" json:"age"` @@ -2896,7 +2942,7 @@ func NewUpdateUserRequest() *UpdateUserRequest { func (p *UpdateUserRequest) InitDefault() { } -func (p *UpdateUserRequest) GetUserID() (v int64) { +func (p *UpdateUserRequest) GetUserID() (v string) { return p.UserID } @@ -2973,7 +3019,7 @@ func (p *UpdateUserRequest) Read(iprot thrift.TProtocol) (err error) { switch fieldId { case 1: - if fieldTypeId == thrift.I64 { + if fieldTypeId == thrift.STRING { if err = p.ReadField1(iprot); err != nil { goto ReadFieldError } @@ -3091,8 +3137,8 @@ ReadStructEndError: func (p *UpdateUserRequest) ReadField1(iprot thrift.TProtocol) error { - var _field int64 - if v, err := iprot.ReadI64(); err != nil { + var _field string + if v, err := iprot.ReadString(); err != nil { return err } else { _field = v @@ -3280,10 +3326,10 @@ WriteStructEndError: } func (p *UpdateUserRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("user_id", thrift.I64, 1); err != nil { + if err = oprot.WriteFieldBegin("user_id", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteI64(p.UserID); err != nil { + if err := oprot.WriteString(p.UserID); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -3648,6 +3694,380 @@ func (p *UpdateUserResponse) String() string { } +type FindUserResponse struct { + Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` + Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` + UserInfo *UserInfoReq `thrift:"userInfo,3" form:"userInfo" json:"userInfo" query:"userInfo"` +} + +func NewFindUserResponse() *FindUserResponse { + return &FindUserResponse{} +} + +func (p *FindUserResponse) InitDefault() { +} + +func (p *FindUserResponse) GetCode() (v Code) { + return p.Code +} + +func (p *FindUserResponse) GetMsg() (v string) { + return p.Msg +} + +var FindUserResponse_UserInfo_DEFAULT *UserInfoReq + +func (p *FindUserResponse) GetUserInfo() (v *UserInfoReq) { + if !p.IsSetUserInfo() { + return FindUserResponse_UserInfo_DEFAULT + } + return p.UserInfo +} + +var fieldIDToName_FindUserResponse = map[int16]string{ + 1: "code", + 2: "msg", + 3: "userInfo", +} + +func (p *FindUserResponse) IsSetUserInfo() bool { + return p.UserInfo != nil +} + +func (p *FindUserResponse) 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.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + 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_FindUserResponse[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 *FindUserResponse) 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 *FindUserResponse) ReadField2(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 *FindUserResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewUserInfoReq() + if err := _field.Read(iprot); err != nil { + return err + } + p.UserInfo = _field + return nil +} + +func (p *FindUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("FindUserResponse"); 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 *FindUserResponse) 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 *FindUserResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); 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 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *FindUserResponse) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("userInfo", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.UserInfo.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 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} + +func (p *FindUserResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FindUserResponse(%+v)", *p) + +} + +type FindUserRequest struct { + Keyword string `thrift:"keyword,1" json:"keyword" path:"user_id" query:"keyword"` +} + +func NewFindUserRequest() *FindUserRequest { + return &FindUserRequest{} +} + +func (p *FindUserRequest) InitDefault() { +} + +func (p *FindUserRequest) GetKeyword() (v string) { + return p.Keyword +} + +var fieldIDToName_FindUserRequest = map[int16]string{ + 1: "keyword", +} + +func (p *FindUserRequest) 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 + } + 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_FindUserRequest[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 *FindUserRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Keyword = _field + return nil +} + +func (p *FindUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("FindUserRequest"); 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 *FindUserRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("keyword", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Keyword); 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 *FindUserRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FindUserRequest(%+v)", *p) + +} + /** 用户好友关系 **/ @@ -5293,7 +5713,7 @@ type FriendRelationshipInfo struct { ApplicantID string `thrift:"applicant_id,1" form:"applicant_id" json:"applicant_id" query:"applicant_id"` TargetUserID string `thrift:"target_user_id,2" form:"target_user_id" json:"target_user_id" query:"target_user_id"` ApplicationMessage string `thrift:"application_message,3" form:"application_message" json:"application_message" query:"application_message"` - Status string `thrift:"status,4" form:"status" json:"status" query:"status"` + Status int8 `thrift:"status,4" form:"status" json:"status" query:"status"` } func NewFriendRelationshipInfo() *FriendRelationshipInfo { @@ -5315,7 +5735,7 @@ func (p *FriendRelationshipInfo) GetApplicationMessage() (v string) { return p.ApplicationMessage } -func (p *FriendRelationshipInfo) GetStatus() (v string) { +func (p *FriendRelationshipInfo) GetStatus() (v int8) { return p.Status } @@ -5369,7 +5789,7 @@ func (p *FriendRelationshipInfo) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 4: - if fieldTypeId == thrift.STRING { + if fieldTypeId == thrift.BYTE { if err = p.ReadField4(iprot); err != nil { goto ReadFieldError } @@ -5440,8 +5860,8 @@ func (p *FriendRelationshipInfo) ReadField3(iprot thrift.TProtocol) error { } func (p *FriendRelationshipInfo) ReadField4(iprot thrift.TProtocol) error { - var _field string - if v, err := iprot.ReadString(); err != nil { + var _field int8 + if v, err := iprot.ReadByte(); err != nil { return err } else { _field = v @@ -5539,10 +5959,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *FriendRelationshipInfo) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("status", thrift.STRING, 4); err != nil { + if err = oprot.WriteFieldBegin("status", thrift.BYTE, 4); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Status); err != nil { + if err := oprot.WriteByte(p.Status); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -5564,11 +5984,11 @@ func (p *FriendRelationshipInfo) String() string { } type CreateFriendRelationshipReq struct { - //id + //发起者id ApplicantID string `thrift:"applicant_id,1" form:"applicant_id" json:"applicant_id" query:"applicant_id"` //好友id TargetUserID string `thrift:"target_user_id,2" form:"target_user_id" json:"target_user_id" query:"target_user_id"` - //好友id + //留言 ApplicationMessage string `thrift:"application_message,3" form:"application_message" json:"application_message" query:"application_message"` } @@ -5985,8 +6405,10 @@ type UpdateFriendRelationshipReq struct { ApplicantID string `thrift:"applicant_id,1" form:"applicant_id" json:"applicant_id" query:"applicant_id"` //好友id TargetUserID string `thrift:"target_user_id,2" form:"target_user_id" json:"target_user_id" query:"target_user_id"` + //状态 + Status int8 `thrift:"Status,3" form:"Status" json:"Status" query:"Status"` //好友id - Status string `thrift:"Status,3" form:"Status" json:"Status" query:"Status"` + ID int64 `thrift:"id,4" form:"id" json:"id" query:"id"` } func NewUpdateFriendRelationshipReq() *UpdateFriendRelationshipReq { @@ -6004,14 +6426,19 @@ func (p *UpdateFriendRelationshipReq) GetTargetUserID() (v string) { return p.TargetUserID } -func (p *UpdateFriendRelationshipReq) GetStatus() (v string) { +func (p *UpdateFriendRelationshipReq) GetStatus() (v int8) { return p.Status } +func (p *UpdateFriendRelationshipReq) GetID() (v int64) { + return p.ID +} + var fieldIDToName_UpdateFriendRelationshipReq = map[int16]string{ 1: "applicant_id", 2: "target_user_id", 3: "Status", + 4: "id", } func (p *UpdateFriendRelationshipReq) Read(iprot thrift.TProtocol) (err error) { @@ -6049,13 +6476,21 @@ func (p *UpdateFriendRelationshipReq) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 3: - if fieldTypeId == thrift.STRING { + if fieldTypeId == thrift.BYTE { if err = p.ReadField3(iprot); err != nil { goto ReadFieldError } } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 4: + if fieldTypeId == thrift.I64 { + if err = p.ReadField4(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 @@ -6109,8 +6544,8 @@ func (p *UpdateFriendRelationshipReq) ReadField2(iprot thrift.TProtocol) error { } func (p *UpdateFriendRelationshipReq) ReadField3(iprot thrift.TProtocol) error { - var _field string - if v, err := iprot.ReadString(); err != nil { + var _field int8 + if v, err := iprot.ReadByte(); err != nil { return err } else { _field = v @@ -6118,6 +6553,17 @@ func (p *UpdateFriendRelationshipReq) ReadField3(iprot thrift.TProtocol) error { p.Status = _field return nil } +func (p *UpdateFriendRelationshipReq) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = v + } + p.ID = _field + return nil +} func (p *UpdateFriendRelationshipReq) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -6137,6 +6583,10 @@ func (p *UpdateFriendRelationshipReq) Write(oprot thrift.TProtocol) (err error) fieldId = 3 goto WriteFieldError } + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -6188,10 +6638,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *UpdateFriendRelationshipReq) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Status", thrift.STRING, 3); err != nil { + if err = oprot.WriteFieldBegin("Status", thrift.BYTE, 3); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Status); err != nil { + if err := oprot.WriteByte(p.Status); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -6203,6 +6653,22 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } +func (p *UpdateFriendRelationshipReq) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("id", thrift.I64, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.ID); 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 *UpdateFriendRelationshipReq) String() string { if p == nil { @@ -6537,11 +7003,330 @@ func (p *ListFriendRelationshipReq) String() string { } +type FriendRelationshipListInfo struct { + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` + ApplicationMessage string `thrift:"application_message,2" form:"application_message" json:"application_message" query:"application_message"` + Status int8 `thrift:"status,3" form:"status" json:"status" query:"status"` + UserName string `thrift:"user_name,4" form:"user_name" json:"user_name" query:"user_name"` + AvatarImageURL string `thrift:"avatar_image_url,5" form:"avatar_image_url" json:"avatar_image_url" query:"avatar_image_url"` +} + +func NewFriendRelationshipListInfo() *FriendRelationshipListInfo { + return &FriendRelationshipListInfo{} +} + +func (p *FriendRelationshipListInfo) InitDefault() { +} + +func (p *FriendRelationshipListInfo) GetUserID() (v string) { + return p.UserID +} + +func (p *FriendRelationshipListInfo) GetApplicationMessage() (v string) { + return p.ApplicationMessage +} + +func (p *FriendRelationshipListInfo) GetStatus() (v int8) { + return p.Status +} + +func (p *FriendRelationshipListInfo) GetUserName() (v string) { + return p.UserName +} + +func (p *FriendRelationshipListInfo) GetAvatarImageURL() (v string) { + return p.AvatarImageURL +} + +var fieldIDToName_FriendRelationshipListInfo = map[int16]string{ + 1: "user_id", + 2: "application_message", + 3: "status", + 4: "user_name", + 5: "avatar_image_url", +} + +func (p *FriendRelationshipListInfo) 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.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.BYTE { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.STRING { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.STRING { + if err = p.ReadField5(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_FriendRelationshipListInfo[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 *FriendRelationshipListInfo) 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 *FriendRelationshipListInfo) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ApplicationMessage = _field + return nil +} +func (p *FriendRelationshipListInfo) ReadField3(iprot thrift.TProtocol) error { + + var _field int8 + if v, err := iprot.ReadByte(); err != nil { + return err + } else { + _field = v + } + p.Status = _field + return nil +} +func (p *FriendRelationshipListInfo) ReadField4(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.UserName = _field + return nil +} +func (p *FriendRelationshipListInfo) ReadField5(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.AvatarImageURL = _field + return nil +} + +func (p *FriendRelationshipListInfo) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("FriendRelationshipListInfo"); 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 = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + if err = p.writeField5(oprot); err != nil { + fieldId = 5 + 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 *FriendRelationshipListInfo) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("user_id", 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 *FriendRelationshipListInfo) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("application_message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ApplicationMessage); 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 *FriendRelationshipListInfo) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("status", thrift.BYTE, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteByte(p.Status); 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 *FriendRelationshipListInfo) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("user_name", thrift.STRING, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.UserName); 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 *FriendRelationshipListInfo) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("avatar_image_url", thrift.STRING, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.AvatarImageURL); 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 *FriendRelationshipListInfo) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FriendRelationshipListInfo(%+v)", *p) + +} + type ListFriendRelationshipRes struct { - Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` - Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` - FriendRelationshipInfos []*FriendRelationshipInfo `thrift:"FriendRelationshipInfos,3" form:"FriendRelationshipInfos" json:"FriendRelationshipInfos" query:"FriendRelationshipInfos"` - Total int64 `thrift:"total,4" form:"total" json:"total" query:"total"` + Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` + Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` + FriendRelationshipInfos []*FriendRelationshipListInfo `thrift:"FriendRelationshipInfos,3" form:"FriendRelationshipInfos" json:"FriendRelationshipInfos" query:"FriendRelationshipInfos"` + Total int64 `thrift:"total,4" form:"total" json:"total" query:"total"` } func NewListFriendRelationshipRes() *ListFriendRelationshipRes { @@ -6559,7 +7344,7 @@ func (p *ListFriendRelationshipRes) GetMsg() (v string) { return p.Msg } -func (p *ListFriendRelationshipRes) GetFriendRelationshipInfos() (v []*FriendRelationshipInfo) { +func (p *ListFriendRelationshipRes) GetFriendRelationshipInfos() (v []*FriendRelationshipListInfo) { return p.FriendRelationshipInfos } @@ -6680,8 +7465,8 @@ func (p *ListFriendRelationshipRes) ReadField3(iprot thrift.TProtocol) error { if err != nil { return err } - _field := make([]*FriendRelationshipInfo, 0, size) - values := make([]FriendRelationshipInfo, size) + _field := make([]*FriendRelationshipListInfo, 0, size) + values := make([]FriendRelationshipListInfo, size) for i := 0; i < size; i++ { _elem := &values[i] _elem.InitDefault() @@ -9976,6 +10761,8 @@ type UserService interface { InfoUser(ctx context.Context, req *InfoUserRequest) (r *QueryUserResponse, err error) CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) + + FindUser(ctx context.Context, req *FindUserRequest) (r *FindUserResponse, err error) } type UserServiceClient struct { @@ -10040,6 +10827,15 @@ func (p *UserServiceClient) CreateUser(ctx context.Context, req *CreateUserReque } return _result.GetSuccess(), nil } +func (p *UserServiceClient) FindUser(ctx context.Context, req *FindUserRequest) (r *FindUserResponse, err error) { + var _args UserServiceFindUserArgs + _args.Req = req + var _result UserServiceFindUserResult + if err = p.Client_().Call(ctx, "FindUser", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} type UserRelationsService interface { DeleteUserRelations(ctx context.Context, req *DeleteUserRelationsReq) (r *DeleteUserRelationsRes, err error) @@ -10306,6 +11102,7 @@ func NewUserServiceProcessor(handler UserService) *UserServiceProcessor { self.AddToProcessorMap("DeleteUser", &userServiceProcessorDeleteUser{handler: handler}) self.AddToProcessorMap("InfoUser", &userServiceProcessorInfoUser{handler: handler}) self.AddToProcessorMap("CreateUser", &userServiceProcessorCreateUser{handler: handler}) + self.AddToProcessorMap("FindUser", &userServiceProcessorFindUser{handler: handler}) return self } func (p *UserServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -10518,6 +11315,54 @@ func (p *userServiceProcessorCreateUser) Process(ctx context.Context, seqId int3 return true, err } +type userServiceProcessorFindUser struct { + handler UserService +} + +func (p *userServiceProcessorFindUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := UserServiceFindUserArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("FindUser", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := UserServiceFindUserResult{} + var retval *FindUserResponse + if retval, err2 = p.handler.FindUser(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing FindUser: "+err2.Error()) + oprot.WriteMessageBegin("FindUser", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("FindUser", 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 UserServiceUpdateUserArgs struct { Req *UpdateUserRequest `thrift:"req,1"` } @@ -11686,6 +12531,298 @@ func (p *UserServiceCreateUserResult) String() string { } +type UserServiceFindUserArgs struct { + Req *FindUserRequest `thrift:"req,1"` +} + +func NewUserServiceFindUserArgs() *UserServiceFindUserArgs { + return &UserServiceFindUserArgs{} +} + +func (p *UserServiceFindUserArgs) InitDefault() { +} + +var UserServiceFindUserArgs_Req_DEFAULT *FindUserRequest + +func (p *UserServiceFindUserArgs) GetReq() (v *FindUserRequest) { + if !p.IsSetReq() { + return UserServiceFindUserArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_UserServiceFindUserArgs = map[int16]string{ + 1: "req", +} + +func (p *UserServiceFindUserArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *UserServiceFindUserArgs) 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_UserServiceFindUserArgs[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 *UserServiceFindUserArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewFindUserRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *UserServiceFindUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("FindUser_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 *UserServiceFindUserArgs) 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 *UserServiceFindUserArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserServiceFindUserArgs(%+v)", *p) + +} + +type UserServiceFindUserResult struct { + Success *FindUserResponse `thrift:"success,0,optional"` +} + +func NewUserServiceFindUserResult() *UserServiceFindUserResult { + return &UserServiceFindUserResult{} +} + +func (p *UserServiceFindUserResult) InitDefault() { +} + +var UserServiceFindUserResult_Success_DEFAULT *FindUserResponse + +func (p *UserServiceFindUserResult) GetSuccess() (v *FindUserResponse) { + if !p.IsSetSuccess() { + return UserServiceFindUserResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_UserServiceFindUserResult = map[int16]string{ + 0: "success", +} + +func (p *UserServiceFindUserResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *UserServiceFindUserResult) 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_UserServiceFindUserResult[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 *UserServiceFindUserResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewFindUserResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *UserServiceFindUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("FindUser_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 *UserServiceFindUserResult) 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 *UserServiceFindUserResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserServiceFindUserResult(%+v)", *p) + +} + type UserRelationsServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler UserRelationsService diff --git a/acquaintances/biz/router/user/middleware.go b/acquaintances/biz/router/user/middleware.go index 07a3994..516e6b9 100644 --- a/acquaintances/biz/router/user/middleware.go +++ b/acquaintances/biz/router/user/middleware.go @@ -195,3 +195,13 @@ func _listfriendrelationshipMw() []app.HandlerFunc { // your code... return nil } + +func _finduserMw() []app.HandlerFunc { + // your code... + return nil +} + +func _findMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/acquaintances/biz/router/user/user.go b/acquaintances/biz/router/user/user.go index 593144a..04baeea 100644 --- a/acquaintances/biz/router/user/user.go +++ b/acquaintances/biz/router/user/user.go @@ -44,6 +44,10 @@ func Register(r *server.Hertz) { _user.GET("/", append(_infouserMw(), user.InfoUser)...) _user.POST("/", append(_createuserMw(), user.CreateUser)...) _user.PUT("/", append(_updateuserMw(), user.UpdateUser)...) + { + _find := _user.Group("/find", _findMw()...) + _find.GET("/", append(_finduserMw(), user.FindUser)...) + } { _friendrelationship := _user.Group("/friendRelationship", _friendrelationshipMw()...) _friendrelationship.GET("/", append(_listfriendrelationshipMw(), user.ListFriendRelationship)...) diff --git a/acquaintances/idl/area.thrift b/acquaintances/idl/area.thrift index 28ffcf6..3298ada 100644 --- a/acquaintances/idl/area.thrift +++ b/acquaintances/idl/area.thrift @@ -15,6 +15,7 @@ struct Area { 5: string NumCode 6: string PhoneCode 7: string DomainSuffix + 8: i64 Id } diff --git a/acquaintances/idl/user.thrift b/acquaintances/idl/user.thrift index 2aa1bb4..74ebe0c 100644 --- a/acquaintances/idl/user.thrift +++ b/acquaintances/idl/user.thrift @@ -23,7 +23,7 @@ enum user_status { } struct User { - 1: i64 user_id //id + 1: string user_id //id 2: string user_name //用户名 3: Gender gender //性别 4: i64 age //年龄 @@ -34,7 +34,7 @@ struct User { 9: string mobile //手机号 10: string user_password //密码 11: user_status user_status //用户状态 - 12: string user_email //用户邮箱 + 12: string email //用户邮箱 13: string alias //别名 14: string address //详细地址 15: string last_login_ip //上传登录ip @@ -51,9 +51,10 @@ struct UserInfoReq { 6: string birthday //生日 7: i64 area //国家/地区 8: string mobile //手机号 - 9: string user_email //用户邮箱 + 9: string email //用户邮箱 10: string alias //别名 11: string address //详细地址 + 12: string user_id //id } @@ -72,7 +73,7 @@ struct CreateUserResponse{ } struct InfoUserRequest{ - 1: i64 user_id (api.path="user_id",api.vd="$>0") + 1: string user_id (api.path="user_id",api.query="user_id") } struct QueryUserResponse{ @@ -82,7 +83,7 @@ struct QueryUserResponse{ } struct DeleteUserRequest{ - 1: i64 user_id (api.path="user_id",api.vd="$>0") + 1: string user_id (api.path="user_id") } struct DeleteUserResponse{ @@ -91,7 +92,7 @@ struct DeleteUserResponse{ } struct UpdateUserRequest{ - 1: i64 user_id (api.path="user_id") + 1: string user_id (api.path="user_id") 2: string name (api.body="name") 3: Gender gender (api.body="gender") 4: i64 age (api.body="age") @@ -110,11 +111,22 @@ struct UpdateUserResponse{ } +struct FindUserResponse{ + 1: Code code + 2: string msg + 3: UserInfoReq userInfo +} + +struct FindUserRequest{ + 1: string keyword (api.path="user_id",api.query="keyword") +} + service UserService { UpdateUserResponse UpdateUser(1:UpdateUserRequest req)(api.put="/v1/user/") DeleteUserResponse DeleteUser(1:DeleteUserRequest req)(api.delete="/v1/user/") QueryUserResponse InfoUser(1: InfoUserRequest req)(api.get="/v1/user/") CreateUserResponse CreateUser(1:CreateUserRequest req)(api.post="/v1/user/") + FindUserResponse FindUser(1:FindUserRequest req)(api.get="/v1/user/find/") } @@ -178,13 +190,13 @@ struct FriendRelationshipInfo { 1: string applicant_id 2: string target_user_id 3: string application_message - 4: string status + 4: i8 status } struct CreateFriendRelationshipReq { - 1: string applicant_id //id + 1: string applicant_id //发起者id 2: string target_user_id //好友id - 3: string application_message //好友id + 3: string application_message //留言 } struct CreateFriendRelationshipRes{ @@ -196,7 +208,8 @@ struct CreateFriendRelationshipRes{ struct UpdateFriendRelationshipReq { 1: string applicant_id //id 2: string target_user_id //好友id - 3: string Status //好友id + 3: i8 Status //状态 + 4: i64 id //好友id } struct UpdateFriendRelationshipRes{ @@ -209,11 +222,18 @@ struct ListFriendRelationshipReq{ 1: string user_id //id } +struct FriendRelationshipListInfo { + 1: string user_id + 2: string application_message + 3: i8 status + 4: string user_name + 5: string avatar_image_url +} struct ListFriendRelationshipRes{ 1: Code code 2: string msg - 3: list FriendRelationshipInfos + 3: list FriendRelationshipInfos 4: i64 total }