domain

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudStorageVoiceFilePath

func CloudStorageVoiceFilePath(lessonID, voiceID int64, voiceFileKey string) string

func Contains

func Contains(s *[]string, e string) bool

func CopyLessonThumbnail

func CopyLessonThumbnail(ctx context.Context, id int64, currentStatus LessonStatus, newStatus LessonStatus) error

func CreateAvatar

func CreateAvatar(ctx context.Context, avatar *Avatar, user *User) error

CreateAvatar creates a new avatar belongs to user.

func CreateBackgroundMusic

func CreateBackgroundMusic(ctx context.Context, userID int64, backgroundMusic *BackgroundMusic) error

func CreateDeleteLessonOrderInTransaction

func CreateDeleteLessonOrderInTransaction(tx *datastore.Transaction, lessonID int64) error

func CreateGraphics

func CreateGraphics(ctx context.Context, userID int64, graphics []*Graphic) error

func CreateInitialLessonMaterial

func CreateInitialLessonMaterial(ctx context.Context, userID int64, avatarID int64, backgroundImageID int64, lessonID int64) (int64, error)

func CreateIntroductionGraphics

func CreateIntroductionGraphics(ctx context.Context, userID int64, lessonID int64) error

func CreateIntroductionLesson

func CreateIntroductionLesson(ctx context.Context, user *User, lesson *Lesson) error

func CreateLesson

func CreateLesson(ctx context.Context, lesson *Lesson) error

func CreateLessonThumbnailBlankFile

func CreateLessonThumbnailBlankFile(ctx context.Context, id int64, isPublic bool) (string, error)

func CreateSynthesisVoice

func CreateSynthesisVoice(ctx context.Context, params *CreateSynthesisVoiceParam, voice Voice) error

CreateSynthesisVoice is creates new voice.

func CreateSynthesizedVoice

func CreateSynthesizedVoice(ctx context.Context, params *CreateSynthesisVoiceParam, bucketName, filePath string) ([]byte, error)

func CreateUserInTransaction

func CreateUserInTransaction(tx *datastore.Transaction, user *User) (*datastore.PendingKey, error)

CreateUserInTransaction creates new user.

func CreateUserThumbnailBlankFile

func CreateUserThumbnailBlankFile(ctx context.Context, id int64) (string, error)

CreateUserThumbnailBlankFile is create blank image file to public bucket.

func CreateVoice

func CreateVoice(ctx context.Context, voice *Voice) error

CreateVoice is creates new voice.

func DeleteGraphicByID

func DeleteGraphicByID(ctx context.Context, id int64, userID int64) error

func DeleteLesson

func DeleteLesson(ctx context.Context, id int64) error

DeleteLessonは、idから同定したLessonを削除します。

func DeleteLessonInTransaction

func DeleteLessonInTransaction(tx *datastore.Transaction, id int64) error

DeleteLessonInTransactionは、トランザクションでidから同定したLessonを削除します。

func DeleteUser

func DeleteUser(ctx context.Context, id int64) error

DeleteUser deletes user.

func GetGraphicSignedURL

func GetGraphicSignedURL(ctx context.Context, graphic *Graphic) (string, error)

func GetGraphicsByLessonID

func GetGraphicsByLessonID(ctx context.Context, lessonID int64, graphics *[]*Graphic) error

func GetLessonMaterial

func GetLessonMaterial(ctx context.Context, id int64, lessonID int64, lessonMaterial *LessonMaterial) error

func GetVoices

func GetVoices(ctx context.Context, lessonID int64, voices *[]Voice) error

GetVoices is get voice entities belongs to lesson.

func IncrementLessonViewCount

func IncrementLessonViewCount(ctx context.Context, lessonID int64) error

IncrementLessonViewCountは、lessonIDのLessonのViewCountを1つ増分します。 増分は即座に行われず、Redisに格納されます。その後、定時バッチでLesson.ViewCountとUser.TotalLessonViewCountに反映されます。

func LessonViewCountKeyPrefix

func LessonViewCountKeyPrefix(currentTime time.Time) string

LessonViewCountKeyは、Redis内で使用されるLesson参照回数保持用のキーのプリフィックスをstringで返します。

