Documentation
¶
Index ¶
- Constants
- Variables
- func CasdoorConfigInit()
- type Account
- type AppConfig
- type Article
- type ArticleEntry
- type ArticleLike
- type CasdoorConfig
- type CasdoorSDKService
- type CasdoorSDKServiceAdapter
- func (c *CasdoorSDKServiceAdapter) GetApplication(name string) (*casdoorsdk.Application, error)
- func (c *CasdoorSDKServiceAdapter) GetOAuthToken(code string, state string) (token *oauth2.Token, err error)
- func (c *CasdoorSDKServiceAdapter) GetUser(name string) (user *casdoorsdk.User, err error)
- func (c *CasdoorSDKServiceAdapter) GetUserById(uid string) (user *casdoorsdk.User, err error)
- func (c *CasdoorSDKServiceAdapter) GetUserByUserId(uid string) (user *casdoorsdk.User, err error)
- func (c *CasdoorSDKServiceAdapter) GetUserClaim(uid string) (claim *casdoorsdk.User, err error)
- func (c *CasdoorSDKServiceAdapter) GetUsers() ([]*casdoorsdk.User, error)
- func (c *CasdoorSDKServiceAdapter) ParseJwtToken(token string) (claims *casdoorsdk.Claims, err error)
- func (c *CasdoorSDKServiceAdapter) UpdateCasdoorUserById(uid string, user *casdoorsdk.User) (res bool, err error)
- func (c *CasdoorSDKServiceAdapter) UpdateUser(user *UserInfo) (res bool, err error)
- func (c *CasdoorSDKServiceAdapter) UpdateUserById(uid string, user *UserInfo) (res bool, err error)
- type Community
- func (p *Community) Article(ctx context.Context, id string) (article *Article, err error)
- func (a *Community) ArticleLView(ctx context.Context, articleId, ip, userId, platform string)
- func (p *Community) ArticleLike(ctx context.Context, articleId int, userId string) (bool, error)
- func (p *Community) ArticleLikeState(ctx context.Context, userId, articleId string) (bool, error)
- func (p *Community) CanEditable(ctx context.Context, uid, id string) (editable bool, err error)
- func (c *Community) DelMedia(ctx context.Context, userId, mediaId string) error
- func (c *Community) DelMedias(ctx context.Context, userId string, ids []string) error
- func (p *Community) DeleteArticle(ctx context.Context, uid, id string) (err error)
- func (p *Community) GetAccessToken(code, state string) (token *oauth2.Token, err error)
- func (p *Community) GetApplicationInfo() (*casdoorsdk.Application, error)
- func (p *Community) GetArticlesByUid(ctx context.Context, uid string, page string, limit int) (items []*ArticleEntry, next string, err error)
- func (p *Community) GetClientIP(r *http.Request) string
- func (c *Community) GetMediaType(ctx context.Context, mediaId string) (string, error)
- func (c *Community) GetMediaUrl(ctx context.Context, mediaId string) (string, error)
- func (p *Community) GetOAuthToken(code string, state string) (token *oauth2.Token, err error)
- func (p *Community) GetTranslateArticle(ctx context.Context, id string) (article *Article, err error)
- func (p *Community) GetUser(token string) (user *User, err error)
- func (p *Community) GetUserAuthById(uid string) (user *UserAuth, err error)
- func (p *Community) GetUserById(uid string) (user *User, err error)
- func (p *Community) GetUserClaim(uid string) (claim *casdoorsdk.User, err error)
- func (c *Community) GetVideoDuration(url string) (duration string, err error)
- func (c *Community) GetVideoSubtitle(ctx context.Context, mediaId string) (string, string, error)
- func (p *Community) IsAdmin(uid string) (res bool, err error)
- func (p *Community) ListArticle(ctx context.Context, from string, limit int, searchValue string, label string) (items []*ArticleEntry, next string, err error)
- func (c *Community) ListMediaByUserId(ctx context.Context, userId string, format string, page, limitInt int) ([]File, int, error)
- func (p *Community) ListPageUsers(from, limit int) (users []*UserAuth, next int, err error)
- func (c *Community) NewVideoTask(ctx context.Context, userId, resourceId string) error
- func (p *Community) ParseJwtToken(token string) (userId string, err error)
- func (p *Community) PutArticle(ctx context.Context, uid string, article *Article) (id string, err error)
- func (p *Community) RedirectToCasdoor(redirect string) (loginURL string)
- func (c *Community) RetryCaptionGenerate(ctx context.Context, userId, videoId string) error
- func (c *Community) SaveMedia(ctx context.Context, userId string, data []byte, fileExt string) (int64, error)
- func (c *Community) SetVideoTaskCache(key string, value VideoTaskTimestamp)
- func (c *Community) SetVideoTaskFailed(ctx context.Context, resourceId string) error
- func (c *Community) SetVideoTaskOutput(ctx context.Context, resourceId string, output string) error
- func (c *Community) SetVideoTaskSuccess(ctx context.Context, resourceId string) error
- func (p *Community) Share(ip, platform, userId, articleId string)
- func (c *Community) TimedCheckVideoTask(ctx context.Context, timeout time.Duration)
- func (p *Community) TranslateArticle(ctx context.Context, inputArticle *Article) (translatedArticle *Article, err error)
- func (p *Community) TranslateMarkdownText(ctx context.Context, src string, from string, to language.Tag) (string, error)
- func (p *Community) UpdateUser(user *UserInfo) (res bool, err error)
- func (p *Community) UpdateUserById(uid string, user *UserInfo) (res bool, err error)
- func (p *Community) UpdateUserPublicAuth(uid string, publicAuth bool) (res bool, err error)
- type Config
- type DBConfig
- type File
- type PlatformCount
- type QiNiuConfig
- type S3Reader
- type S3Service
- type S3ServiceAdapter
- func (s *S3ServiceAdapter) Delete(ctx context.Context, key string) (err error)
- func (s *S3ServiceAdapter) NewReader(ctx context.Context, key string, opts *blob.ReaderOptions) (_ S3Reader, err error)
- func (s *S3ServiceAdapter) NewWriter(ctx context.Context, key string, opts *blob.WriterOptions) (_ S3Writer, err error)
- type S3Writer
- type Translation
- type Userdeprecated
- type UserAuth
- type UserClaim
- type UserInfo
- type VideoSubtitle
- type VideoTask
- type VideoTaskCache
- type VideoTaskMap
- type VideoTaskTimestamp
Constants ¶
const ( MarkBegin = "" MarkEnd = "eof" )
const PublicAuthKey = "communityPublicAuth"
Variables ¶
var ( ErrNotExist = os.ErrNotExist ErrPermission = os.ErrPermission Twitter = "twitter" FaceBook = "facebook" WeChat = "wechat" )
var (
ErrTimeout = errors.New("timeout")
)
Functions ¶
Types ¶
type Article ¶
type Article struct { ArticleEntry Content string // in markdown Trans bool VttId string }
type ArticleEntry ¶
type ArticleLike ¶ added in v1.0.0
type CasdoorConfig ¶ added in v1.0.0
type CasdoorSDKService ¶ added in v1.0.0
type CasdoorSDKService interface { GetUser(name string) (user *casdoorsdk.User, err error) GetUsers() ([]*casdoorsdk.User, error) ParseJwtToken(token string) (claims *casdoorsdk.Claims, err error) GetUserClaim(uid string) (claim *casdoorsdk.User, err error) GetUserById(uid string) (user *casdoorsdk.User, err error) UpdateUserById(uid string, user *UserInfo) (res bool, err error) UpdateCasdoorUserById(uid string, user *casdoorsdk.User) (res bool, err error) UpdateUser(user *UserInfo) (res bool, err error) GetUserByUserId(uid string) (user *casdoorsdk.User, err error) GetOAuthToken(code string, state string) (token *oauth2.Token, err error) GetApplication(name string) (*casdoorsdk.Application, error) }
CasdoorSDKService is the interface for casdoor sdk and easy to mock
type CasdoorSDKServiceAdapter ¶ added in v1.0.0
type CasdoorSDKServiceAdapter struct{}
Adapter for mock
func (*CasdoorSDKServiceAdapter) GetApplication ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) GetApplication(name string) (*casdoorsdk.Application, error)
func (*CasdoorSDKServiceAdapter) GetOAuthToken ¶ added in v1.0.0
func (*CasdoorSDKServiceAdapter) GetUser ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) GetUser(name string) (user *casdoorsdk.User, err error)
func (*CasdoorSDKServiceAdapter) GetUserById ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) GetUserById(uid string) (user *casdoorsdk.User, err error)
func (*CasdoorSDKServiceAdapter) GetUserByUserId ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) GetUserByUserId(uid string) (user *casdoorsdk.User, err error)
func (*CasdoorSDKServiceAdapter) GetUserClaim ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) GetUserClaim(uid string) (claim *casdoorsdk.User, err error)
func (*CasdoorSDKServiceAdapter) GetUsers ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) GetUsers() ([]*casdoorsdk.User, error)
func (*CasdoorSDKServiceAdapter) ParseJwtToken ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) ParseJwtToken(token string) (claims *casdoorsdk.Claims, err error)
func (*CasdoorSDKServiceAdapter) UpdateCasdoorUserById ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) UpdateCasdoorUserById(uid string, user *casdoorsdk.User) (res bool, err error)
func (*CasdoorSDKServiceAdapter) UpdateUser ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) UpdateUser(user *UserInfo) (res bool, err error)
func (*CasdoorSDKServiceAdapter) UpdateUserById ¶ added in v1.0.0
func (c *CasdoorSDKServiceAdapter) UpdateUserById(uid string, user *UserInfo) (res bool, err error)
type Community ¶
type Community struct { // Casdoor Service for mock CasdoorSDKService CasdoorSDKService S3Service S3Service // contains filtered or unexported fields }
func (*Community) ArticleLView ¶ added in v1.0.0
func (*Community) ArticleLike ¶ added in v1.0.0
func (*Community) ArticleLikeState ¶ added in v1.0.0
func (*Community) CanEditable ¶
CanEditable determine whether the user has the permission to operate.
func (*Community) DeleteArticle ¶
DeleteArticle delete the article.
func (*Community) GetAccessToken ¶ added in v1.0.0
func (*Community) GetApplicationInfo ¶ added in v1.0.0
func (p *Community) GetApplicationInfo() (*casdoorsdk.Application, error)
get community application information
func (*Community) GetArticlesByUid ¶ added in v1.0.0
func (p *Community) GetArticlesByUid(ctx context.Context, uid string, page string, limit int) (items []*ArticleEntry, next string, err error)
GetArticlesByUid get articles by user id.
func (*Community) GetClientIP ¶ added in v1.0.0
func (*Community) GetMediaType ¶ added in v1.0.0
func (*Community) GetMediaUrl ¶ added in v1.0.0
get file key
func (*Community) GetOAuthToken ¶ added in v1.0.0
func (*Community) GetTranslateArticle ¶ added in v1.0.0
func (*Community) GetUserAuthById ¶ added in v1.0.0
GetUserAuthById get userAuth by uid
func (*Community) GetUserById ¶ added in v1.0.0
GetUserById get user by uid
func (*Community) GetUserClaim ¶ added in v1.0.0
func (p *Community) GetUserClaim(uid string) (claim *casdoorsdk.User, err error)
GetUserClaim get user(full) by token
func (*Community) GetVideoDuration ¶ added in v1.0.0
func (*Community) GetVideoSubtitle ¶ added in v1.0.0
func (*Community) ListArticle ¶
func (p *Community) ListArticle(ctx context.Context, from string, limit int, searchValue string, label string) (items []*ArticleEntry, next string, err error)
ListArticle lists articles from a position.
func (*Community) ListMediaByUserId ¶ added in v1.0.0
func (c *Community) ListMediaByUserId(ctx context.Context, userId string, format string, page, limitInt int) ([]File, int, error)
func (c *Community) ListMediaByUserId(ctx context.Context, userId string, format string) ([]File, error) {
func (*Community) ListPageUsers ¶ added in v1.0.0
ListUser get all users
func (*Community) NewVideoTask ¶ added in v1.0.0
NewVideoTask create new video task
func (*Community) ParseJwtToken ¶ added in v1.0.0
ParseJwtToken return user id by token
func (*Community) PutArticle ¶
func (p *Community) PutArticle(ctx context.Context, uid string, article *Article) (id string, err error)
PutArticle adds new article (ID == "") or edits an existing article (ID != "").
func (*Community) RedirectToCasdoor ¶ added in v1.0.0
func (*Community) RetryCaptionGenerate ¶ added in v1.0.0
func (*Community) SetVideoTaskCache ¶ added in v1.0.0
func (c *Community) SetVideoTaskCache(key string, value VideoTaskTimestamp)
SetVideoTaskCache set video task cache
func (*Community) SetVideoTaskFailed ¶ added in v1.0.0
SetVideoTaskFailed set video task failed
func (*Community) SetVideoTaskOutput ¶ added in v1.0.0
SetVideoTaskOutput set video task output link
func (*Community) SetVideoTaskSuccess ¶ added in v1.0.0
SetVideoTaskSuccess set video task success
func (*Community) TimedCheckVideoTask ¶ added in v1.0.0
Timed check status of video task with timeout
func (*Community) TranslateArticle ¶ added in v1.0.0
func (*Community) TranslateMarkdownText ¶ added in v1.0.0
func (*Community) UpdateUser ¶ added in v1.0.0
func (*Community) UpdateUserById ¶ added in v1.0.0
UpdateUserById update user by uid
type Config ¶
type Config struct { AppConfig AppConfig DBConfig DBConfig QiNiuConfig QiNiuConfig CasdoorConfig CasdoorConfig }
func NewConfigFromEnv ¶ added in v1.0.0
func NewConfigFromEnv() *Config
type PlatformCount ¶ added in v1.0.0
type QiNiuConfig ¶ added in v1.0.0
type S3Service ¶ added in v1.0.0
type S3Service interface { NewReader(ctx context.Context, key string, opts *blob.ReaderOptions) (_ S3Reader, err error) NewWriter(ctx context.Context, key string, opts *blob.WriterOptions) (_ S3Writer, err error) Delete(ctx context.Context, key string) (err error) }
S3Service is the interface for s3 service and easy to mock
type S3ServiceAdapter ¶ added in v1.0.0
type S3ServiceAdapter struct {
// contains filtered or unexported fields
}
func (*S3ServiceAdapter) Delete ¶ added in v1.0.0
func (s *S3ServiceAdapter) Delete(ctx context.Context, key string) (err error)
func (*S3ServiceAdapter) NewReader ¶ added in v1.0.0
func (s *S3ServiceAdapter) NewReader(ctx context.Context, key string, opts *blob.ReaderOptions) (_ S3Reader, err error)
func (*S3ServiceAdapter) NewWriter ¶ added in v1.0.0
func (s *S3ServiceAdapter) NewWriter(ctx context.Context, key string, opts *blob.WriterOptions) (_ S3Writer, err error)
type Translation ¶ added in v1.0.0
type Translation struct { Engine *translation.Engine VideoTaskCache *VideoTaskCache }
type UserClaim ¶ added in v1.0.0
type UserClaim casdoorsdk.Claims
type UserInfo ¶ added in v1.0.0
type UserInfo casdoorsdk.User
type VideoSubtitle ¶ added in v1.0.0
todo
type VideoTask ¶ added in v1.0.0
type VideoTask struct { Id int ResourceId string UserId string // User id TaskId string // ASR task id Output string // Recognition result link Status int // 0: progress, -1: failed, 1: ok CreateAt time.Time UpdateAt time.Time }
VideoTask video task define
type VideoTaskCache ¶ added in v1.0.0
VideoTaskCache video task cache Simple cache, no expiration
func NewVideoTaskCache ¶ added in v1.0.0
func NewVideoTaskCache() *VideoTaskCache
NewVideoTaskCache create new video task cache
func (*VideoTaskCache) Clear ¶ added in v1.0.0
func (c *VideoTaskCache) Clear()
Clear clear video task cache
func (*VideoTaskCache) Delete ¶ added in v1.0.0
func (c *VideoTaskCache) Delete(key string)
Delete delete video task
func (*VideoTaskCache) Get ¶ added in v1.0.0
func (c *VideoTaskCache) Get(key string) (VideoTaskTimestamp, bool)
Get get video task timestamp
func (*VideoTaskCache) Set ¶ added in v1.0.0
func (c *VideoTaskCache) Set(key string, value VideoTaskTimestamp)
Set set video task timestamp
type VideoTaskMap ¶ added in v1.0.0
type VideoTaskMap map[string]VideoTaskTimestamp
type VideoTaskTimestamp ¶ added in v1.0.0
type VideoTaskTimestamp int64