diff --git a/acquaintances/biz/dal/mysql/user.go b/acquaintances/biz/dal/mysql/user.go index 5cb65f0..243d567 100644 --- a/acquaintances/biz/dal/mysql/user.go +++ b/acquaintances/biz/dal/mysql/user.go @@ -3,8 +3,12 @@ package mysql import ( "acquaintances/biz/model" "acquaintances/biz/model/user" + "encoding/base64" "errors" + "fmt" + "golang.org/x/crypto/scrypt" "gorm.io/gorm" + "time" "github.com/cloudwego/hertz/pkg/common/hlog" ) @@ -123,3 +127,64 @@ func FindUser(keyword *string) (*user.UserInfoReq, error) { } return res, nil } + +// CheckLogin 验证登录(适配 Scrypt 加密) +func CheckLogin(username, password string) (*model.User, error) { + var user model.User + + // 1. 查询用户(支持 user_id/手机号/用户名登录) + result := DB.Model(&model.User{}).Where( + "user_id = ? OR mobile = ? OR user_name = ?", + username, username, username, + ).First(&user) + + // 2. 处理查询错误 + if result.Error != nil { + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return nil, fmt.Errorf("用户名或密码错误") // 模糊错误,防枚举 + } + return nil, fmt.Errorf("登录失败:%w", result.Error) + } + + // 3. 检查用户状态 + //TODO + + // 4. 验证密码(核心:使用 Scrypt 算法校验) + // 4.1 解码存储的盐值(加密时用 base64.URLEncoding) + salt, err := base64.URLEncoding.DecodeString(user.UserSalt) + if err != nil { + return nil, fmt.Errorf("密码验证失败") + } + + // 4.2 用相同算法计算输入密码的哈希 + const keyLen = 10 + inputHash, err := scrypt.Key([]byte(password), salt, 16384, 8, 1, keyLen) + if err != nil { + return nil, fmt.Errorf("密码验证失败") + } + + // 4.3 对比计算结果与存储的密码哈希 + storedHash := user.UserPassword + inputHashBase64 := base64.StdEncoding.EncodeToString(inputHash) + if inputHashBase64 != storedHash { + return nil, fmt.Errorf("用户名或密码错误") + } + + // 5. 更新最后登录信息 + return &user, updateLastLoginInfo(user.ID, getClientIP()) +} + +// 辅助函数:更新登录信息 +func updateLastLoginInfo(userID uint, loginIP string) error { + now := time.Now() + return DB.Model(&model.User{}).Where("id = ?", userID).Updates(map[string]interface{}{ + "last_login_ip": loginIP, + "last_login_time": &now, + }).Error +} + +// 辅助函数:获取客户端IP +func getClientIP() string { + //TODO + return "127.0.0.1" +} diff --git a/acquaintances/biz/handler/user/user_service.go b/acquaintances/biz/handler/user/user_service.go index 0986683..b61fc7d 100644 --- a/acquaintances/biz/handler/user/user_service.go +++ b/acquaintances/biz/handler/user/user_service.go @@ -145,3 +145,39 @@ func FindUser(ctx context.Context, c *app.RequestContext) { resp.UserInfo = data c.JSON(consts.StatusOK, resp) } + +// LoginUser . +// @router /v1/user/login/ [POST] +func LoginUser(ctx context.Context, c *app.RequestContext) { + var err error + var req user.LoginUserRequest + err = c.BindAndValidate(&req) + if err != nil { + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + data, err := mysql.CheckLogin(req.UserName, req.Password) + if err != nil { + c.JSON(consts.StatusBadRequest, err.Error()) + return + } + resp := new(user.LoginUserResponse) + 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.UserInfo = resData + c.JSON(consts.StatusOK, resp) +} diff --git a/acquaintances/biz/model/user/user.go b/acquaintances/biz/model/user/user.go index 9fd9003..364cf5b 100644 --- a/acquaintances/biz/model/user/user.go +++ b/acquaintances/biz/model/user/user.go @@ -1678,10 +1678,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" form:"gender" json:"gender" vd:"($ == 1||$ == 2)"` - Age int64 `thrift:"age,3" form:"age" form:"age" json:"age" vd:"$>0"` + 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" json:"mobile" vd:"(len($) > 0 && len($) < 12)"` - Area int64 `thrift:"area,5" form:"area" json:"area" vd:"$>0"` + Area int64 `thrift:"area,5" form:"area" form:"area" json:"area" vd:"$>0"` UserPassword string `thrift:"user_password,6" form:"user_password" json:"user_password" vd:"(len($) > 0 && len($) < 15)"` } @@ -3930,7 +3930,7 @@ func (p *FindUserResponse) String() string { } type FindUserRequest struct { - Keyword string `thrift:"keyword,1" json:"keyword" path:"user_id" query:"keyword"` + Keyword string `thrift:"keyword,1" form:"keyword" json:"keyword" path:"keyword"` } func NewFindUserRequest() *FindUserRequest { @@ -4068,6 +4068,470 @@ func (p *FindUserRequest) String() string { } +type LoginUserResponse 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"` + Token string `thrift:"token,4" form:"token" json:"token" query:"token"` +} + +func NewLoginUserResponse() *LoginUserResponse { + return &LoginUserResponse{} +} + +func (p *LoginUserResponse) InitDefault() { +} + +func (p *LoginUserResponse) GetCode() (v Code) { + return p.Code +} + +func (p *LoginUserResponse) GetMsg() (v string) { + return p.Msg +} + +var LoginUserResponse_UserInfo_DEFAULT *UserInfoReq + +func (p *LoginUserResponse) GetUserInfo() (v *UserInfoReq) { + if !p.IsSetUserInfo() { + return LoginUserResponse_UserInfo_DEFAULT + } + return p.UserInfo +} + +func (p *LoginUserResponse) GetToken() (v string) { + return p.Token +} + +var fieldIDToName_LoginUserResponse = map[int16]string{ + 1: "code", + 2: "msg", + 3: "userInfo", + 4: "token", +} + +func (p *LoginUserResponse) IsSetUserInfo() bool { + return p.UserInfo != nil +} + +func (p *LoginUserResponse) 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 + } + 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 + } + 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_LoginUserResponse[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 *LoginUserResponse) 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 *LoginUserResponse) 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 *LoginUserResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewUserInfoReq() + if err := _field.Read(iprot); err != nil { + return err + } + p.UserInfo = _field + return nil +} +func (p *LoginUserResponse) ReadField4(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Token = _field + return nil +} + +func (p *LoginUserResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("LoginUserResponse"); 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 = 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 *LoginUserResponse) 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 *LoginUserResponse) 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 *LoginUserResponse) 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 *LoginUserResponse) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("token", thrift.STRING, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Token); 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 *LoginUserResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LoginUserResponse(%+v)", *p) + +} + +type LoginUserRequest struct { + UserName string `thrift:"userName,1" form:"user_name" json:"user_name" path:"user_name"` + Password string `thrift:"password,2" form:"password" json:"password" path:"password"` +} + +func NewLoginUserRequest() *LoginUserRequest { + return &LoginUserRequest{} +} + +func (p *LoginUserRequest) InitDefault() { +} + +func (p *LoginUserRequest) GetUserName() (v string) { + return p.UserName +} + +func (p *LoginUserRequest) GetPassword() (v string) { + return p.Password +} + +var fieldIDToName_LoginUserRequest = map[int16]string{ + 1: "userName", + 2: "password", +} + +func (p *LoginUserRequest) 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) +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_LoginUserRequest[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 *LoginUserRequest) ReadField1(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 *LoginUserRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Password = _field + return nil +} + +func (p *LoginUserRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("LoginUserRequest"); 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 *LoginUserRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("userName", thrift.STRING, 1); 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 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *LoginUserRequest) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("password", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Password); 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 *LoginUserRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LoginUserRequest(%+v)", *p) + +} + /** 用户好友关系 **/ @@ -10763,6 +11227,8 @@ type UserService interface { CreateUser(ctx context.Context, req *CreateUserRequest) (r *CreateUserResponse, err error) FindUser(ctx context.Context, req *FindUserRequest) (r *FindUserResponse, err error) + + LoginUser(ctx context.Context, req *LoginUserRequest) (r *LoginUserResponse, err error) } type UserServiceClient struct { @@ -10836,6 +11302,15 @@ func (p *UserServiceClient) FindUser(ctx context.Context, req *FindUserRequest) } return _result.GetSuccess(), nil } +func (p *UserServiceClient) LoginUser(ctx context.Context, req *LoginUserRequest) (r *LoginUserResponse, err error) { + var _args UserServiceLoginUserArgs + _args.Req = req + var _result UserServiceLoginUserResult + if err = p.Client_().Call(ctx, "LoginUser", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} type UserRelationsService interface { DeleteUserRelations(ctx context.Context, req *DeleteUserRelationsReq) (r *DeleteUserRelationsRes, err error) @@ -11103,6 +11578,7 @@ func NewUserServiceProcessor(handler UserService) *UserServiceProcessor { self.AddToProcessorMap("InfoUser", &userServiceProcessorInfoUser{handler: handler}) self.AddToProcessorMap("CreateUser", &userServiceProcessorCreateUser{handler: handler}) self.AddToProcessorMap("FindUser", &userServiceProcessorFindUser{handler: handler}) + self.AddToProcessorMap("LoginUser", &userServiceProcessorLoginUser{handler: handler}) return self } func (p *UserServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -11363,6 +11839,54 @@ func (p *userServiceProcessorFindUser) Process(ctx context.Context, seqId int32, return true, err } +type userServiceProcessorLoginUser struct { + handler UserService +} + +func (p *userServiceProcessorLoginUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := UserServiceLoginUserArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("LoginUser", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := UserServiceLoginUserResult{} + var retval *LoginUserResponse + if retval, err2 = p.handler.LoginUser(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing LoginUser: "+err2.Error()) + oprot.WriteMessageBegin("LoginUser", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("LoginUser", 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"` } @@ -12823,6 +13347,298 @@ func (p *UserServiceFindUserResult) String() string { } +type UserServiceLoginUserArgs struct { + Req *LoginUserRequest `thrift:"req,1"` +} + +func NewUserServiceLoginUserArgs() *UserServiceLoginUserArgs { + return &UserServiceLoginUserArgs{} +} + +func (p *UserServiceLoginUserArgs) InitDefault() { +} + +var UserServiceLoginUserArgs_Req_DEFAULT *LoginUserRequest + +func (p *UserServiceLoginUserArgs) GetReq() (v *LoginUserRequest) { + if !p.IsSetReq() { + return UserServiceLoginUserArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_UserServiceLoginUserArgs = map[int16]string{ + 1: "req", +} + +func (p *UserServiceLoginUserArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *UserServiceLoginUserArgs) 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_UserServiceLoginUserArgs[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 *UserServiceLoginUserArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewLoginUserRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *UserServiceLoginUserArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("LoginUser_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 *UserServiceLoginUserArgs) 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 *UserServiceLoginUserArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserServiceLoginUserArgs(%+v)", *p) + +} + +type UserServiceLoginUserResult struct { + Success *LoginUserResponse `thrift:"success,0,optional"` +} + +func NewUserServiceLoginUserResult() *UserServiceLoginUserResult { + return &UserServiceLoginUserResult{} +} + +func (p *UserServiceLoginUserResult) InitDefault() { +} + +var UserServiceLoginUserResult_Success_DEFAULT *LoginUserResponse + +func (p *UserServiceLoginUserResult) GetSuccess() (v *LoginUserResponse) { + if !p.IsSetSuccess() { + return UserServiceLoginUserResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_UserServiceLoginUserResult = map[int16]string{ + 0: "success", +} + +func (p *UserServiceLoginUserResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *UserServiceLoginUserResult) 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_UserServiceLoginUserResult[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 *UserServiceLoginUserResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewLoginUserResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *UserServiceLoginUserResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("LoginUser_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 *UserServiceLoginUserResult) 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 *UserServiceLoginUserResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserServiceLoginUserResult(%+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 516e6b9..e3b34a1 100644 --- a/acquaintances/biz/router/user/middleware.go +++ b/acquaintances/biz/router/user/middleware.go @@ -205,3 +205,13 @@ func _findMw() []app.HandlerFunc { // your code... return nil } + +func _loginMw() []app.HandlerFunc { + // your code... + return nil +} + +func _loginuserMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/acquaintances/biz/router/user/user.go b/acquaintances/biz/router/user/user.go index 04baeea..f0d23d7 100644 --- a/acquaintances/biz/router/user/user.go +++ b/acquaintances/biz/router/user/user.go @@ -54,6 +54,10 @@ func Register(r *server.Hertz) { _friendrelationship.POST("/", append(_createfriendrelationshipMw(), user.CreateFriendRelationship)...) _friendrelationship.PUT("/", append(_updatefriendrelationshipMw(), user.UpdateFriendRelationship)...) } + { + _login := _user.Group("/login", _loginMw()...) + _login.POST("/", append(_loginuserMw(), user.LoginUser)...) + } { _relation := _user.Group("/relation", _relationMw()...) _relation.DELETE("/", append(_deleteuserrelationsMw(), user.DeleteUserRelations)...) diff --git a/acquaintances/idl/user.thrift b/acquaintances/idl/user.thrift index 74ebe0c..11a6f6e 100644 --- a/acquaintances/idl/user.thrift +++ b/acquaintances/idl/user.thrift @@ -118,15 +118,29 @@ struct FindUserResponse{ } struct FindUserRequest{ - 1: string keyword (api.path="user_id",api.query="keyword") + 1: string keyword (api.path="keyword",api.body="keyword") } +struct LoginUserResponse{ + 1: Code code + 2: string msg + 3: UserInfoReq userInfo + 4: string token +} + +struct LoginUserRequest{ + 1: string userName (api.path="user_name",api.body="user_name") + 2: string password (api.path="password",api.body="password") +} + + 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/") + LoginUserResponse LoginUser(1:LoginUserRequest req)(api.post="/v1/user/login/") } diff --git a/pushNotificationCenter/biz/dal/file/file.go b/pushNotificationCenter/biz/dal/file/file.go new file mode 100644 index 0000000..ba5e53c --- /dev/null +++ b/pushNotificationCenter/biz/dal/file/file.go @@ -0,0 +1,12 @@ +package file + +import ( + "fmt" + "pushNotificationCenter/config" +) + +// 生成永久访问URL(基于存储桶域名和对象路径) +func GetPermanentURL(bucketName, objectKey string) string { + // 格式: http:///<桶名>/<对象键> + return fmt.Sprintf(`http://%s:%s/api/v1/buckets/%s/objects/download?prefix=%s`, config.MinioHost, config.MinioPort, bucketName, objectKey) +} diff --git a/pushNotificationCenter/biz/dal/file/init.go b/pushNotificationCenter/biz/dal/file/init.go new file mode 100644 index 0000000..3bab369 --- /dev/null +++ b/pushNotificationCenter/biz/dal/file/init.go @@ -0,0 +1,68 @@ +package file + +import ( + "context" + "encoding/json" + "fmt" + "github.com/cloudwego/hertz/pkg/common/hlog" + "github.com/minio/minio-go/v7" + "github.com/minio/minio-go/v7/pkg/credentials" +) + +// 全局MinIO客户端实例 +var MinioClient *minio.Client + +// 初始化MinIO客户端 +func InitMinIO() error { + endpoint := "127.0.0.1:7001" // MinIO服务地址 + accessKeyID := "admin" // 访问密钥 + secretAccessKey := "1234567890" // 密钥 + useSSL := false // 开发环境通常不使用SSL + + // 初始化MinIO客户端 + client, err := minio.New(endpoint, &minio.Options{ + Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), + Secure: useSSL, + }) + if err != nil { + return err + } + hlog.Infof("Created minio client suscces") + MinioClient = client + return nil +} + +// 设置存储桶的公共读策略,允许永久访问 +func SetBucketPublicRead(ctx context.Context, client *minio.Client, bucketName string) error { + // 定义存储桶访问策略(允许所有人读取对象) + policy := map[string]interface{}{ + "Version": "2012-10-17", + "Statement": []map[string]interface{}{ + { + "Effect": "Allow", + "Principal": map[string]interface{}{ + "AWS": []string{"*"}, // 允许所有用户 + }, + "Action": []string{ + "s3:GetObject", // 仅授予读取权限 + }, + "Resource": []string{ + fmt.Sprintf("arn:aws:s3:::%s/*", bucketName), // 匹配桶内所有对象 + }, + }, + }, + } + + // 转换为JSON字符串 + policyBytes, err := json.Marshal(policy) + if err != nil { + return fmt.Errorf("策略序列化失败: %v", err) + } + + // 应用策略到存储桶 + if err := client.SetBucketPolicy(ctx, bucketName, string(policyBytes)); err != nil { + return fmt.Errorf("设置存储桶策略失败: %v", err) + } + hlog.Infof("设置存储桶策略成功") + return nil +} diff --git a/pushNotificationCenter/biz/dal/init.go b/pushNotificationCenter/biz/dal/init.go index d1f6c25..f79fcc9 100644 --- a/pushNotificationCenter/biz/dal/init.go +++ b/pushNotificationCenter/biz/dal/init.go @@ -1,10 +1,25 @@ package dal import ( + "context" + "github.com/cloudwego/hertz/pkg/common/hlog" + "pushNotificationCenter/biz/dal/file" + "pushNotificationCenter/biz/dal/mysql" "pushNotificationCenter/biz/dal/redis" ) func Init() { redis.InitRedis() go redis.ChatGroupProcessorInit() + go mysql.Init() + go func() { + err := file.InitMinIO() + if err != nil { + hlog.Errorf("init minio failed: %s", err.Error()) + } + err = file.SetBucketPublicRead(context.Background(), file.MinioClient, "all") + if err != nil { + hlog.Errorf("init minio failed: %s", err.Error()) + } + }() } diff --git a/pushNotificationCenter/biz/dal/mysql/chat_group.go b/pushNotificationCenter/biz/dal/mysql/chat_group.go new file mode 100644 index 0000000..81db46b --- /dev/null +++ b/pushNotificationCenter/biz/dal/mysql/chat_group.go @@ -0,0 +1,43 @@ +package mysql + +import ( + "errors" + "github.com/cloudwego/hertz/pkg/common/hlog" + "pushNotificationCenter/biz/model" +) + +// GetGroupMemberUserIDs 通过群ID获取所有成员的用户ID切片 +// 返回值:用户ID切片、错误信息 +func GetGroupMemberUserIDs(groupID string) ([]string, error) { + db := DB + if db == nil { + hlog.Errorf("GetGroupMemberUserIDs DB Error") + panic("GetGroupMemberUserIDs DB Error") + } + // 1. 参数校验 + if groupID == "" { + return nil, errors.New("群ID不能为空") + } + + // 2. 查询群用户关系表,获取该群下的所有用户ID + var relations []model.GroupUserRelation + result := db.Model(&model.GroupUserRelation{}). + Where("chat_group_id = ?", groupID). + Find(&relations) + + // 3. 处理查询错误 + if result.Error != nil { + return nil, errors.New("查询群成员失败: " + result.Error.Error()) + } + if len(relations) == 0 { + return []string{}, nil // 无成员时返回空切片,避免nil + } + + // 4. 提取用户ID到切片 + userIDs := make([]string, 0, len(relations)) + for _, rel := range relations { + userIDs = append(userIDs, rel.UserID) + } + + return userIDs, nil +} diff --git a/pushNotificationCenter/biz/dal/mysql/init.go b/pushNotificationCenter/biz/dal/mysql/init.go new file mode 100644 index 0000000..a4b83ff --- /dev/null +++ b/pushNotificationCenter/biz/dal/mysql/init.go @@ -0,0 +1,40 @@ +package mysql + +import ( + "fmt" + "github.com/cloudwego/hertz/pkg/common/hlog" + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "pushNotificationCenter/config" + "time" +) + +var dsn = fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", + config.MysqlUser, + config.MysqlPassWord, + config.MysqlHost, + config.MysqlPort, + config.MysqlDBName, +) + +var DB *gorm.DB + +func Init() { + var err error + DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{ + SkipDefaultTransaction: true, + PrepareStmt: true, + Logger: logger.Default.LogMode(logger.Info), + }) + if err != nil { + hlog.Error("mysql init error", err.Error()) + panic(err) + } + // 连接池配置 + sqlDB, _ := DB.DB() + sqlDB.SetMaxIdleConns(10) + sqlDB.SetMaxOpenConns(100) + sqlDB.SetConnMaxLifetime(time.Hour) // 建议设置为 1h 或更低 + hlog.Infof("mysql init success") +} diff --git a/pushNotificationCenter/biz/dal/redis/chat_group_processor.go b/pushNotificationCenter/biz/dal/redis/chat_group_processor.go index 47af53a..b1e3d5b 100644 --- a/pushNotificationCenter/biz/dal/redis/chat_group_processor.go +++ b/pushNotificationCenter/biz/dal/redis/chat_group_processor.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/cloudwego/hertz/pkg/common/hlog" "log" + "pushNotificationCenter/biz/dal/mysql" "pushNotificationCenter/protocol" "strings" ) @@ -45,7 +46,10 @@ func handleGroupMessage(groupID string, msg protocol.Message) { // 实际应用中这里需要查询群组成员 // 这里简化处理,假设群组有固定成员 - members := getGroupMembers(groupID) + members, err := getGroupMembers(groupID) + if err != nil { + hlog.Errorf("群成员获取失败: %v", err) + } // 向每个群成员发送消息 for _, member := range members { @@ -69,8 +73,12 @@ func forwardToUser(userID string, msg protocol.Message) { } // 获取群组成员 (简化版) -func getGroupMembers(groupID string) []string { +func getGroupMembers(groupID string) ([]string, error) { // 实际应用中应从数据库或缓存获取 // 这里返回固定成员 - return []string{"user1", "user2", "user3"} + users, err := mysql.GetGroupMemberUserIDs(groupID) + if err != nil { + return nil, err + } + return users, nil } diff --git a/pushNotificationCenter/biz/handler/file/service/file_service.go b/pushNotificationCenter/biz/handler/file/service/file_service.go new file mode 100644 index 0000000..90ad2ae --- /dev/null +++ b/pushNotificationCenter/biz/handler/file/service/file_service.go @@ -0,0 +1,208 @@ +// Code generated by hertz generator. + +package service + +import ( + "bytes" + "context" + "crypto/md5" + "encoding/hex" + "fmt" + "github.com/cloudwego/hertz/pkg/common/hlog" + "github.com/minio/minio-go/v7" + "io" + "pushNotificationCenter/biz/dal/file" + "time" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" + service "pushNotificationCenter/biz/model/file/service" +) + +// UploadFile 处理文件上传请求 +// @router /v1/file/ [POST] +func UploadFile(ctx context.Context, c *app.RequestContext) { + var err error + var req service.UploadFileRequest + + //绑定并验证请求参数 + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + if req.BucketName == "" { + req.BucketName = "all" + } + + fileUp, err := c.Request.FormFile("file") + if err != nil { + return + } + hlog.Infof("upload file %s", fileUp.Filename) + req.FileName = fileUp.Filename + open, err := fileUp.Open() + if err != nil { + return + } + defer open.Close() + req.FileContent, err = io.ReadAll(open) + if err != nil || len(req.FileContent) == 0 { + hlog.Infof("upload file %s err %v,len:%d", req.FileName, err, len(req.FileContent)) + return + } + + hlog.Infof("start upload file FileName:%s,FileName:%s", req.FileName, req.FileName) + // 初始化响应 + resp := new(service.UploadFileResponse) + + // 检查MinIO客户端是否初始化 + if file.MinioClient == nil { + resp.ErrorMsg = "MinIO client not initialized" + c.JSON(consts.StatusInternalServerError, resp) + return + } + hlog.Infof("minio is ok") + // 检查存储桶是否存在,不存在则创建 + exists, err := file.MinioClient.BucketExists(ctx, req.BucketName) + if err != nil { + hlog.Infof("minio bucket exists failed: %v", err) + resp.ErrorMsg = fmt.Sprintf("Failed to check bucket: %v", err) + c.JSON(consts.StatusInternalServerError, resp) + return + } + + if !exists { + hlog.Infof("minio bucket does not exist: %s", req.BucketName) + err = file.MinioClient.MakeBucket(ctx, req.BucketName, minio.MakeBucketOptions{}) + if err != nil { + hlog.Infof("minio bucket create failed: %v", err) + resp.ErrorMsg = fmt.Sprintf("Failed to create bucket: %v", err) + c.JSON(consts.StatusInternalServerError, resp) + return + } + } + hlog.Infof("minio bucket ok") + + // 生成文件ID (可以根据实际需求修改生成策略) + fileID := generateFileID(req.FileName, req.FileContent) + + // 构建对象存储路径 + objectKey := buildObjectKey(req.ObjectPrefix, fileID, req.FileName) + // 上传文件到MinIO + info, err := file.MinioClient.PutObject(ctx, req.BucketName, objectKey, + bytes.NewReader(req.FileContent), int64(len(req.FileContent)), + minio.PutObjectOptions{ + ContentType: req.ContentType, + }) + + if err != nil { + hlog.Infof("upload file %s err %v,len:%d", objectKey, err, len(req.FileContent)) + resp.ErrorMsg = fmt.Sprintf("Failed to upload file: %v", err) + c.JSON(consts.StatusInternalServerError, resp) + return + } + + // 准备文件信息 + now := time.Now().Unix() + fileInfo := &service.FileInfo{ + FileID: fileID, + FileName: req.FileName, + ContentType: req.ContentType, + FileSize: int64(len(req.FileContent)), + BucketName: req.BucketName, + ObjectKey: objectKey, + UploadTime: now, + Etag: info.ETag, + } + + // 保存文件信息到数据库 (这里只是示例,实际应使用数据库) + if err := saveFileInfo(fileInfo); err != nil { + resp.ErrorMsg = fmt.Sprintf("Failed to save file info: %v", err) + c.JSON(consts.StatusInternalServerError, resp) + return + } + + // 构建下载路由 + downloadRoute := file.GetPermanentURL(req.BucketName, objectKey) + + // 准备成功响应 + resp.Success = true + resp.FileInfo = fileInfo + resp.DownloadRoute = downloadRoute + hlog.Infof("upload file %v success", resp) + c.JSON(consts.StatusOK, resp) +} + +// 生成文件唯一ID +func generateFileID(fileName string, content []byte) string { + hasher := md5.New() + hasher.Write([]byte(fileName)) + hasher.Write(content) + hasher.Write([]byte(time.Now().String())) + return hex.EncodeToString(hasher.Sum(nil)) +} + +// 构建对象存储路径 +func buildObjectKey(prefix, fileID, fileName string) string { + if prefix != "" { + return fmt.Sprintf("%s/%s-%s", prefix, fileID, fileName) + } + return fmt.Sprintf("%s-%s", fileID, fileName) +} + +// 保存文件信息到数据库 (示例方法) +func saveFileInfo(info *service.FileInfo) error { + // 实际应用中应该将文件信息保存到数据库 + // 这里仅作示例 + fmt.Printf("Saving file info: %+v\n", info) + return nil +} + +// GetDownloadInfo . +// @router /v1/file/ [GET] +func GetDownloadInfo(ctx context.Context, c *app.RequestContext) { + var err error + var req service.GetDownloadInfoRequest + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(service.GetDownloadInfoResponse) + + c.JSON(consts.StatusOK, resp) +} + +// DeleteFile . +// @router /v1/file/ [DELETE] +func DeleteFile(ctx context.Context, c *app.RequestContext) { + var err error + var req service.DeleteFileRequest + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(service.CommonResponse) + + c.JSON(consts.StatusOK, resp) +} + +// GetFileInfo . +// @router /v1/file/info/ [DELETE] +func GetFileInfo(ctx context.Context, c *app.RequestContext) { + var err error + var req string + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(service.FileInfo) + + c.JSON(consts.StatusOK, resp) +} diff --git a/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go b/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go index 78a76b8..c8b9147 100644 --- a/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go +++ b/pushNotificationCenter/biz/handler/wsCenter/wsCenter_server.go @@ -108,7 +108,6 @@ func (c *Client) writePump() { func handleIncomingMessage(senderID string, msg []byte) { var message protocol.Message - hlog.Infof("+++++++++++++:%v", msg) if err := json.Unmarshal(msg, &message); err != nil { hlog.Errorf("消息解析错误: %v", err) return diff --git a/pushNotificationCenter/biz/model/chat_group.go b/pushNotificationCenter/biz/model/chat_group.go new file mode 100644 index 0000000..c65144b --- /dev/null +++ b/pushNotificationCenter/biz/model/chat_group.go @@ -0,0 +1,43 @@ +package model + +import "gorm.io/gorm" + +// ChatGroupInfo 聊天群组信息结构体 +// 存储群组的基本信息,如名称、头像、公告等 +type ChatGroupInfo struct { + gorm.Model + ChatGroupID string `gorm:"column:chat_group_id;type:varchar(64);primary_key;comment:群唯一标识ID"` // 群组唯一ID + ChatGroupName string `gorm:"column:chat_group_name;type:varchar(128);not null;comment:群组名称"` // 群组名称 + ChatGroupImageURL string `gorm:"column:chat_group_image_url;type:varchar(255);comment:群组头像图片URL地址"` // 群组头像URL + ChatGroupNotice string `gorm:"column:chat_group_notice;type:text;comment:群组公告内容"` // 群组公告 +} + +// TableName 指定数据库表名 +func (c *ChatGroupInfo) TableName() string { + return "chat_group_info" +} + +type ChatGroupRole int + +const ( + General ChatGroupRole = iota + Administrators + GroupLeader +) + +// GroupUserRelation 群与用户关系结构体 +// 记录用户与群组的关联关系及用户在群内的相关属性 +type GroupUserRelation struct { + gorm.Model + ChatGroupID string `gorm:"column:chat_group_id;type:varchar(64);not null;index;comment:关联的群ID"` // 群组ID,关联ChatGroupInfo表 + UserID string `gorm:"column:user_id;type:varchar(64);not null;index;comment:关联的用户ID"` // 用户ID,关联用户表 + Role ChatGroupRole `gorm:"column:role;type:int;not null;default:0;comment:用户群内角色(0-普通成员,1-管理员,2-群主)"` // 用户在群内的角色 + LastReadTime int64 `gorm:"column:last_read_time;type:bigint;default:0;comment:最后阅读消息时间(Unix时间戳)"` // 最后阅读时间(时间戳) + IsMuted bool `gorm:"column:is_muted;type:tinyint(1);default:false;comment:是否被禁言(true-是,false-否)"` // 是否被禁言 + MuteExpireTime int64 `gorm:"column:mute_expire_time;type:bigint;default:0;comment:禁言过期时间(Unix时间戳,0表示永久)"` // 禁言过期时间 +} + +// TableName 指定数据库表名 +func (g *GroupUserRelation) TableName() string { + return "group_user_relation" +} diff --git a/pushNotificationCenter/biz/model/file/service/minio.go b/pushNotificationCenter/biz/model/file/service/minio.go new file mode 100644 index 0000000..475af8a --- /dev/null +++ b/pushNotificationCenter/biz/model/file/service/minio.go @@ -0,0 +1,3472 @@ +// Code generated by thriftgo (0.4.2). DO NOT EDIT. + +package service + +import ( + "context" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +/** + * 文件元数据信息 + */ +type FileInfo struct { + // 文件唯一标识 + FileID string `thrift:"file_id,1" form:"file_id" json:"file_id" query:"file_id"` + // 文件名 + FileName string `thrift:"file_name,2" form:"file_name" json:"file_name" query:"file_name"` + // 文件类型(MIME) + ContentType string `thrift:"content_type,3" form:"content_type" json:"content_type" query:"content_type"` + // 文件大小(字节) + FileSize int64 `thrift:"file_size,4" form:"file_size" json:"file_size" query:"file_size"` + // 存储桶名称 + BucketName string `thrift:"bucket_name,5" form:"bucket_name" json:"bucket_name" query:"bucket_name"` + // MinIO中的对象键(路径) + ObjectKey string `thrift:"object_key,6" form:"object_key" json:"object_key" query:"object_key"` + // 上传时间(timestamp) + UploadTime int64 `thrift:"upload_time,7" form:"upload_time" json:"upload_time" query:"upload_time"` + // 直接下载URL + DownloadURL string `thrift:"download_url,8" form:"download_url" json:"download_url" query:"download_url"` + // 文件校验值 + Etag string `thrift:"etag,9" form:"etag" json:"etag" query:"etag"` +} + +func NewFileInfo() *FileInfo { + return &FileInfo{} +} + +func (p *FileInfo) InitDefault() { +} + +func (p *FileInfo) GetFileID() (v string) { + return p.FileID +} + +func (p *FileInfo) GetFileName() (v string) { + return p.FileName +} + +func (p *FileInfo) GetContentType() (v string) { + return p.ContentType +} + +func (p *FileInfo) GetFileSize() (v int64) { + return p.FileSize +} + +func (p *FileInfo) GetBucketName() (v string) { + return p.BucketName +} + +func (p *FileInfo) GetObjectKey() (v string) { + return p.ObjectKey +} + +func (p *FileInfo) GetUploadTime() (v int64) { + return p.UploadTime +} + +func (p *FileInfo) GetDownloadURL() (v string) { + return p.DownloadURL +} + +func (p *FileInfo) GetEtag() (v string) { + return p.Etag +} + +var fieldIDToName_FileInfo = map[int16]string{ + 1: "file_id", + 2: "file_name", + 3: "content_type", + 4: "file_size", + 5: "bucket_name", + 6: "object_key", + 7: "upload_time", + 8: "download_url", + 9: "etag", +} + +func (p *FileInfo) 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 + } + 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 + } + 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 + } + case 6: + if fieldTypeId == thrift.STRING { + if err = p.ReadField6(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 7: + if fieldTypeId == thrift.I64 { + if err = p.ReadField7(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRING { + if err = p.ReadField8(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 9: + if fieldTypeId == thrift.STRING { + if err = p.ReadField9(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_FileInfo[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 *FileInfo) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FileID = _field + return nil +} +func (p *FileInfo) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FileName = _field + return nil +} +func (p *FileInfo) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ContentType = _field + return nil +} +func (p *FileInfo) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = v + } + p.FileSize = _field + return nil +} +func (p *FileInfo) ReadField5(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.BucketName = _field + return nil +} +func (p *FileInfo) ReadField6(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ObjectKey = _field + return nil +} +func (p *FileInfo) ReadField7(iprot thrift.TProtocol) error { + + var _field int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = v + } + p.UploadTime = _field + return nil +} +func (p *FileInfo) ReadField8(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.DownloadURL = _field + return nil +} +func (p *FileInfo) ReadField9(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Etag = _field + return nil +} + +func (p *FileInfo) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("FileInfo"); 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 = p.writeField6(oprot); err != nil { + fieldId = 6 + goto WriteFieldError + } + if err = p.writeField7(oprot); err != nil { + fieldId = 7 + goto WriteFieldError + } + if err = p.writeField8(oprot); err != nil { + fieldId = 8 + goto WriteFieldError + } + if err = p.writeField9(oprot); err != nil { + fieldId = 9 + 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 *FileInfo) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_id", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FileID); 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 *FileInfo) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_name", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FileName); 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 *FileInfo) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("content_type", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ContentType); 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 *FileInfo) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_size", thrift.I64, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.FileSize); 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 *FileInfo) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("bucket_name", thrift.STRING, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.BucketName); 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 *FileInfo) writeField6(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("object_key", thrift.STRING, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ObjectKey); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} +func (p *FileInfo) writeField7(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("upload_time", thrift.I64, 7); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.UploadTime); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) +} +func (p *FileInfo) writeField8(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("download_url", thrift.STRING, 8); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.DownloadURL); 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 *FileInfo) writeField9(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("etag", thrift.STRING, 9); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Etag); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) +} + +func (p *FileInfo) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileInfo(%+v)", *p) + +} + +/** + * 上传文件请求 + */ +type UploadFileRequest struct { + // 文件内容二进制 + FileContent []byte `thrift:"file_content,1" form:"file_content" json:"file_content" query:"file_content"` + // 文件名 + FileName string `thrift:"file_name,2" form:"file_name" json:"file_name" query:"file_name"` + // 文件类型 + ContentType string `thrift:"content_type,3" form:"content_type" json:"content_type" query:"content_type"` + // 目标存储桶 + BucketName string `thrift:"bucket_name,4" form:"bucket_name" json:"bucket_name" query:"bucket_name"` + // 可选的对象存储前缀路径 + ObjectPrefix string `thrift:"object_prefix,5" form:"object_prefix" json:"object_prefix" query:"object_prefix"` +} + +func NewUploadFileRequest() *UploadFileRequest { + return &UploadFileRequest{} +} + +func (p *UploadFileRequest) InitDefault() { +} + +func (p *UploadFileRequest) GetFileContent() (v []byte) { + return p.FileContent +} + +func (p *UploadFileRequest) GetFileName() (v string) { + return p.FileName +} + +func (p *UploadFileRequest) GetContentType() (v string) { + return p.ContentType +} + +func (p *UploadFileRequest) GetBucketName() (v string) { + return p.BucketName +} + +func (p *UploadFileRequest) GetObjectPrefix() (v string) { + return p.ObjectPrefix +} + +var fieldIDToName_UploadFileRequest = map[int16]string{ + 1: "file_content", + 2: "file_name", + 3: "content_type", + 4: "bucket_name", + 5: "object_prefix", +} + +func (p *UploadFileRequest) 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 + } + 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_UploadFileRequest[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 *UploadFileRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field []byte + if v, err := iprot.ReadBinary(); err != nil { + return err + } else { + _field = []byte(v) + } + p.FileContent = _field + return nil +} +func (p *UploadFileRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FileName = _field + return nil +} +func (p *UploadFileRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ContentType = _field + return nil +} +func (p *UploadFileRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.BucketName = _field + return nil +} +func (p *UploadFileRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ObjectPrefix = _field + return nil +} + +func (p *UploadFileRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UploadFileRequest"); 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 *UploadFileRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_content", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBinary([]byte(p.FileContent)); 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 *UploadFileRequest) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_name", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FileName); 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 *UploadFileRequest) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("content_type", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ContentType); 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 *UploadFileRequest) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("bucket_name", thrift.STRING, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.BucketName); 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 *UploadFileRequest) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("object_prefix", thrift.STRING, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ObjectPrefix); 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 *UploadFileRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UploadFileRequest(%+v)", *p) + +} + +/** + * 上传文件响应 + */ +type UploadFileResponse struct { + // 操作是否成功 + Success bool `thrift:"success,1" form:"success" json:"success" query:"success"` + // 文件信息(成功时返回) + FileInfo *FileInfo `thrift:"file_info,2" form:"file_info" json:"file_info" query:"file_info"` + // 错误信息(失败时返回) + ErrorMsg string `thrift:"error_msg,3" form:"error_msg" json:"error_msg" query:"error_msg"` + // 下载路由地址,如 "/file/download/{file_id}" + DownloadRoute string `thrift:"download_route,4" form:"download_route" json:"download_route" query:"download_route"` +} + +func NewUploadFileResponse() *UploadFileResponse { + return &UploadFileResponse{} +} + +func (p *UploadFileResponse) InitDefault() { +} + +func (p *UploadFileResponse) GetSuccess() (v bool) { + return p.Success +} + +var UploadFileResponse_FileInfo_DEFAULT *FileInfo + +func (p *UploadFileResponse) GetFileInfo() (v *FileInfo) { + if !p.IsSetFileInfo() { + return UploadFileResponse_FileInfo_DEFAULT + } + return p.FileInfo +} + +func (p *UploadFileResponse) GetErrorMsg() (v string) { + return p.ErrorMsg +} + +func (p *UploadFileResponse) GetDownloadRoute() (v string) { + return p.DownloadRoute +} + +var fieldIDToName_UploadFileResponse = map[int16]string{ + 1: "success", + 2: "file_info", + 3: "error_msg", + 4: "download_route", +} + +func (p *UploadFileResponse) IsSetFileInfo() bool { + return p.FileInfo != nil +} + +func (p *UploadFileResponse) 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.BOOL { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRING { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + 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 + } + 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_UploadFileResponse[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 *UploadFileResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = v + } + p.Success = _field + return nil +} +func (p *UploadFileResponse) ReadField2(iprot thrift.TProtocol) error { + _field := NewFileInfo() + if err := _field.Read(iprot); err != nil { + return err + } + p.FileInfo = _field + return nil +} +func (p *UploadFileResponse) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ErrorMsg = _field + return nil +} +func (p *UploadFileResponse) ReadField4(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.DownloadRoute = _field + return nil +} + +func (p *UploadFileResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UploadFileResponse"); 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 = 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 *UploadFileResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("success", thrift.BOOL, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(p.Success); 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 *UploadFileResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_info", thrift.STRUCT, 2); err != nil { + goto WriteFieldBeginError + } + if err := p.FileInfo.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *UploadFileResponse) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("error_msg", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ErrorMsg); 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 *UploadFileResponse) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("download_route", thrift.STRING, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.DownloadRoute); 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 *UploadFileResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UploadFileResponse(%+v)", *p) + +} + +/** + * 获取文件下载信息请求 + */ +type GetDownloadInfoRequest struct { + // 文件唯一标识 + FileID string `thrift:"file_id,1" form:"file_id" json:"file_id" query:"file_id"` + // URL有效期(秒),默认3600 + ExpireSeconds int64 `thrift:"expire_seconds,2" form:"expire_seconds" json:"expire_seconds" query:"expire_seconds"` +} + +func NewGetDownloadInfoRequest() *GetDownloadInfoRequest { + return &GetDownloadInfoRequest{} +} + +func (p *GetDownloadInfoRequest) InitDefault() { +} + +func (p *GetDownloadInfoRequest) GetFileID() (v string) { + return p.FileID +} + +func (p *GetDownloadInfoRequest) GetExpireSeconds() (v int64) { + return p.ExpireSeconds +} + +var fieldIDToName_GetDownloadInfoRequest = map[int16]string{ + 1: "file_id", + 2: "expire_seconds", +} + +func (p *GetDownloadInfoRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I64 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetDownloadInfoRequest[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 *GetDownloadInfoRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FileID = _field + return nil +} +func (p *GetDownloadInfoRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = v + } + p.ExpireSeconds = _field + return nil +} + +func (p *GetDownloadInfoRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetDownloadInfoRequest"); 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 *GetDownloadInfoRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_id", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FileID); 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 *GetDownloadInfoRequest) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("expire_seconds", thrift.I64, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.ExpireSeconds); 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 *GetDownloadInfoRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetDownloadInfoRequest(%+v)", *p) + +} + +/** + * 文件下载信息响应 + */ +type GetDownloadInfoResponse struct { + // 操作是否成功 + Success bool `thrift:"success,1" form:"success" json:"success" query:"success"` + // 直接下载URL(可用于浏览器直接访问) + DirectURL string `thrift:"direct_url,2" form:"direct_url" json:"direct_url" query:"direct_url"` + // 应用内下载路由,如 "/file/download/xxx" + RouteURL string `thrift:"route_url,3" form:"route_url" json:"route_url" query:"route_url"` + // 文件元信息 + FileInfo *FileInfo `thrift:"file_info,4" form:"file_info" json:"file_info" query:"file_info"` + // 错误信息(失败时返回) + ErrorMsg string `thrift:"error_msg,5" form:"error_msg" json:"error_msg" query:"error_msg"` +} + +func NewGetDownloadInfoResponse() *GetDownloadInfoResponse { + return &GetDownloadInfoResponse{} +} + +func (p *GetDownloadInfoResponse) InitDefault() { +} + +func (p *GetDownloadInfoResponse) GetSuccess() (v bool) { + return p.Success +} + +func (p *GetDownloadInfoResponse) GetDirectURL() (v string) { + return p.DirectURL +} + +func (p *GetDownloadInfoResponse) GetRouteURL() (v string) { + return p.RouteURL +} + +var GetDownloadInfoResponse_FileInfo_DEFAULT *FileInfo + +func (p *GetDownloadInfoResponse) GetFileInfo() (v *FileInfo) { + if !p.IsSetFileInfo() { + return GetDownloadInfoResponse_FileInfo_DEFAULT + } + return p.FileInfo +} + +func (p *GetDownloadInfoResponse) GetErrorMsg() (v string) { + return p.ErrorMsg +} + +var fieldIDToName_GetDownloadInfoResponse = map[int16]string{ + 1: "success", + 2: "direct_url", + 3: "route_url", + 4: "file_info", + 5: "error_msg", +} + +func (p *GetDownloadInfoResponse) IsSetFileInfo() bool { + return p.FileInfo != nil +} + +func (p *GetDownloadInfoResponse) 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.BOOL { + 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 + } + case 4: + if fieldTypeId == thrift.STRUCT { + 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_GetDownloadInfoResponse[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 *GetDownloadInfoResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = v + } + p.Success = _field + return nil +} +func (p *GetDownloadInfoResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.DirectURL = _field + return nil +} +func (p *GetDownloadInfoResponse) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.RouteURL = _field + return nil +} +func (p *GetDownloadInfoResponse) ReadField4(iprot thrift.TProtocol) error { + _field := NewFileInfo() + if err := _field.Read(iprot); err != nil { + return err + } + p.FileInfo = _field + return nil +} +func (p *GetDownloadInfoResponse) ReadField5(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ErrorMsg = _field + return nil +} + +func (p *GetDownloadInfoResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetDownloadInfoResponse"); 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 *GetDownloadInfoResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("success", thrift.BOOL, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(p.Success); 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 *GetDownloadInfoResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("direct_url", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.DirectURL); 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 *GetDownloadInfoResponse) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("route_url", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.RouteURL); 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 *GetDownloadInfoResponse) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_info", thrift.STRUCT, 4); err != nil { + goto WriteFieldBeginError + } + if err := p.FileInfo.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 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *GetDownloadInfoResponse) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("error_msg", thrift.STRING, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ErrorMsg); 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 *GetDownloadInfoResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetDownloadInfoResponse(%+v)", *p) + +} + +/** + * 文件删除请求 + */ +type DeleteFileRequest struct { + // 文件ID + FileID string `thrift:"file_id,1" form:"file_id" json:"file_id" query:"file_id"` +} + +func NewDeleteFileRequest() *DeleteFileRequest { + return &DeleteFileRequest{} +} + +func (p *DeleteFileRequest) InitDefault() { +} + +func (p *DeleteFileRequest) GetFileID() (v string) { + return p.FileID +} + +var fieldIDToName_DeleteFileRequest = map[int16]string{ + 1: "file_id", +} + +func (p *DeleteFileRequest) 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_DeleteFileRequest[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 *DeleteFileRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FileID = _field + return nil +} + +func (p *DeleteFileRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("DeleteFileRequest"); 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 *DeleteFileRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_id", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FileID); 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 *DeleteFileRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("DeleteFileRequest(%+v)", *p) + +} + +/** + * 通用操作响应 + */ +type CommonResponse struct { + // 操作是否成功 + Success bool `thrift:"success,1" form:"success" json:"success" query:"success"` + // 错误信息(失败时返回) + ErrorMsg string `thrift:"error_msg,2" form:"error_msg" json:"error_msg" query:"error_msg"` +} + +func NewCommonResponse() *CommonResponse { + return &CommonResponse{} +} + +func (p *CommonResponse) InitDefault() { +} + +func (p *CommonResponse) GetSuccess() (v bool) { + return p.Success +} + +func (p *CommonResponse) GetErrorMsg() (v string) { + return p.ErrorMsg +} + +var fieldIDToName_CommonResponse = map[int16]string{ + 1: "success", + 2: "error_msg", +} + +func (p *CommonResponse) 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.BOOL { + 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_CommonResponse[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 *CommonResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = v + } + p.Success = _field + return nil +} +func (p *CommonResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.ErrorMsg = _field + return nil +} + +func (p *CommonResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("CommonResponse"); 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 *CommonResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("success", thrift.BOOL, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(p.Success); 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 *CommonResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("error_msg", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.ErrorMsg); 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 *CommonResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("CommonResponse(%+v)", *p) + +} + +/** + * 文件服务接口定义(基于路由下载) + */ +type FileService interface { + /** + * 上传文件到MinIO + * 返回包含下载路由的信息 + */ + UploadFile(ctx context.Context, request *UploadFileRequest) (r *UploadFileResponse, err error) + /** + * 获取文件下载信息(包含直接URL和路由地址) + */ + GetDownloadInfo(ctx context.Context, request *GetDownloadInfoRequest) (r *GetDownloadInfoResponse, err error) + /** + * 从MinIO删除文件 + */ + DeleteFile(ctx context.Context, request *DeleteFileRequest) (r *CommonResponse, err error) + /** + * 获取文件元信息 + */ + GetFileInfo(ctx context.Context, fileID string) (r *FileInfo, err error) +} + +type FileServiceClient struct { + c thrift.TClient +} + +func NewFileServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *FileServiceClient { + return &FileServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewFileServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *FileServiceClient { + return &FileServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewFileServiceClient(c thrift.TClient) *FileServiceClient { + return &FileServiceClient{ + c: c, + } +} + +func (p *FileServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *FileServiceClient) UploadFile(ctx context.Context, request *UploadFileRequest) (r *UploadFileResponse, err error) { + var _args FileServiceUploadFileArgs + _args.Request = request + var _result FileServiceUploadFileResult + if err = p.Client_().Call(ctx, "UploadFile", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *FileServiceClient) GetDownloadInfo(ctx context.Context, request *GetDownloadInfoRequest) (r *GetDownloadInfoResponse, err error) { + var _args FileServiceGetDownloadInfoArgs + _args.Request = request + var _result FileServiceGetDownloadInfoResult + if err = p.Client_().Call(ctx, "GetDownloadInfo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *FileServiceClient) DeleteFile(ctx context.Context, request *DeleteFileRequest) (r *CommonResponse, err error) { + var _args FileServiceDeleteFileArgs + _args.Request = request + var _result FileServiceDeleteFileResult + if err = p.Client_().Call(ctx, "DeleteFile", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *FileServiceClient) GetFileInfo(ctx context.Context, fileID string) (r *FileInfo, err error) { + var _args FileServiceGetFileInfoArgs + _args.FileID = fileID + var _result FileServiceGetFileInfoResult + if err = p.Client_().Call(ctx, "GetFileInfo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type FileServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler FileService +} + +func (p *FileServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *FileServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *FileServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewFileServiceProcessor(handler FileService) *FileServiceProcessor { + self := &FileServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("UploadFile", &fileServiceProcessorUploadFile{handler: handler}) + self.AddToProcessorMap("GetDownloadInfo", &fileServiceProcessorGetDownloadInfo{handler: handler}) + self.AddToProcessorMap("DeleteFile", &fileServiceProcessorDeleteFile{handler: handler}) + self.AddToProcessorMap("GetFileInfo", &fileServiceProcessorGetFileInfo{handler: handler}) + return self +} +func (p *FileServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type fileServiceProcessorUploadFile struct { + handler FileService +} + +func (p *fileServiceProcessorUploadFile) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := FileServiceUploadFileArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("UploadFile", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := FileServiceUploadFileResult{} + var retval *UploadFileResponse + if retval, err2 = p.handler.UploadFile(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing UploadFile: "+err2.Error()) + oprot.WriteMessageBegin("UploadFile", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("UploadFile", 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 fileServiceProcessorGetDownloadInfo struct { + handler FileService +} + +func (p *fileServiceProcessorGetDownloadInfo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := FileServiceGetDownloadInfoArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("GetDownloadInfo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := FileServiceGetDownloadInfoResult{} + var retval *GetDownloadInfoResponse + if retval, err2 = p.handler.GetDownloadInfo(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing GetDownloadInfo: "+err2.Error()) + oprot.WriteMessageBegin("GetDownloadInfo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("GetDownloadInfo", 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 fileServiceProcessorDeleteFile struct { + handler FileService +} + +func (p *fileServiceProcessorDeleteFile) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := FileServiceDeleteFileArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("DeleteFile", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := FileServiceDeleteFileResult{} + var retval *CommonResponse + if retval, err2 = p.handler.DeleteFile(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing DeleteFile: "+err2.Error()) + oprot.WriteMessageBegin("DeleteFile", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("DeleteFile", 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 fileServiceProcessorGetFileInfo struct { + handler FileService +} + +func (p *fileServiceProcessorGetFileInfo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := FileServiceGetFileInfoArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("GetFileInfo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := FileServiceGetFileInfoResult{} + var retval *FileInfo + if retval, err2 = p.handler.GetFileInfo(ctx, args.FileID); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing GetFileInfo: "+err2.Error()) + oprot.WriteMessageBegin("GetFileInfo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("GetFileInfo", 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 FileServiceUploadFileArgs struct { + Request *UploadFileRequest `thrift:"request,1"` +} + +func NewFileServiceUploadFileArgs() *FileServiceUploadFileArgs { + return &FileServiceUploadFileArgs{} +} + +func (p *FileServiceUploadFileArgs) InitDefault() { +} + +var FileServiceUploadFileArgs_Request_DEFAULT *UploadFileRequest + +func (p *FileServiceUploadFileArgs) GetRequest() (v *UploadFileRequest) { + if !p.IsSetRequest() { + return FileServiceUploadFileArgs_Request_DEFAULT + } + return p.Request +} + +var fieldIDToName_FileServiceUploadFileArgs = map[int16]string{ + 1: "request", +} + +func (p *FileServiceUploadFileArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *FileServiceUploadFileArgs) 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_FileServiceUploadFileArgs[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 *FileServiceUploadFileArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewUploadFileRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Request = _field + return nil +} + +func (p *FileServiceUploadFileArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UploadFile_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 *FileServiceUploadFileArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.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 *FileServiceUploadFileArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceUploadFileArgs(%+v)", *p) + +} + +type FileServiceUploadFileResult struct { + Success *UploadFileResponse `thrift:"success,0,optional"` +} + +func NewFileServiceUploadFileResult() *FileServiceUploadFileResult { + return &FileServiceUploadFileResult{} +} + +func (p *FileServiceUploadFileResult) InitDefault() { +} + +var FileServiceUploadFileResult_Success_DEFAULT *UploadFileResponse + +func (p *FileServiceUploadFileResult) GetSuccess() (v *UploadFileResponse) { + if !p.IsSetSuccess() { + return FileServiceUploadFileResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_FileServiceUploadFileResult = map[int16]string{ + 0: "success", +} + +func (p *FileServiceUploadFileResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *FileServiceUploadFileResult) 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_FileServiceUploadFileResult[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 *FileServiceUploadFileResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewUploadFileResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *FileServiceUploadFileResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UploadFile_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 *FileServiceUploadFileResult) 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 *FileServiceUploadFileResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceUploadFileResult(%+v)", *p) + +} + +type FileServiceGetDownloadInfoArgs struct { + Request *GetDownloadInfoRequest `thrift:"request,1"` +} + +func NewFileServiceGetDownloadInfoArgs() *FileServiceGetDownloadInfoArgs { + return &FileServiceGetDownloadInfoArgs{} +} + +func (p *FileServiceGetDownloadInfoArgs) InitDefault() { +} + +var FileServiceGetDownloadInfoArgs_Request_DEFAULT *GetDownloadInfoRequest + +func (p *FileServiceGetDownloadInfoArgs) GetRequest() (v *GetDownloadInfoRequest) { + if !p.IsSetRequest() { + return FileServiceGetDownloadInfoArgs_Request_DEFAULT + } + return p.Request +} + +var fieldIDToName_FileServiceGetDownloadInfoArgs = map[int16]string{ + 1: "request", +} + +func (p *FileServiceGetDownloadInfoArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *FileServiceGetDownloadInfoArgs) 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_FileServiceGetDownloadInfoArgs[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 *FileServiceGetDownloadInfoArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewGetDownloadInfoRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Request = _field + return nil +} + +func (p *FileServiceGetDownloadInfoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetDownloadInfo_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 *FileServiceGetDownloadInfoArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.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 *FileServiceGetDownloadInfoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceGetDownloadInfoArgs(%+v)", *p) + +} + +type FileServiceGetDownloadInfoResult struct { + Success *GetDownloadInfoResponse `thrift:"success,0,optional"` +} + +func NewFileServiceGetDownloadInfoResult() *FileServiceGetDownloadInfoResult { + return &FileServiceGetDownloadInfoResult{} +} + +func (p *FileServiceGetDownloadInfoResult) InitDefault() { +} + +var FileServiceGetDownloadInfoResult_Success_DEFAULT *GetDownloadInfoResponse + +func (p *FileServiceGetDownloadInfoResult) GetSuccess() (v *GetDownloadInfoResponse) { + if !p.IsSetSuccess() { + return FileServiceGetDownloadInfoResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_FileServiceGetDownloadInfoResult = map[int16]string{ + 0: "success", +} + +func (p *FileServiceGetDownloadInfoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *FileServiceGetDownloadInfoResult) 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_FileServiceGetDownloadInfoResult[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 *FileServiceGetDownloadInfoResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewGetDownloadInfoResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *FileServiceGetDownloadInfoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetDownloadInfo_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 *FileServiceGetDownloadInfoResult) 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 *FileServiceGetDownloadInfoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceGetDownloadInfoResult(%+v)", *p) + +} + +type FileServiceDeleteFileArgs struct { + Request *DeleteFileRequest `thrift:"request,1"` +} + +func NewFileServiceDeleteFileArgs() *FileServiceDeleteFileArgs { + return &FileServiceDeleteFileArgs{} +} + +func (p *FileServiceDeleteFileArgs) InitDefault() { +} + +var FileServiceDeleteFileArgs_Request_DEFAULT *DeleteFileRequest + +func (p *FileServiceDeleteFileArgs) GetRequest() (v *DeleteFileRequest) { + if !p.IsSetRequest() { + return FileServiceDeleteFileArgs_Request_DEFAULT + } + return p.Request +} + +var fieldIDToName_FileServiceDeleteFileArgs = map[int16]string{ + 1: "request", +} + +func (p *FileServiceDeleteFileArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *FileServiceDeleteFileArgs) 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_FileServiceDeleteFileArgs[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 *FileServiceDeleteFileArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewDeleteFileRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Request = _field + return nil +} + +func (p *FileServiceDeleteFileArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("DeleteFile_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 *FileServiceDeleteFileArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.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 *FileServiceDeleteFileArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceDeleteFileArgs(%+v)", *p) + +} + +type FileServiceDeleteFileResult struct { + Success *CommonResponse `thrift:"success,0,optional"` +} + +func NewFileServiceDeleteFileResult() *FileServiceDeleteFileResult { + return &FileServiceDeleteFileResult{} +} + +func (p *FileServiceDeleteFileResult) InitDefault() { +} + +var FileServiceDeleteFileResult_Success_DEFAULT *CommonResponse + +func (p *FileServiceDeleteFileResult) GetSuccess() (v *CommonResponse) { + if !p.IsSetSuccess() { + return FileServiceDeleteFileResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_FileServiceDeleteFileResult = map[int16]string{ + 0: "success", +} + +func (p *FileServiceDeleteFileResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *FileServiceDeleteFileResult) 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_FileServiceDeleteFileResult[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 *FileServiceDeleteFileResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewCommonResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *FileServiceDeleteFileResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("DeleteFile_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 *FileServiceDeleteFileResult) 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 *FileServiceDeleteFileResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceDeleteFileResult(%+v)", *p) + +} + +type FileServiceGetFileInfoArgs struct { + FileID string `thrift:"file_id,1"` +} + +func NewFileServiceGetFileInfoArgs() *FileServiceGetFileInfoArgs { + return &FileServiceGetFileInfoArgs{} +} + +func (p *FileServiceGetFileInfoArgs) InitDefault() { +} + +func (p *FileServiceGetFileInfoArgs) GetFileID() (v string) { + return p.FileID +} + +var fieldIDToName_FileServiceGetFileInfoArgs = map[int16]string{ + 1: "file_id", +} + +func (p *FileServiceGetFileInfoArgs) 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_FileServiceGetFileInfoArgs[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 *FileServiceGetFileInfoArgs) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.FileID = _field + return nil +} + +func (p *FileServiceGetFileInfoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetFileInfo_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 *FileServiceGetFileInfoArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("file_id", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.FileID); 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 *FileServiceGetFileInfoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceGetFileInfoArgs(%+v)", *p) + +} + +type FileServiceGetFileInfoResult struct { + Success *FileInfo `thrift:"success,0,optional"` +} + +func NewFileServiceGetFileInfoResult() *FileServiceGetFileInfoResult { + return &FileServiceGetFileInfoResult{} +} + +func (p *FileServiceGetFileInfoResult) InitDefault() { +} + +var FileServiceGetFileInfoResult_Success_DEFAULT *FileInfo + +func (p *FileServiceGetFileInfoResult) GetSuccess() (v *FileInfo) { + if !p.IsSetSuccess() { + return FileServiceGetFileInfoResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_FileServiceGetFileInfoResult = map[int16]string{ + 0: "success", +} + +func (p *FileServiceGetFileInfoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *FileServiceGetFileInfoResult) 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_FileServiceGetFileInfoResult[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 *FileServiceGetFileInfoResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewFileInfo() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *FileServiceGetFileInfoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetFileInfo_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 *FileServiceGetFileInfoResult) 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 *FileServiceGetFileInfoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("FileServiceGetFileInfoResult(%+v)", *p) + +} diff --git a/pushNotificationCenter/biz/model/user.go b/pushNotificationCenter/biz/model/user.go new file mode 100644 index 0000000..150baab --- /dev/null +++ b/pushNotificationCenter/biz/model/user.go @@ -0,0 +1,30 @@ +package model + +import ( + "encoding/json" + "gorm.io/gorm" + "time" +) + +type User struct { + gorm.Model + UserID string `gorm:"column:user_id;type:varchar(32);uniqueIndex:idx_user_id;not null;comment:'用户唯一标识'"` + UserName string `gorm:"column:user_name;type:varchar(50);uniqueIndex:idx_user_name;not null;comment:'用户昵称'"` + Gender int8 `gorm:"column:gender;type:tinyint unsigned;default:0;comment:'性别;0:保密,1:男,2:女'"` + Age uint8 `gorm:"column:age;type:tinyint unsigned;default:0;comment:'年龄(岁)'"` + 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 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 int8 `gorm:"column:user_status;type:tinyint unsigned;default:1;comment:'用户状态;0:禁用,1:正常,2:注销'"` + UserEmail string `gorm:"column:email;type:varchar(100);comment:'用户邮箱'"` + Alias string `gorm:"column:alias;type:varchar(50);comment:'用户别名'"` + Address string `gorm:"column:address;type:text;comment:'用户详细地址'"` + LastLoginIP string `gorm:"column:last_login_ip;type:varchar(15);comment:'上次登录IP(IPv4)'"` + LastLoginTime *time.Time `gorm:"column:last_login_time;type:datetime;comment:'上次登录时间'"` + UserSalt string `gorm:"column:user_salt;type:varchar(16);not null;comment:'密码加密盐'"` + // 扩展字段(预留) + ExtraInfo json.RawMessage `gorm:"column:extra_info;type:json;comment:'预留'"` +} diff --git a/pushNotificationCenter/biz/router/file/service/middleware.go b/pushNotificationCenter/biz/router/file/service/middleware.go new file mode 100644 index 0000000..0e9197a --- /dev/null +++ b/pushNotificationCenter/biz/router/file/service/middleware.go @@ -0,0 +1,47 @@ +// Code generated by hertz generator. + +package service + +import ( + "github.com/cloudwego/hertz/pkg/app" +) + +func rootMw() []app.HandlerFunc { + // your code... + return nil +} + +func _v1Mw() []app.HandlerFunc { + // your code... + return nil +} + +func _fileMw() []app.HandlerFunc { + // your code... + return nil +} + +func _deletefileMw() []app.HandlerFunc { + // your code... + return nil +} + +func _getdownloadinfoMw() []app.HandlerFunc { + // your code... + return nil +} + +func _uploadfileMw() []app.HandlerFunc { + // your code... + return nil +} + +func _infoMw() []app.HandlerFunc { + // your code... + return nil +} + +func _getfileinfoMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/pushNotificationCenter/biz/router/file/service/minio.go b/pushNotificationCenter/biz/router/file/service/minio.go new file mode 100644 index 0000000..b4a0dad --- /dev/null +++ b/pushNotificationCenter/biz/router/file/service/minio.go @@ -0,0 +1,48 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package service + +import ( + "github.com/cloudwego/hertz/pkg/app/server" + service "pushNotificationCenter/biz/handler/file/service" + "github.com/hertz-contrib/cors" +) + +/* + This file will register all the routes of the services in the master idl. + And it will update automatically when you use the "update" command for the idl. + So don't modify the contents of the file, or your code will be deleted when it is updated. +*/ + +// Register register routes based on the IDL 'api.${HTTP Method}' annotation. +func Register(r *server.Hertz) { + + root := r.Group("/", rootMw()...) + { + _v1 := root.Group("/v1", _v1Mw()...) + _v1.Use(cors.New(cors.Config{ + // 允许的源( origins ),* 表示允许所有源(生产环境建议指定具体域名) + AllowOrigins: []string{"*"}, + // 允许的请求方法 + AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, + // 允许的请求头 + AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization"}, + // 是否允许发送 Cookie + AllowCredentials: true, + // 预检请求的有效期(秒),在此期间不需要重复发送预检请求 + MaxAge: 12 * 3600, + // 允许暴露的响应头(前端通过 XMLHttpRequest 可以访问的头信息) + ExposeHeaders: []string{"Content-Length"}, + })) + { + _file := _v1.Group("/file", _fileMw()...) + _file.DELETE("/", append(_deletefileMw(), service.DeleteFile)...) + _file.GET("/", append(_getdownloadinfoMw(), service.GetDownloadInfo)...) + _file.POST("/", append(_uploadfileMw(), service.UploadFile)...) + { + _info := _file.Group("/info", _infoMw()...) + _info.DELETE("/", append(_getfileinfoMw(), service.GetFileInfo)...) + } + } + } +} diff --git a/pushNotificationCenter/biz/router/register.go b/pushNotificationCenter/biz/router/register.go index efde969..6d89e26 100644 --- a/pushNotificationCenter/biz/router/register.go +++ b/pushNotificationCenter/biz/router/register.go @@ -8,6 +8,7 @@ import ( "github.com/cloudwego/hertz/pkg/common/hlog" "net/http" "pushNotificationCenter/biz/handler/wsCenter" + file_service "pushNotificationCenter/biz/router/file/service" hello_example "pushNotificationCenter/biz/router/hello/example" "pushNotificationCenter/config" ) @@ -15,6 +16,8 @@ import ( // GeneratedRegister registers routers generated by IDL. func GeneratedRegister(r *server.Hertz) { //INSERT_POINT: DO NOT DELETE THIS LINE! + file_service.Register(r) + hello_example.Register(r) } @@ -26,4 +29,4 @@ func WsListenInit() { } }() -} \ No newline at end of file +} diff --git a/pushNotificationCenter/config.ini b/pushNotificationCenter/config.ini index f3acc9e..5fbe1ea 100644 --- a/pushNotificationCenter/config.ini +++ b/pushNotificationCenter/config.ini @@ -13,9 +13,24 @@ DbPort = 6379 DbUser = root DbPassWord = +#数据库参数 +[database] +MysqlHost = 127.0.0.1 +MysqlPort = 3306 +MysqlUser = root +MysqlPassWord = 123456 +MysqlDBName = iuqt_acquaintances + #ETCD参数 [etcd] EtcdPort = 2379 EtcdHost = 127.0.0.1 EtcdUser = root -EtcdPassword = sixqin@123 \ No newline at end of file +EtcdPassword = sixqin@123 + +#minio参数 +[minio] +MinioHost = 127.0.0.1 +MinioPort = 7000 +MinioUser = admin +MinioPassword = 1234567890 diff --git a/pushNotificationCenter/config/setting.go b/pushNotificationCenter/config/setting.go index 919a4da..698ea7e 100644 --- a/pushNotificationCenter/config/setting.go +++ b/pushNotificationCenter/config/setting.go @@ -17,7 +17,7 @@ var ( //WsPort WsPort string - //数据库 + //redis数据库 Db string //网络地址 DbHost string @@ -31,11 +31,25 @@ var ( DbName string //服务id号 WorkerIDBits int + //etcd EtcdPort string EtcdHost string EtcdUser string EtcdPassword string + + //minio + MinioHost string + MinioPort string + MinioUser string + MinioPassword string + + //mysql + MysqlPassWord string + MysqlHost string + MysqlPort string + MysqlUser string + MysqlDBName string ) // 初始化函数 @@ -47,6 +61,8 @@ func init() { LoadServer(file) LoadDb(file) LoadEtcd(file) + LoadMinio(file) + LoadMysql(file) } // 读取服务器配置 @@ -68,6 +84,15 @@ func LoadDb(file *ini.File) { DbName = file.Section("redis").Key("DbName").MustString("iuqt_pushNotificationCenter") } +// 读取mysql数据库配置 +func LoadMysql(file *ini.File) { + MysqlHost = file.Section("database").Key("MysqlHost").MustString("127.0.0.1") + MysqlPort = file.Section("database").Key("MysqlPort").MustString("3306") + MysqlUser = file.Section("database").Key("MysqlUser").MustString("root") + MysqlPassWord = file.Section("database").Key("MysqlPassWord").MustString("123456") + MysqlDBName = file.Section("database").Key("MysqlDBName").MustString("iuqt_acquaintances") +} + // 读取Etcd参数 func LoadEtcd(file *ini.File) { EtcdHost = file.Section("etcd").Key("EtcdHost").MustString("127.0.0.1") @@ -75,3 +100,11 @@ func LoadEtcd(file *ini.File) { EtcdUser = file.Section("etcd").Key("EtcdUser").MustString("root") EtcdPassword = file.Section("etcd").Key("EtcdPassWord").MustString("sixqin@123") } + +// 读取Minio参数 +func LoadMinio(file *ini.File) { + MinioHost = file.Section("minio").Key("MinioHost").MustString("127.0.0.1") + MinioPort = file.Section("minio").Key("MinioPort").MustString("7000") + MinioUser = file.Section("minio").Key("MinioUser").MustString("admin") + MinioPassword = file.Section("minio").Key("MinioPassword").MustString("1234567890") +} diff --git a/pushNotificationCenter/go.mod b/pushNotificationCenter/go.mod index de3be9f..6fbacc5 100644 --- a/pushNotificationCenter/go.mod +++ b/pushNotificationCenter/go.mod @@ -8,12 +8,17 @@ require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 github.com/cloudwego/hertz v0.10.1 github.com/go-redis/redis/v8 v8.11.5 - github.com/gorilla/websocket v1.4.2 + github.com/gorilla/websocket v1.5.3 + github.com/hertz-contrib/cors v0.1.0 github.com/hertz-contrib/registry/etcd v0.0.0-20250319055937-8a220332e808 + github.com/minio/minio-go/v7 v7.0.94 gopkg.in/ini.v1 v1.51.0 + gorm.io/driver/mysql v1.6.0 + gorm.io/gorm v1.30.0 ) require ( + filippo.io/edwards25519 v1.1.0 // indirect github.com/bytedance/gopkg v0.1.1 // indirect github.com/bytedance/sonic v1.13.2 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect @@ -24,14 +29,27 @@ require ( github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/go-ini/ini v1.67.0 // indirect + github.com/go-sql-driver/mysql v1.8.1 // indirect + github.com/goccy/go-json v0.10.5 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/klauspost/compress v1.18.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.10 // indirect + github.com/minio/crc64nvme v1.0.1 // indirect + github.com/minio/md5-simd v1.1.2 // indirect github.com/nyaruka/phonenumbers v1.0.55 // indirect + github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect + github.com/rs/xid v1.6.0 // indirect github.com/tidwall/gjson v1.14.4 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect + github.com/tinylib/msgp v1.3.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect go.etcd.io/etcd/api/v3 v3.5.7 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect @@ -40,9 +58,10 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect - golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.38.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect google.golang.org/grpc v1.41.0 // indirect google.golang.org/protobuf v1.34.1 // indirect diff --git a/pushNotificationCenter/go.sum b/pushNotificationCenter/go.sum index 4e38f2c..aff9c54 100644 --- a/pushNotificationCenter/go.sum +++ b/pushNotificationCenter/go.sum @@ -11,6 +11,8 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -31,10 +33,15 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/bytedance/go-tagexpr/v2 v2.9.2/go.mod h1:5qsx05dYOiUXOUgnQ7w3Oz8BYs2qtM/bJokdLb79wRM= +github.com/bytedance/gopkg v0.0.0-20220413063733-65bf48ffb3a7/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= +github.com/bytedance/mockey v1.2.1/go.mod h1:+Jm/fzWZAuhEDrPXVjDf/jLM2BlLXJkwk94zf2JZ3X4= github.com/bytedance/mockey v1.2.12/go.mod h1:3ZA4MQasmqC87Tw0w7Ygdy7eHIc2xgpZ8Pona5rsYIk= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.8.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I= github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= @@ -51,16 +58,20 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/gopkg v0.1.4 h1:EoQiCG4sTonTPHxOGE0VlQs+sQR+Hsi2uN0qqwu8O50= github.com/cloudwego/gopkg v0.1.4/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= +github.com/cloudwego/hertz v0.6.2/go.mod h1:2em2hGREvCBawsTQcQxyWBGVlCeo+N1pp2q0HkkbwR0= github.com/cloudwego/hertz v0.9.6/go.mod h1:X5Ez52XhtszU4t+CTBGIJI4PqmcI1oSf8ULBz0SWfLo= github.com/cloudwego/hertz v0.10.1 h1:gTM2JIGO7vmRoaDz71GctyoUE19pXGuznFX55HjGs1g= github.com/cloudwego/hertz v0.10.1/go.mod h1:0sofikwk5YcHCerClgCzcaoamY61JiRwR5G0mAUo+Y0= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= github.com/cloudwego/netpoll v0.6.4/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= github.com/cloudwego/netpoll v0.7.0 h1:bDrxQaNfijRI1zyGgXHQoE/nYegL0nr+ijO1Norelc4= github.com/cloudwego/netpoll v0.7.0/go.mod h1:PI+YrmyS7cIr0+SD4seJz3Eo3ckkXdu2ZVKBLhURLNU= @@ -90,8 +101,9 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -107,6 +119,8 @@ github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmV github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= +github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -115,7 +129,11 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= +github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -165,12 +183,15 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= @@ -199,9 +220,18 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/henrylee2cn/ameda v1.4.8/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/ameda v1.4.10/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8/go.mod h1:Nhe/DM3671a5udlv2AdV2ni/MZzgfv2qrPL5nIi3EGQ= +github.com/hertz-contrib/cors v0.1.0 h1:PQ5mATygSMzTlYtfyMyHjobYoJeHKe2Qt3tcAOgbI6E= +github.com/hertz-contrib/cors v0.1.0/go.mod h1:VPReoq+Rvu/lZOfpp5CcX3x4mpZUc3EpSXBcVDcbvOc= github.com/hertz-contrib/registry/etcd v0.0.0-20250319055937-8a220332e808 h1:lxr8/UejpKb5mZ7D27fIFZNwm0qn/exw38wtDYd2F5Q= github.com/hertz-contrib/registry/etcd v0.0.0-20250319055937-8a220332e808/go.mod h1:r1ek0FpFPqYRnsIG8vhM40NQMPpCE/RO9NaiUQv+vS4= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= @@ -219,8 +249,12 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= +github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -235,6 +269,12 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/minio/crc64nvme v1.0.1 h1:DHQPrYPdqK7jQG/Ls5CTBZWeex/2FMS3G5XGkycuFrY= +github.com/minio/crc64nvme v1.0.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= +github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= +github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= +github.com/minio/minio-go/v7 v7.0.94 h1:1ZoksIKPyaSt64AVOyaQvhDOgVC3MfZsWM6mZXRUGtM= +github.com/minio/minio-go/v7 v7.0.94/go.mod h1:71t2CqDt3ThzESgZUlU1rBN54mksGGlkLcFgguDnnAc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -263,6 +303,8 @@ github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5h github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY= +github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -297,6 +339,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -341,12 +385,16 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww= +github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -414,8 +462,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -470,8 +519,9 @@ golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -487,8 +537,9 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -519,6 +570,7 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -528,8 +580,9 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= @@ -547,8 +600,9 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE= @@ -661,6 +715,10 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg= +gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo= +gorm.io/gorm v1.30.0 h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs= +gorm.io/gorm v1.30.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pushNotificationCenter/idl/minio.thrift b/pushNotificationCenter/idl/minio.thrift new file mode 100644 index 0000000..b6c251e --- /dev/null +++ b/pushNotificationCenter/idl/minio.thrift @@ -0,0 +1,97 @@ +namespace go file.service + +/** + * 文件元数据信息 + */ +struct FileInfo { + 1: string file_id // 文件唯一标识 + 2: string file_name // 文件名 + 3: string content_type // 文件类型(MIME) + 4: i64 file_size // 文件大小(字节) + 5: string bucket_name // 存储桶名称 + 6: string object_key // MinIO中的对象键(路径) + 7: i64 upload_time // 上传时间(timestamp) + 8: string download_url // 直接下载URL + 9: string etag // 文件校验值 +} + +/** + * 上传文件请求 + */ +struct UploadFileRequest { + 1: binary file_content // 文件内容二进制 + 2: string file_name // 文件名 + 3: string content_type // 文件类型 + 4: string bucket_name // 目标存储桶 + 5: string object_prefix // 可选的对象存储前缀路径 +} + +/** + * 上传文件响应 + */ +struct UploadFileResponse { + 1: bool success // 操作是否成功 + 2: FileInfo file_info // 文件信息(成功时返回) + 3: string error_msg // 错误信息(失败时返回) + 4: string download_route // 下载路由地址,如 "/file/download/{file_id}" +} + +/** + * 获取文件下载信息请求 + */ +struct GetDownloadInfoRequest { + 1: string file_id // 文件唯一标识 + 2: i64 expire_seconds // URL有效期(秒),默认3600 +} + +/** + * 文件下载信息响应 + */ +struct GetDownloadInfoResponse { + 1: bool success // 操作是否成功 + 2: string direct_url // 直接下载URL(可用于浏览器直接访问) + 3: string route_url // 应用内下载路由,如 "/file/download/xxx" + 4: FileInfo file_info // 文件元信息 + 5: string error_msg // 错误信息(失败时返回) +} + +/** + * 文件删除请求 + */ +struct DeleteFileRequest { + 1: string file_id // 文件ID +} + +/** + * 通用操作响应 + */ +struct CommonResponse { + 1: bool success // 操作是否成功 + 2: string error_msg // 错误信息(失败时返回) +} + +/** + * 文件服务接口定义(基于路由下载) + */ +service FileService { + /** + * 上传文件到MinIO + * 返回包含下载路由的信息 + */ + UploadFileResponse UploadFile(1: UploadFileRequest request)(api.post="/v1/file/") + + /** + * 获取文件下载信息(包含直接URL和路由地址) + */ + GetDownloadInfoResponse GetDownloadInfo(1: GetDownloadInfoRequest request)(api.get="/v1/file/") + + /** + * 从MinIO删除文件 + */ + CommonResponse DeleteFile(1: DeleteFileRequest request)(api.delete="/v1/file/") + + /** + * 获取文件元信息 + */ + FileInfo GetFileInfo(1: string file_id)(api.delete="/v1/file/info/") +} diff --git a/pushNotificationCenter/main.go b/pushNotificationCenter/main.go index e95174f..3f90df6 100644 --- a/pushNotificationCenter/main.go +++ b/pushNotificationCenter/main.go @@ -26,6 +26,7 @@ func main() { // ... addr := fmt.Sprintf("%s:%s", config.ServerHost, config.HttpPort) h := server.Default( + server.WithMaxRequestBodySize(10*1024*1024), server.WithHostPorts(addr), server.WithRegistry(r, ®istry.Info{ ServiceName: config.ServiceName, diff --git a/pushNotificationCenter/protocol/message.go b/pushNotificationCenter/protocol/message.go index 9bc1bdb..8605e37 100644 --- a/pushNotificationCenter/protocol/message.go +++ b/pushNotificationCenter/protocol/message.go @@ -1,7 +1,5 @@ package protocol -import "encoding/json" - // 消息类型 const ( TypePrivate = "private" @@ -11,13 +9,13 @@ const ( // 消息结构 type Message struct { - Type string `json:"type"` // 消息类型: private/group - FileType string `json:"file_type"` // 消息类型: private/group - From string `json:"from"` // 发送者ID - To string `json:"to"` // 接收者ID(用户或群组) - Content json.RawMessage `json:"content"` // 消息内容 - MsgID string `json:"msg_id"` // 消息唯一ID - SendTime string `json:"send_time"` // 发送时间 + Type string `json:"type"` // 消息类型: private/group + FileType string `json:"file_type"` // 消息类型: private/group + From string `json:"from"` // 发送者ID + To string `json:"to"` // 接收者ID(用户或群组) + Content string `json:"content"` // 消息内容 + MsgID string `json:"msg_id"` // 消息唯一ID + SendTime string `json:"send_time"` // 发送时间 } // 系统消息