func MergeJsonToStruct

func MergeJsonToStruct(jsonDiff *map[string]interface{}, origin interface{}, allowFields *[]string)

func ProviderID

func ProviderID(r *http.Request) (string, error)

ProviderID is return user account provider and subject in JWT.

func ReserveUserProviderIDInTransaction

func ReserveUserProviderIDInTransaction(tx *datastore.Transaction, providerID string) error

ReserveUserProviderIDInTransaction creates user's ProviderID for exclusion control.

func SetLessonThumbnailURL

func SetLessonThumbnailURL(ctx context.Context, lesson *Lesson) error

func TopLevelStructKeys

func TopLevelStructKeys(target interface{}) []string

func UUIDWithoutHypen

func UUIDWithoutHypen() (string, error)

func UpdateLesson

func UpdateLesson(ctx context.Context, lesson *Lesson) error

func UpdateLessonAndMaterial

func UpdateLessonAndMaterial(ctx context.Context, user *User, lesson *Lesson, needsCopyThumbnail bool, requestID string, jsonBody *map[string]interface{}, lessonFields *[]string, lessonMaterialFields *[]string) error

UpdateLessonAndMaterialは、jsonのフィールドを既存のLesson/LessonMaterialへマージし、トランザクション中で二つのエンティティを更新します。 jsonのフィールド名がlessonFieldsまたはlessonMaterialFieldsに含まれない場合、そのフィールドは無視されます。

func UpdateLessonMaterial

func UpdateLessonMaterial(ctx context.Context, id int64, lessonID int64, jsonBody *map[string]interface{}, targetFields *[]string) error

func UpdateUser

func UpdateUser(ctx context.Context, user *User) error

UpdateUserは、受け取ったUserでエンティティを更新します。

func UpdateUserByJson

func UpdateUserByJson(ctx context.Context, user *User, jsonBody *map[string]interface{}, targetFields *[]string) error

UpdateUserByJsonは、json構造のinterfaceを受け取り、Userを更新します。

func ValidTokenClaims

func ValidTokenClaims(r *http.Request) (map[string]interface{}, error)

ValidTokenClaims returns claims in JWT.

Types

type AuthErrorCode

type AuthErrorCode uint
const (
	TokenNotFound             AuthErrorCode = 1
	UnexpectedSigningMethod   AuthErrorCode = 2
	InvalidToken              AuthErrorCode = 3
	FailedDatastoreInitialize AuthErrorCode = 4
	FailedGettingUser         AuthErrorCode = 5
	UserNotFound              AuthErrorCode = 6
)

func (AuthErrorCode) Error

func (e AuthErrorCode) Error() string

type Avatar

type Avatar struct {
	ID       int64        `json:"id" datastore:"-"`
	Name     string       `json:"name"`
	URL      string       `json:"url"`
	Config   AvatarConfig `json:"config"`
	Version  int64        `json:"version"`
	IsPublic bool         `json:"-"`
	Created  time.Time    `json:"created"`
	Updated  time.Time    `json:"updated"`
}

Avatar is used for lesson.

func GetCurrentUsersAvatarByID

func GetCurrentUsersAvatarByID(ctx context.Context, id int64, userID int64) (Avatar, error)

func GetCurrentUsersAvatars

func GetCurrentUsersAvatars(ctx context.Context, userID int64) ([]Avatar, error)

GetCurrentUsersAvatars gets avatars belongs to user.

func GetPublicAvatarByID

func GetPublicAvatarByID(ctx context.Context, id int64) (Avatar, error)

GetPublicAvatarByID gets avatar by id.

func GetPublicAvatars

func GetPublicAvatars(ctx context.Context) ([]Avatar, error)

GetPublicAvatars gets public avatars.

type AvatarAnimation

type AvatarAnimation struct {
	BoneName    string    `json:"boneName"`
	Axis        string    `json:"axis"` // x, y, zのいずれか
	DurationSec float32   `json:"durationSec"`
	KeyTimes    []float32 `json:"keyTimes"`
	Rotations   []float32 `json:"rotations"`
}

type AvatarConfig

