Skip to content

Commit

Permalink
Merge pull request #15 from khanzadimahdi/14-article-videos
Browse files Browse the repository at this point in the history
article video
  • Loading branch information
khanzadimahdi authored Jul 23, 2024
2 parents 7b8e0d6 + 6b1d0e3 commit fe429f6
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions backend/application/article/getArticle/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
type GetArticleResponse struct {
UUID string `json:"uuid"`
Cover string `json:"cover"`
Video string `json:"video"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
Body string `json:"body"`
Expand Down Expand Up @@ -70,6 +71,7 @@ func NewGetArticleReponse(a article.Article, e []element.Element, elementsConten
return &GetArticleResponse{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Body: a.Body,
Expand Down
2 changes: 2 additions & 0 deletions backend/application/article/getArticles/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type articleResponse struct {
UUID string `json:"uuid"`
Cover string `json:"cover"`
Video string `json:"video"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
PublishedAt time.Time `json:"published_at"`
Expand Down Expand Up @@ -36,6 +37,7 @@ func NewGetArticlesReponse(a []article.Article, totalPages, currentPage uint) *G
for i := range a {
items[i].UUID = a[i].UUID
items[i].Cover = a[i].Cover
items[i].Video = a[i].Video
items[i].Title = a[i].Title
items[i].Excerpt = a[i].Excerpt
items[i].PublishedAt = a[i].PublishedAt
Expand Down
2 changes: 2 additions & 0 deletions backend/application/article/getArticlesByHashtag/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type articleResponse struct {
UUID string `json:"uuid"`
Cover string `json:"cover"`
Video string `json:"video"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
PublishedAt time.Time `json:"published_at"`
Expand All @@ -35,6 +36,7 @@ func NewGetArticlesByHashtagReponse(a []article.Article, currentPage uint) *GetA
for i := range a {
items[i].UUID = a[i].UUID
items[i].Cover = a[i].Cover
items[i].Video = a[i].Video
items[i].Title = a[i].Title
items[i].Excerpt = a[i].Excerpt
items[i].PublishedAt = a[i].PublishedAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type validationErrors map[string]string
type Request struct {
Cover string `json:"cover"`
Title string `json:"title"`
Video string `json:"video"`
Excerpt string `json:"excerpt"`
Body string `json:"body"`
PublishedAt time.Time `json:"published_at"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (uc *UseCase) CreateArticle(request Request) (*CreateArticleResponse, error

a := article.Article{
Cover: request.Cover,
Video: request.Video,
Title: request.Title,
Excerpt: request.Excerpt,
Body: request.Body,
Expand Down
2 changes: 2 additions & 0 deletions backend/application/dashboard/article/getArticle/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type GetArticleResponse struct {
UUID string `json:"uuid"`
Cover string `json:"cover"`
Video string `json:"video"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
Body string `json:"body"`
Expand All @@ -30,6 +31,7 @@ func NewGetArticleReponse(a article.Article) *GetArticleResponse {
return &GetArticleResponse{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Body: a.Body,
Expand Down
2 changes: 2 additions & 0 deletions backend/application/dashboard/article/getArticles/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type articleResponse struct {
UUID string `json:"uuid"`
Cover string `json:"cover"`
Video string `json:"video"`
Title string `json:"title"`
PublishedAt time.Time `json:"published_at"`
Author author `json:"author"`
Expand All @@ -35,6 +36,7 @@ func NewGetArticlesResponse(a []article.Article, totalPages, currentPage uint) *
for i := range a {
items[i].UUID = a[i].UUID
items[i].Cover = a[i].Cover
items[i].Video = a[i].Video
items[i].Title = a[i].Title
items[i].PublishedAt = a[i].PublishedAt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type validationErrors map[string]string
type Request struct {
UUID string `json:"uuid"`
Cover string `json:"cover"`
Video string `json:"video"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
Body string `json:"body"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func (uc *UseCase) UpdateArticle(request Request) (*UpdateArticleResponse, error
a := article.Article{
UUID: request.UUID,
Cover: request.Cover,
Video: request.Video,
Title: request.Title,
Excerpt: request.Excerpt,
Body: request.Body,
Expand Down
2 changes: 2 additions & 0 deletions backend/application/dashboard/file/uploadFile/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package createfile

import "io"

const MaxFileSize int64 = 100 << 20 // 100MB

type validationErrors map[string]string

type Request struct {
Expand Down
1 change: 1 addition & 0 deletions backend/domain/article/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Article struct {
UUID string
Cover string
Video string
Title string
Excerpt string
Body string
Expand Down
2 changes: 1 addition & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/khanzadimahdi/testproject

go 1.22

toolchain go1.22.1
toolchain go1.22.5

require (
github.com/gofrs/uuid/v5 v5.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
type ArticleBson struct {
UUID string `bson:"_id,omitempty"`
Cover string `bson:"cover,omitempty"`
Video string `bson:"video,omitempty"`
Title string `bson:"title,omitempty"`
Excerpt string `bson:"excerpt,omitempty"`
Body string `bson:"body,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (r *ArticlesRepository) GetAll(offset uint, limit uint) ([]article.Article,
items = append(items, article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Tags: a.Tags,
Expand Down Expand Up @@ -119,6 +120,7 @@ func (r *ArticlesRepository) GetAllPublished(offset uint, limit uint) ([]article
items = append(items, article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Tags: a.Tags,
Expand Down Expand Up @@ -163,6 +165,7 @@ func (r *ArticlesRepository) GetByUUIDs(UUIDs []string) ([]article.Article, erro
items = append(items, article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Body: a.Body,
Excerpt: a.Excerpt,
Expand Down Expand Up @@ -215,6 +218,7 @@ func (r *ArticlesRepository) GetMostViewed(limit uint) ([]article.Article, error
items = append(items, article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Tags: a.Tags,
Expand Down Expand Up @@ -271,6 +275,7 @@ func (r *ArticlesRepository) GetByHashtag(hashtags []string, offset uint, limit
items = append(items, article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Tags: a.Tags,
Expand Down Expand Up @@ -305,6 +310,7 @@ func (r *ArticlesRepository) GetOne(UUID string) (article.Article, error) {
return article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Body: a.Body,
Expand Down Expand Up @@ -339,6 +345,7 @@ func (r *ArticlesRepository) GetOnePublished(UUID string) (article.Article, erro
return article.Article{
UUID: a.UUID,
Cover: a.Cover,
Video: a.Video,
Title: a.Title,
Excerpt: a.Excerpt,
Body: a.Body,
Expand Down Expand Up @@ -397,6 +404,7 @@ func (r *ArticlesRepository) Save(a *article.Article) (string, error) {
UUID: a.UUID,
Cover: a.Cover,
Title: a.Title,
Video: a.Video,
Excerpt: a.Excerpt,
Body: a.Body,
PublishedAt: a.PublishedAt,
Expand Down
4 changes: 1 addition & 3 deletions backend/presentation/http/api/dashboard/file/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ func (h *createHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return
}

const maxFileSize int64 = 5 << 20 // 5MB

if err := r.ParseMultipartForm(maxFileSize); err != nil {
if err := r.ParseMultipartForm(uploadfile.MaxFileSize); err != nil {
rw.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down

0 comments on commit fe429f6

Please sign in to comment.