Documentation
¶
Index ¶
- func IsNetworkError(err error) bool
- func IsNotFoundError(err error) bool
- func IsUnauthorizedError(err error) bool
- type APIError
- type AnswerService
- func (s *AnswerService) Accept(ctx context.Context, questionID, answerID string) error
- func (s *AnswerService) Add(ctx context.Context, req *models.AnswerAddReq) (*models.AnswerInfo, error)
- func (s *AnswerService) Delete(ctx context.Context, id string) error
- func (s *AnswerService) Get(ctx context.Context, id string) (*models.AnswerInfo, error)
- func (s *AnswerService) Page(ctx context.Context, req *models.AnswerListReq) (*models.AnswerListResp, error)
- func (s *AnswerService) Update(ctx context.Context, req *models.AnswerUpdateReq) error
- type AuthService
- type Client
- func (c *Client) DeleteJSON(ctx context.Context, path string, body interface{}) error
- func (c *Client) GetJSON(ctx context.Context, path string, params map[string]string, result interface{}) error
- func (c *Client) GetToken() string
- func (c *Client) PostJSON(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) PutJSON(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) SetToken(token string)
- type CommentService
- func (s *CommentService) Add(ctx context.Context, req *models.CommentAddReq) (*models.CommentInfo, error)
- func (s *CommentService) Delete(ctx context.Context, id string) error
- func (s *CommentService) Get(ctx context.Context, id string) (*models.CommentInfo, error)
- func (s *CommentService) Page(ctx context.Context, req *models.CommentListReq) (*models.CommentListResp, error)
- func (s *CommentService) Update(ctx context.Context, req *models.CommentUpdateReq) error
- type Config
- type NotificationService
- func (s *NotificationService) ClearAll(ctx context.Context, nType string) error
- func (s *NotificationService) ClearID(ctx context.Context, id string) error
- func (s *NotificationService) Page(ctx context.Context, req *models.NotificationListReq) (*models.NotificationListResp, error)
- func (s *NotificationService) Status(ctx context.Context) (*models.NotificationStatusResp, error)
- type QuestionService
- func (s *QuestionService) Add(ctx context.Context, req *models.QuestionAddReq) (*models.QuestionInfoResp, error)
- func (s *QuestionService) Close(ctx context.Context, id string, closeType int, closeMsg string) error
- func (s *QuestionService) Delete(ctx context.Context, id string) error
- func (s *QuestionService) Get(ctx context.Context, id string) (*models.QuestionInfoResp, error)
- func (s *QuestionService) Page(ctx context.Context, req *models.QuestionListReq) (*models.QuestionPageResp, error)
- func (s *QuestionService) Reopen(ctx context.Context, id string) error
- func (s *QuestionService) Update(ctx context.Context, req *models.QuestionUpdateReq) error
- type RespBody
- type SearchService
- type TagService
- func (s *TagService) Add(ctx context.Context, req *models.TagAddReq) (*models.TagDetail, error)
- func (s *TagService) Delete(ctx context.Context, slugName string) error
- func (s *TagService) Get(ctx context.Context, slugName string) (*models.TagDetail, error)
- func (s *TagService) Page(ctx context.Context, req *models.TagListReq) (*models.TagListResp, error)
- func (s *TagService) Search(ctx context.Context, prefix string) ([]*models.TagItem, error)
- func (s *TagService) Update(ctx context.Context, req *models.TagUpdateReq) error
- type UserService
- type VoteService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNetworkError ¶
func IsNotFoundError ¶
func IsUnauthorizedError ¶
Types ¶
type AnswerService ¶
type AnswerService struct {
// contains filtered or unexported fields
}
func NewAnswerService ¶
func NewAnswerService(client *Client) *AnswerService
func (*AnswerService) Accept ¶
func (s *AnswerService) Accept(ctx context.Context, questionID, answerID string) error
func (*AnswerService) Add ¶
func (s *AnswerService) Add(ctx context.Context, req *models.AnswerAddReq) (*models.AnswerInfo, error)
func (*AnswerService) Get ¶
func (s *AnswerService) Get(ctx context.Context, id string) (*models.AnswerInfo, error)
func (*AnswerService) Page ¶
func (s *AnswerService) Page(ctx context.Context, req *models.AnswerListReq) (*models.AnswerListResp, error)
func (*AnswerService) Update ¶
func (s *AnswerService) Update(ctx context.Context, req *models.AnswerUpdateReq) error
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
func NewAuthService ¶
func NewAuthService(client *Client) *AuthService
func (*AuthService) GetCurrentUser ¶
func (s *AuthService) GetCurrentUser(ctx context.Context) (*models.UserInfoResp, error)
func (*AuthService) IsAuthenticated ¶
func (s *AuthService) IsAuthenticated() bool
func (*AuthService) Login ¶
func (s *AuthService) Login(ctx context.Context, email, pass string) (*models.LoginResponse, error)
type Client ¶
type Client struct {
Comment *CommentService
Tag *TagService
Search *SearchService
Notification *NotificationService
User *UserService
Vote *VoteService
Question *QuestionService
Answer *AnswerService
// contains filtered or unexported fields
}
func (*Client) DeleteJSON ¶
DeleteJSON DELETE 请求并解包 RespBody
func (*Client) GetJSON ¶
func (c *Client) GetJSON(ctx context.Context, path string, params map[string]string, result interface{}) error
GetJSON GET 请求并解包 RespBody
func (*Client) PostJSON ¶
func (c *Client) PostJSON(ctx context.Context, path string, body interface{}, result interface{}) error
PostJSON POST 请求并解包 RespBody
type CommentService ¶
type CommentService struct {
// contains filtered or unexported fields
}
func NewCommentService ¶
func NewCommentService(client *Client) *CommentService
func (*CommentService) Add ¶
func (s *CommentService) Add(ctx context.Context, req *models.CommentAddReq) (*models.CommentInfo, error)
func (*CommentService) Delete ¶
func (s *CommentService) Delete(ctx context.Context, id string) error
func (*CommentService) Get ¶
func (s *CommentService) Get(ctx context.Context, id string) (*models.CommentInfo, error)
func (*CommentService) Page ¶
func (s *CommentService) Page(ctx context.Context, req *models.CommentListReq) (*models.CommentListResp, error)
func (*CommentService) Update ¶
func (s *CommentService) Update(ctx context.Context, req *models.CommentUpdateReq) error
type NotificationService ¶
type NotificationService struct {
// contains filtered or unexported fields
}
func NewNotificationService ¶
func NewNotificationService(client *Client) *NotificationService
func (*NotificationService) ClearAll ¶
func (s *NotificationService) ClearAll(ctx context.Context, nType string) error
func (*NotificationService) ClearID ¶
func (s *NotificationService) ClearID(ctx context.Context, id string) error
func (*NotificationService) Page ¶
func (s *NotificationService) Page(ctx context.Context, req *models.NotificationListReq) (*models.NotificationListResp, error)
func (*NotificationService) Status ¶
func (s *NotificationService) Status(ctx context.Context) (*models.NotificationStatusResp, error)
type QuestionService ¶
type QuestionService struct {
// contains filtered or unexported fields
}
func NewQuestionService ¶
func NewQuestionService(client *Client) *QuestionService
func (*QuestionService) Add ¶
func (s *QuestionService) Add(ctx context.Context, req *models.QuestionAddReq) (*models.QuestionInfoResp, error)
func (*QuestionService) Delete ¶
func (s *QuestionService) Delete(ctx context.Context, id string) error
func (*QuestionService) Get ¶
func (s *QuestionService) Get(ctx context.Context, id string) (*models.QuestionInfoResp, error)
func (*QuestionService) Page ¶
func (s *QuestionService) Page(ctx context.Context, req *models.QuestionListReq) (*models.QuestionPageResp, error)
func (*QuestionService) Reopen ¶
func (s *QuestionService) Reopen(ctx context.Context, id string) error
func (*QuestionService) Update ¶
func (s *QuestionService) Update(ctx context.Context, req *models.QuestionUpdateReq) error
type RespBody ¶
type RespBody struct {
Code int `json:"code"`
Reason string `json:"reason"`
Message string `json:"msg"`
Data json.RawMessage `json:"data"`
}
RespBody Answer API 统一响应结构
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
func NewSearchService ¶
func NewSearchService(client *Client) *SearchService
func (*SearchService) Search ¶
func (s *SearchService) Search(ctx context.Context, req *models.SearchReq) (*models.SearchResp, error)
type TagService ¶
type TagService struct {
// contains filtered or unexported fields
}
func NewTagService ¶
func NewTagService(client *Client) *TagService
func (*TagService) Page ¶
func (s *TagService) Page(ctx context.Context, req *models.TagListReq) (*models.TagListResp, error)
func (*TagService) Update ¶
func (s *TagService) Update(ctx context.Context, req *models.TagUpdateReq) error
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService 用户服务
func (*UserService) GetByUsername ¶
func (s *UserService) GetByUsername(ctx context.Context) (*models.UserBasicInfo, error)
GetByUsername 获取当前登录用户信息
func (*UserService) SearchUsers ¶
func (s *UserService) SearchUsers(ctx context.Context, query string) ([]*models.UserBasicInfo, error)
SearchUsers 搜索用户
type VoteService ¶
type VoteService struct {
// contains filtered or unexported fields
}
func NewVoteService ¶
func NewVoteService(client *Client) *VoteService
Click to show internal directories.
Click to hide internal directories.