type AvatarConfig struct {
	Scale             float32           `json:"scale"`
	Positions         []float32         `json:"positions"`
	InitialPoses      []AvatarRotation  `json:"initialPoses"`
	WalkingAnimations []AvatarAnimation `json:"walkingAnimations"`
}

type AvatarErrorCode

type AvatarErrorCode uint
const (
	AvatarNotFound AvatarErrorCode = 1
)

func (AvatarErrorCode) Error

func (e AvatarErrorCode) Error() string

type AvatarRotation

type AvatarRotation struct {
	BoneName  string    `json:"boneName"`
	Rotations []float32 `json:"rotations"`
}

type BackgroundImage

type BackgroundImage struct {
	ID     int64  `json:"id"`
	Name   string `json:"name" datastore:",noindex"`
	URL    string `json:"url" datastore:"-"`
	SortID int64  `json:"-"`
}

BackgroundImage type is used in the class.

func GetAllBackgroundImages

func GetAllBackgroundImages(ctx context.Context) ([]BackgroundImage, error)

GetAllBackgroundImagesはSortIDの照準でソートした全てのBackgroundImageを返します

func GetBackgroundImage

func GetBackgroundImage(ctx context.Context) (BackgroundImage, error)

GetBackgroundImageは、ソートを行わずに一つだけBackGroundImageを返します

type BackgroundImageErrorCode

type BackgroundImageErrorCode uint
const (
	BackgroundImageNotFound BackgroundImageErrorCode = 1
)

func (BackgroundImageErrorCode) Error

func (e BackgroundImageErrorCode) Error() string

type BackgroundMusic

type BackgroundMusic struct {
	ID       int64     `json:"id" datastore:"-"`
	Name     string    `json:"name" datastore:",noindex"`
	URL      string    `json:"url" datastore:"-"`
	SortID   int64     `json:"-"`
	IsPublic bool      `json:"-"`
	Created  time.Time `json:"created"`
}

BackgroundMusic type is used in the class.

func GetCurrentUsersBackgroundMusics

func GetCurrentUsersBackgroundMusics(ctx context.Context, userID int64) ([]BackgroundMusic, error)

func GetPublicBackgroundMusics

func GetPublicBackgroundMusics(ctx context.Context) ([]BackgroundMusic, error)

GetPublicBackgroundMusics is return sorted public musics.

type Caption

type Caption struct {
	Body            string `json:"body,omitempty"`
	BodyColor       string `json:"bodyColor,omitempty"`
	BorderColor     string `json:"borderColor,omitempty"`
	HorizontalAlign string `json:"horizontalAlign,omitempty"`
	VerticalAlign   string `json:"verticalAlign,omitempty"`
}

type Category

type Category struct {
	ID          int64  `json:"id" datastore:"-"`
	SubjectID   int64  `json:"subjectID"`
	SubjectName string `json:"subjectName" datastore:",noindex"`
	GroupName   string `json:"groupName" datastore:",noindex"`
	Name        string `json:"name" datastore:",noindex"`
	SortID      int64  `json:"-"`
}

Category of the class type.

func GetJapaneseCategory

func GetJapaneseCategory(ctx context.Context, id int64, subjectID int64) (Category, error)

GetJapaneseCategory is return a category from id.

type CategoryErrorCode

type CategoryErrorCode uint
const (
	CategoryNotFound CategoryErrorCode = 1
)

func (CategoryErrorCode) Error

func (e CategoryErrorCode) Error() string

type CreateSynthesisVoiceParam

type CreateSynthesisVoiceParam struct {
	LessonID int64  `json:"lessonID"`
	Text     string `json:"text"`
	VoiceSynthesisConfig
}

type DeleteOrder

type DeleteOrder struct {
	ID         int64 `datastore:"-"`
	EntityName string
	TargetID   int64 `datastore:",noindex"`
	Created    time.Time
}

DeleteOrderはエンティティの削除予約を作成します。LessonまたはUserの関連エンティティの定時削除に使用されることを想定しています。

type DrawingAction

type DrawingAction int8
const (
	DrawingActionDraw  DrawingAction = 0
	DrawingActionClear DrawingAction = 1
	DrawingActionShow  DrawingAction = 2
	DrawingActionHide  DrawingAction = 3
)

