diff --git a/.idea/IUQT.iml b/.idea/IUQT.iml deleted file mode 100644 index 7ee078d..0000000 --- a/.idea/IUQT.iml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index a99e095..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 5040e4d..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {} - { - "isMigrated": true -} - - - { - "associatedIndex": 5 -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - \ No newline at end of file diff --git a/acquaintances/biz/dal/mysql/user.go b/acquaintances/biz/dal/mysql/user.go index dc35b71..eb2171e 100644 --- a/acquaintances/biz/dal/mysql/user.go +++ b/acquaintances/biz/dal/mysql/user.go @@ -3,6 +3,8 @@ package mysql import ( "acquaintances/biz/model" "acquaintances/biz/model/user" + "errors" + "github.com/cloudwego/hertz/pkg/common/hlog" ) @@ -29,7 +31,7 @@ func UpdatesUser(user *user.UpdateUserRequest) error { if user.Address != "" { maps["address"] = user.Address } - if user.Area != "" { + if user.Area != 0 { maps["area"] = user.Area } if user.Mobile != "" { @@ -51,6 +53,9 @@ func UpdatesUser(user *user.UpdateUserRequest) error { return db.Where("user_id = ?", user.UserID).Updates(maps).Error } +// InfoUser 查询单个用户 +// 参数:用户ID +// 返回:用户信息指针,错误 func InfoUser(id int64) (*user.UserInfoReq, error) { db := DB.Model(&model.User{}) db.Where("user_id = ?", id) @@ -60,3 +65,23 @@ func InfoUser(id int64) (*user.UserInfoReq, error) { } return res, nil } + +// GetUsersById 批量查询用户信息 +// 参数:用户ID切片 +// 返回:用户信息切片指针,错误 +func GetUsersById(ids []string) ([]*user.UserInfoReq, error) { + db := DB.Model(&model.User{}) + // 参数校验 + if len(ids) == 0 { + return nil, errors.New("user IDs cannot be empty") + } + query := db. + Where("user_id IN (?)", ids) + + var users []*user.UserInfoReq + if err := query.Find(&users).Error; err != nil { + return nil, err + } + + return users, nil +} diff --git a/acquaintances/biz/dal/mysql/user_relations.go b/acquaintances/biz/dal/mysql/user_relations.go index 22de090..78697a3 100644 --- a/acquaintances/biz/dal/mysql/user_relations.go +++ b/acquaintances/biz/dal/mysql/user_relations.go @@ -3,23 +3,119 @@ package mysql import ( "acquaintances/biz/model" "acquaintances/biz/model/user" + "encoding/json" + "time" + + "github.com/cloudwego/hertz/pkg/common/hlog" ) func CreateUserRelations(relations user.CreateUserRelationsReq) error { db := DB.Model(&model.UserRelations{}) - return db.Create(relations).Error + var data model.UserRelations + friends, err := getFriend(relations.UserID) + if err != nil { + hlog.Error("DeleteUserRelations:", err) + return err + } + // 检查是否已存在 + for _, friend := range friends { + if friend.FriendID == relations.FriendID { + return nil + } + } + // 不存在 + newFriend := model.Friend{ + FriendID: relations.FriendID, + Remark: relations.Remark, + CreateTime: time.Now().Unix(), + } + friends = append(friends, newFriend) + data.FriendList, err = json.Marshal(friends) + if err != nil { + hlog.Error("DeleteUserRelations:", err) + return err + } + data.FriendCount = int64(len(friends)) + return db.Create(data).Error } func DeleteUserRelations(relations user.DeleteUserRelationsReq) error { db := DB.Model(&model.UserRelations{}) - return db.Delete(&model.UserRelations{UserID: relations.UserID, FriendID: relations.FriendID}).Error + friends, err := getFriend(relations.UserID) + if err != nil { + hlog.Error("DeleteUserRelations:", err) + return err + } + var newFriends []model.Friend + for _, friend := range friends { + if friend.FriendID != relations.FriendID { + newFriends = append(newFriends, friend) + } + } + + maps := make(map[string]interface{}) + maps["friend_count"] = int64(len(newFriends)) + maps["friend_list"], err = json.Marshal(newFriends) + if err != nil { + hlog.Error("DeleteUserRelations:", err) + return err + } + return db.Where("user_id = ?", relations.UserID).Updates(maps).Error } -func GetUserListRelations(relations user.ListUserRelationsReq) (*user.ListUserRelationsResponse, error) { +func UpdateUserRelations(relations user.UpdateUserRelationsReq) error { db := DB.Model(&model.UserRelations{}) - var res *user.ListUserRelationsResponse - if err := db.Where("user_id = ? or friend_id= ?", relations.UserID).Find(&res).Error; err != nil { - return nil, err + friends, err := getFriend(relations.UserID) + if err != nil { + hlog.Error("UpdateUserRelations:", err) + return err } + for _, friend := range friends { + if friend.FriendID == relations.FriendID { + friend.Remark = relations.Remark + } + } + maps := make(map[string]interface{}) + maps["friend_list"], err = json.Marshal(friends) + if err != nil { + hlog.Error("UpdateUserRelations:", err) + return err + } + return db.Where("user_id = ?", relations.UserID).Updates(maps).Error +} + + +func GetUserListRelations(relations user.ListUserRelationsReq) (*user.ListUserRelationsRes, error) { + var res *user.ListUserRelationsRes + friends, err := getFriend(relations.UserID) + if err != nil { + hlog.Error("GetUserListRelations:", err) + return nil,err + } + var ids []string + for _,v :=range friends{ + ids = append(ids, v.FriendID) + } + res.Users,err = GetUsersById(ids) + if err != nil{ + hlog.Error("GetUserListRelations:", err) + return nil,err + } + res.Total = int64(len(friends)) return res, nil } + +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 err := json.Unmarshal(beforeRes.FriendList, &friends); err != nil { + hlog.Error("getFriend:", err) + return nil, err + } + return friends, nil +} diff --git a/acquaintances/biz/handler/ping.go b/acquaintances/biz/handler/ping.go index 950d476..cdbeaba 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": "pong", + "message": "acquaintances pong", }) } diff --git a/acquaintances/biz/handler/user/user_relations_service.go b/acquaintances/biz/handler/user/user_relations_service.go index 18de6c8..edc5fc1 100644 --- a/acquaintances/biz/handler/user/user_relations_service.go +++ b/acquaintances/biz/handler/user/user_relations_service.go @@ -7,7 +7,9 @@ import ( "context" user "acquaintances/biz/model/user" + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/common/hlog" "github.com/cloudwego/hertz/pkg/protocol/consts" ) @@ -60,7 +62,7 @@ func ListUserRelations(ctx context.Context, c *app.RequestContext) { return } - resp := new(user.ListUserRelationsResponse) + resp := new(user.ListUserRelationsRes) resp, err = mysql.GetUserListRelations(req) if err != nil { c.JSON(consts.StatusInternalServerError, err.Error()) @@ -69,3 +71,23 @@ func ListUserRelations(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusOK, resp) } + +// UpdateUserRelations . +// @router /v1/user/relation/ [PUT] +func UpdateUserRelations(ctx context.Context, c *app.RequestContext) { + var err error + var req user.UpdateUserRelationsReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + resp := new(user.UpdateUserRelationsRes) + if err = mysql.UpdateUserRelations(req); err != nil { + hlog.Error("UpdateUserRelations:", err) + c.JSON(consts.StatusInternalServerError, err.Error()) + return + } + + c.JSON(consts.StatusOK, resp) +} diff --git a/acquaintances/biz/handler/user/user_service.go b/acquaintances/biz/handler/user/user_service.go index 26fe489..760329e 100644 --- a/acquaintances/biz/handler/user/user_service.go +++ b/acquaintances/biz/handler/user/user_service.go @@ -96,7 +96,7 @@ func CreateUser(ctx context.Context, c *app.RequestContext) { Gender: req.Gender, Age: uint8(req.Age), Mobile: req.Mobile, - Area: req.Area, + Area: uint8(req.Area), UserPassword: req.UserPassword, }, }); err != nil { diff --git a/acquaintances/biz/model/area.go b/acquaintances/biz/model/area.go index e143a2c..31dd698 100644 --- a/acquaintances/biz/model/area.go +++ b/acquaintances/biz/model/area.go @@ -9,6 +9,7 @@ import ( // Country 国家和地区信息结构体(基于ISO 3166-1标准) type Country struct { + gorm.Model ChineseName string `gorm:"column:chinese_name;type:varchar(50);not null;comment:'中文简称'"` EnglishName string `gorm:"column:english_name;type:varchar(100);not null;comment:'英文简称'"` ISO2 string `gorm:"column:iso2;type:char(2);not null;uniqueIndex:idx_iso2;comment:'ISO 3166-1两位字母码'"` diff --git a/acquaintances/biz/model/user.go b/acquaintances/biz/model/user.go index 1aab69d..6b50d50 100644 --- a/acquaintances/biz/model/user.go +++ b/acquaintances/biz/model/user.go @@ -17,7 +17,7 @@ type User struct { Introduce string `gorm:"column:introduce;type:varchar(200);default:'';comment:'个性签名'"` AvatarImageURL string `gorm:"column:avatar_image_url;type:varchar(255);default:'';comment:'头像URL'"` Birthday *time.Time `gorm:"column:birthday;type:date;comment:'出生日期'"` - Area string `gorm:"column:area;type:varchar(10);comment:'国家/地区编码(ISO 3166-1)'"` + Area uint8 `gorm:"column:area;type:tinyint;comment:'国家/地区编码(ISO 3166-1)'"` Mobile string `gorm:"column:mobile;type:char(11);uniqueIndex:idx_mobile;not null;unique;comment:'手机号码'"` UserPassword string `gorm:"column:password;type:varchar(100);not null;comment:'加密密码'"` UserStatus user.UserStatus `gorm:"column:user_status;type:tinyint unsigned;default:1;comment:'用户状态;0:禁用,1:正常,2:注销'"` diff --git a/acquaintances/biz/model/user/user.go b/acquaintances/biz/model/user/user.go index c185b9f..72bd188 100644 --- a/acquaintances/biz/model/user/user.go +++ b/acquaintances/biz/model/user/user.go @@ -170,7 +170,7 @@ type User struct { //生日 Birthday string `thrift:"birthday,7" form:"birthday" json:"birthday" query:"birthday"` //国家/地区 - Area string `thrift:"area,8" form:"area" json:"area" query:"area"` + Area int64 `thrift:"area,8" form:"area" json:"area" query:"area"` //手机号 Mobile string `thrift:"mobile,9" form:"mobile" json:"mobile" query:"mobile"` //密码 @@ -226,7 +226,7 @@ func (p *User) GetBirthday() (v string) { return p.Birthday } -func (p *User) GetArea() (v string) { +func (p *User) GetArea() (v int64) { return p.Area } @@ -361,7 +361,7 @@ func (p *User) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 8: - if fieldTypeId == thrift.STRING { + if fieldTypeId == thrift.I64 { if err = p.ReadField8(iprot); err != nil { goto ReadFieldError } @@ -548,8 +548,8 @@ func (p *User) ReadField7(iprot thrift.TProtocol) error { } func (p *User) ReadField8(iprot thrift.TProtocol) error { - var _field string - if v, err := iprot.ReadString(); err != nil { + var _field int64 + if v, err := iprot.ReadI64(); err != nil { return err } else { _field = v @@ -862,10 +862,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) } func (p *User) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("area", thrift.STRING, 8); err != nil { + if err = oprot.WriteFieldBegin("area", thrift.I64, 8); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Area); err != nil { + if err := oprot.WriteI64(p.Area); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -1044,7 +1044,7 @@ type UserInfoReq struct { //生日 Birthday string `thrift:"birthday,6" form:"birthday" json:"birthday" query:"birthday"` //国家/地区 - Area string `thrift:"area,7" form:"area" json:"area" query:"area"` + Area int64 `thrift:"area,7" form:"area" json:"area" query:"area"` //手机号 Mobile string `thrift:"mobile,8" form:"mobile" json:"mobile" query:"mobile"` //用户邮箱 @@ -1086,7 +1086,7 @@ func (p *UserInfoReq) GetBirthday() (v string) { return p.Birthday } -func (p *UserInfoReq) GetArea() (v string) { +func (p *UserInfoReq) GetArea() (v int64) { return p.Area } @@ -1187,7 +1187,7 @@ func (p *UserInfoReq) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 7: - if fieldTypeId == thrift.STRING { + if fieldTypeId == thrift.I64 { if err = p.ReadField7(iprot); err != nil { goto ReadFieldError } @@ -1323,8 +1323,8 @@ func (p *UserInfoReq) ReadField6(iprot thrift.TProtocol) error { } func (p *UserInfoReq) ReadField7(iprot thrift.TProtocol) error { - var _field string - if v, err := iprot.ReadString(); err != nil { + var _field int64 + if v, err := iprot.ReadI64(); err != nil { return err } else { _field = v @@ -1542,10 +1542,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) } func (p *UserInfoReq) writeField7(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("area", thrift.STRING, 7); err != nil { + if err = oprot.WriteFieldBegin("area", thrift.I64, 7); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Area); err != nil { + if err := oprot.WriteI64(p.Area); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -1632,10 +1632,10 @@ 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)"` + 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" json:"mobile" vd:"(len($) > 0 && len($) < 12)"` - Area string `thrift:"area,5" form:"area" json:"area" vd:"(len($) > 0 && len($) < 5)"` + 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"` UserPassword string `thrift:"user_password,6" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"` } @@ -1662,7 +1662,7 @@ func (p *CreateUserRequest) GetMobile() (v string) { return p.Mobile } -func (p *CreateUserRequest) GetArea() (v string) { +func (p *CreateUserRequest) GetArea() (v int64) { return p.Area } @@ -1730,7 +1730,7 @@ func (p *CreateUserRequest) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 5: - if fieldTypeId == thrift.STRING { + if fieldTypeId == thrift.I64 { if err = p.ReadField5(iprot); err != nil { goto ReadFieldError } @@ -1820,8 +1820,8 @@ func (p *CreateUserRequest) ReadField4(iprot thrift.TProtocol) error { } func (p *CreateUserRequest) ReadField5(iprot thrift.TProtocol) error { - var _field string - if v, err := iprot.ReadString(); err != nil { + var _field int64 + if v, err := iprot.ReadI64(); err != nil { return err } else { _field = v @@ -1954,10 +1954,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) } func (p *CreateUserRequest) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("area", thrift.STRING, 5); err != nil { + if err = oprot.WriteFieldBegin("area", thrift.I64, 5); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Area); err != nil { + if err := oprot.WriteI64(p.Area); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -2884,7 +2884,7 @@ type UpdateUserRequest struct { AvatarImageURL string `thrift:"avatar_image_url,6" form:"avatar_image_url" json:"avatar_image_url"` Birthday string `thrift:"birthday,7" form:"birthday" json:"birthday"` UserPassword string `thrift:"user_password,8" form:"user_password" json:"user_password"` - Area string `thrift:"area,9" form:"area" json:"area"` + Area int64 `thrift:"area,9" form:"area" json:"area"` Mobile string `thrift:"mobile,10" form:"mobile" json:"mobile"` Address string `thrift:"address,11" form:"address" json:"address"` } @@ -2928,7 +2928,7 @@ func (p *UpdateUserRequest) GetUserPassword() (v string) { return p.UserPassword } -func (p *UpdateUserRequest) GetArea() (v string) { +func (p *UpdateUserRequest) GetArea() (v int64) { return p.Area } @@ -3037,7 +3037,7 @@ func (p *UpdateUserRequest) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 9: - if fieldTypeId == thrift.STRING { + if fieldTypeId == thrift.I64 { if err = p.ReadField9(iprot); err != nil { goto ReadFieldError } @@ -3179,8 +3179,8 @@ func (p *UpdateUserRequest) ReadField8(iprot thrift.TProtocol) error { } func (p *UpdateUserRequest) ReadField9(iprot thrift.TProtocol) error { - var _field string - if v, err := iprot.ReadString(); err != nil { + var _field int64 + if v, err := iprot.ReadI64(); err != nil { return err } else { _field = v @@ -3408,10 +3408,10 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) } func (p *UpdateUserRequest) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("area", thrift.STRING, 9); err != nil { + if err = oprot.WriteFieldBegin("area", thrift.I64, 9); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Area); err != nil { + if err := oprot.WriteI64(p.Area); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -3651,41 +3651,41 @@ func (p *UpdateUserResponse) String() string { /** 用户好友关系 **/ -type UserRelations struct { +type CreateUserRelationsReq struct { //id UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` //好友id FriendID string `thrift:"friend_id,2" form:"friend_id" json:"friend_id" query:"friend_id"` - //关系状态 - Status string `thrift:"status,3" form:"status" json:"status" query:"status"` + //备注 + Remark string `thrift:"remark,3" form:"remark" json:"remark" query:"remark"` } -func NewUserRelations() *UserRelations { - return &UserRelations{} +func NewCreateUserRelationsReq() *CreateUserRelationsReq { + return &CreateUserRelationsReq{} } -func (p *UserRelations) InitDefault() { +func (p *CreateUserRelationsReq) InitDefault() { } -func (p *UserRelations) GetUserID() (v string) { +func (p *CreateUserRelationsReq) GetUserID() (v string) { return p.UserID } -func (p *UserRelations) GetFriendID() (v string) { +func (p *CreateUserRelationsReq) GetFriendID() (v string) { return p.FriendID } -func (p *UserRelations) GetStatus() (v string) { - return p.Status +func (p *CreateUserRelationsReq) GetRemark() (v string) { + return p.Remark } -var fieldIDToName_UserRelations = map[int16]string{ +var fieldIDToName_CreateUserRelationsReq = map[int16]string{ 1: "user_id", 2: "friend_id", - 3: "status", + 3: "remark", } -func (p *UserRelations) Read(iprot thrift.TProtocol) (err error) { +func (p *CreateUserRelationsReq) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3740,223 +3740,6 @@ func (p *UserRelations) Read(iprot thrift.TProtocol) (err error) { 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_UserRelations[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 *UserRelations) 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 *UserRelations) ReadField2(iprot thrift.TProtocol) error { - - var _field string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _field = v - } - p.FriendID = _field - return nil -} -func (p *UserRelations) ReadField3(iprot thrift.TProtocol) error { - - var _field string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _field = v - } - p.Status = _field - return nil -} - -func (p *UserRelations) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("UserRelations"); 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 *UserRelations) 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 *UserRelations) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("friend_id", thrift.STRING, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.FriendID); 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 *UserRelations) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("status", thrift.STRING, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(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 *UserRelations) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("UserRelations(%+v)", *p) - -} - -type CreateUserRelationsReq struct { - //id - UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` - //好友id - FriendID string `thrift:"friend_id,2" form:"friend_id" json:"friend_id" query:"friend_id"` -} - -func NewCreateUserRelationsReq() *CreateUserRelationsReq { - return &CreateUserRelationsReq{} -} - -func (p *CreateUserRelationsReq) InitDefault() { -} - -func (p *CreateUserRelationsReq) GetUserID() (v string) { - return p.UserID -} - -func (p *CreateUserRelationsReq) GetFriendID() (v string) { - return p.FriendID -} - -var fieldIDToName_CreateUserRelationsReq = map[int16]string{ - 1: "user_id", - 2: "friend_id", -} - -func (p *CreateUserRelationsReq) 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 - } - 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) @@ -3995,6 +3778,17 @@ func (p *CreateUserRelationsReq) ReadField2(iprot thrift.TProtocol) error { p.FriendID = _field return nil } +func (p *CreateUserRelationsReq) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Remark = _field + return nil +} func (p *CreateUserRelationsReq) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -4010,6 +3804,10 @@ func (p *CreateUserRelationsReq) Write(oprot thrift.TProtocol) (err error) { fieldId = 2 goto WriteFieldError } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -4060,6 +3858,22 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } +func (p *CreateUserRelationsReq) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("remark", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Remark); 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 *CreateUserRelationsReq) String() string { if p == nil { @@ -4069,32 +3883,32 @@ func (p *CreateUserRelationsReq) String() string { } -type CreateUserRelationsResponse struct { +type CreateUserRelationsRes struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` } -func NewCreateUserRelationsResponse() *CreateUserRelationsResponse { - return &CreateUserRelationsResponse{} +func NewCreateUserRelationsRes() *CreateUserRelationsRes { + return &CreateUserRelationsRes{} } -func (p *CreateUserRelationsResponse) InitDefault() { +func (p *CreateUserRelationsRes) InitDefault() { } -func (p *CreateUserRelationsResponse) GetCode() (v Code) { +func (p *CreateUserRelationsRes) GetCode() (v Code) { return p.Code } -func (p *CreateUserRelationsResponse) GetMsg() (v string) { +func (p *CreateUserRelationsRes) GetMsg() (v string) { return p.Msg } -var fieldIDToName_CreateUserRelationsResponse = map[int16]string{ +var fieldIDToName_CreateUserRelationsRes = map[int16]string{ 1: "code", 2: "msg", } -func (p *CreateUserRelationsResponse) Read(iprot thrift.TProtocol) (err error) { +func (p *CreateUserRelationsRes) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -4147,7 +3961,7 @@ ReadStructBeginError: 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_CreateUserRelationsResponse[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_CreateUserRelationsRes[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -4157,7 +3971,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *CreateUserRelationsResponse) ReadField1(iprot thrift.TProtocol) error { +func (p *CreateUserRelationsRes) ReadField1(iprot thrift.TProtocol) error { var _field Code if v, err := iprot.ReadI32(); err != nil { @@ -4168,7 +3982,7 @@ func (p *CreateUserRelationsResponse) ReadField1(iprot thrift.TProtocol) error { p.Code = _field return nil } -func (p *CreateUserRelationsResponse) ReadField2(iprot thrift.TProtocol) error { +func (p *CreateUserRelationsRes) ReadField2(iprot thrift.TProtocol) error { var _field string if v, err := iprot.ReadString(); err != nil { @@ -4180,9 +3994,9 @@ func (p *CreateUserRelationsResponse) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *CreateUserRelationsResponse) Write(oprot thrift.TProtocol) (err error) { +func (p *CreateUserRelationsRes) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("CreateUserRelationsResponse"); err != nil { + if err = oprot.WriteStructBegin("CreateUserRelationsRes"); err != nil { goto WriteStructBeginError } if p != nil { @@ -4212,7 +4026,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *CreateUserRelationsResponse) writeField1(oprot thrift.TProtocol) (err error) { +func (p *CreateUserRelationsRes) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { goto WriteFieldBeginError } @@ -4228,7 +4042,7 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *CreateUserRelationsResponse) writeField2(oprot thrift.TProtocol) (err error) { +func (p *CreateUserRelationsRes) writeField2(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); err != nil { goto WriteFieldBeginError } @@ -4245,11 +4059,11 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } -func (p *CreateUserRelationsResponse) String() string { +func (p *CreateUserRelationsRes) String() string { if p == nil { return "" } - return fmt.Sprintf("CreateUserRelationsResponse(%+v)", *p) + return fmt.Sprintf("CreateUserRelationsRes(%+v)", *p) } @@ -4439,32 +4253,32 @@ func (p *DeleteUserRelationsReq) String() string { } -type DeleteUserRelationsResponse struct { +type DeleteUserRelationsRes struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` } -func NewDeleteUserRelationsResponse() *DeleteUserRelationsResponse { - return &DeleteUserRelationsResponse{} +func NewDeleteUserRelationsRes() *DeleteUserRelationsRes { + return &DeleteUserRelationsRes{} } -func (p *DeleteUserRelationsResponse) InitDefault() { +func (p *DeleteUserRelationsRes) InitDefault() { } -func (p *DeleteUserRelationsResponse) GetCode() (v Code) { +func (p *DeleteUserRelationsRes) GetCode() (v Code) { return p.Code } -func (p *DeleteUserRelationsResponse) GetMsg() (v string) { +func (p *DeleteUserRelationsRes) GetMsg() (v string) { return p.Msg } -var fieldIDToName_DeleteUserRelationsResponse = map[int16]string{ +var fieldIDToName_DeleteUserRelationsRes = map[int16]string{ 1: "code", 2: "msg", } -func (p *DeleteUserRelationsResponse) Read(iprot thrift.TProtocol) (err error) { +func (p *DeleteUserRelationsRes) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -4517,7 +4331,7 @@ ReadStructBeginError: 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_DeleteUserRelationsResponse[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_DeleteUserRelationsRes[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -4527,7 +4341,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *DeleteUserRelationsResponse) ReadField1(iprot thrift.TProtocol) error { +func (p *DeleteUserRelationsRes) ReadField1(iprot thrift.TProtocol) error { var _field Code if v, err := iprot.ReadI32(); err != nil { @@ -4538,7 +4352,7 @@ func (p *DeleteUserRelationsResponse) ReadField1(iprot thrift.TProtocol) error { p.Code = _field return nil } -func (p *DeleteUserRelationsResponse) ReadField2(iprot thrift.TProtocol) error { +func (p *DeleteUserRelationsRes) ReadField2(iprot thrift.TProtocol) error { var _field string if v, err := iprot.ReadString(); err != nil { @@ -4550,9 +4364,9 @@ func (p *DeleteUserRelationsResponse) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *DeleteUserRelationsResponse) Write(oprot thrift.TProtocol) (err error) { +func (p *DeleteUserRelationsRes) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("DeleteUserRelationsResponse"); err != nil { + if err = oprot.WriteStructBegin("DeleteUserRelationsRes"); err != nil { goto WriteStructBeginError } if p != nil { @@ -4582,7 +4396,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *DeleteUserRelationsResponse) writeField1(oprot thrift.TProtocol) (err error) { +func (p *DeleteUserRelationsRes) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { goto WriteFieldBeginError } @@ -4598,7 +4412,7 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *DeleteUserRelationsResponse) writeField2(oprot thrift.TProtocol) (err error) { +func (p *DeleteUserRelationsRes) writeField2(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); err != nil { goto WriteFieldBeginError } @@ -4615,11 +4429,427 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } -func (p *DeleteUserRelationsResponse) String() string { +func (p *DeleteUserRelationsRes) String() string { if p == nil { return "" } - return fmt.Sprintf("DeleteUserRelationsResponse(%+v)", *p) + return fmt.Sprintf("DeleteUserRelationsRes(%+v)", *p) + +} + +type UpdateUserRelationsReq struct { + //id + UserID string `thrift:"user_id,1" form:"user_id" json:"user_id" query:"user_id"` + //好友id + FriendID string `thrift:"friend_id,2" form:"friend_id" json:"friend_id" query:"friend_id"` + //备注 + Remark string `thrift:"remark,3" form:"remark" json:"remark" query:"remark"` +} + +func NewUpdateUserRelationsReq() *UpdateUserRelationsReq { + return &UpdateUserRelationsReq{} +} + +func (p *UpdateUserRelationsReq) InitDefault() { +} + +func (p *UpdateUserRelationsReq) GetUserID() (v string) { + return p.UserID +} + +func (p *UpdateUserRelationsReq) GetFriendID() (v string) { + return p.FriendID +} + +func (p *UpdateUserRelationsReq) GetRemark() (v string) { + return p.Remark +} + +var fieldIDToName_UpdateUserRelationsReq = map[int16]string{ + 1: "user_id", + 2: "friend_id", + 3: "remark", +} + +func (p *UpdateUserRelationsReq) 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.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_UpdateUserRelationsReq[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 *UpdateUserRelationsReq) 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 *UpdateUserRelationsReq) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FriendID = _field + return nil +} +func (p *UpdateUserRelationsReq) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Remark = _field + return nil +} + +func (p *UpdateUserRelationsReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UpdateUserRelationsReq"); 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 *UpdateUserRelationsReq) 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 *UpdateUserRelationsReq) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("friend_id", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FriendID); 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 *UpdateUserRelationsReq) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("remark", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Remark); 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 *UpdateUserRelationsReq) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UpdateUserRelationsReq(%+v)", *p) + +} + +type UpdateUserRelationsRes struct { + Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` + Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` +} + +func NewUpdateUserRelationsRes() *UpdateUserRelationsRes { + return &UpdateUserRelationsRes{} +} + +func (p *UpdateUserRelationsRes) InitDefault() { +} + +func (p *UpdateUserRelationsRes) GetCode() (v Code) { + return p.Code +} + +func (p *UpdateUserRelationsRes) GetMsg() (v string) { + return p.Msg +} + +var fieldIDToName_UpdateUserRelationsRes = map[int16]string{ + 1: "code", + 2: "msg", +} + +func (p *UpdateUserRelationsRes) 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 + } + 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_UpdateUserRelationsRes[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 *UpdateUserRelationsRes) 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 *UpdateUserRelationsRes) 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 *UpdateUserRelationsRes) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UpdateUserRelationsRes"); 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 *UpdateUserRelationsRes) 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 *UpdateUserRelationsRes) 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 *UpdateUserRelationsRes) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UpdateUserRelationsRes(%+v)", *p) } @@ -4763,44 +4993,44 @@ func (p *ListUserRelationsReq) String() string { } -type ListUserRelationsResponse struct { +type ListUserRelationsRes struct { Code Code `thrift:"code,1" form:"code" json:"code" query:"code"` Msg string `thrift:"msg,2" form:"msg" json:"msg" query:"msg"` Users []*UserInfoReq `thrift:"users,3" form:"users" json:"users" query:"users"` Total int64 `thrift:"total,4" form:"total" json:"total" query:"total"` } -func NewListUserRelationsResponse() *ListUserRelationsResponse { - return &ListUserRelationsResponse{} +func NewListUserRelationsRes() *ListUserRelationsRes { + return &ListUserRelationsRes{} } -func (p *ListUserRelationsResponse) InitDefault() { +func (p *ListUserRelationsRes) InitDefault() { } -func (p *ListUserRelationsResponse) GetCode() (v Code) { +func (p *ListUserRelationsRes) GetCode() (v Code) { return p.Code } -func (p *ListUserRelationsResponse) GetMsg() (v string) { +func (p *ListUserRelationsRes) GetMsg() (v string) { return p.Msg } -func (p *ListUserRelationsResponse) GetUsers() (v []*UserInfoReq) { +func (p *ListUserRelationsRes) GetUsers() (v []*UserInfoReq) { return p.Users } -func (p *ListUserRelationsResponse) GetTotal() (v int64) { +func (p *ListUserRelationsRes) GetTotal() (v int64) { return p.Total } -var fieldIDToName_ListUserRelationsResponse = map[int16]string{ +var fieldIDToName_ListUserRelationsRes = map[int16]string{ 1: "code", 2: "msg", 3: "users", 4: "total", } -func (p *ListUserRelationsResponse) Read(iprot thrift.TProtocol) (err error) { +func (p *ListUserRelationsRes) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -4869,7 +5099,7 @@ ReadStructBeginError: 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_ListUserRelationsResponse[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ListUserRelationsRes[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -4879,7 +5109,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *ListUserRelationsResponse) ReadField1(iprot thrift.TProtocol) error { +func (p *ListUserRelationsRes) ReadField1(iprot thrift.TProtocol) error { var _field Code if v, err := iprot.ReadI32(); err != nil { @@ -4890,7 +5120,7 @@ func (p *ListUserRelationsResponse) ReadField1(iprot thrift.TProtocol) error { p.Code = _field return nil } -func (p *ListUserRelationsResponse) ReadField2(iprot thrift.TProtocol) error { +func (p *ListUserRelationsRes) ReadField2(iprot thrift.TProtocol) error { var _field string if v, err := iprot.ReadString(); err != nil { @@ -4901,7 +5131,7 @@ func (p *ListUserRelationsResponse) ReadField2(iprot thrift.TProtocol) error { p.Msg = _field return nil } -func (p *ListUserRelationsResponse) ReadField3(iprot thrift.TProtocol) error { +func (p *ListUserRelationsRes) ReadField3(iprot thrift.TProtocol) error { _, size, err := iprot.ReadListBegin() if err != nil { return err @@ -4924,7 +5154,7 @@ func (p *ListUserRelationsResponse) ReadField3(iprot thrift.TProtocol) error { p.Users = _field return nil } -func (p *ListUserRelationsResponse) ReadField4(iprot thrift.TProtocol) error { +func (p *ListUserRelationsRes) ReadField4(iprot thrift.TProtocol) error { var _field int64 if v, err := iprot.ReadI64(); err != nil { @@ -4936,9 +5166,9 @@ func (p *ListUserRelationsResponse) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *ListUserRelationsResponse) Write(oprot thrift.TProtocol) (err error) { +func (p *ListUserRelationsRes) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("ListUserRelationsResponse"); err != nil { + if err = oprot.WriteStructBegin("ListUserRelationsRes"); err != nil { goto WriteStructBeginError } if p != nil { @@ -4976,7 +5206,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *ListUserRelationsResponse) writeField1(oprot thrift.TProtocol) (err error) { +func (p *ListUserRelationsRes) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil { goto WriteFieldBeginError } @@ -4992,7 +5222,7 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *ListUserRelationsResponse) writeField2(oprot thrift.TProtocol) (err error) { +func (p *ListUserRelationsRes) writeField2(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); err != nil { goto WriteFieldBeginError } @@ -5008,7 +5238,7 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } -func (p *ListUserRelationsResponse) writeField3(oprot thrift.TProtocol) (err error) { +func (p *ListUserRelationsRes) writeField3(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("users", thrift.LIST, 3); err != nil { goto WriteFieldBeginError } @@ -5032,7 +5262,7 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } -func (p *ListUserRelationsResponse) writeField4(oprot thrift.TProtocol) (err error) { +func (p *ListUserRelationsRes) writeField4(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("total", thrift.I64, 4); err != nil { goto WriteFieldBeginError } @@ -5049,11 +5279,11 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) } -func (p *ListUserRelationsResponse) String() string { +func (p *ListUserRelationsRes) String() string { if p == nil { return "" } - return fmt.Sprintf("ListUserRelationsResponse(%+v)", *p) + return fmt.Sprintf("ListUserRelationsRes(%+v)", *p) } @@ -5131,11 +5361,13 @@ func (p *UserServiceClient) CreateUser(ctx context.Context, req *CreateUserReque } type UserRelationsService interface { - DeleteUserRelations(ctx context.Context, req *DeleteUserRelationsReq) (r *DeleteUserRelationsReq, err error) + DeleteUserRelations(ctx context.Context, req *DeleteUserRelationsReq) (r *DeleteUserRelationsRes, err error) - ListUserRelations(ctx context.Context, req *ListUserRelationsReq) (r *ListUserRelationsResponse, err error) + ListUserRelations(ctx context.Context, req *ListUserRelationsReq) (r *ListUserRelationsRes, err error) - CreateUserRelations(ctx context.Context, req *CreateUserRelationsReq) (r *CreateUserRelationsReq, err error) + CreateUserRelations(ctx context.Context, req *CreateUserRelationsReq) (r *CreateUserRelationsRes, err error) + + UpdateUserRelations(ctx context.Context, req *UpdateUserRelationsReq) (r *UpdateUserRelationsRes, err error) } type UserRelationsServiceClient struct { @@ -5164,7 +5396,7 @@ func (p *UserRelationsServiceClient) Client_() thrift.TClient { return p.c } -func (p *UserRelationsServiceClient) DeleteUserRelations(ctx context.Context, req *DeleteUserRelationsReq) (r *DeleteUserRelationsReq, err error) { +func (p *UserRelationsServiceClient) DeleteUserRelations(ctx context.Context, req *DeleteUserRelationsReq) (r *DeleteUserRelationsRes, err error) { var _args UserRelationsServiceDeleteUserRelationsArgs _args.Req = req var _result UserRelationsServiceDeleteUserRelationsResult @@ -5173,7 +5405,7 @@ func (p *UserRelationsServiceClient) DeleteUserRelations(ctx context.Context, re } return _result.GetSuccess(), nil } -func (p *UserRelationsServiceClient) ListUserRelations(ctx context.Context, req *ListUserRelationsReq) (r *ListUserRelationsResponse, err error) { +func (p *UserRelationsServiceClient) ListUserRelations(ctx context.Context, req *ListUserRelationsReq) (r *ListUserRelationsRes, err error) { var _args UserRelationsServiceListUserRelationsArgs _args.Req = req var _result UserRelationsServiceListUserRelationsResult @@ -5182,7 +5414,7 @@ func (p *UserRelationsServiceClient) ListUserRelations(ctx context.Context, req } return _result.GetSuccess(), nil } -func (p *UserRelationsServiceClient) CreateUserRelations(ctx context.Context, req *CreateUserRelationsReq) (r *CreateUserRelationsReq, err error) { +func (p *UserRelationsServiceClient) CreateUserRelations(ctx context.Context, req *CreateUserRelationsReq) (r *CreateUserRelationsRes, err error) { var _args UserRelationsServiceCreateUserRelationsArgs _args.Req = req var _result UserRelationsServiceCreateUserRelationsResult @@ -5191,6 +5423,15 @@ func (p *UserRelationsServiceClient) CreateUserRelations(ctx context.Context, re } return _result.GetSuccess(), nil } +func (p *UserRelationsServiceClient) UpdateUserRelations(ctx context.Context, req *UpdateUserRelationsReq) (r *UpdateUserRelationsRes, err error) { + var _args UserRelationsServiceUpdateUserRelationsArgs + _args.Req = req + var _result UserRelationsServiceUpdateUserRelationsResult + if err = p.Client_().Call(ctx, "UpdateUserRelations", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} type UserServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction @@ -6619,6 +6860,7 @@ func NewUserRelationsServiceProcessor(handler UserRelationsService) *UserRelatio self.AddToProcessorMap("DeleteUserRelations", &userRelationsServiceProcessorDeleteUserRelations{handler: handler}) self.AddToProcessorMap("ListUserRelations", &userRelationsServiceProcessorListUserRelations{handler: handler}) self.AddToProcessorMap("CreateUserRelations", &userRelationsServiceProcessorCreateUserRelations{handler: handler}) + self.AddToProcessorMap("UpdateUserRelations", &userRelationsServiceProcessorUpdateUserRelations{handler: handler}) return self } func (p *UserRelationsServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -6658,7 +6900,7 @@ func (p *userRelationsServiceProcessorDeleteUserRelations) Process(ctx context.C iprot.ReadMessageEnd() var err2 error result := UserRelationsServiceDeleteUserRelationsResult{} - var retval *DeleteUserRelationsReq + var retval *DeleteUserRelationsRes if retval, err2 = p.handler.DeleteUserRelations(ctx, args.Req); err2 != nil { x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteUserRelations: "+err2.Error()) oprot.WriteMessageBegin("DeleteUserRelations", thrift.EXCEPTION, seqId) @@ -6706,7 +6948,7 @@ func (p *userRelationsServiceProcessorListUserRelations) Process(ctx context.Con iprot.ReadMessageEnd() var err2 error result := UserRelationsServiceListUserRelationsResult{} - var retval *ListUserRelationsResponse + var retval *ListUserRelationsRes if retval, err2 = p.handler.ListUserRelations(ctx, args.Req); err2 != nil { x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ListUserRelations: "+err2.Error()) oprot.WriteMessageBegin("ListUserRelations", thrift.EXCEPTION, seqId) @@ -6754,7 +6996,7 @@ func (p *userRelationsServiceProcessorCreateUserRelations) Process(ctx context.C iprot.ReadMessageEnd() var err2 error result := UserRelationsServiceCreateUserRelationsResult{} - var retval *CreateUserRelationsReq + var retval *CreateUserRelationsRes if retval, err2 = p.handler.CreateUserRelations(ctx, args.Req); err2 != nil { x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing CreateUserRelations: "+err2.Error()) oprot.WriteMessageBegin("CreateUserRelations", thrift.EXCEPTION, seqId) @@ -6783,6 +7025,54 @@ func (p *userRelationsServiceProcessorCreateUserRelations) Process(ctx context.C return true, err } +type userRelationsServiceProcessorUpdateUserRelations struct { + handler UserRelationsService +} + +func (p *userRelationsServiceProcessorUpdateUserRelations) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := UserRelationsServiceUpdateUserRelationsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("UpdateUserRelations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := UserRelationsServiceUpdateUserRelationsResult{} + var retval *UpdateUserRelationsRes + if retval, err2 = p.handler.UpdateUserRelations(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UpdateUserRelations: "+err2.Error()) + oprot.WriteMessageBegin("UpdateUserRelations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("UpdateUserRelations", 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 UserRelationsServiceDeleteUserRelationsArgs struct { Req *DeleteUserRelationsReq `thrift:"req,1"` } @@ -6929,7 +7219,7 @@ func (p *UserRelationsServiceDeleteUserRelationsArgs) String() string { } type UserRelationsServiceDeleteUserRelationsResult struct { - Success *DeleteUserRelationsReq `thrift:"success,0,optional"` + Success *DeleteUserRelationsRes `thrift:"success,0,optional"` } func NewUserRelationsServiceDeleteUserRelationsResult() *UserRelationsServiceDeleteUserRelationsResult { @@ -6939,9 +7229,9 @@ func NewUserRelationsServiceDeleteUserRelationsResult() *UserRelationsServiceDel func (p *UserRelationsServiceDeleteUserRelationsResult) InitDefault() { } -var UserRelationsServiceDeleteUserRelationsResult_Success_DEFAULT *DeleteUserRelationsReq +var UserRelationsServiceDeleteUserRelationsResult_Success_DEFAULT *DeleteUserRelationsRes -func (p *UserRelationsServiceDeleteUserRelationsResult) GetSuccess() (v *DeleteUserRelationsReq) { +func (p *UserRelationsServiceDeleteUserRelationsResult) GetSuccess() (v *DeleteUserRelationsRes) { if !p.IsSetSuccess() { return UserRelationsServiceDeleteUserRelationsResult_Success_DEFAULT } @@ -7012,7 +7302,7 @@ ReadStructEndError: } func (p *UserRelationsServiceDeleteUserRelationsResult) ReadField0(iprot thrift.TProtocol) error { - _field := NewDeleteUserRelationsReq() + _field := NewDeleteUserRelationsRes() if err := _field.Read(iprot); err != nil { return err } @@ -7221,7 +7511,7 @@ func (p *UserRelationsServiceListUserRelationsArgs) String() string { } type UserRelationsServiceListUserRelationsResult struct { - Success *ListUserRelationsResponse `thrift:"success,0,optional"` + Success *ListUserRelationsRes `thrift:"success,0,optional"` } func NewUserRelationsServiceListUserRelationsResult() *UserRelationsServiceListUserRelationsResult { @@ -7231,9 +7521,9 @@ func NewUserRelationsServiceListUserRelationsResult() *UserRelationsServiceListU func (p *UserRelationsServiceListUserRelationsResult) InitDefault() { } -var UserRelationsServiceListUserRelationsResult_Success_DEFAULT *ListUserRelationsResponse +var UserRelationsServiceListUserRelationsResult_Success_DEFAULT *ListUserRelationsRes -func (p *UserRelationsServiceListUserRelationsResult) GetSuccess() (v *ListUserRelationsResponse) { +func (p *UserRelationsServiceListUserRelationsResult) GetSuccess() (v *ListUserRelationsRes) { if !p.IsSetSuccess() { return UserRelationsServiceListUserRelationsResult_Success_DEFAULT } @@ -7304,7 +7594,7 @@ ReadStructEndError: } func (p *UserRelationsServiceListUserRelationsResult) ReadField0(iprot thrift.TProtocol) error { - _field := NewListUserRelationsResponse() + _field := NewListUserRelationsRes() if err := _field.Read(iprot); err != nil { return err } @@ -7513,7 +7803,7 @@ func (p *UserRelationsServiceCreateUserRelationsArgs) String() string { } type UserRelationsServiceCreateUserRelationsResult struct { - Success *CreateUserRelationsReq `thrift:"success,0,optional"` + Success *CreateUserRelationsRes `thrift:"success,0,optional"` } func NewUserRelationsServiceCreateUserRelationsResult() *UserRelationsServiceCreateUserRelationsResult { @@ -7523,9 +7813,9 @@ func NewUserRelationsServiceCreateUserRelationsResult() *UserRelationsServiceCre func (p *UserRelationsServiceCreateUserRelationsResult) InitDefault() { } -var UserRelationsServiceCreateUserRelationsResult_Success_DEFAULT *CreateUserRelationsReq +var UserRelationsServiceCreateUserRelationsResult_Success_DEFAULT *CreateUserRelationsRes -func (p *UserRelationsServiceCreateUserRelationsResult) GetSuccess() (v *CreateUserRelationsReq) { +func (p *UserRelationsServiceCreateUserRelationsResult) GetSuccess() (v *CreateUserRelationsRes) { if !p.IsSetSuccess() { return UserRelationsServiceCreateUserRelationsResult_Success_DEFAULT } @@ -7596,7 +7886,7 @@ ReadStructEndError: } func (p *UserRelationsServiceCreateUserRelationsResult) ReadField0(iprot thrift.TProtocol) error { - _field := NewCreateUserRelationsReq() + _field := NewCreateUserRelationsRes() if err := _field.Read(iprot); err != nil { return err } @@ -7658,3 +7948,295 @@ func (p *UserRelationsServiceCreateUserRelationsResult) String() string { return fmt.Sprintf("UserRelationsServiceCreateUserRelationsResult(%+v)", *p) } + +type UserRelationsServiceUpdateUserRelationsArgs struct { + Req *UpdateUserRelationsReq `thrift:"req,1"` +} + +func NewUserRelationsServiceUpdateUserRelationsArgs() *UserRelationsServiceUpdateUserRelationsArgs { + return &UserRelationsServiceUpdateUserRelationsArgs{} +} + +func (p *UserRelationsServiceUpdateUserRelationsArgs) InitDefault() { +} + +var UserRelationsServiceUpdateUserRelationsArgs_Req_DEFAULT *UpdateUserRelationsReq + +func (p *UserRelationsServiceUpdateUserRelationsArgs) GetReq() (v *UpdateUserRelationsReq) { + if !p.IsSetReq() { + return UserRelationsServiceUpdateUserRelationsArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_UserRelationsServiceUpdateUserRelationsArgs = map[int16]string{ + 1: "req", +} + +func (p *UserRelationsServiceUpdateUserRelationsArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *UserRelationsServiceUpdateUserRelationsArgs) 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_UserRelationsServiceUpdateUserRelationsArgs[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 *UserRelationsServiceUpdateUserRelationsArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewUpdateUserRelationsReq() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *UserRelationsServiceUpdateUserRelationsArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UpdateUserRelations_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 *UserRelationsServiceUpdateUserRelationsArgs) 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 *UserRelationsServiceUpdateUserRelationsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserRelationsServiceUpdateUserRelationsArgs(%+v)", *p) + +} + +type UserRelationsServiceUpdateUserRelationsResult struct { + Success *UpdateUserRelationsRes `thrift:"success,0,optional"` +} + +func NewUserRelationsServiceUpdateUserRelationsResult() *UserRelationsServiceUpdateUserRelationsResult { + return &UserRelationsServiceUpdateUserRelationsResult{} +} + +func (p *UserRelationsServiceUpdateUserRelationsResult) InitDefault() { +} + +var UserRelationsServiceUpdateUserRelationsResult_Success_DEFAULT *UpdateUserRelationsRes + +func (p *UserRelationsServiceUpdateUserRelationsResult) GetSuccess() (v *UpdateUserRelationsRes) { + if !p.IsSetSuccess() { + return UserRelationsServiceUpdateUserRelationsResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_UserRelationsServiceUpdateUserRelationsResult = map[int16]string{ + 0: "success", +} + +func (p *UserRelationsServiceUpdateUserRelationsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *UserRelationsServiceUpdateUserRelationsResult) 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_UserRelationsServiceUpdateUserRelationsResult[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 *UserRelationsServiceUpdateUserRelationsResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewUpdateUserRelationsRes() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *UserRelationsServiceUpdateUserRelationsResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UpdateUserRelations_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 *UserRelationsServiceUpdateUserRelationsResult) 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 *UserRelationsServiceUpdateUserRelationsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserRelationsServiceUpdateUserRelationsResult(%+v)", *p) + +} diff --git a/acquaintances/biz/model/user_relations.go b/acquaintances/biz/model/user_relations.go index 76de084..50d6886 100644 --- a/acquaintances/biz/model/user_relations.go +++ b/acquaintances/biz/model/user_relations.go @@ -1,19 +1,23 @@ package model import ( + "encoding/json" + "gorm.io/gorm" ) -// Friendship 好友关系表 +// UserRelations 好友关系表 type UserRelations struct { gorm.Model - UserID string `gorm:"type:bigint;not null;index:idx_user_status;column:用户id;"` - FriendID string `gorm:"type:bigint;not null;index:idx_friend_status;column:好友id"` - Status uint8 `gorm:"type:tinyint;default:0;column:关系状态"` // 0: 待确认, 1: 已确认, 2: 已拒绝, 3: 已删除 + UserID string `gorm:"column:user_id;type:varchar(32);not null;index:idx_user_friend,unique;comment:用户id"` + FriendList json.RawMessage `gorm:"column:friend_list;type:json;comment:'好友列表'"` + FriendCount int64 `gorm:"column:friend_count;type:int;default:0;comment:好友数量"` +} - // 关联用户 - User *User `gorm:"foreignKey:UserID;references:UserID"` - Friend *User `gorm:"foreignKey:FriendID;references:UserID"` +type Friend struct{ + FriendID string `json:"friend_id"` + Remark string `json:"remark"` // 好友备注 + CreateTime int64 `json:"create_time"` // 创建时间 } func (u *UserRelations) TableName() string { diff --git a/acquaintances/biz/router/user/middleware.go b/acquaintances/biz/router/user/middleware.go index 8266c73..ff3ca14 100644 --- a/acquaintances/biz/router/user/middleware.go +++ b/acquaintances/biz/router/user/middleware.go @@ -115,3 +115,8 @@ func _listuserrelationsMw() []app.HandlerFunc { // your code... return nil } + +func _updateuserrelationsMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/acquaintances/biz/router/user/user.go b/acquaintances/biz/router/user/user.go index 0029d2b..10caddd 100644 --- a/acquaintances/biz/router/user/user.go +++ b/acquaintances/biz/router/user/user.go @@ -30,6 +30,7 @@ func Register(r *server.Hertz) { _relation.DELETE("/", append(_deleteuserrelationsMw(), user.DeleteUserRelations)...) _relation.GET("/", append(_listuserrelationsMw(), user.ListUserRelations)...) _relation.POST("/", append(_createuserrelationsMw(), user.CreateUserRelations)...) + _relation.PUT("/", append(_updateuserrelationsMw(), user.UpdateUserRelations)...) } } } diff --git a/acquaintances/idl/user.thrift b/acquaintances/idl/user.thrift index 4b013df..fed41a4 100644 --- a/acquaintances/idl/user.thrift +++ b/acquaintances/idl/user.thrift @@ -30,7 +30,7 @@ struct User { 5: string introduce //个性签名 6: string avatar_image_url //头像地址 7: string birthday //生日 - 8: string area //国家/地区 + 8: i64 area //国家/地区 9: string mobile //手机号 10: string user_password //密码 11: user_status user_status //用户状态 @@ -49,7 +49,7 @@ struct UserInfoReq { 4: string introduce //个性签名 5: string avatar_image_url //头像地址 6: string birthday //生日 - 7: string area //国家/地区 + 7: i64 area //国家/地区 8: string mobile //手机号 9: string user_email //用户邮箱 10: string alias //别名 @@ -62,7 +62,7 @@ struct CreateUserRequest{ 2: Gender gender (api.body="gender", api.form="gender",api.vd="($ == 1||$ == 2)") 3: i64 age (api.body="age", api.form="age",api.vd="$>0") 4: string mobile (api.body="mobile", api.form="mobile",api.vd="(len($) > 0 && len($) < 12)") - 5: string area (api.body="area", api.form="area",api.vd="(len($) > 0 && len($) < 5)") + 5: i64 area (api.body="area", api.form="area",api.vd="$>0") 6: string user_password (api.body="user_password", api.form="user_password",api.vd="(len($) > 0 && len($) < 15)") } @@ -99,7 +99,7 @@ struct UpdateUserRequest{ 6: string avatar_image_url (api.body="avatar_image_url") 7: string birthday (api.body="birthday") 8: string user_password (api.body="user_password") - 9: string area (api.body="area") + 9: i64 area (api.body="area") 10: string mobile (api.body="mobile") 11: string address (api.body="address") } @@ -121,19 +121,13 @@ service UserService { /** 用户好友关系 **/ -struct UserRelations { - 1: string user_id //id - 2: string friend_id //好友id - 3: string status //关系状态 -} - - struct CreateUserRelationsReq { 1: string user_id //id 2: string friend_id //好友id + 3: string remark //备注 } -struct CreateUserRelationsResponse{ +struct CreateUserRelationsRes{ 1: Code code 2: string msg } @@ -143,7 +137,18 @@ struct DeleteUserRelationsReq { 2: string friend_id //好友id } -struct DeleteUserRelationsResponse{ +struct DeleteUserRelationsRes{ + 1: Code code + 2: string msg +} + +struct UpdateUserRelationsReq { + 1: string user_id //id + 2: string friend_id //好友id + 3: string remark //备注 +} + +struct UpdateUserRelationsRes{ 1: Code code 2: string msg } @@ -153,7 +158,7 @@ struct ListUserRelationsReq{ } -struct ListUserRelationsResponse{ +struct ListUserRelationsRes{ 1: Code code 2: string msg 3: list users @@ -161,8 +166,9 @@ struct ListUserRelationsResponse{ } service UserRelationsService { - DeleteUserRelationsReq DeleteUserRelations(1:DeleteUserRelationsReq req)(api.delete="/v1/user/relation/") //删除申请 - ListUserRelationsResponse ListUserRelations(1: ListUserRelationsReq req)(api.get="/v1/user/relation/") //获取好友列表 - CreateUserRelationsReq CreateUserRelations(1:CreateUserRelationsReq req)(api.post="/v1/user/relation/") //发起好友申请 + DeleteUserRelationsRes DeleteUserRelations(1:DeleteUserRelationsReq req)(api.delete="/v1/user/relation/") //删除申请 + ListUserRelationsRes ListUserRelations(1: ListUserRelationsReq req)(api.get="/v1/user/relation/") //获取好友列表 + CreateUserRelationsRes CreateUserRelations(1:CreateUserRelationsReq req)(api.post="/v1/user/relation/") //发起好友申请 + UpdateUserRelationsRes UpdateUserRelations(1:UpdateUserRelationsReq req)(api.put="/v1/user/relation/") //修改好友备注 } diff --git a/userAuthCenter b/userAuthCenter deleted file mode 160000 index d608d82..0000000 --- a/userAuthCenter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d608d82458f4f14d21b922754774a804eb0fef71