Compare commits

...
7 Commits
Author SHA1 Message Date
brian 9c98e7c526 removing requirement for admin review 2026-07-17 20:42:13 -06:00
brian a3e56ba3ad use a real id, not all zeroes 2026-07-17 20:40:47 -06:00
brian 7a04bdb2aa another movie to test when adding 2026-07-17 20:37:38 -06:00
brian 808c416471 formatted them with fmt 2026-07-17 20:37:26 -06:00
brian 351affe570 adding route for add movie 2026-07-17 20:37:16 -06:00
brian 111c107474 adding release year 2026-07-17 20:36:54 -06:00
brian 4501133b5c moving makefile 2026-07-17 20:36:25 -06:00
7 changed files with 51 additions and 11 deletions
@@ -64,7 +64,7 @@ func GetMovie() gin.HandlerFunc {
}
}
func AddMovie() gin.HandlersChain {
func AddMovie() gin.HandlerFunc {
return func(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
defer cancel()
@@ -89,4 +89,4 @@ func AddMovie() gin.HandlersChain {
c.JSON(http.StatusCreated, result)
}
}
}
@@ -1,13 +1,13 @@
package database
import (
"fmt"
"log"
"os"
"fmt"
"log"
"os"
"github.com/joho/godotenv"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
"github.com/joho/godotenv"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)
func Connect() *mongo.Client {
+2
View File
@@ -20,6 +20,8 @@ func main() {
router.GET("/movie/:imdb_id", controller.GetMovie())
router.POST("/movie", controller.AddMovie())
if err := router.Run(":5180"); err != nil {
log.Fatal("failure to start the server")
}
+4 -3
View File
@@ -15,12 +15,13 @@ type Ranking struct {
}
type Movie struct {
ID bson.ObjectID `bson:"_id" json:"_id"`
ID bson.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
ImdbID string `bson:"imdb_id" json:"imdb_id" validate:"required"`
ReleaseYear int `bson:"release_year" json:"release_year" validate:"required"` // how to get this to be a numeric value that is four digits starting with 19?
Title string `bson:"title" json:"title" validate:"required,min=2,max=500"`
PosterPath string `bson:"poster_path" json:"poster_path" validate:"required,url"`
YoutubeId string `bson:"youtube_id" json:"youtube_id" validate:"required"`
Genre []Genre `bson:"genre" json:"genre" validate:"required,dive"`
AdminReview string `bson:"admin_review" json:"admin_review" validate:"required"`
Ranking Ranking `bson:"ranking" json:"ranking" validate:"required"`
AdminReview string `bson:"admin_review" json:"admin_review"`
Ranking Ranking `bson:"ranking" json:"ranking" validate:"required"`
}
+15
View File
@@ -2,6 +2,7 @@
{
"imdb_id": "tt0111161",
"title": "The Shawshank Redemption",
"release_year": 1994,
"poster_path": "https://image.tmdb.org/t/p/w300/2GgerXCbCMgvt2kLwWEmJWCSG65.jpg",
"youtube_id": "PLl99DlL6b4",
"genre": [
@@ -19,6 +20,7 @@
{
"imdb_id": "tt7131622",
"title": "Once upon a time in Hollywood",
"release_year": 2019,
"poster_path": "https://image.tmdb.org/t/p/w300/wQKeS2JrsRF8XSfd9zqflrc5gad.jpg",
"youtube_id": "ELeMaP8EPAA",
"genre": [
@@ -40,6 +42,7 @@
{
"imdb_id": "tt0080339",
"title": "Airplane!",
"release_year": 1980,
"poster_path": "https://image.tmdb.org/t/p/w300/zOiB3p2WTTiwCFgTMnXuDGgzbTN.jpg",
"youtube_id": "07pPmCfKi3U",
"genre": [
@@ -57,6 +60,7 @@
{
"imdb_id": "tt1119646",
"title": "The Hangover",
"release_year": 2009,
"poster_path": "https://image.tmdb.org/t/p/w300/c15rH9S5JN83UXqu9iM4TQsW6Rl.jpg",
"youtube_id": "jj6wcUes1no",
"genre": [
@@ -74,6 +78,7 @@
{
"imdb_id": "tt0109040",
"title": "Ace Ventura: Pet Detective",
"release_year": 1994,
"poster_path": "https://image.tmdb.org/t/p/w300/dukxJWd72ffNWfqfFSVFFuym4RG.jpg",
"youtube_id": "qjBb1CKLpzE",
"genre": [
@@ -91,6 +96,7 @@
{
"imdb_id": "tt0105695",
"title": "Unforgiven",
"release_year": 1992,
"poster_path": "https://image.tmdb.org/t/p/w300/7W0CsZBe5fkX29DvHBi5Ct1WqLe.jpg",
"youtube_id": "6_UlfsdGiEc",
"genre": [
@@ -112,6 +118,7 @@
{
"imdb_id": "tt0060196",
"title": "The Good, The Bad, and the Ugly",
"release_year": 1966,
"poster_path": "https://image.tmdb.org/t/p/w300/e881nA7p982CHL5GjI1LICwHMd7.jpg",
"youtube_id": "WCN5JJY_wiA",
"genre": [
@@ -129,6 +136,7 @@
{
"imdb_id": "tt0903624",
"title": "The Hobbit: An Unexpected Journey",
"release_year": 2012,
"poster_path": "https://image.tmdb.org/t/p/w300/vdAGcr1F6wJPRryeODVAcy2mU4z.jpg",
"youtube_id": "9PSXjr1gbjc",
"genre": [
@@ -146,6 +154,7 @@
{
"imdb_id": "tt0241527",
"title": "Harry Potter and the Philosopher's Stone",
"release_year": 2001,
"poster_path": "https://image.tmdb.org/t/p/w300/e6JYlushXIXK85JGfDHEFHrrNYK.jpg",
"youtube_id": "VyHV0BRtdxo",
"genre": [
@@ -163,6 +172,7 @@
{
"imdb_id": "tt2267998",
"title": "Gone Girl",
"release_year": 2014,
"poster_path": "https://image.tmdb.org/t/p/w300/xpA0q0DJWKe7AY63pVPZbGLwuo5.jpg",
"youtube_id": "2-_-1nJf8Vg",
"genre": [
@@ -184,6 +194,7 @@
{
"imdb_id": "tt8946378",
"title": "Knives Out",
"release_year": 2019,
"poster_path": "https://image.tmdb.org/t/p/w300/hVcCOlHU0HmGBBQNmS9RlalBXGz.jpg",
"youtube_id": "qGqiHJTsRkQ",
"genre": [
@@ -209,6 +220,7 @@
{
"imdb_id": "tt0080684",
"title": "Star Wars: The Empire Strikes Back",
"release_year": 1980,
"poster_path": "https://image.tmdb.org/t/p/w300/1mh82R1qLKwdutQVGnpHItdwPCP.jpg",
"youtube_id": "JNwNXF9Y6kY",
"genre": [
@@ -230,6 +242,7 @@
{
"imdb_id": "tt0102975",
"title": "Star Trek: The Undiscovered Country",
"release_year": 1991,
"poster_path": "https://image.tmdb.org/t/p/w300/jukY1tFpuXgqrJLl1PvdOMarCvN.jpg",
"youtube_id": "RYA2q2Sm_Jo",
"genre": [
@@ -251,6 +264,7 @@
{
"imdb_id": "tt1297919",
"title": "Blitz",
"release_year": 2011,
"poster_path": "https://image.tmdb.org/t/p/w300/tI4fPu0LZ0FNdZdi6fvYGCRiuQs.jpg",
"youtube_id": "mhO2WJ3MNRI",
"genre": [
@@ -276,6 +290,7 @@
{
"imdb_id": "tt0790724",
"title": "Jack Reacher",
"release_year": 2012,
"poster_path": "https://image.tmdb.org/t/p/w300/8sih1uieUopA9zrEO1meNhmm7aO.jpg",
"youtube_id": "A7FiWkyevqY",
"genre": [
+22
View File
@@ -0,0 +1,22 @@
{
"imdb_id": "tt0240468",
"title": "Kung Pow! Enter the Fist",
"release_year": 2002,
"poster_path": "https://www.themoviedb.org/t/p/w600_and_h900_face/gVsZ1hsJ9g11oCCav4N8ccp9bRw.jpg",
"youtube_id": "yieQoIEPenM",
"admin_review": "An amazing movie!",
"genre": [
{
"genre_id": 1,
"genre_name": "Comedy"
},
{
"genre_id": 7,
"genre_name": "Action"
}
],
"ranking": {
"ranking_value": 1,
"ranking_name": "Excellent"
}
}