func (DrawingAction) MarshalJSON

func (r DrawingAction) MarshalJSON() ([]byte, error)

func (DrawingAction) String

func (r DrawingAction) String() string

func (*DrawingAction) UnmarshalJSON

func (a *DrawingAction) UnmarshalJSON(data []byte) error

type DrawingUnitAction

type DrawingUnitAction int8
const (
	DrawingUnitActionDraw DrawingUnitAction = 0
	DrawingUnitActionUndo DrawingUnitAction = 1
)

func (DrawingUnitAction) MarshalJSON

func (r DrawingUnitAction) MarshalJSON() ([]byte, error)

func (DrawingUnitAction) String

func (r DrawingUnitAction) String() string

func (*DrawingUnitAction) UnmarshalJSON

func (a *DrawingUnitAction) UnmarshalJSON(data []byte) error

type EmbeddingAction

type EmbeddingAction int8
const (
	EmbeddingActionShow EmbeddingAction = 0
	EmbeddingActionHide EmbeddingAction = 1
)

func (EmbeddingAction) MarshalJSON

func (r EmbeddingAction) MarshalJSON() ([]byte, error)

func (EmbeddingAction) String

func (r EmbeddingAction) String() string

func (*EmbeddingAction) UnmarshalJSON

func (a *EmbeddingAction) UnmarshalJSON(data []byte) error

type Graphic

type Graphic struct {
	ID              int64     `json:"id" datastore:"-"`
	PublicGraphicID int64     `json:"-" datastore:",noindex"`
	LessonID        int64     `json:"lessonID"`
	FileType        string    `json:"fileType" datastore:",noindex"`
	URL             string    `json:"url" datastore:"-"`
	Created         time.Time `json:"created"`
}

Graphic is used for lesson.

func GetGraphicByID

func GetGraphicByID(ctx context.Context, id int64, userID int64) (Graphic, error)

func GetGraphicsByIDs

func GetGraphicsByIDs(ctx context.Context, userID int64, ids []int64) ([]*Graphic, error)

type GraphicAction

type GraphicAction int8
const (
	GraphicActionShow GraphicAction = 0
	GraphicActionHide GraphicAction = 1
)

func (GraphicAction) MarshalJSON

func (r GraphicAction) MarshalJSON() ([]byte, error)

func (GraphicAction) String

func (r GraphicAction) String() string

func (*GraphicAction) UnmarshalJSON

func (a *GraphicAction) UnmarshalJSON(data []byte) error

type GraphicErrorCode

type GraphicErrorCode uint
const (
	GraphicNotFound GraphicErrorCode = 1
)

func (GraphicErrorCode) Error

func (e GraphicErrorCode) Error() string

type Lesson

type Lesson struct {
	ID                   int64             `json:"id" datastore:"-"`
	UserID               int64             `json:"userID"`
	Author               User              `json:"author" datastore:"-"`
	MaterialID           int64             `json:"materialID"`
	AvatarID             int64             `json:"avatarID" datastore:",noindex"`         // 公開処理完了時にLessonMaterialの値で更新される
	AvatarLightColor     string            `json:"avatarLightColor" datastore:",noindex"` // 公開処理完了時にLessonMaterialの値で更新される
	Avatar               Avatar            `json:"avatar,omitempty" datastore:"-"`
	PrevLessonID         int64             `json:"prevLessonID" datastore:",noindex"`
	PrevLessonTitle      string            `json:"prevLessonTitle" datastore:"-"`
	NextLessonID         int64             `json:"nextLessonID" datastore:",noindex"`
	NextLessonTitle      string            `json:"nextLessonTitle" datastore:"-"`
	NeedsRecording       bool              `json:"needsRecording" datastore:",noindex"` // 収録画面での収録必要の有無
	IsIntroduction       bool              `json:"isIntroduction"`                      // 自己紹介用の授業
	HasThumbnail         bool              `json:"hasThumbnail" datastore:",noindex"`
	ThumbnailURL         string            `json:"thumbnailURL" datastore:"-"`
	SpeechURL            string            `json:"speechURL" datastore:"-"`
	BodyURL              string            `json:"bodyURL" datastore:"-"`
	Status               LessonStatus      `json:"status"`
	References           []LessonReference `json:"references" datastore:",noindex"`
	Reviews              []LessonReview    `json:"reviews" datastore:",noindex"`
	SubjectID            int64             `json:"subjectID"`
	SubjectName          string            `json:"subjectName" datastore:",noindex"`
	JapaneseCategoryID   int64             `json:"japaneseCategoryID"`
	JapaneseCategoryName string            `json:"japaneseCategoryName" datastore:",noindex"`
	Title                string            `json:"title"`
	Description          string            `json:"description"`
	DurationSec          float32           `json:"durationSec" datastore:",noindex"`
	ViewCount            int64             `json:"viewCount" datastore:",noindex"`
	ViewKey              string            `json:"viewKey" datastore:",noindex"`
	Version              int32             `json:"version" datastore:",noindex"`
	Created              time.Time         `json:"created"`
	Updated              time.Time         `json:"updated" datastore:",noindex"`
	Published            time.Time         `json:"published"` // 公開処理完了時にLessonMaterialのUpdatedの値で更新される
}

