Spaces:
Paused
Paused
File size: 928 Bytes
882796d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | package usecases
import (
"fmt"
"komikku-api/bin/modules/chapter/models/domain"
chapterQ "komikku-api/bin/modules/chapter/repositories/queries"
httpError "komikku-api/bin/pkg/http-error"
"komikku-api/bin/pkg/utils"
)
type chapterCommandUsecase struct {
chapterQuery chapterQ.ChapterQuery
}
func (c chapterCommandUsecase) GetChapterDetail(endpoint string) utils.Result {
var result utils.Result
resultGetChapterDetail := c.chapterQuery.DetailChapter(endpoint)
if resultGetChapterDetail.Error != nil {
errObj := httpError.NewNotFound()
errObj.Message = fmt.Sprintf("%v", resultGetChapterDetail.Error)
result.Error = errObj
return result
}
chapterDetail := resultGetChapterDetail.Data.(domain.ChapterDetail)
result.Data = chapterDetail
return result
}
func CreateNewChapterUsecase( chapterQuery chapterQ.ChapterQuery) ChapterUsecase {
return &chapterCommandUsecase{
chapterQuery: chapterQuery,
}
}
|