Fix project pakage and fix struct json
parent
5b349bf1b7
commit
7dfe981b53
|
@ -1,2 +1,2 @@
|
|||
CREATE USER test11 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 USER test WITH PASSWORD 'test' CREATEDB;
|
||||
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"
|
||||
"log"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/restserver"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/restserver"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ log_level: "debug"
|
|||
|
||||
# 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:
|
||||
database:
|
||||
container_name: postgres
|
||||
container_name: databaseFilms
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "7000:5432"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=root
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=5429593sS
|
||||
- POSTGRES_USER=films
|
||||
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
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package bd
|
||||
|
||||
import "os"
|
||||
|
||||
type ConfigBD struct {
|
||||
BaseUrlBd string `yaml:"baseurlbd"`
|
||||
}
|
||||
|
||||
func NewConfig() *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 (
|
||||
"testing"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
)
|
||||
|
||||
type Filmsrepo struct {
|
||||
|
@ -28,7 +28,7 @@ func FindDyId(id int) (*model.Films, error) {
|
|||
|
||||
func (f *Filmsrepo) FindByAll() (*[]model.Films, error) {
|
||||
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 {
|
||||
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.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
||||
&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 {
|
||||
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,
|
||||
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
||||
&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
|
||||
RatingKinopoiskVoteCount *int
|
||||
Created *string
|
||||
Contenttype *string
|
||||
Ratingagelimits *string
|
||||
Media *any
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ type Siries struct {
|
|||
RatingImdbVoteCount *int
|
||||
RatingKinopoiskVoteCount *int
|
||||
Created *string
|
||||
Contenttype *string
|
||||
Ratingagelimits *string
|
||||
Translations *any
|
||||
Episodes *any
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"strconv"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
)
|
||||
|
||||
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,
|
||||
&buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year,
|
||||
&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
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
)
|
||||
|
||||
type Userrepo struct {
|
||||
|
|
|
@ -3,7 +3,7 @@ package restserver
|
|||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
resultstruct "git.ukamnya.ru/stulyaganov/RestApi/internal/restserver/resultStruct"
|
||||
resultstruct "git.ukamnya.ru/stulyaganov/RestApiv2/internal/restserver/resultStruct"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package restserver
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package resultstruct
|
||||
|
||||
import "git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
import "git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
|
||||
type Films struct {
|
||||
Result bool
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package resultstruct
|
||||
|
||||
import "git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
import "git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
|
||||
type Siries struct {
|
||||
Result bool
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
resultstruct "git.ukamnya.ru/stulyaganov/RestApi/internal/restserver/resultStruct"
|
||||
resultstruct "git.ukamnya.ru/stulyaganov/RestApiv2/internal/restserver/resultStruct"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package restserver
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"git.ukamnya.ru/stulyaganov/RestApi/internal/bd/model"
|
||||
"git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd/model"
|
||||
)
|
||||
|
||||
func (r *RestServer) configureRouterUser() {
|
||||
|
|
Loading…
Reference in New Issue