Lesson is the lesson infomation type.

func GetLessonByID

func GetLessonByID(ctx context.Context, id int64) (Lesson, error)

func GetLessonsByUserID

func GetLessonsByUserID(ctx context.Context, userID int64) ([]Lesson, error)

func GetPublicLessonsByUserID

func GetPublicLessonsByUserID(ctx context.Context, userID int64) ([]Lesson, error)

type LessonAvatar

type LessonAvatar struct {
	ElapsedTime float32   `json:"elapsedTime"`
	DurationSec float32   `json:"durationSec"`
	Positions   []float32 `json:"positions"` // x, y, zの順で格納
}

type LessonDrawing

type LessonDrawing struct {
	ElapsedTime float32             `json:"elapsedTime"`
	DurationSec float32             `json:"durationSec"`
	Action      DrawingAction       `json:"action"`
	Units       []LessonDrawingUnit `json:"units"`
}

type LessonDrawingStroke

type LessonDrawingStroke struct {
	Eraser    bool         `json:"eraser,omitempty"`
	Color     string       `json:"color,omitempty"`
	LineWidth int32        `json:"lineWidth,omitempty"`
	Positions []Position2D `json:"positions,omitempty"`
}

type LessonDrawingUnit

type LessonDrawingUnit struct {
	ElapsedTime float32             `json:"elapsedTime"`
	DurationSec float32             `json:"durationSec"`
	Action      DrawingUnitAction   `json:"action"`
	Stroke      LessonDrawingStroke `json:"stroke"`
}

type LessonEmbedding

type LessonEmbedding struct {
	ElapsedTime float32         `json:"elapsedTime"`
	Action      EmbeddingAction `json:"action"`
	ContentID   string          `json:"contentID"`
	StartAtSec  int32           `json:"startAtSec"`
	ServiceName string          `json:"serviceName"`
}

type LessonErrorCode

type LessonErrorCode uint
const (
	AlreadyIntroductionExist LessonErrorCode = 1
)

func (LessonErrorCode) Error

func (e LessonErrorCode) Error() string

type LessonGraphic

type LessonGraphic struct {
	ElapsedTime float32       `json:"elapsedTime"`
	GraphicID   int64         `json:"graphicID"`
	Action      GraphicAction `json:"action"`
}

type LessonMaterial

type LessonMaterial struct {
	ID                   int64                `json:"id" datastore:"-"`
	UserID               int64                `json:"userID"`
	AvatarID             int64                `json:"avatarID"`
	Avatar               Avatar               `json:"avatar" datastore:"-"`
	AvatarLightColor     string               `json:"avatarLightColor" datastore:",noindex"`
	DurationSec          float32              `json:"durationSec" datastore:",noindex"`
	BackgroundImageID    int64                `json:"backgroundImageID"`
	BackgroundImageURL   string               `json:"backgroundImageURL" datastore:"-"`
	VoiceSynthesisConfig VoiceSynthesisConfig `json:"voiceSynthesisConfig" datastore:",noindex"`
	Avatars              []LessonAvatar       `json:"avatars" datastore:",noindex"`
	Graphics             []LessonGraphic      `json:"graphics" datastore:",noindex"`
	Drawings             []LessonDrawing      `json:"drawings" datastore:",noindex"`
	Embeddings           []LessonEmbedding    `json:"embeddings" datastore:",noindex"`
	Musics               []LessonMusic        `json:"musics" datastore:",noindex"`
	Speeches             []LessonSpeech       `json:"speeches" datastore:",noindex"`
	Created              time.Time            `json:"created" datastore:",noindex"`
	Updated              time.Time            `json:"updated" datastore:",noindex"`
}

