diff --git a/auto/api/m/v1/user.go b/auto/api/m/v1/user.go index 7b6842fe..ee4e4bb5 100644 --- a/auto/api/m/v1/user.go +++ b/auto/api/m/v1/user.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -12,7 +12,7 @@ import ( ) type _binding_ interface { - Bind(*gin.Context) mir.Error + Bind(*gin.Context) error } type _render_ interface { @@ -20,8 +20,8 @@ type _render_ interface { } type _default_ interface { - Bind(*gin.Context, any) mir.Error - Render(*gin.Context, any, mir.Error) + Bind(*gin.Context, any) error + Render(*gin.Context, any, error) } type LoginReq struct { @@ -55,8 +55,8 @@ type User interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - Logout() mir.Error - Login(*LoginReq) (*LoginResp, mir.Error) + Logout() error + Login(*LoginReq) (*LoginResp, error) mustEmbedUnimplementedUserServant() } @@ -101,11 +101,11 @@ func (UnimplementedUserServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedUserServant) Logout() mir.Error { +func (UnimplementedUserServant) Logout() error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) { +func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/r/v1/user.go b/auto/api/r/v1/user.go index 5fc6f743..74908ba6 100644 --- a/auto/api/r/v1/user.go +++ b/auto/api/r/v1/user.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -12,7 +12,7 @@ import ( ) type _binding_ interface { - Bind(*gin.Context) mir.Error + Bind(*gin.Context) error } type _render_ interface { @@ -20,8 +20,8 @@ type _render_ interface { } type _default_ interface { - Bind(*gin.Context, any) mir.Error - Render(*gin.Context, any, mir.Error) + Bind(*gin.Context, any) error + Render(*gin.Context, any, error) } type LoginReq struct { @@ -55,8 +55,8 @@ type User interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - Logout() mir.Error - Login(*LoginReq) (*LoginResp, mir.Error) + Logout() error + Login(*LoginReq) (*LoginResp, error) mustEmbedUnimplementedUserServant() } @@ -101,11 +101,11 @@ func (UnimplementedUserServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedUserServant) Logout() mir.Error { +func (UnimplementedUserServant) Logout() error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) { +func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/s/v1/user.go b/auto/api/s/v1/user.go index 053acf88..472888a1 100644 --- a/auto/api/s/v1/user.go +++ b/auto/api/s/v1/user.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -12,7 +12,7 @@ import ( ) type _binding_ interface { - Bind(*gin.Context) mir.Error + Bind(*gin.Context) error } type _render_ interface { @@ -20,8 +20,8 @@ type _render_ interface { } type _default_ interface { - Bind(*gin.Context, any) mir.Error - Render(*gin.Context, any, mir.Error) + Bind(*gin.Context, any) error + Render(*gin.Context, any, error) } type LoginReq struct { @@ -52,9 +52,9 @@ type UserInfo struct { type User interface { _default_ - Logout() mir.Error - Login(*LoginReq) (*LoginResp, mir.Error) - Index() mir.Error + Logout() error + Login(*LoginReq) (*LoginResp, error) + Index() error mustEmbedUnimplementedUserServant() } @@ -101,15 +101,15 @@ func RegisterUserServant(e *gin.Engine, s User) { // UnimplementedUserServant can be embedded to have forward compatible implementations. type UnimplementedUserServant struct{} -func (UnimplementedUserServant) Logout() mir.Error { +func (UnimplementedUserServant) Logout() error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) { +func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedUserServant) Index() mir.Error { +func (UnimplementedUserServant) Index() error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/admin.go b/auto/api/v1/admin.go index 3b0e9606..c58b234a 100644 --- a/auto/api/v1/admin.go +++ b/auto/api/v1/admin.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -13,7 +13,7 @@ import ( ) type _binding_ interface { - Bind(*gin.Context) mir.Error + Bind(*gin.Context) error } type _render_ interface { @@ -21,9 +21,9 @@ type _render_ interface { } type _default_ interface { - Bind(*gin.Context, any) mir.Error - BindJson(*gin.Context, any) mir.Error - Render(*gin.Context, any, mir.Error) + Bind(*gin.Context, any) error + BindJson(*gin.Context, any) error + Render(*gin.Context, any, error) } type Admin interface { @@ -32,8 +32,8 @@ type Admin interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - SiteInfo(*web.SiteInfoReq) (*web.SiteInfoResp, mir.Error) - ChangeUserStatus(*web.ChangeUserStatusReq) mir.Error + SiteInfo(*web.SiteInfoReq) (*web.SiteInfoResp, error) + ChangeUserStatus(*web.ChangeUserStatusReq) error mustEmbedUnimplementedAdminServant() } @@ -82,11 +82,11 @@ func (UnimplementedAdminServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedAdminServant) SiteInfo(req *web.SiteInfoReq) (*web.SiteInfoResp, mir.Error) { +func (UnimplementedAdminServant) SiteInfo(req *web.SiteInfoReq) (*web.SiteInfoResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedAdminServant) ChangeUserStatus(req *web.ChangeUserStatusReq) mir.Error { +func (UnimplementedAdminServant) ChangeUserStatus(req *web.ChangeUserStatusReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/alipay_priv.go b/auto/api/v1/alipay_priv.go index 3330907f..a689b96f 100644 --- a/auto/api/v1/alipay_priv.go +++ b/auto/api/v1/alipay_priv.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,9 +18,9 @@ type AlipayPriv interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - UserWalletBills(*web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error) - UserRechargeResult(*web.UserRechargeResultReq) (*web.UserRechargeResultResp, mir.Error) - UserRechargeLink(*web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, mir.Error) + UserWalletBills(*web.UserWalletBillsReq) (*web.UserWalletBillsResp, error) + UserRechargeResult(*web.UserRechargeResultReq) (*web.UserRechargeResultResp, error) + UserRechargeLink(*web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, error) mustEmbedUnimplementedAlipayPrivServant() } @@ -40,8 +40,7 @@ func RegisterAlipayPrivServant(e *gin.Engine, s AlipayPriv) { default: } req := new(web.UserWalletBillsReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -55,8 +54,7 @@ func RegisterAlipayPrivServant(e *gin.Engine, s AlipayPriv) { default: } req := new(web.UserRechargeResultReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -70,8 +68,7 @@ func RegisterAlipayPrivServant(e *gin.Engine, s AlipayPriv) { default: } req := new(web.UserRechargeLinkReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -87,15 +84,15 @@ func (UnimplementedAlipayPrivServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedAlipayPrivServant) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error) { +func (UnimplementedAlipayPrivServant) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserWalletBillsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedAlipayPrivServant) UserRechargeResult(req *web.UserRechargeResultReq) (*web.UserRechargeResultResp, mir.Error) { +func (UnimplementedAlipayPrivServant) UserRechargeResult(req *web.UserRechargeResultReq) (*web.UserRechargeResultResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedAlipayPrivServant) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, mir.Error) { +func (UnimplementedAlipayPrivServant) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/alipay_pub.go b/auto/api/v1/alipay_pub.go index a6fdeef9..1acc6b91 100644 --- a/auto/api/v1/alipay_pub.go +++ b/auto/api/v1/alipay_pub.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -15,7 +15,7 @@ import ( type AlipayPub interface { _default_ - AlipayNotify(*web.AlipayNotifyReq) mir.Error + AlipayNotify(*web.AlipayNotifyReq) error mustEmbedUnimplementedAlipayPubServant() } @@ -32,8 +32,7 @@ func RegisterAlipayPubServant(e *gin.Engine, s AlipayPub) { default: } req := new(web.AlipayNotifyReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -44,7 +43,7 @@ func RegisterAlipayPubServant(e *gin.Engine, s AlipayPub) { // UnimplementedAlipayPubServant can be embedded to have forward compatible implementations. type UnimplementedAlipayPubServant struct{} -func (UnimplementedAlipayPubServant) AlipayNotify(req *web.AlipayNotifyReq) mir.Error { +func (UnimplementedAlipayPubServant) AlipayNotify(req *web.AlipayNotifyReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/core.go b/auto/api/v1/core.go index 2df5e66b..c86d5dbb 100644 --- a/auto/api/v1/core.go +++ b/auto/api/v1/core.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,22 +18,22 @@ type Core interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - TweetCollectionStatus(*web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, mir.Error) - TweetStarStatus(*web.TweetStarStatusReq) (*web.TweetStarStatusResp, mir.Error) - SuggestTags(*web.SuggestTagsReq) (*web.SuggestTagsResp, mir.Error) - SuggestUsers(*web.SuggestUsersReq) (*web.SuggestUsersResp, mir.Error) - ChangeAvatar(*web.ChangeAvatarReq) mir.Error - ChangeNickname(*web.ChangeNicknameReq) mir.Error - ChangePassword(*web.ChangePasswordReq) mir.Error - UserPhoneBind(*web.UserPhoneBindReq) mir.Error - GetStars(*web.GetStarsReq) (*web.GetStarsResp, mir.Error) - GetCollections(*web.GetCollectionsReq) (*web.GetCollectionsResp, mir.Error) - SendUserWhisper(*web.SendWhisperReq) mir.Error - ReadAllMessage(*web.ReadAllMessageReq) mir.Error - ReadMessage(*web.ReadMessageReq) mir.Error - GetMessages(*web.GetMessagesReq) (*web.GetMessagesResp, mir.Error) - GetUserInfo(*web.UserInfoReq) (*web.UserInfoResp, mir.Error) - SyncSearchIndex(*web.SyncSearchIndexReq) mir.Error + TweetCollectionStatus(*web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, error) + TweetStarStatus(*web.TweetStarStatusReq) (*web.TweetStarStatusResp, error) + SuggestTags(*web.SuggestTagsReq) (*web.SuggestTagsResp, error) + SuggestUsers(*web.SuggestUsersReq) (*web.SuggestUsersResp, error) + ChangeAvatar(*web.ChangeAvatarReq) error + ChangeNickname(*web.ChangeNicknameReq) error + ChangePassword(*web.ChangePasswordReq) error + UserPhoneBind(*web.UserPhoneBindReq) error + GetStars(*web.GetStarsReq) (*web.GetStarsResp, error) + GetCollections(*web.GetCollectionsReq) (*web.GetCollectionsResp, error) + SendUserWhisper(*web.SendWhisperReq) error + ReadAllMessage(*web.ReadAllMessageReq) error + ReadMessage(*web.ReadMessageReq) error + GetMessages(*web.GetMessagesReq) (*web.GetMessagesResp, error) + GetUserInfo(*web.UserInfoReq) (*web.UserInfoResp, error) + SyncSearchIndex(*web.SyncSearchIndexReq) error mustEmbedUnimplementedCoreServant() } @@ -53,8 +53,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.TweetCollectionStatusReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -68,8 +67,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.TweetStarStatusReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -83,8 +81,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.SuggestTagsReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -98,8 +95,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.SuggestUsersReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -165,8 +161,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.GetStarsReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -180,8 +175,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.GetCollectionsReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -253,8 +247,7 @@ func RegisterCoreServant(e *gin.Engine, s Core) { default: } req := new(web.UserInfoReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -283,67 +276,67 @@ func (UnimplementedCoreServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedCoreServant) TweetCollectionStatus(req *web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, mir.Error) { +func (UnimplementedCoreServant) TweetCollectionStatus(req *web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) TweetStarStatus(req *web.TweetStarStatusReq) (*web.TweetStarStatusResp, mir.Error) { +func (UnimplementedCoreServant) TweetStarStatus(req *web.TweetStarStatusReq) (*web.TweetStarStatusResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) SuggestTags(req *web.SuggestTagsReq) (*web.SuggestTagsResp, mir.Error) { +func (UnimplementedCoreServant) SuggestTags(req *web.SuggestTagsReq) (*web.SuggestTagsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) SuggestUsers(req *web.SuggestUsersReq) (*web.SuggestUsersResp, mir.Error) { +func (UnimplementedCoreServant) SuggestUsers(req *web.SuggestUsersReq) (*web.SuggestUsersResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) ChangeAvatar(req *web.ChangeAvatarReq) mir.Error { +func (UnimplementedCoreServant) ChangeAvatar(req *web.ChangeAvatarReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) ChangeNickname(req *web.ChangeNicknameReq) mir.Error { +func (UnimplementedCoreServant) ChangeNickname(req *web.ChangeNicknameReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) ChangePassword(req *web.ChangePasswordReq) mir.Error { +func (UnimplementedCoreServant) ChangePassword(req *web.ChangePasswordReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) UserPhoneBind(req *web.UserPhoneBindReq) mir.Error { +func (UnimplementedCoreServant) UserPhoneBind(req *web.UserPhoneBindReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) GetStars(req *web.GetStarsReq) (*web.GetStarsResp, mir.Error) { +func (UnimplementedCoreServant) GetStars(req *web.GetStarsReq) (*web.GetStarsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) GetCollections(req *web.GetCollectionsReq) (*web.GetCollectionsResp, mir.Error) { +func (UnimplementedCoreServant) GetCollections(req *web.GetCollectionsReq) (*web.GetCollectionsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) SendUserWhisper(req *web.SendWhisperReq) mir.Error { +func (UnimplementedCoreServant) SendUserWhisper(req *web.SendWhisperReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) ReadAllMessage(req *web.ReadAllMessageReq) mir.Error { +func (UnimplementedCoreServant) ReadAllMessage(req *web.ReadAllMessageReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) ReadMessage(req *web.ReadMessageReq) mir.Error { +func (UnimplementedCoreServant) ReadMessage(req *web.ReadMessageReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) GetMessages(req *web.GetMessagesReq) (*web.GetMessagesResp, mir.Error) { +func (UnimplementedCoreServant) GetMessages(req *web.GetMessagesReq) (*web.GetMessagesResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, mir.Error) { +func (UnimplementedCoreServant) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedCoreServant) SyncSearchIndex(req *web.SyncSearchIndexReq) mir.Error { +func (UnimplementedCoreServant) SyncSearchIndex(req *web.SyncSearchIndexReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/followship.go b/auto/api/v1/followship.go index b8f9bc09..e04b8271 100644 --- a/auto/api/v1/followship.go +++ b/auto/api/v1/followship.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,10 +18,10 @@ type Followship interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - ListFollowings(*web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error) - ListFollows(*web.ListFollowsReq) (*web.ListFollowsResp, mir.Error) - UnfollowUser(*web.UnfollowUserReq) mir.Error - FollowUser(*web.FollowUserReq) mir.Error + ListFollowings(*web.ListFollowingsReq) (*web.ListFollowingsResp, error) + ListFollows(*web.ListFollowsReq) (*web.ListFollowsResp, error) + UnfollowUser(*web.UnfollowUserReq) error + FollowUser(*web.FollowUserReq) error mustEmbedUnimplementedFollowshipServant() } @@ -97,19 +97,19 @@ func (UnimplementedFollowshipServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedFollowshipServant) ListFollowings(req *web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error) { +func (UnimplementedFollowshipServant) ListFollowings(req *web.ListFollowingsReq) (*web.ListFollowingsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFollowshipServant) ListFollows(req *web.ListFollowsReq) (*web.ListFollowsResp, mir.Error) { +func (UnimplementedFollowshipServant) ListFollows(req *web.ListFollowsReq) (*web.ListFollowsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFollowshipServant) UnfollowUser(req *web.UnfollowUserReq) mir.Error { +func (UnimplementedFollowshipServant) UnfollowUser(req *web.UnfollowUserReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFollowshipServant) FollowUser(req *web.FollowUserReq) mir.Error { +func (UnimplementedFollowshipServant) FollowUser(req *web.FollowUserReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/friendship.go b/auto/api/v1/friendship.go index 12e96946..2de99080 100644 --- a/auto/api/v1/friendship.go +++ b/auto/api/v1/friendship.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,11 +18,11 @@ type Friendship interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - GetContacts(*web.GetContactsReq) (*web.GetContactsResp, mir.Error) - DeleteFriend(*web.DeleteFriendReq) mir.Error - RejectFriend(*web.RejectFriendReq) mir.Error - AddFriend(*web.AddFriendReq) mir.Error - RequestingFriend(*web.RequestingFriendReq) mir.Error + GetContacts(*web.GetContactsReq) (*web.GetContactsResp, error) + DeleteFriend(*web.DeleteFriendReq) error + RejectFriend(*web.RejectFriendReq) error + AddFriend(*web.AddFriendReq) error + RequestingFriend(*web.RequestingFriendReq) error mustEmbedUnimplementedFriendshipServant() } @@ -110,23 +110,23 @@ func (UnimplementedFriendshipServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedFriendshipServant) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, mir.Error) { +func (UnimplementedFriendshipServant) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFriendshipServant) DeleteFriend(req *web.DeleteFriendReq) mir.Error { +func (UnimplementedFriendshipServant) DeleteFriend(req *web.DeleteFriendReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFriendshipServant) RejectFriend(req *web.RejectFriendReq) mir.Error { +func (UnimplementedFriendshipServant) RejectFriend(req *web.RejectFriendReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFriendshipServant) AddFriend(req *web.AddFriendReq) mir.Error { +func (UnimplementedFriendshipServant) AddFriend(req *web.AddFriendReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedFriendshipServant) RequestingFriend(req *web.RequestingFriendReq) mir.Error { +func (UnimplementedFriendshipServant) RequestingFriend(req *web.RequestingFriendReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/loose.go b/auto/api/v1/loose.go index 4a77b98d..911fc4c3 100644 --- a/auto/api/v1/loose.go +++ b/auto/api/v1/loose.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,12 +18,12 @@ type Loose interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) - TweetComments(*web.TweetCommentsReq) (*web.TweetCommentsResp, mir.Error) - TopicList(*web.TopicListReq) (*web.TopicListResp, mir.Error) - GetUserProfile(*web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error) - GetUserTweets(*web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) - Timeline(*web.TimelineReq) (*web.TimelineResp, mir.Error) + TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, error) + TweetComments(*web.TweetCommentsReq) (*web.TweetCommentsResp, error) + TopicList(*web.TopicListReq) (*web.TopicListResp, error) + GetUserProfile(*web.GetUserProfileReq) (*web.GetUserProfileResp, error) + GetUserTweets(*web.GetUserTweetsReq) (*web.GetUserTweetsResp, error) + Timeline(*web.TimelineReq) (*web.TimelineResp, error) mustEmbedUnimplementedLooseServant() } @@ -123,8 +123,7 @@ func RegisterLooseServant(e *gin.Engine, s Loose) { default: } req := new(web.TimelineReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -145,27 +144,27 @@ func (UnimplementedLooseServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedLooseServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) { +func (UnimplementedLooseServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedLooseServant) TweetComments(req *web.TweetCommentsReq) (*web.TweetCommentsResp, mir.Error) { +func (UnimplementedLooseServant) TweetComments(req *web.TweetCommentsReq) (*web.TweetCommentsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedLooseServant) TopicList(req *web.TopicListReq) (*web.TopicListResp, mir.Error) { +func (UnimplementedLooseServant) TopicList(req *web.TopicListReq) (*web.TopicListResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedLooseServant) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error) { +func (UnimplementedLooseServant) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfileResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedLooseServant) GetUserTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) { +func (UnimplementedLooseServant) GetUserTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedLooseServant) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error) { +func (UnimplementedLooseServant) Timeline(req *web.TimelineReq) (*web.TimelineResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/priv.go b/auto/api/v1/priv.go index f6ab299d..e84f1245 100644 --- a/auto/api/v1/priv.go +++ b/auto/api/v1/priv.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,30 +18,30 @@ type Priv interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - UnfollowTopic(*web.UnfollowTopicReq) mir.Error - FollowTopic(*web.FollowTopicReq) mir.Error - PinTopic(*web.PinTopicReq) (*web.PinTopicResp, mir.Error) - StickTopic(*web.StickTopicReq) (*web.StickTopicResp, mir.Error) - ThumbsDownTweetReply(*web.TweetReplyThumbsReq) mir.Error - ThumbsUpTweetReply(*web.TweetReplyThumbsReq) mir.Error - ThumbsDownTweetComment(*web.TweetCommentThumbsReq) mir.Error - ThumbsUpTweetComment(*web.TweetCommentThumbsReq) mir.Error - DeleteCommentReply(*web.DeleteCommentReplyReq) mir.Error - CreateCommentReply(*web.CreateCommentReplyReq) (*web.CreateCommentReplyResp, mir.Error) - HighlightComment(*web.HighlightCommentReq) (*web.HighlightCommentResp, mir.Error) - DeleteComment(*web.DeleteCommentReq) mir.Error - CreateComment(*web.CreateCommentReq) (*web.CreateCommentResp, mir.Error) - VisibleTweet(*web.VisibleTweetReq) (*web.VisibleTweetResp, mir.Error) - HighlightTweet(*web.HighlightTweetReq) (*web.HighlightTweetResp, mir.Error) - StickTweet(*web.StickTweetReq) (*web.StickTweetResp, mir.Error) - LockTweet(*web.LockTweetReq) (*web.LockTweetResp, mir.Error) - CollectionTweet(*web.CollectionTweetReq) (*web.CollectionTweetResp, mir.Error) - StarTweet(*web.StarTweetReq) (*web.StarTweetResp, mir.Error) - DeleteTweet(*web.DeleteTweetReq) mir.Error - CreateTweet(*web.CreateTweetReq) (*web.CreateTweetResp, mir.Error) - DownloadAttachment(*web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, mir.Error) - DownloadAttachmentPrecheck(*web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, mir.Error) - UploadAttachment(*web.UploadAttachmentReq) (*web.UploadAttachmentResp, mir.Error) + UnfollowTopic(*web.UnfollowTopicReq) error + FollowTopic(*web.FollowTopicReq) error + PinTopic(*web.PinTopicReq) (*web.PinTopicResp, error) + StickTopic(*web.StickTopicReq) (*web.StickTopicResp, error) + ThumbsDownTweetReply(*web.TweetReplyThumbsReq) error + ThumbsUpTweetReply(*web.TweetReplyThumbsReq) error + ThumbsDownTweetComment(*web.TweetCommentThumbsReq) error + ThumbsUpTweetComment(*web.TweetCommentThumbsReq) error + DeleteCommentReply(*web.DeleteCommentReplyReq) error + CreateCommentReply(*web.CreateCommentReplyReq) (*web.CreateCommentReplyResp, error) + HighlightComment(*web.HighlightCommentReq) (*web.HighlightCommentResp, error) + DeleteComment(*web.DeleteCommentReq) error + CreateComment(*web.CreateCommentReq) (*web.CreateCommentResp, error) + VisibleTweet(*web.VisibleTweetReq) (*web.VisibleTweetResp, error) + HighlightTweet(*web.HighlightTweetReq) (*web.HighlightTweetResp, error) + StickTweet(*web.StickTweetReq) (*web.StickTweetResp, error) + LockTweet(*web.LockTweetReq) (*web.LockTweetResp, error) + CollectionTweet(*web.CollectionTweetReq) (*web.CollectionTweetResp, error) + StarTweet(*web.StarTweetReq) (*web.StarTweetResp, error) + DeleteTweet(*web.DeleteTweetReq) error + CreateTweet(*web.CreateTweetReq) (*web.CreateTweetResp, error) + DownloadAttachment(*web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, error) + DownloadAttachmentPrecheck(*web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, error) + UploadAttachment(*web.UploadAttachmentReq) (*web.UploadAttachmentResp, error) mustEmbedUnimplementedPrivServant() } @@ -192,8 +192,7 @@ func RegisterPrivServant(e *gin.Engine, s Priv, m ...PrivChain) { default: } req := new(web.CreateCommentReplyReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -234,8 +233,7 @@ func RegisterPrivServant(e *gin.Engine, s Priv, m ...PrivChain) { default: } req := new(web.CreateCommentReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -346,8 +344,7 @@ func RegisterPrivServant(e *gin.Engine, s Priv, m ...PrivChain) { default: } req := new(web.CreateTweetReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -366,8 +363,7 @@ func RegisterPrivServant(e *gin.Engine, s Priv, m ...PrivChain) { default: } req := new(web.DownloadAttachmentReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -381,8 +377,7 @@ func RegisterPrivServant(e *gin.Engine, s Priv, m ...PrivChain) { default: } req := new(web.DownloadAttachmentPrecheckReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -396,8 +391,7 @@ func RegisterPrivServant(e *gin.Engine, s Priv, m ...PrivChain) { default: } req := new(web.UploadAttachmentReq) - var bv _binding_ = req - if err := bv.Bind(c); err != nil { + if err := s.Bind(c, req); err != nil { s.Render(c, nil, err) return } @@ -413,99 +407,99 @@ func (UnimplementedPrivServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedPrivServant) UnfollowTopic(req *web.UnfollowTopicReq) mir.Error { +func (UnimplementedPrivServant) UnfollowTopic(req *web.UnfollowTopicReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) FollowTopic(req *web.FollowTopicReq) mir.Error { +func (UnimplementedPrivServant) FollowTopic(req *web.FollowTopicReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) PinTopic(req *web.PinTopicReq) (*web.PinTopicResp, mir.Error) { +func (UnimplementedPrivServant) PinTopic(req *web.PinTopicReq) (*web.PinTopicResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) StickTopic(req *web.StickTopicReq) (*web.StickTopicResp, mir.Error) { +func (UnimplementedPrivServant) StickTopic(req *web.StickTopicReq) (*web.StickTopicResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) mir.Error { +func (UnimplementedPrivServant) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) mir.Error { +func (UnimplementedPrivServant) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) mir.Error { +func (UnimplementedPrivServant) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) mir.Error { +func (UnimplementedPrivServant) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) DeleteCommentReply(req *web.DeleteCommentReplyReq) mir.Error { +func (UnimplementedPrivServant) DeleteCommentReply(req *web.DeleteCommentReplyReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.CreateCommentReplyResp, mir.Error) { +func (UnimplementedPrivServant) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.CreateCommentReplyResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) HighlightComment(req *web.HighlightCommentReq) (*web.HighlightCommentResp, mir.Error) { +func (UnimplementedPrivServant) HighlightComment(req *web.HighlightCommentReq) (*web.HighlightCommentResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) DeleteComment(req *web.DeleteCommentReq) mir.Error { +func (UnimplementedPrivServant) DeleteComment(req *web.DeleteCommentReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) CreateComment(req *web.CreateCommentReq) (*web.CreateCommentResp, mir.Error) { +func (UnimplementedPrivServant) CreateComment(req *web.CreateCommentReq) (*web.CreateCommentResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp, mir.Error) { +func (UnimplementedPrivServant) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) HighlightTweet(req *web.HighlightTweetReq) (*web.HighlightTweetResp, mir.Error) { +func (UnimplementedPrivServant) HighlightTweet(req *web.HighlightTweetReq) (*web.HighlightTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, mir.Error) { +func (UnimplementedPrivServant) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) LockTweet(req *web.LockTweetReq) (*web.LockTweetResp, mir.Error) { +func (UnimplementedPrivServant) LockTweet(req *web.LockTweetReq) (*web.LockTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) CollectionTweet(req *web.CollectionTweetReq) (*web.CollectionTweetResp, mir.Error) { +func (UnimplementedPrivServant) CollectionTweet(req *web.CollectionTweetReq) (*web.CollectionTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) StarTweet(req *web.StarTweetReq) (*web.StarTweetResp, mir.Error) { +func (UnimplementedPrivServant) StarTweet(req *web.StarTweetReq) (*web.StarTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) DeleteTweet(req *web.DeleteTweetReq) mir.Error { +func (UnimplementedPrivServant) DeleteTweet(req *web.DeleteTweetReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) CreateTweet(req *web.CreateTweetReq) (*web.CreateTweetResp, mir.Error) { +func (UnimplementedPrivServant) CreateTweet(req *web.CreateTweetReq) (*web.CreateTweetResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, mir.Error) { +func (UnimplementedPrivServant) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, mir.Error) { +func (UnimplementedPrivServant) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPrivServant) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAttachmentResp, mir.Error) { +func (UnimplementedPrivServant) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAttachmentResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/pub.go b/auto/api/v1/pub.go index a9864d98..730adcf5 100644 --- a/auto/api/v1/pub.go +++ b/auto/api/v1/pub.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -15,11 +15,11 @@ import ( type Pub interface { _default_ - SendCaptcha(*web.SendCaptchaReq) mir.Error - GetCaptcha() (*web.GetCaptchaResp, mir.Error) - Register(*web.RegisterReq) (*web.RegisterResp, mir.Error) - Login(*web.LoginReq) (*web.LoginResp, mir.Error) - Version() (*web.VersionResp, mir.Error) + SendCaptcha(*web.SendCaptchaReq) error + GetCaptcha() (*web.GetCaptchaResp, error) + Register(*web.RegisterReq) (*web.RegisterResp, error) + Login(*web.LoginReq) (*web.LoginResp, error) + Version() (*web.VersionResp, error) mustEmbedUnimplementedPubServant() } @@ -95,23 +95,23 @@ func RegisterPubServant(e *gin.Engine, s Pub) { // UnimplementedPubServant can be embedded to have forward compatible implementations. type UnimplementedPubServant struct{} -func (UnimplementedPubServant) SendCaptcha(req *web.SendCaptchaReq) mir.Error { +func (UnimplementedPubServant) SendCaptcha(req *web.SendCaptchaReq) error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPubServant) GetCaptcha() (*web.GetCaptchaResp, mir.Error) { +func (UnimplementedPubServant) GetCaptcha() (*web.GetCaptchaResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPubServant) Register(req *web.RegisterReq) (*web.RegisterResp, mir.Error) { +func (UnimplementedPubServant) Register(req *web.RegisterReq) (*web.RegisterResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPubServant) Login(req *web.LoginReq) (*web.LoginResp, mir.Error) { +func (UnimplementedPubServant) Login(req *web.LoginReq) (*web.LoginResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedPubServant) Version() (*web.VersionResp, mir.Error) { +func (UnimplementedPubServant) Version() (*web.VersionResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/relax.go b/auto/api/v1/relax.go index 45bf50e2..b31520f6 100644 --- a/auto/api/v1/relax.go +++ b/auto/api/v1/relax.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,7 +18,7 @@ type Relax interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - GetUnreadMsgCount(*web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, mir.Error) + GetUnreadMsgCount(*web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, error) mustEmbedUnimplementedRelaxServant() } @@ -71,7 +71,7 @@ func (UnimplementedRelaxServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedRelaxServant) GetUnreadMsgCount(req *web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, mir.Error) { +func (UnimplementedRelaxServant) GetUnreadMsgCount(req *web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/site.go b/auto/api/v1/site.go index d8d412d9..8896df03 100644 --- a/auto/api/v1/site.go +++ b/auto/api/v1/site.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -16,8 +16,8 @@ import ( type Site interface { _default_ - Profile() (*conf.WebProfileConf, mir.Error) - Version() (*web.VersionResp, mir.Error) + Profile() (*conf.WebProfileConf, error) + Version() (*web.VersionResp, error) mustEmbedUnimplementedSiteServant() } @@ -52,11 +52,11 @@ func RegisterSiteServant(e *gin.Engine, s Site) { // UnimplementedSiteServant can be embedded to have forward compatible implementations. type UnimplementedSiteServant struct{} -func (UnimplementedSiteServant) Profile() (*conf.WebProfileConf, mir.Error) { +func (UnimplementedSiteServant) Profile() (*conf.WebProfileConf, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedSiteServant) Version() (*web.VersionResp, mir.Error) { +func (UnimplementedSiteServant) Version() (*web.VersionResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/v1/trends.go b/auto/api/v1/trends.go index f91ea61b..5ac21041 100644 --- a/auto/api/v1/trends.go +++ b/auto/api/v1/trends.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -18,7 +18,7 @@ type Trends interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - GetIndexTrends(*web.GetIndexTrendsReq) (*web.GetIndexTrendsResp, mir.Error) + GetIndexTrends(*web.GetIndexTrendsReq) (*web.GetIndexTrendsResp, error) mustEmbedUnimplementedTrendsServant() } @@ -59,7 +59,7 @@ func (UnimplementedTrendsServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedTrendsServant) GetIndexTrends(req *web.GetIndexTrendsReq) (*web.GetIndexTrendsResp, mir.Error) { +func (UnimplementedTrendsServant) GetIndexTrends(req *web.GetIndexTrendsReq) (*web.GetIndexTrendsResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/auto/api/x/v1/user.go b/auto/api/x/v1/user.go index 83b9d26a..9d4b0a61 100644 --- a/auto/api/x/v1/user.go +++ b/auto/api/x/v1/user.go @@ -1,6 +1,6 @@ // Code generated by go-mir. DO NOT EDIT. // versions: -// - mir 5.0.1 +// - mir 5.1.0 package v1 @@ -12,7 +12,7 @@ import ( ) type _binding_ interface { - Bind(*gin.Context) mir.Error + Bind(*gin.Context) error } type _render_ interface { @@ -20,8 +20,8 @@ type _render_ interface { } type _default_ interface { - Bind(*gin.Context, any) mir.Error - Render(*gin.Context, any, mir.Error) + Bind(*gin.Context, any) error + Render(*gin.Context, any, error) } type LoginReq struct { @@ -55,8 +55,8 @@ type User interface { // Chain provide handlers chain for gin Chain() gin.HandlersChain - Logout() mir.Error - Login(*LoginReq) (*LoginResp, mir.Error) + Logout() error + Login(*LoginReq) (*LoginResp, error) mustEmbedUnimplementedUserServant() } @@ -101,11 +101,11 @@ func (UnimplementedUserServant) Chain() gin.HandlersChain { return nil } -func (UnimplementedUserServant) Logout() mir.Error { +func (UnimplementedUserServant) Logout() error { return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } -func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) { +func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, error) { return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) } diff --git a/go.mod b/go.mod index 779d7003..82d9f299 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Masterminds/semver/v3 v3.2.1 github.com/RoaringBitmap/roaring v1.9.4 github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 - github.com/alimy/mir/v5 v5.0.1 + github.com/alimy/mir/v5 v5.1.0 github.com/alimy/tryst v1.1.0 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/allegro/bigcache/v3 v3.1.0 diff --git a/go.sum b/go.sum index cfc7626d..a3d8e3e7 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/RoaringBitmap/roaring v1.9.4 h1:yhEIoH4YezLYT04s1nHehNO64EKFTop/wBhxv github.com/RoaringBitmap/roaring v1.9.4/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90= github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 h1:uFrPOl1VBt/Abfl2z+A/DFc+AwmFLxEHR1+Yq6cXvww= github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868/go.mod h1:srphKZ1i+yGXxl/LpBS7ZIECTjCTPzZzAMtJWoG3sLo= -github.com/alimy/mir/v5 v5.0.1 h1:tPGUo5C0hUNZhGwOFJjqn9wDJAdb3XJmNxI9KwejRl0= -github.com/alimy/mir/v5 v5.0.1/go.mod h1:R76XQiU3K7T4V0aOcd4r5OeO7Gf8yTIVtnLbt1LLf2U= +github.com/alimy/mir/v5 v5.1.0 h1:GDYvCUsg1PVSRN/yB/NB3TXCK9z10HkIoknxypfDxQs= +github.com/alimy/mir/v5 v5.1.0/go.mod h1:R76XQiU3K7T4V0aOcd4r5OeO7Gf8yTIVtnLbt1LLf2U= github.com/alimy/tryst v1.1.0 h1:EiGiTLLw9n6bfg1WwnqoZTb1gnDHDHxozjfE/cuVjlI= github.com/alimy/tryst v1.1.0/go.mod h1:t/Ocn3Qd2P8Sg5VIL11s1H7cBCYZcDy+VNwiFHix+lI= github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g= diff --git a/internal/model/web/alipay.go b/internal/model/web/alipay.go index 0d21b428..803a66fd 100644 --- a/internal/model/web/alipay.go +++ b/internal/model/web/alipay.go @@ -7,7 +7,6 @@ package web import ( "context" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/conf" "github.com/rocboss/paopao-ce/internal/servants/base" @@ -54,7 +53,7 @@ type AlipayNotifyReq struct { TradeStatus alipay.TradeStatus } -func (r *AlipayNotifyReq) Bind(c *gin.Context) mir.Error { +func (r *AlipayNotifyReq) Bind(c *gin.Context) error { if err := c.Request.ParseForm(); err != nil { logrus.Errorf("parse form err: %s", err) return ErrRechargeNotifyError @@ -71,7 +70,7 @@ func (r *AlipayNotifyReq) Bind(c *gin.Context) mir.Error { return nil } -func (r *UserWalletBillsReq) Bind(c *gin.Context) mir.Error { +func (r *UserWalletBillsReq) Bind(c *gin.Context) error { uid, ok := base.UserIdFrom(c) if !ok { return xerror.UnauthorizedTokenError @@ -81,12 +80,12 @@ func (r *UserWalletBillsReq) Bind(c *gin.Context) mir.Error { return nil } -func (r *UserRechargeLinkReq) Bind(c *gin.Context) mir.Error { +func (r *UserRechargeLinkReq) Bind(c *gin.Context) error { r.Host = c.Request.Host return bindAny(c, r) } -func (r *UserRechargeResultReq) Bind(c *gin.Context) mir.Error { +func (r *UserRechargeResultReq) Bind(c *gin.Context) error { uid, exist := base.UserIdFrom(c) if !exist { return xerror.UnauthorizedTokenError diff --git a/internal/model/web/core.go b/internal/model/web/core.go index 6ff66280..63ab1939 100644 --- a/internal/model/web/core.go +++ b/internal/model/web/core.go @@ -5,7 +5,6 @@ package web import ( - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/core/cs" "github.com/rocboss/paopao-ce/internal/model/joint" @@ -127,7 +126,7 @@ type TweetCollectionStatusResp struct { Status bool `json:"status"` } -func (r *UserInfoReq) Bind(c *gin.Context) mir.Error { +func (r *UserInfoReq) Bind(c *gin.Context) error { username, exist := base.UserNameFrom(c) if !exist { return xerror.UnauthorizedAuthNotExist @@ -136,25 +135,25 @@ func (r *UserInfoReq) Bind(c *gin.Context) mir.Error { return nil } -func (r *GetCollectionsReq) Bind(c *gin.Context) mir.Error { +func (r *GetCollectionsReq) Bind(c *gin.Context) error { return (*BasePageReq)(r).Bind(c) } -func (r *GetStarsReq) Bind(c *gin.Context) mir.Error { +func (r *GetStarsReq) Bind(c *gin.Context) error { return (*BasePageReq)(r).Bind(c) } -func (r *SuggestTagsReq) Bind(c *gin.Context) mir.Error { +func (r *SuggestTagsReq) Bind(c *gin.Context) error { r.Keyword = c.Query("k") return nil } -func (r *SuggestUsersReq) Bind(c *gin.Context) mir.Error { +func (r *SuggestUsersReq) Bind(c *gin.Context) error { r.Keyword = c.Query("k") return nil } -func (r *TweetCollectionStatusReq) Bind(c *gin.Context) mir.Error { +func (r *TweetCollectionStatusReq) Bind(c *gin.Context) error { userId, exist := base.UserIdFrom(c) if !exist { return xerror.UnauthorizedAuthNotExist @@ -166,7 +165,7 @@ func (r *TweetCollectionStatusReq) Bind(c *gin.Context) mir.Error { return nil } -func (r *TweetStarStatusReq) Bind(c *gin.Context) mir.Error { +func (r *TweetStarStatusReq) Bind(c *gin.Context) error { UserId, exist := base.UserIdFrom(c) if !exist { return xerror.UnauthorizedAuthNotExist diff --git a/internal/model/web/loose.go b/internal/model/web/loose.go index 936c43ea..4e9dae62 100644 --- a/internal/model/web/loose.go +++ b/internal/model/web/loose.go @@ -5,7 +5,6 @@ package web import ( - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/conf" "github.com/rocboss/paopao-ce/internal/core" @@ -127,7 +126,7 @@ func (r *TweetCommentsReq) SetPageInfo(page int, pageSize int) { r.Page, r.PageSize = page, pageSize } -func (r *TimelineReq) Bind(c *gin.Context) mir.Error { +func (r *TimelineReq) Bind(c *gin.Context) error { user, _ := base.UserFrom(c) r.BaseInfo = BaseInfo{ User: user, diff --git a/internal/model/web/priv.go b/internal/model/web/priv.go index 2c930aeb..ca2b1360 100644 --- a/internal/model/web/priv.go +++ b/internal/model/web/priv.go @@ -10,7 +10,6 @@ import ( "net/http" "strings" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/core" "github.com/rocboss/paopao-ce/internal/core/cs" @@ -243,7 +242,7 @@ func (p *PostContentItem) Check(acs core.AttachmentCheckService) error { return nil } -func (r *UploadAttachmentReq) Bind(c *gin.Context) (xerr mir.Error) { +func (r *UploadAttachmentReq) Bind(c *gin.Context) (xerr error) { userId, exist := base.UserIdFrom(c) if !exist { return xerror.UnauthorizedAuthNotExist @@ -276,7 +275,7 @@ func (r *UploadAttachmentReq) Bind(c *gin.Context) (xerr mir.Error) { return nil } -func (r *DownloadAttachmentPrecheckReq) Bind(c *gin.Context) mir.Error { +func (r *DownloadAttachmentPrecheckReq) Bind(c *gin.Context) error { user, exist := base.UserFrom(c) if !exist { return xerror.UnauthorizedAuthNotExist @@ -288,7 +287,7 @@ func (r *DownloadAttachmentPrecheckReq) Bind(c *gin.Context) mir.Error { return nil } -func (r *DownloadAttachmentReq) Bind(c *gin.Context) mir.Error { +func (r *DownloadAttachmentReq) Bind(c *gin.Context) error { user, exist := base.UserFrom(c) if !exist { return xerror.UnauthorizedAuthNotExist @@ -300,17 +299,17 @@ func (r *DownloadAttachmentReq) Bind(c *gin.Context) mir.Error { return nil } -func (r *CreateTweetReq) Bind(c *gin.Context) mir.Error { +func (r *CreateTweetReq) Bind(c *gin.Context) error { r.ClientIP = c.ClientIP() return bindAny(c, r) } -func (r *CreateCommentReplyReq) Bind(c *gin.Context) mir.Error { +func (r *CreateCommentReplyReq) Bind(c *gin.Context) error { r.ClientIP = c.ClientIP() return bindAny(c, r) } -func (r *CreateCommentReq) Bind(c *gin.Context) mir.Error { +func (r *CreateCommentReq) Bind(c *gin.Context) error { r.ClientIP = c.ClientIP() return bindAny(c, r) } diff --git a/internal/servants/base/base.go b/internal/servants/base/base.go index a9cca117..3c381487 100644 --- a/internal/servants/base/base.go +++ b/internal/servants/base/base.go @@ -29,8 +29,8 @@ import ( ) type BaseServant struct { - bindAny func(c *gin.Context, obj any) mir.Error - bindJson func(c *gin.Context, obj any) mir.Error + bindAny func(c *gin.Context, obj any) error + bindJson func(c *gin.Context, obj any) error } type DaoServant struct { @@ -82,7 +82,7 @@ func UserNameFrom(c *gin.Context) (string, bool) { return "", false } -func bindAny(c *gin.Context, obj any) mir.Error { +func bindAny(c *gin.Context, obj any) error { var errs xerror.ValidErrors err := c.ShouldBind(obj) if err != nil { @@ -106,7 +106,7 @@ func bindAny(c *gin.Context, obj any) mir.Error { return nil } -func bindAnySentry(c *gin.Context, obj any) mir.Error { +func bindAnySentry(c *gin.Context, obj any) error { hub := sentrygin.GetHubFromContext(c) var errs xerror.ValidErrors err := c.ShouldBind(obj) @@ -140,7 +140,7 @@ func bindAnySentry(c *gin.Context, obj any) mir.Error { } -func RenderAny(c *gin.Context, data any, err mir.Error) { +func RenderAny(c *gin.Context, data any, err error) { if err == nil { c.JSON(http.StatusOK, &joint.JsonResp{ Code: 0, @@ -148,22 +148,23 @@ func RenderAny(c *gin.Context, data any, err mir.Error) { Data: data, }) } else { - c.JSON(xerror.HttpStatusCode(err), &joint.JsonResp{ - Code: err.StatusCode(), + statusCode, code := xerror.HttpStatusCode(err) + c.JSON(statusCode, &joint.JsonResp{ + Code: code, Msg: err.Error(), }) } } -func (s *BaseServant) Bind(c *gin.Context, obj any) mir.Error { +func (s *BaseServant) Bind(c *gin.Context, obj any) error { return s.bindAny(c, obj) } -func (s *BaseServant) BindJson(c *gin.Context, obj any) mir.Error { +func (s *BaseServant) BindJson(c *gin.Context, obj any) error { return s.bindJson(c, obj) } -func (s *BaseServant) Render(c *gin.Context, data any, err mir.Error) { +func (s *BaseServant) Render(c *gin.Context, data any, err error) { if err == nil { c.JSON(http.StatusOK, &joint.JsonResp{ Code: 0, @@ -171,8 +172,9 @@ func (s *BaseServant) Render(c *gin.Context, data any, err mir.Error) { Data: data, }) } else { - c.JSON(xerror.HttpStatusCode(err), &joint.JsonResp{ - Code: err.StatusCode(), + statusCode, code := xerror.HttpStatusCode(err) + c.JSON(statusCode, &joint.JsonResp{ + Code: code, Msg: err.Error(), }) } @@ -417,14 +419,14 @@ func (s *DaoServant) RelationTypFrom(me *ms.User, username string) (res *cs.Vist return } -func NewBindAnyFn() func(c *gin.Context, obj any) mir.Error { +func NewBindAnyFn() func(c *gin.Context, obj any) error { if conf.UseSentryGin() { return bindAnySentry } return bindAny } -func NewBindJsonFn() func(c *gin.Context, obj any) mir.Error { +func NewBindJsonFn() func(c *gin.Context, obj any) error { if conf.UseSentryGin() { return bindAnySentry } diff --git a/internal/servants/web/admin.go b/internal/servants/web/admin.go index 787ab9b8..6810e89a 100644 --- a/internal/servants/web/admin.go +++ b/internal/servants/web/admin.go @@ -7,7 +7,6 @@ package web import ( "time" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/conf" @@ -34,7 +33,7 @@ func (s *adminSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JWT(), chain.Admin()} } -func (s *adminSrv) ChangeUserStatus(req *web.ChangeUserStatusReq) mir.Error { +func (s *adminSrv) ChangeUserStatus(req *web.ChangeUserStatusReq) error { user, err := s.Ds.GetUserByID(req.ID) if err != nil || user.Model == nil || user.ID <= 0 { return web.ErrNoExistUsername @@ -47,7 +46,7 @@ func (s *adminSrv) ChangeUserStatus(req *web.ChangeUserStatusReq) mir.Error { return nil } -func (s *adminSrv) SiteInfo(req *web.SiteInfoReq) (*web.SiteInfoResp, mir.Error) { +func (s *adminSrv) SiteInfo(req *web.SiteInfoReq) (*web.SiteInfoResp, error) { res, err := &web.SiteInfoResp{ServerUpTime: s.serverUpTime}, error(nil) res.RegisterUserCount, err = s.Ds.GetRegisterUserCount() if err != nil { diff --git a/internal/servants/web/alipay.go b/internal/servants/web/alipay.go index 88263639..1fed1408 100644 --- a/internal/servants/web/alipay.go +++ b/internal/servants/web/alipay.go @@ -7,7 +7,6 @@ package web import ( "fmt" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/model/web" @@ -34,7 +33,7 @@ type alipayPrivSrv struct { alipayClient *alipay.Client } -func (s *alipayPubSrv) AlipayNotify(req *web.AlipayNotifyReq) mir.Error { +func (s *alipayPubSrv) AlipayNotify(req *web.AlipayNotifyReq) error { if req.TradeStatus == alipay.TradeStatusSuccess { if err := s.Redis.SetRechargeStatus(req.Ctx, req.TradeNo); err == nil { recharge, err := s.Ds.GetRechargeByID(req.ID) @@ -60,7 +59,7 @@ func (s *alipayPrivSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JWT()} } -func (s *alipayPrivSrv) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error) { +func (s *alipayPrivSrv) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserWalletBillsResp, error) { bills, err := s.Ds.GetUserWalletBills(req.UserId, (req.Page-1)*req.PageSize, req.PageSize) if err != nil { logrus.Errorf("GetUserWalletBills err: %s", err) @@ -75,7 +74,7 @@ func (s *alipayPrivSrv) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserW return (*web.UserWalletBillsResp)(resp), nil } -func (s *alipayPrivSrv) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, mir.Error) { +func (s *alipayPrivSrv) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, error) { recharge, err := s.Ds.CreateRecharge(req.User.ID, req.Amount) if err != nil { logrus.Errorf("Ds.CreateRecharge err: %v", err) @@ -100,7 +99,7 @@ func (s *alipayPrivSrv) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.Use }, nil } -func (s *alipayPrivSrv) UserRechargeResult(req *web.UserRechargeResultReq) (*web.UserRechargeResultResp, mir.Error) { +func (s *alipayPrivSrv) UserRechargeResult(req *web.UserRechargeResultReq) (*web.UserRechargeResultResp, error) { recharge, err := s.Ds.GetRechargeByID(req.Id) if err != nil { logrus.Errorf("Ds.GetRechargeByID err: %v", err) diff --git a/internal/servants/web/core.go b/internal/servants/web/core.go index 205c1a45..d3c0ef4a 100644 --- a/internal/servants/web/core.go +++ b/internal/servants/web/core.go @@ -11,7 +11,6 @@ import ( "time" "unicode/utf8" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/conf" @@ -48,7 +47,7 @@ func (s *coreSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JWT()} } -func (s *coreSrv) SyncSearchIndex(req *web.SyncSearchIndexReq) mir.Error { +func (s *coreSrv) SyncSearchIndex(req *web.SyncSearchIndexReq) error { if req.User != nil && req.User.IsAdmin { s.PushAllPostToSearch() } else { @@ -57,7 +56,7 @@ func (s *coreSrv) SyncSearchIndex(req *web.SyncSearchIndexReq) mir.Error { return nil } -func (s *coreSrv) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, mir.Error) { +func (s *coreSrv) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, error) { user, err := s.Ds.UserProfileByName(req.Username) if err != nil { logrus.Errorf("coreSrv.GetUserInfo occurs error[1]: %s", err) @@ -86,7 +85,7 @@ func (s *coreSrv) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, mir.Erro return resp, nil } -func (s *coreSrv) GetMessages(req *web.GetMessagesReq) (res *web.GetMessagesResp, _ mir.Error) { +func (s *coreSrv) GetMessages(req *web.GetMessagesReq) (res *web.GetMessagesResp, _ error) { limit, offset := req.PageSize, (req.Page-1)*req.PageSize // 尝试直接从缓存中获取数据 key, ok := "", false @@ -152,7 +151,7 @@ func (s *coreSrv) GetMessages(req *web.GetMessagesReq) (res *web.GetMessagesResp }, nil } -func (s *coreSrv) ReadMessage(req *web.ReadMessageReq) mir.Error { +func (s *coreSrv) ReadMessage(req *web.ReadMessageReq) error { message, err := s.Ds.GetMessageByID(req.ID) if err != nil { return web.ErrReadMessageFailed @@ -169,7 +168,7 @@ func (s *coreSrv) ReadMessage(req *web.ReadMessageReq) mir.Error { return nil } -func (s *coreSrv) ReadAllMessage(req *web.ReadAllMessageReq) mir.Error { +func (s *coreSrv) ReadAllMessage(req *web.ReadAllMessageReq) error { if err := s.Ds.ReadAllMessage(req.Uid); err != nil { logrus.Errorf("coreSrv.Ds.ReadAllMessage err: %s", err) return web.ErrReadMessageFailed @@ -179,7 +178,7 @@ func (s *coreSrv) ReadAllMessage(req *web.ReadAllMessageReq) mir.Error { return nil } -func (s *coreSrv) SendUserWhisper(req *web.SendWhisperReq) mir.Error { +func (s *coreSrv) SendUserWhisper(req *web.SendWhisperReq) error { // 不允许发送私信给自己 if req.Uid == req.UserID { return web.ErrNoWhisperToSelf @@ -209,7 +208,7 @@ func (s *coreSrv) SendUserWhisper(req *web.SendWhisperReq) mir.Error { return nil } -func (s *coreSrv) GetCollections(req *web.GetCollectionsReq) (*web.GetCollectionsResp, mir.Error) { +func (s *coreSrv) GetCollections(req *web.GetCollectionsReq) (*web.GetCollectionsResp, error) { collections, err := s.Ds.GetUserPostCollections(req.UserId, (req.Page-1)*req.PageSize, req.PageSize) if err != nil { logrus.Errorf("Ds.GetUserPostCollections err: %s", err) @@ -237,7 +236,7 @@ func (s *coreSrv) GetCollections(req *web.GetCollectionsReq) (*web.GetCollection return (*web.GetCollectionsResp)(resp), nil } -func (s *coreSrv) UserPhoneBind(req *web.UserPhoneBindReq) mir.Error { +func (s *coreSrv) UserPhoneBind(req *web.UserPhoneBindReq) error { // 手机重复性检查 u, err := s.Ds.GetUserByPhone(req.Phone) if err == nil && u.Model != nil && u.ID != 0 && u.ID != req.User.ID { @@ -274,7 +273,7 @@ func (s *coreSrv) UserPhoneBind(req *web.UserPhoneBindReq) mir.Error { return nil } -func (s *coreSrv) GetStars(req *web.GetStarsReq) (*web.GetStarsResp, mir.Error) { +func (s *coreSrv) GetStars(req *web.GetStarsReq) (*web.GetStarsResp, error) { stars, err := s.Ds.GetUserPostStars(req.UserId, req.PageSize, (req.Page-1)*req.PageSize) if err != nil { logrus.Errorf("Ds.GetUserPostStars err: %s", err) @@ -298,7 +297,7 @@ func (s *coreSrv) GetStars(req *web.GetStarsReq) (*web.GetStarsResp, mir.Error) return (*web.GetStarsResp)(resp), nil } -func (s *coreSrv) ChangePassword(req *web.ChangePasswordReq) mir.Error { +func (s *coreSrv) ChangePassword(req *web.ChangePasswordReq) error { // 密码检查 if err := checkPassword(req.Password); err != nil { return err @@ -317,7 +316,7 @@ func (s *coreSrv) ChangePassword(req *web.ChangePasswordReq) mir.Error { return nil } -func (s *coreSrv) SuggestTags(req *web.SuggestTagsReq) (*web.SuggestTagsResp, mir.Error) { +func (s *coreSrv) SuggestTags(req *web.SuggestTagsReq) (*web.SuggestTagsResp, error) { tags, err := s.Ds.TagsByKeyword(req.Keyword) if err != nil { logrus.Errorf("Ds.GetTagsByKeyword err: %s", err) @@ -330,7 +329,7 @@ func (s *coreSrv) SuggestTags(req *web.SuggestTagsReq) (*web.SuggestTagsResp, mi return resp, nil } -func (s *coreSrv) SuggestUsers(req *web.SuggestUsersReq) (*web.SuggestUsersResp, mir.Error) { +func (s *coreSrv) SuggestUsers(req *web.SuggestUsersReq) (*web.SuggestUsersResp, error) { users, err := s.Ds.GetUsersByKeyword(req.Keyword) if err != nil { logrus.Errorf("Ds.GetUsersByKeyword err: %s", err) @@ -343,7 +342,7 @@ func (s *coreSrv) SuggestUsers(req *web.SuggestUsersReq) (*web.SuggestUsersResp, return resp, nil } -func (s *coreSrv) ChangeNickname(req *web.ChangeNicknameReq) mir.Error { +func (s *coreSrv) ChangeNickname(req *web.ChangeNicknameReq) error { if utf8.RuneCountInString(req.Nickname) < 2 || utf8.RuneCountInString(req.Nickname) > 12 { return web.ErrNicknameLengthLimit } @@ -358,7 +357,7 @@ func (s *coreSrv) ChangeNickname(req *web.ChangeNicknameReq) mir.Error { return nil } -func (s *coreSrv) ChangeAvatar(req *web.ChangeAvatarReq) (xerr mir.Error) { +func (s *coreSrv) ChangeAvatar(req *web.ChangeAvatarReq) (xerr error) { defer func() { if xerr != nil { deleteOssObjects(s.oss, []string{req.Avatar}) @@ -384,7 +383,7 @@ func (s *coreSrv) ChangeAvatar(req *web.ChangeAvatarReq) (xerr mir.Error) { return nil } -func (s *coreSrv) TweetCollectionStatus(req *web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, mir.Error) { +func (s *coreSrv) TweetCollectionStatus(req *web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, error) { resp := &web.TweetCollectionStatusResp{ Status: true, } @@ -395,7 +394,7 @@ func (s *coreSrv) TweetCollectionStatus(req *web.TweetCollectionStatusReq) (*web return resp, nil } -func (s *coreSrv) TweetStarStatus(req *web.TweetStarStatusReq) (*web.TweetStarStatusResp, mir.Error) { +func (s *coreSrv) TweetStarStatus(req *web.TweetStarStatusReq) (*web.TweetStarStatusResp, error) { resp := &web.TweetStarStatusResp{ Status: true, } diff --git a/internal/servants/web/followship.go b/internal/servants/web/followship.go index 0e90612d..a66bac0d 100644 --- a/internal/servants/web/followship.go +++ b/internal/servants/web/followship.go @@ -5,7 +5,6 @@ package web import ( - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/dao/cache" @@ -29,7 +28,7 @@ func (s *followshipSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JwtLoose()} } -func (s *followshipSrv) ListFollowings(r *web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error) { +func (s *followshipSrv) ListFollowings(r *web.ListFollowingsReq) (*web.ListFollowingsResp, error) { he, err := s.Ds.GetUserByUsername(r.Username) if err != nil { logrus.Errorf("Ds.GetUserByUsername err: %s", err) @@ -49,7 +48,7 @@ func (s *followshipSrv) ListFollowings(r *web.ListFollowingsReq) (*web.ListFollo return (*web.ListFollowingsResp)(resp), nil } -func (s *followshipSrv) ListFollows(r *web.ListFollowsReq) (*web.ListFollowsResp, mir.Error) { +func (s *followshipSrv) ListFollows(r *web.ListFollowsReq) (*web.ListFollowsResp, error) { he, err := s.Ds.GetUserByUsername(r.Username) if err != nil { logrus.Errorf("Ds.GetUserByUsername err: %s", err) @@ -75,7 +74,7 @@ func (s *followshipSrv) ListFollows(r *web.ListFollowsReq) (*web.ListFollowsResp return (*web.ListFollowsResp)(resp), nil } -func (s *followshipSrv) UnfollowUser(r *web.UnfollowUserReq) mir.Error { +func (s *followshipSrv) UnfollowUser(r *web.UnfollowUserReq) error { if r.User == nil { return xerror.UnauthorizedTokenError } else if r.User.ID == r.UserId { @@ -94,7 +93,7 @@ func (s *followshipSrv) UnfollowUser(r *web.UnfollowUserReq) mir.Error { return nil } -func (s *followshipSrv) FollowUser(r *web.FollowUserReq) mir.Error { +func (s *followshipSrv) FollowUser(r *web.FollowUserReq) error { if r.User == nil { return xerror.UnauthorizedTokenError } else if r.User.ID == r.UserId { diff --git a/internal/servants/web/friendship.go b/internal/servants/web/friendship.go index 5cf4eca8..68ab7953 100644 --- a/internal/servants/web/friendship.go +++ b/internal/servants/web/friendship.go @@ -5,7 +5,6 @@ package web import ( - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/model/web" @@ -28,7 +27,7 @@ func (s *friendshipSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JWT()} } -func (s *friendshipSrv) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, mir.Error) { +func (s *friendshipSrv) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, error) { if req.User == nil { return nil, xerror.ServerError } @@ -41,7 +40,7 @@ func (s *friendshipSrv) GetContacts(req *web.GetContactsReq) (*web.GetContactsRe return (*web.GetContactsResp)(resp), nil } -func (s *friendshipSrv) DeleteFriend(req *web.DeleteFriendReq) mir.Error { +func (s *friendshipSrv) DeleteFriend(req *web.DeleteFriendReq) error { if req.User == nil { return xerror.ServerError } @@ -61,7 +60,7 @@ func (s *friendshipSrv) DeleteFriend(req *web.DeleteFriendReq) mir.Error { return nil } -func (s *friendshipSrv) RejectFriend(req *web.RejectFriendReq) mir.Error { +func (s *friendshipSrv) RejectFriend(req *web.RejectFriendReq) error { if req.User == nil { return xerror.ServerError } @@ -78,7 +77,7 @@ func (s *friendshipSrv) RejectFriend(req *web.RejectFriendReq) mir.Error { return nil } -func (s *friendshipSrv) AddFriend(req *web.AddFriendReq) mir.Error { +func (s *friendshipSrv) AddFriend(req *web.AddFriendReq) error { if req.User == nil { return xerror.ServerError } @@ -98,7 +97,7 @@ func (s *friendshipSrv) AddFriend(req *web.AddFriendReq) mir.Error { return nil } -func (s *friendshipSrv) RequestingFriend(req *web.RequestingFriendReq) mir.Error { +func (s *friendshipSrv) RequestingFriend(req *web.RequestingFriendReq) error { if req.User == nil { return xerror.ServerError } diff --git a/internal/servants/web/loose.go b/internal/servants/web/loose.go index 270203c7..e8ca4b63 100644 --- a/internal/servants/web/loose.go +++ b/internal/servants/web/loose.go @@ -7,7 +7,6 @@ package web import ( "fmt" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/conf" @@ -44,7 +43,7 @@ func (s *looseSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JwtLoose()} } -func (s *looseSrv) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error) { +func (s *looseSrv) Timeline(req *web.TimelineReq) (*web.TimelineResp, error) { limit, offset := req.PageSize, (req.Page-1)*req.PageSize if req.Query == "" && req.Type == "search" { return s.getIndexTweets(req, limit, offset) @@ -79,7 +78,7 @@ func (s *looseSrv) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error) }, nil } -func (s *looseSrv) getIndexTweets(req *web.TimelineReq, limit int, offset int) (res *web.TimelineResp, err mir.Error) { +func (s *looseSrv) getIndexTweets(req *web.TimelineReq, limit int, offset int) (res *web.TimelineResp, err error) { // 尝试直接从缓存中获取数据 key, ok := "", false if res, key, ok = s.indexTweetsFromCache(req, limit, offset); ok { @@ -171,7 +170,7 @@ func (s *looseSrv) tweetCommentsFromCache(req *web.TweetCommentsReq, limit int, return } -func (s *looseSrv) GetUserTweets(req *web.GetUserTweetsReq) (res *web.GetUserTweetsResp, err mir.Error) { +func (s *looseSrv) GetUserTweets(req *web.GetUserTweetsReq) (res *web.GetUserTweetsResp, err error) { user, xerr := s.RelationTypFrom(req.User, req.Username) if xerr != nil { return nil, err @@ -223,7 +222,7 @@ func (s *looseSrv) userTweetsFromCache(req *web.GetUserTweetsReq, user *cs.VistU return } -func (s *looseSrv) getUserStarTweets(req *web.GetUserTweetsReq, user *cs.VistUser) (*web.GetUserTweetsResp, mir.Error) { +func (s *looseSrv) getUserStarTweets(req *web.GetUserTweetsReq, user *cs.VistUser) (*web.GetUserTweetsResp, error) { stars, totalRows, err := s.Ds.ListUserStarTweets(user, req.PageSize, (req.Page-1)*req.PageSize) if err != nil { logrus.Errorf("getUserStarTweets err[1]: %s", err) @@ -256,7 +255,7 @@ func (s *looseSrv) getUserStarTweets(req *web.GetUserTweetsReq, user *cs.VistUse }, nil } -func (s *looseSrv) listUserTweets(req *web.GetUserTweetsReq, user *cs.VistUser) (*web.GetUserTweetsResp, mir.Error) { +func (s *looseSrv) listUserTweets(req *web.GetUserTweetsReq, user *cs.VistUser) (*web.GetUserTweetsResp, error) { var ( tweets []*ms.Post total int64 @@ -295,7 +294,7 @@ func (s *looseSrv) listUserTweets(req *web.GetUserTweetsReq, user *cs.VistUser) }, nil } -func (s *looseSrv) getUserPostTweets(req *web.GetUserTweetsReq, user *cs.VistUser, isHighlight bool) (*web.GetUserTweetsResp, mir.Error) { +func (s *looseSrv) getUserPostTweets(req *web.GetUserTweetsReq, user *cs.VistUser, isHighlight bool) (*web.GetUserTweetsResp, error) { style := cs.StyleUserTweetsGuest switch user.RelTyp { case cs.RelationAdmin: @@ -337,7 +336,7 @@ func (s *looseSrv) getUserPostTweets(req *web.GetUserTweetsReq, user *cs.VistUse }, nil } -func (s *looseSrv) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error) { +func (s *looseSrv) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfileResp, error) { he, err := s.Ds.UserProfileByName(req.Username) if err != nil { logrus.Errorf("looseSrv.GetUserProfile occurs error[1]: %s", err) @@ -372,7 +371,7 @@ func (s *looseSrv) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfi }, nil } -func (s *looseSrv) TopicList(req *web.TopicListReq) (*web.TopicListResp, mir.Error) { +func (s *looseSrv) TopicList(req *web.TopicListReq) (*web.TopicListResp, error) { var ( tags, extralTags cs.TagList err error @@ -409,7 +408,7 @@ func (s *looseSrv) TopicList(req *web.TopicListReq) (*web.TopicListResp, mir.Err }, nil } -func (s *looseSrv) TweetComments(req *web.TweetCommentsReq) (res *web.TweetCommentsResp, err mir.Error) { +func (s *looseSrv) TweetComments(req *web.TweetCommentsReq) (res *web.TweetCommentsResp, err error) { limit, offset := req.PageSize, (req.Page-1)*req.PageSize // 尝试直接从缓存中获取数据 key, ok := "", false @@ -503,7 +502,7 @@ func (s *looseSrv) TweetComments(req *web.TweetCommentsReq) (res *web.TweetComme }, nil } -func (s *looseSrv) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) { +func (s *looseSrv) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, error) { post, err := s.Ds.GetPostByID(req.TweetId) if err != nil { return nil, web.ErrGetPostFailed diff --git a/internal/servants/web/priv.go b/internal/servants/web/priv.go index a86ecda1..0c8cc199 100644 --- a/internal/servants/web/priv.go +++ b/internal/servants/web/priv.go @@ -10,7 +10,6 @@ import ( "strings" "time" - "github.com/alimy/mir/v5" "github.com/alimy/tryst/cfg" "github.com/disintegration/imaging" "github.com/gin-gonic/gin" @@ -62,7 +61,7 @@ func (s *privSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JWT(), chain.Priv()} } -func (s *privSrv) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) mir.Error { +func (s *privSrv) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) error { if err := s.Ds.ThumbsDownReply(req.Uid, req.TweetId, req.CommentId, req.ReplyId); err != nil { logrus.Errorf("thumbs down tweet reply error: %s req:%v", err, req) return web.ErrThumbsDownTweetReply @@ -70,7 +69,7 @@ func (s *privSrv) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) mir.Error { return nil } -func (s *privSrv) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) mir.Error { +func (s *privSrv) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) error { if err := s.Ds.ThumbsUpReply(req.Uid, req.TweetId, req.CommentId, req.ReplyId); err != nil { logrus.Errorf("thumbs up tweet reply error: %s req:%v", err, req) return web.ErrThumbsUpTweetReply @@ -78,7 +77,7 @@ func (s *privSrv) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) mir.Error { return nil } -func (s *privSrv) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) mir.Error { +func (s *privSrv) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) error { if err := s.Ds.ThumbsDownComment(req.Uid, req.TweetId, req.CommentId); err != nil { logrus.Errorf("thumbs down tweet comment error: %s req:%v", err, req) return web.ErrThumbsDownTweetComment @@ -88,7 +87,7 @@ func (s *privSrv) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) mir.Err return nil } -func (s *privSrv) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) mir.Error { +func (s *privSrv) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) error { if err := s.Ds.ThumbsUpComment(req.Uid, req.TweetId, req.CommentId); err != nil { logrus.Errorf("thumbs up tweet comment error: %s req:%v", err, req) return web.ErrThumbsUpTweetComment @@ -98,7 +97,7 @@ func (s *privSrv) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) mir.Error return nil } -func (s *privSrv) UnfollowTopic(req *web.UnfollowTopicReq) mir.Error { +func (s *privSrv) UnfollowTopic(req *web.UnfollowTopicReq) error { if err := s.Ds.UnfollowTopic(req.Uid, req.TopicId); err != nil { logrus.Errorf("user(%d) unfollow topic(%d) failed: %s", req.Uid, req.TopicId, err) return web.ErrUnfollowTopicFailed @@ -106,7 +105,7 @@ func (s *privSrv) UnfollowTopic(req *web.UnfollowTopicReq) mir.Error { return nil } -func (s *privSrv) FollowTopic(req *web.FollowTopicReq) mir.Error { +func (s *privSrv) FollowTopic(req *web.FollowTopicReq) error { if err := s.Ds.FollowTopic(req.Uid, req.TopicId); err != nil { logrus.Errorf("user(%d) follow topic(%d) failed: %s", req.Uid, req.TopicId, err) return web.ErrFollowTopicFailed @@ -114,7 +113,7 @@ func (s *privSrv) FollowTopic(req *web.FollowTopicReq) mir.Error { return nil } -func (s *privSrv) StickTopic(req *web.StickTopicReq) (*web.StickTopicResp, mir.Error) { +func (s *privSrv) StickTopic(req *web.StickTopicReq) (*web.StickTopicResp, error) { status, err := s.Ds.StickTopic(req.Uid, req.TopicId) if err != nil { logrus.Errorf("user(%d) stick topic(%d) failed: %s", req.Uid, req.TopicId, err) @@ -125,7 +124,7 @@ func (s *privSrv) StickTopic(req *web.StickTopicReq) (*web.StickTopicResp, mir.E }, nil } -func (s *privSrv) PinTopic(req *web.PinTopicReq) (*web.PinTopicResp, mir.Error) { +func (s *privSrv) PinTopic(req *web.PinTopicReq) (*web.PinTopicResp, error) { status, err := s.Ds.PinTopic(req.Uid, req.TopicId) if err != nil { logrus.Errorf("user(%d) pin topic(%d) failed: %s", req.Uid, req.TopicId, err) @@ -136,7 +135,7 @@ func (s *privSrv) PinTopic(req *web.PinTopicReq) (*web.PinTopicResp, mir.Error) }, nil } -func (s *privSrv) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAttachmentResp, mir.Error) { +func (s *privSrv) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAttachmentResp, error) { defer req.File.Close() // 生成随机路径 @@ -182,7 +181,7 @@ func (s *privSrv) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAtt }, nil } -func (s *privSrv) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, mir.Error) { +func (s *privSrv) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, error) { content, err := s.Ds.GetPostContentByID(req.ContentID) if err != nil { logrus.Errorf("Ds.GetPostContentByID err: %s", err) @@ -205,7 +204,7 @@ func (s *privSrv) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheck return resp, nil } -func (s *privSrv) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, mir.Error) { +func (s *privSrv) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, error) { content, err := s.Ds.GetPostContentByID(req.ContentID) if err != nil { logrus.Errorf("s.GetPostContentByID err: %v", err) @@ -249,7 +248,7 @@ func (s *privSrv) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.Downl }, nil } -func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp, xerr mir.Error) { +func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp, xerr error) { var mediaContents []string defer func() { if xerr != nil { @@ -336,7 +335,7 @@ func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp, return (*web.CreateTweetResp)(formatedPosts[0]), nil } -func (s *privSrv) DeleteTweet(req *web.DeleteTweetReq) mir.Error { +func (s *privSrv) DeleteTweet(req *web.DeleteTweetReq) error { if req.User == nil { return web.ErrNoPermission } @@ -368,7 +367,7 @@ func (s *privSrv) DeleteTweet(req *web.DeleteTweetReq) mir.Error { return nil } -func (s *privSrv) DeleteCommentReply(req *web.DeleteCommentReplyReq) mir.Error { +func (s *privSrv) DeleteCommentReply(req *web.DeleteCommentReplyReq) error { reply, err := s.Ds.GetCommentReplyByID(req.ID) if err != nil { logrus.Errorf("Ds.GetCommentReplyByID err: %s", err) @@ -390,7 +389,7 @@ func (s *privSrv) DeleteCommentReply(req *web.DeleteCommentReplyReq) mir.Error { return nil } -func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (_ *web.CreateCommentReplyResp, xerr mir.Error) { +func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (_ *web.CreateCommentReplyResp, xerr error) { var ( post *ms.Post comment *ms.Comment @@ -470,7 +469,7 @@ func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (_ *web.Cre return (*web.CreateCommentReplyResp)(reply), nil } -func (s *privSrv) DeleteComment(req *web.DeleteCommentReq) mir.Error { +func (s *privSrv) DeleteComment(req *web.DeleteCommentReq) error { comment, err := s.Ds.GetCommentByID(req.ID) if err != nil { logrus.Errorf("Ds.GetCommentByID err: %v\n", err) @@ -499,7 +498,7 @@ func (s *privSrv) DeleteComment(req *web.DeleteCommentReq) mir.Error { return nil } -func (s *privSrv) HighlightComment(req *web.HighlightCommentReq) (*web.HighlightCommentResp, mir.Error) { +func (s *privSrv) HighlightComment(req *web.HighlightCommentReq) (*web.HighlightCommentResp, error) { status, err := s.Ds.HighlightComment(req.Uid, req.CommentId) if err == cs.ErrNoPermission { return nil, web.ErrNoPermission @@ -515,7 +514,7 @@ func (s *privSrv) HighlightComment(req *web.HighlightCommentReq) (*web.Highlight }, nil } -func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateCommentResp, xerr mir.Error) { +func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateCommentResp, xerr error) { var ( mediaContents []string err error @@ -609,7 +608,7 @@ func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateComment return (*web.CreateCommentResp)(comment), nil } -func (s *privSrv) CollectionTweet(req *web.CollectionTweetReq) (*web.CollectionTweetResp, mir.Error) { +func (s *privSrv) CollectionTweet(req *web.CollectionTweetReq) (*web.CollectionTweetResp, error) { status := false collection, err := s.Ds.GetUserPostCollection(req.ID, req.Uid) if err != nil { @@ -629,7 +628,7 @@ func (s *privSrv) CollectionTweet(req *web.CollectionTweetReq) (*web.CollectionT }, nil } -func (s *privSrv) StarTweet(req *web.StarTweetReq) (*web.StarTweetResp, mir.Error) { +func (s *privSrv) StarTweet(req *web.StarTweetReq) (*web.StarTweetResp, error) { status := false star, err := s.Ds.GetUserPostStar(req.ID, req.Uid) if err != nil { @@ -649,7 +648,7 @@ func (s *privSrv) StarTweet(req *web.StarTweetReq) (*web.StarTweetResp, mir.Erro }, nil } -func (s *privSrv) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp, mir.Error) { +func (s *privSrv) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp, error) { if req.Visibility >= web.TweetVisitInvalid { return nil, xerror.InvalidParams } @@ -674,7 +673,7 @@ func (s *privSrv) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp, }, nil } -func (s *privSrv) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, mir.Error) { +func (s *privSrv) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, error) { post, err := s.Ds.GetPostByID(req.ID) if err != nil { logrus.Errorf("Ds.GetPostByID err: %v\n", err) @@ -692,7 +691,7 @@ func (s *privSrv) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, mir.E }, nil } -func (s *privSrv) HighlightTweet(req *web.HighlightTweetReq) (res *web.HighlightTweetResp, err mir.Error) { +func (s *privSrv) HighlightTweet(req *web.HighlightTweetReq) (res *web.HighlightTweetResp, err error) { if status, xerr := s.Ds.HighlightPost(req.User.ID, req.ID); xerr == nil { res = &web.HighlightTweetResp{ HighlightStatus: status, @@ -707,7 +706,7 @@ func (s *privSrv) HighlightTweet(req *web.HighlightTweetReq) (res *web.Highlight return } -func (s *privSrv) LockTweet(req *web.LockTweetReq) (*web.LockTweetResp, mir.Error) { +func (s *privSrv) LockTweet(req *web.LockTweetReq) (*web.LockTweetResp, error) { post, err := s.Ds.GetPostByID(req.ID) if err != nil { return nil, web.ErrLockPostFailed @@ -781,7 +780,7 @@ func (s *privSrv) createPostPreHandler(commentID int64, userID, atUserID int64) return post, comment, atUserID, nil } -func (s *privSrv) createPostStar(postID, userID int64) (*ms.PostStar, mir.Error) { +func (s *privSrv) createPostStar(postID, userID int64) (*ms.PostStar, error) { post, err := s.Ds.GetPostByID(postID) if err != nil { return nil, xerror.ServerError @@ -807,7 +806,7 @@ func (s *privSrv) createPostStar(postID, userID int64) (*ms.PostStar, mir.Error) return star, nil } -func (s *privSrv) deletePostStar(star *ms.PostStar) mir.Error { +func (s *privSrv) deletePostStar(star *ms.PostStar) error { post, err := s.Ds.GetPostByID(star.PostID) if err != nil { return xerror.ServerError @@ -832,7 +831,7 @@ func (s *privSrv) deletePostStar(star *ms.PostStar) mir.Error { return nil } -func (s *privSrv) createPostCollection(postID, userID int64) (*ms.PostCollection, mir.Error) { +func (s *privSrv) createPostCollection(postID, userID int64) (*ms.PostCollection, error) { post, err := s.Ds.GetPostByID(postID) if err != nil { return nil, xerror.ServerError @@ -858,7 +857,7 @@ func (s *privSrv) createPostCollection(postID, userID int64) (*ms.PostCollection return collection, nil } -func (s *privSrv) deletePostCollection(collection *ms.PostCollection) mir.Error { +func (s *privSrv) deletePostCollection(collection *ms.PostCollection) error { post, err := s.Ds.GetPostByID(collection.PostID) if err != nil { return xerror.ServerError @@ -887,7 +886,7 @@ func (s *privSrv) checkPostAttachmentIsPaid(postID, userID int64) bool { return err == nil && bill.Model != nil && bill.ID > 0 } -func (s *privSrv) buyPostAttachment(post *ms.Post, user *ms.User) mir.Error { +func (s *privSrv) buyPostAttachment(post *ms.Post, user *ms.User) error { if user.Balance < post.AttachmentPrice { return web.ErrInsuffientDownloadMoney } diff --git a/internal/servants/web/pub.go b/internal/servants/web/pub.go index b74f2d6a..fa81cae5 100644 --- a/internal/servants/web/pub.go +++ b/internal/servants/web/pub.go @@ -14,7 +14,6 @@ import ( "unicode/utf8" "github.com/afocus/captcha" - "github.com/alimy/mir/v5" "github.com/gofrs/uuid/v5" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/core/ms" @@ -42,7 +41,7 @@ type pubSrv struct { *base.DaoServant } -func (s *pubSrv) SendCaptcha(req *web.SendCaptchaReq) mir.Error { +func (s *pubSrv) SendCaptcha(req *web.SendCaptchaReq) error { ctx := context.Background() // 验证图片验证码 @@ -66,7 +65,7 @@ func (s *pubSrv) SendCaptcha(req *web.SendCaptchaReq) mir.Error { return nil } -func (s *pubSrv) GetCaptcha() (*web.GetCaptchaResp, mir.Error) { +func (s *pubSrv) GetCaptcha() (*web.GetCaptchaResp, error) { cap := captcha.New() if err := cap.AddFontFromBytes(assets.ComicBytes); err != nil { logrus.Errorf("cap.AddFontFromBytes err:%s", err) @@ -91,7 +90,7 @@ func (s *pubSrv) GetCaptcha() (*web.GetCaptchaResp, mir.Error) { }, nil } -func (s *pubSrv) Register(req *web.RegisterReq) (*web.RegisterResp, mir.Error) { +func (s *pubSrv) Register(req *web.RegisterReq) (*web.RegisterResp, error) { if _disallowUserRegister { return nil, web.ErrDisallowUserRegister } @@ -124,7 +123,7 @@ func (s *pubSrv) Register(req *web.RegisterReq) (*web.RegisterResp, mir.Error) { }, nil } -func (s *pubSrv) Login(req *web.LoginReq) (*web.LoginResp, mir.Error) { +func (s *pubSrv) Login(req *web.LoginReq) (*web.LoginResp, error) { ctx := context.Background() user, err := s.Ds.GetUserByUsername(req.Username) if err != nil { @@ -162,14 +161,14 @@ func (s *pubSrv) Login(req *web.LoginReq) (*web.LoginResp, mir.Error) { }, nil } -func (s *pubSrv) Version() (*web.VersionResp, mir.Error) { +func (s *pubSrv) Version() (*web.VersionResp, error) { return &web.VersionResp{ BuildInfo: version.ReadBuildInfo(), }, nil } // validUsername 验证用户 -func (s *pubSrv) validUsername(username string) mir.Error { +func (s *pubSrv) validUsername(username string) error { // 检测用户是否合规 if utf8.RuneCountInString(username) < 3 || utf8.RuneCountInString(username) > 12 { return web.ErrUsernameLengthLimit diff --git a/internal/servants/web/relax.go b/internal/servants/web/relax.go index ea36f76b..b92f167d 100644 --- a/internal/servants/web/relax.go +++ b/internal/servants/web/relax.go @@ -5,7 +5,6 @@ package web import ( - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" "github.com/redis/rueidis" api "github.com/rocboss/paopao-ce/auto/api/v1" @@ -38,7 +37,7 @@ func (s *relaxSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JwtSurely()} } -func (s *relaxSrv) GetUnreadMsgCount(req *web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, mir.Error) { +func (s *relaxSrv) GetUnreadMsgCount(req *web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, error) { if data, xerr := s.wc.GetUnreadMsgCountResp(req.Uid); xerr == nil && len(data) > 0 { // logrus.Debugln("GetUnreadMsgCount get resp from cache") return &web.GetUnreadMsgCountResp{ diff --git a/internal/servants/web/site.go b/internal/servants/web/site.go index d92608d9..1dbc1832 100644 --- a/internal/servants/web/site.go +++ b/internal/servants/web/site.go @@ -5,7 +5,6 @@ package web import ( - "github.com/alimy/mir/v5" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/conf" "github.com/rocboss/paopao-ce/internal/model/web" @@ -22,11 +21,11 @@ type siteSrv struct { *base.BaseServant } -func (*siteSrv) Profile() (*web.SiteProfileResp, mir.Error) { +func (*siteSrv) Profile() (*web.SiteProfileResp, error) { return conf.WebProfileSetting, nil } -func (*siteSrv) Version() (*web.VersionResp, mir.Error) { +func (*siteSrv) Version() (*web.VersionResp, error) { return &web.VersionResp{ BuildInfo: version.ReadBuildInfo(), }, nil diff --git a/internal/servants/web/trends.go b/internal/servants/web/trends.go index 9c9ce7d2..0b5ccf66 100644 --- a/internal/servants/web/trends.go +++ b/internal/servants/web/trends.go @@ -7,7 +7,6 @@ package web import ( "fmt" - "github.com/alimy/mir/v5" "github.com/gin-gonic/gin" api "github.com/rocboss/paopao-ce/auto/api/v1" "github.com/rocboss/paopao-ce/internal/conf" @@ -35,7 +34,7 @@ func (s *trendsSrv) Chain() gin.HandlersChain { return gin.HandlersChain{chain.JWT()} } -func (s *trendsSrv) GetIndexTrends(req *web.GetIndexTrendsReq) (res *web.GetIndexTrendsResp, _ mir.Error) { +func (s *trendsSrv) GetIndexTrends(req *web.GetIndexTrendsReq) (res *web.GetIndexTrendsResp, _ error) { limit, offset := req.PageSize, (req.Page-1)*req.PageSize // 尝试直接从缓存中获取数据 key, ok := "", false diff --git a/internal/servants/web/utils.go b/internal/servants/web/utils.go index 9dd24267..24eaabc3 100644 --- a/internal/servants/web/utils.go +++ b/internal/servants/web/utils.go @@ -11,7 +11,6 @@ import ( "time" "unicode/utf8" - "github.com/alimy/mir/v5" "github.com/gofrs/uuid/v5" "github.com/rocboss/paopao-ce/internal/core" "github.com/rocboss/paopao-ce/internal/core/ms" @@ -80,7 +79,7 @@ func getRandomAvatar() string { } // checkPassword 密码检查 -func checkPassword(password string) mir.Error { +func checkPassword(password string) error { // 检测用户是否合规 if utf8.RuneCountInString(password) < 6 || utf8.RuneCountInString(password) > 16 { return web.ErrPasswordLengthLimit @@ -137,7 +136,7 @@ func persistMediaContents(oss core.ObjectStorageService, contents []*web.PostCon return } -func fileCheck(uploadType string, size int64) mir.Error { +func fileCheck(uploadType string, size int64) error { if uploadType != "public/video" && uploadType != "public/image" && uploadType != "public/avatar" && @@ -150,7 +149,7 @@ func fileCheck(uploadType string, size int64) mir.Error { return nil } -func getFileExt(s string) (string, mir.Error) { +func getFileExt(s string) (string, error) { switch s { case "image/png": return ".png", nil @@ -201,7 +200,7 @@ func tagsFrom(originTags []string) []string { } // checkPermision 检查是否拥有者或管理员 -func checkPermision(user *ms.User, targetUserId int64) mir.Error { +func checkPermision(user *ms.User, targetUserId int64) error { if user == nil || (user.ID != targetUserId && !user.IsAdmin) { return web.ErrNoPermission } @@ -209,7 +208,7 @@ func checkPermision(user *ms.User, targetUserId int64) mir.Error { } // checkPostViewPermission 检查当前用户是否可读指定post -func checkPostViewPermission(user *ms.User, post *ms.Post, ds core.DataService) mir.Error { +func checkPostViewPermission(user *ms.User, post *ms.Post, ds core.DataService) error { if post.Visibility == core.PostVisitPublic { return nil } diff --git a/pkg/app/app.go b/pkg/app/app.go index 2d5c11c5..9b742477 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -62,6 +62,6 @@ func (r *Response) ToErrorResponse(err *xerror.Error) { if len(details) > 0 { response["details"] = details } - - r.Ctx.JSON(xerror.HttpStatusCode(err), response) + statusCode, _ := xerror.HttpStatusCode(err) + r.Ctx.JSON(statusCode, response) } diff --git a/pkg/xerror/xerror.go b/pkg/xerror/xerror.go index 249d0914..6f575732 100644 --- a/pkg/xerror/xerror.go +++ b/pkg/xerror/xerror.go @@ -82,26 +82,27 @@ func (e *Error) WithDetails(details ...string) *Error { return &newError } -func HttpStatusCode(e mir.Error) int { - switch e.StatusCode() { +func HttpStatusCode(e error) (statusCode int, code int) { + var ok bool + statusCode = http.StatusInternalServerError + if code, ok = mir.HttpStatusCode(e); !ok { + return + } + switch code { case Success.StatusCode(): - return http.StatusOK + statusCode = http.StatusOK case ServerError.StatusCode(): - return http.StatusInternalServerError + statusCode = http.StatusInternalServerError case InvalidParams.StatusCode(): - return http.StatusBadRequest - case UnauthorizedAuthNotExist.StatusCode(): - fallthrough - case UnauthorizedAuthFailed.StatusCode(): - fallthrough - case UnauthorizedTokenError.StatusCode(): - fallthrough - case UnauthorizedTokenGenerate.StatusCode(): - fallthrough - case UnauthorizedTokenTimeout.StatusCode(): - return http.StatusUnauthorized + statusCode = http.StatusBadRequest + case UnauthorizedAuthNotExist.StatusCode(), + UnauthorizedAuthFailed.StatusCode(), + UnauthorizedTokenError.StatusCode(), + UnauthorizedTokenGenerate.StatusCode(), + UnauthorizedTokenTimeout.StatusCode(): + statusCode = http.StatusUnauthorized case TooManyRequests.StatusCode(): - return http.StatusTooManyRequests + statusCode = http.StatusTooManyRequests } - return http.StatusInternalServerError + return }