diff --git a/server/api/tumdev/campus_backend.pb.go b/server/api/tumdev/campus_backend.pb.go index 097dcdff..5c1ac632 100644 --- a/server/api/tumdev/campus_backend.pb.go +++ b/server/api/tumdev/campus_backend.pb.go @@ -3533,7 +3533,7 @@ type Movie struct { CoverName string `protobuf:"bytes,1,opt,name=cover_name,json=coverName,proto3" json:"cover_name,omitempty"` CoverPath string `protobuf:"bytes,2,opt,name=cover_path,json=coverPath,proto3" json:"cover_path,omitempty"` - MovieId int32 `protobuf:"varint,3,opt,name=movie_id,json=movieId,proto3" json:"movie_id,omitempty"` + MovieId int64 `protobuf:"varint,3,opt,name=movie_id,json=movieId,proto3" json:"movie_id,omitempty"` Date *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=date,proto3" json:"date,omitempty"` Created *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created,proto3" json:"created,omitempty"` Title string `protobuf:"bytes,6,opt,name=title,proto3" json:"title,omitempty"` @@ -3546,7 +3546,7 @@ type Movie struct { // imdb rating ImdbRating string `protobuf:"bytes,12,opt,name=imdb_rating,json=imdbRating,proto3" json:"imdb_rating,omitempty"` Description string `protobuf:"bytes,13,opt,name=description,proto3" json:"description,omitempty"` - CoverId int32 `protobuf:"varint,14,opt,name=cover_id,json=coverId,proto3" json:"cover_id,omitempty"` + CoverId int64 `protobuf:"varint,14,opt,name=cover_id,json=coverId,proto3" json:"cover_id,omitempty"` // Where to find additional information about this movie Link string `protobuf:"bytes,16,opt,name=link,proto3" json:"link,omitempty"` } @@ -3597,7 +3597,7 @@ func (x *Movie) GetCoverPath() string { return "" } -func (x *Movie) GetMovieId() int32 { +func (x *Movie) GetMovieId() int64 { if x != nil { return x.MovieId } @@ -3674,7 +3674,7 @@ func (x *Movie) GetDescription() string { return "" } -func (x *Movie) GetCoverId() int32 { +func (x *Movie) GetCoverId() int64 { if x != nil { return x.CoverId } @@ -4960,7 +4960,7 @@ var file_tumdev_campus_backend_proto_rawDesc = []byte{ 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x07, 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x64, + 0x28, 0x03, 0x52, 0x07, 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x64, 0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x63, @@ -4982,7 +4982,7 @@ var file_tumdev_campus_backend_proto_rawDesc = []byte{ 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0e, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x01, 0x28, 0x03, 0x52, 0x07, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x4a, 0x04, 0x08, 0x0f, 0x10, 0x10, 0x22, 0x13, 0x0a, 0x11, 0x53, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x65, 0x64, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x91, 0x02, 0x0a, 0x13, diff --git a/server/api/tumdev/campus_backend.proto b/server/api/tumdev/campus_backend.proto index 5db832a7..2e05dcf5 100644 --- a/server/api/tumdev/campus_backend.proto +++ b/server/api/tumdev/campus_backend.proto @@ -517,7 +517,7 @@ message GetMoviesReply { message Movie { string cover_name = 1; string cover_path = 2; - int32 movie_id = 3; + int64 movie_id = 3; google.protobuf.Timestamp date = 4; google.protobuf.Timestamp created = 5; string title = 6; @@ -530,7 +530,7 @@ message Movie { // imdb rating string imdb_rating = 12; string description = 13; - int32 cover_id = 14; + int64 cover_id = 14; // was previously the trailer reserved 15; // Where to find additional information about this movie diff --git a/server/api/tumdev/campus_backend.swagger.json b/server/api/tumdev/campus_backend.swagger.json index 311ee13b..56e3172a 100644 --- a/server/api/tumdev/campus_backend.swagger.json +++ b/server/api/tumdev/campus_backend.swagger.json @@ -1445,8 +1445,8 @@ "type": "string" }, "movieId": { - "type": "integer", - "format": "int32" + "type": "string", + "format": "int64" }, "date": { "type": "string", @@ -1483,8 +1483,8 @@ "type": "string" }, "coverId": { - "type": "integer", - "format": "int32" + "type": "string", + "format": "int64" }, "link": { "type": "string", diff --git a/server/backend/movie_test.go b/server/backend/movie_test.go index bf4fad74..0cab874e 100644 --- a/server/backend/movie_test.go +++ b/server/backend/movie_test.go @@ -46,7 +46,7 @@ var ( Date: timestamppb.New(time.Now()), Created: timestamppb.New(time.Now()), Title: "Mission Impossible 4 - Ghost Protocol", - Year: "2011", + ReleaseYear: "2011", Runtime: "133 min", Genre: "Action, Adventure, Thriller", Director: "Brad Bird", @@ -63,7 +63,7 @@ var ( Date: timestamppb.New(time.Now()), Created: timestamppb.New(time.Now()), Title: "Mission Impossible 5 - Rogue Nation", - Year: "2015", + ReleaseYear: "2015", Runtime: "131 min", Genre: "Action, Adventure, Thriller", Director: "Christopher McQuarrie", @@ -82,8 +82,8 @@ func (s *MovieSuite) Test_GetMoviesAll() { s.mock.ExpectQuery("SELECT `kino`.`kino`,`kino`.`date`,`kino`.`created`,`kino`.`title`,`kino`.`year`,`kino`.`runtime`,`kino`.`genre`,`kino`.`director`,`kino`.`actors`,`kino`.`rating`,`kino`.`description`,`kino`.`trailer`,`kino`.`cover`,`kino`.`link`,`Files`.`file` AS `Files__file`,`Files`.`name` AS `Files__name`,`Files`.`path` AS `Files__path`,`Files`.`downloads` AS `Files__downloads`,`Files`.`url` AS `Files__url`,`Files`.`downloaded` AS `Files__downloaded` FROM `kino` LEFT JOIN `files` `Files` ON `kino`.`cover` = `Files`.`file` WHERE kino > ?"). WithArgs(-1). WillReturnRows(sqlmock.NewRows([]string{"kino", "date", "created", "title", "year", "runtime", "genre", "director", "actors", "rating", "description", "trailer", "cover", "link", "Files__file", "Files__name", "Files__path", "Files__downloads", "Files__url", "Files__downloaded"}). - AddRow(movie2.MovieId, movie2.Date.AsTime(), movie2.Created.AsTime(), movie2.Title, movie2.Year, movie2.Runtime, movie2.Genre, movie2.Director, movie2.Actors, movie2.ImdbRating, movie2.Description, nil, movie2.CoverId, movie2.Link, movie2.CoverId, movie2.CoverName, movie2.CoverPath, 1, "", 1). - AddRow(movie1.MovieId, movie1.Date.AsTime(), movie1.Created.AsTime(), movie1.Title, movie1.Year, movie1.Runtime, movie1.Genre, movie1.Director, movie1.Actors, movie1.ImdbRating, movie1.Description, nil, movie1.CoverId, movie1.Link, movie1.CoverId, movie1.CoverName, movie1.CoverPath, 1, "", 1)) + AddRow(movie2.MovieId, movie2.Date.AsTime(), movie2.Created.AsTime(), movie2.Title, movie2.ReleaseYear, movie2.Runtime, movie2.Genre, movie2.Director, movie2.Actors, movie2.ImdbRating, movie2.Description, nil, movie2.CoverId, movie2.Link, movie2.CoverId, movie2.CoverName, movie2.CoverPath, 1, "", 1). + AddRow(movie1.MovieId, movie1.Date.AsTime(), movie1.Created.AsTime(), movie1.Title, movie1.ReleaseYear, movie1.Runtime, movie1.Genre, movie1.Director, movie1.Actors, movie1.ImdbRating, movie1.Description, nil, movie1.CoverId, movie1.Link, movie1.CoverId, movie1.CoverName, movie1.CoverPath, 1, "", 1)) response, err := server.GetMovies(context.Background(), &pb.GetMoviesRequest{LastId: -1}) require.NoError(s.T(), err) require.Equal(s.T(), &pb.GetMoviesReply{Movies: []*pb.Movie{&movie2, &movie1}}, response) @@ -94,7 +94,7 @@ func (s *MovieSuite) Test_GetMoviesOne() { s.mock.ExpectQuery("SELECT `kino`.`kino`,`kino`.`date`,`kino`.`created`,`kino`.`title`,`kino`.`year`,`kino`.`runtime`,`kino`.`genre`,`kino`.`director`,`kino`.`actors`,`kino`.`rating`,`kino`.`description`,`kino`.`trailer`,`kino`.`cover`,`kino`.`link`,`Files`.`file` AS `Files__file`,`Files`.`name` AS `Files__name`,`Files`.`path` AS `Files__path`,`Files`.`downloads` AS `Files__downloads`,`Files`.`url` AS `Files__url`,`Files`.`downloaded` AS `Files__downloaded` FROM `kino` LEFT JOIN `files` `Files` ON `kino`.`cover` = `Files`.`file` WHERE kino > ?"). WithArgs(1). WillReturnRows(sqlmock.NewRows([]string{"kino", "date", "created", "title", "year", "runtime", "genre", "director", "actors", "rating", "description", "trailer", "cover", "link", "Files__file", "Files__name", "Files__path", "Files__downloads", "Files__url", "Files__downloaded"}). - AddRow(movie1.MovieId, movie1.Date.AsTime(), movie1.Created.AsTime(), movie1.Title, movie1.Year, movie1.Runtime, movie1.Genre, movie1.Director, movie1.Actors, movie1.ImdbRating, movie1.Description, nil, movie1.CoverId, movie1.Link, movie1.CoverId, movie1.CoverName, movie1.CoverPath, 1, "", 1)) + AddRow(movie1.MovieId, movie1.Date.AsTime(), movie1.Created.AsTime(), movie1.Title, movie1.ReleaseYear, movie1.Runtime, movie1.Genre, movie1.Director, movie1.Actors, movie1.ImdbRating, movie1.Description, nil, movie1.CoverId, movie1.Link, movie1.CoverId, movie1.CoverName, movie1.CoverPath, 1, "", 1)) response, err := server.GetMovies(context.Background(), &pb.GetMoviesRequest{LastId: 1}) require.NoError(s.T(), err) require.Equal(s.T(), &pb.GetMoviesReply{Movies: []*pb.Movie{&movie1}}, response) diff --git a/server/model/kino.go b/server/model/kino.go index cc5e6a5e..a4b6f645 100644 --- a/server/model/kino.go +++ b/server/model/kino.go @@ -8,7 +8,7 @@ import ( // Kino stores all movies type Kino struct { - Id int32 `gorm:"primary_key;AUTO_INCREMENT;column:kino;type:int;not null;"` + Id int64 `gorm:"primary_key;AUTO_INCREMENT;column:kino;type:int;not null;"` Date time.Time `gorm:"column:date;type:datetime;not null;"` Created time.Time `gorm:"column:created;type:timestamp;not null;default:CURRENT_TIMESTAMP"` Title string `gorm:"column:title;type:text;not null;"` @@ -20,7 +20,7 @@ type Kino struct { ImdbRating string `gorm:"column:rating;type:varchar(4);not null;"` Description string `gorm:"column:description;type:text;not null;"` Trailer null.String `gorm:"column:trailer"` - FilesID int32 `gorm:"column:cover"` + FilesID int64 `gorm:"column:cover"` Files Files `gorm:"foreignKey:FilesID;references:file"` Link string `gorm:"column:link;type:varchar(190);not null;unique;"` }