type LessonMusic

type LessonMusic struct {
	ElapsedTime       float32     `json:"elapsedTime"`
	Action            MusicAction `json:"action"`
	BackgroundMusicID int64       `json:"backgroundMusicID"`
	Volume            float32     `json:"volume"`
	IsFading          bool        `json:"isFading"`
	IsLoop            bool        `json:"isLoop"`
}

type LessonReference

type LessonReference struct {
	Name string `json:"name"`
	Isbn string `json:"isbn"` // ISBN13を想定
}

LessonReference is link to another web page.

type LessonReview

type LessonReview struct {
	ReviewerUserID int64     `json:"userID"`
	Comment        string    `json:"comment"`
	Created        time.Time `json:"created"`
}

LessonReview is review status of lesson by other users.

type LessonSpeech

type LessonSpeech struct {
	ElapsedTime     float32              `json:"elapsedTime"`
	DurationSec     float32              `json:"durationSec"`
	VoiceID         int64                `json:"voiceID"`
	VoiceFileKey    string               `json:"voiceFileKey"`
	Subtitle        string               `json:"subtitle"`
	Caption         Caption              `json:"caption"`
	IsSynthesis     bool                 `json:"isSynthesis"`
	SynthesisConfig VoiceSynthesisConfig `json:"synthesisConfig"`
}

type LessonStatus

type LessonStatus int8
const (
	LessonStatusDraft   LessonStatus = 0
	LessonStatusLimited LessonStatus = 1
	LessonStatusPublic  LessonStatus = 2
)

func (LessonStatus) MarshalJSON

func (r LessonStatus) MarshalJSON() ([]byte, error)

func (LessonStatus) String

func (r LessonStatus) String() string

func (*LessonStatus) UnmarshalJSON

func (s *LessonStatus) UnmarshalJSON(data []byte) error

type MusicAction

type MusicAction int8
const (
	MusicActionStart MusicAction = 0
	MusicActionStop  MusicAction = 1
)

func (MusicAction) MarshalJSON

func (r MusicAction) MarshalJSON() ([]byte, error)

func (MusicAction) String

func (r MusicAction) String() string

func (*MusicAction) UnmarshalJSON

func (a *MusicAction) UnmarshalJSON(data []byte) error

type Position2D

type Position2D struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type PublicGraphic

type PublicGraphic struct {
	ID              int64  `datastore:"-"`
	FileType        string `datastore:",noindex"`
	ForIntroduction bool
	SortID          int64
}

PublicGraphic is image entity used for introduction.

func GetPublicGraphicsForIntroduction

func GetPublicGraphicsForIntroduction(ctx context.Context) ([]PublicGraphic, error)

type ShortCategory

type ShortCategory struct {
	ID          int64  `json:"id"`
	SubjectID   int64  `json:"-"`
	SubjectName string `json:"-"`
	GroupName   string `json:"groupName"`
	Name        string `json:"name"`
	SortID      int64  `json:"-"`
}

func GetAllJapaneseCategories

func GetAllJapaneseCategories(ctx context.Context) ([]ShortCategory, error)

GetAllJapaneseCategories is return all sorted categories.

func GetJapaneseCategories

func GetJapaneseCategories(ctx context.Context, subjectID int64) ([]ShortCategory, error)

GetJapaneseCategories is return categories by the subject.

type ShortLesson

