Fix project pakage and fix struct json
parent
5b349bf1b7
commit
7dfe981b53
|
@ -1,2 +1,2 @@
|
||||||
CREATE USER test11 WITH PASSWORD 'test' CREATEDB;
|
CREATE USER test WITH PASSWORD 'test' CREATEDB;
|
||||||
CREATE DATABASE test11 with owner = test11 ENCODING = 'UTF8' LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8' TABLESPACE = pg_default CONNECTION LIMIT = -1;
|
CREATE DATABASE test with owner = test ENCODING = 'UTF8' LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8' TABLESPACE = pg_default CONNECTION LIMIT = -1;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/restserver"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/restserver"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,4 @@ log_level: "debug"
|
||||||
|
|
||||||
# db
|
# db
|
||||||
DB:
|
DB:
|
||||||
baseurlbd: "host=localhost user=admin password=root dbname=postgres sslmode=disable"
|
baseurlbd: "host=localhost:7000 user=films password=5429593sS dbname=postgres sslmode=disable"
|
|
@ -2,11 +2,11 @@ version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
database:
|
database:
|
||||||
container_name: postgres
|
container_name: databaseFilms
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "7000:5432"
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=root
|
- POSTGRES_PASSWORD=5429593sS
|
||||||
- POSTGRES_USER=admin
|
- POSTGRES_USER=films
|
||||||
build: ./build/postgres/
|
build: ./build/postgres/
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module git.ukamnya.ru/stulyaganov/RestApi
|
module git.ukamnya.ru/stulyaganov/RestApiv2
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package bd
|
package bd
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
type ConfigBD struct {
|
type ConfigBD struct {
|
||||||
BaseUrlBd string `yaml:"baseurlbd"`
|
BaseUrlBd string `yaml:"baseurlbd"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig() *ConfigBD {
|
func NewConfig() *ConfigBD {
|
||||||
return &ConfigBD{
|
return &ConfigBD{
|
||||||
BaseUrlBd: "host=localhost user=admin password=root dbname=postgres sslmode=disable",
|
BaseUrlBd: os.Getenv("DATABASE_URL"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package bd_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd"
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Filmsrepo struct {
|
type Filmsrepo struct {
|
||||||
|
@ -28,7 +28,7 @@ func FindDyId(id int) (*model.Films, error) {
|
||||||
|
|
||||||
func (f *Filmsrepo) FindByAll() (*[]model.Films, error) {
|
func (f *Filmsrepo) FindByAll() (*[]model.Films, error) {
|
||||||
var buffs []model.Films
|
var buffs []model.Films
|
||||||
rows, err := f.db.db.Query(context.Background(), "SELECT Id, Ru_title, Orig_title, Imdb_id, Kinopoisk_id, PosterUrl, PosterUrlPreview, Countries, Genres, Year, Description, RatingKinopoisk, RatingImdb, Iframe_src, RatingImdbVoteCount, RatingKinopoiskVoteCount, Created FROM films")
|
rows, err := f.db.db.Query(context.Background(), "SELECT Id, Ru_title, Orig_title, Imdb_id, Kinopoisk_id, PosterUrl, PosterUrlPreview, Countries, Genres, Year, Description, RatingKinopoisk, RatingImdb, Iframe_src, RatingImdbVoteCount, RatingKinopoiskVoteCount, Created, content_type, ratingagelimits FROM films")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ func (f *Filmsrepo) FindByAll() (*[]model.Films, error) {
|
||||||
&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.Imdb_id, &buff.Kinopoisk_id,
|
&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.Imdb_id, &buff.Kinopoisk_id,
|
||||||
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
||||||
&buff.Description, &buff.RatingKinopoisk, &buff.RatingImdb, &buff.Iframe_src, &buff.RatingImdbVoteCount,
|
&buff.Description, &buff.RatingKinopoisk, &buff.RatingImdb, &buff.Iframe_src, &buff.RatingImdbVoteCount,
|
||||||
&buff.RatingKinopoiskVoteCount, &buff.Created)
|
&buff.RatingKinopoiskVoteCount, &buff.Created, &buff.Contenttype, &buff.Ratingagelimits)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func (f *Filmsrepo) FindById(id string) (*model.Films, error) {
|
||||||
rows.Scan(&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.Imdb_id, &buff.Kinopoisk_id,
|
rows.Scan(&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.Imdb_id, &buff.Kinopoisk_id,
|
||||||
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
||||||
&buff.Description, &buff.RatingKinopoisk, &buff.RatingImdb, &buff.Iframe_src, &buff.RatingImdbVoteCount,
|
&buff.Description, &buff.RatingKinopoisk, &buff.RatingImdb, &buff.Iframe_src, &buff.RatingImdbVoteCount,
|
||||||
&buff.RatingKinopoiskVoteCount, &buff.Created, &buff.Media)
|
&buff.RatingKinopoiskVoteCount, &buff.Created, &buff.Contenttype, &buff.Ratingagelimits, &buff.Media)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,5 +18,7 @@ type Films struct {
|
||||||
RatingImdbVoteCount *int
|
RatingImdbVoteCount *int
|
||||||
RatingKinopoiskVoteCount *int
|
RatingKinopoiskVoteCount *int
|
||||||
Created *string
|
Created *string
|
||||||
|
Contenttype *string
|
||||||
|
Ratingagelimits *string
|
||||||
Media *any
|
Media *any
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ type Siries struct {
|
||||||
RatingImdbVoteCount *int
|
RatingImdbVoteCount *int
|
||||||
RatingKinopoiskVoteCount *int
|
RatingKinopoiskVoteCount *int
|
||||||
Created *string
|
Created *string
|
||||||
|
Contenttype *string
|
||||||
|
Ratingagelimits *string
|
||||||
Translations *any
|
Translations *any
|
||||||
Episodes *any
|
Episodes *any
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Siriesrepo struct {
|
type Siriesrepo struct {
|
||||||
|
@ -22,7 +22,7 @@ func (s *Siriesrepo) FindById(id string) (*model.Siries, error) {
|
||||||
err = rows.Scan(&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.Imdb_id, &buff.Kinopoisk_id,
|
err = rows.Scan(&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.Imdb_id, &buff.Kinopoisk_id,
|
||||||
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
||||||
&buff.Description, &buff.RatingKinopoisk, &buff.RatingImdb, &buff.Iframe_src, &buff.RatingImdbVoteCount,
|
&buff.Description, &buff.RatingKinopoisk, &buff.RatingImdb, &buff.Iframe_src, &buff.RatingImdbVoteCount,
|
||||||
&buff.RatingKinopoiskVoteCount, &buff.Created, &buff.Translations, &buff.Episodes)
|
&buff.RatingKinopoiskVoteCount, &buff.Created, &buff.Contenttype, &buff.Ratingagelimits, &buff.Translations, &buff.Episodes)
|
||||||
}
|
}
|
||||||
return &buff, nil
|
return &buff, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Userrepo struct {
|
type Userrepo struct {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package restserver
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
resultstruct "git.ukamnya.ru/stulyaganov/RestApi/internal/restserver/resultStruct"
|
resultstruct "git.ukamnya.ru/stulyaganov/RestApiv2/internal/restserver/resultStruct"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package restserver
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package resultstruct
|
package resultstruct
|
||||||
|
|
||||||
import "git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
import "git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
|
|
||||||
type Films struct {
|
type Films struct {
|
||||||
Result bool
|
Result bool
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package resultstruct
|
package resultstruct
|
||||||
|
|
||||||
import "git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
import "git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
|
|
||||||
type Siries struct {
|
type Siries struct {
|
||||||
Result bool
|
Result bool
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
resultstruct "git.ukamnya.ru/stulyaganov/RestApi/internal/restserver/resultStruct"
|
resultstruct "git.ukamnya.ru/stulyaganov/RestApiv2/internal/restserver/resultStruct"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package restserver
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *RestServer) configureRouterUser() {
|
func (r *RestServer) configureRouterUser() {
|
||||||
|
|
Loading…
Reference in New Issue