type ShortLesson struct {
	ID          int64  `json:"id" datastore:"-"`
	UserID      int64  `json:"userID"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

func GetLessonsByCategoryID

func GetLessonsByCategoryID(ctx context.Context, cursorStr string, categoryID int64) ([]ShortLesson, string, error)

type Subject

type Subject struct {
	ID           int64  `json:"id" datastore:"-"`
	Name         string `json:"name" datastore:",noindex"`
	JapaneseName string `json:"japaneseName" datastore:",noindex"`
	SortID       int64  `json:"-"`
}

Subject of the class type.

func GetAllSubjects

func GetAllSubjects(ctx context.Context) ([]Subject, error)

GetAllSubjects is return all sorted subjects.

func GetSubject

func GetSubject(ctx context.Context, id int64) (Subject, error)

GetSubject is return a subject from id.

type User

type User struct {
	ID                      int64     `json:"id" datastore:"-"`
	ProviderID              string    `json:"-"`
	BackgroundImageID       int64     `json:"-" datastore:",noindex"`
	BackgroundImageURL      string    `json:"backgroundImageURL" datastore:"-"`
	IntroductionID          int64     `json:"introductionID" datastore:",noindex"`
	IsPublishedIntroduction bool      `json:"isPublishedIntroduction" datastore:",noindex"`
	Name                    string    `json:"name" datastore:",noindex"`
	Profile                 string    `json:"profile" datastore:",noindex"`
	Email                   string    `json:"email,omitempty" datastore:",noindex"`
	TotalLessonViewCount    int64     `json:"totalLessonViewCount,omitempty" datastore:",noindex"`
	Created                 time.Time `json:"-"`
	Updated                 time.Time `json:"-" datastore:",noindex"`
}

User is application registrated user

func GetCurrentUser

func GetCurrentUser(request *http.Request) (User, error)

GetCurrentUser returns user from valid token.

func GetUserByID

func GetUserByID(ctx context.Context, id int64) (User, error)

GetUserByIDはidからユーザーを取得して返します。Emailは必ず空文字列になり、json出力時はフィールドごとなくなります。

func GetUsers

func GetUsers(ctx context.Context, cursorStr string) ([]User, string, error)

type UserErrorCode

type UserErrorCode uint

UserErrorCode is user error code.

const (
	// AlreadyProviderIDExists is exists privider-id of user
	AlreadyProviderIDExists UserErrorCode = 1
)

func (UserErrorCode) Error

func (e UserErrorCode) Error() string

type UserProviderID

type UserProviderID struct {
	ID int64 `datastore:"-"`
}

type Voice

type Voice struct {
	ID          int64     `json:"id" datastore:"-"`
	UserID      int64     `json:"userID" datastore:",noindex"`
	LessonID    int64     `json:"lessonID" datastore:",noindex"`
	FileKey     string    `json:"fileKey" datastore:",noindex"`
	ElapsedTime float32   `json:"elapsedTime" datastore:",noindex"`
	DurationSec float32   `json:"durationSec" datastore:",noindex"`
	Text        string    `json:"text" datastore:",noindex"`
	IsTexted    bool      `json:"isTexted" datastore:",noindex"`
	IsSynthesis bool      `json:"-" datastore:",noindex"`
	Created     time.Time `json:"created" datastore:",noindex"`
	Updated     time.Time `json:"updated" datastore:",noindex"`
}

Voice is used for lesson.

type VoiceErrorCode

type VoiceErrorCode uint
const (
	VoiceNotFound VoiceErrorCode = 1
)

func (VoiceErrorCode) Error

func (e VoiceErrorCode) Error() string

type VoiceSynthesisConfig

type VoiceSynthesisConfig struct {
	LanguageCode string  `json:"languageCode"` // ja-JP/en-US
	Name         string  `json:"name"`         // ja-JP-Wavenet-A~D/en-US-Wavenet-A~J
	SpeakingRate float64 `json:"speakingRate"` // 0.25 ~ 4.0
	Pitch        float64 `json:"pitch"`        // -20.0 ~ 20.0
	VolumeGainDb float64 `json:"volumeGainDb"` // -5.0 ~ 10.0
}

VoiceSynthesisConfig is synthesis voice settings. used from SynthesisVoice params and LessonSpeech. https://github.com/googleapis/go-genproto/blob/master/googleapis/cloud/texttospeech/v1beta1/cloud_tts.pb.go#L663

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL