fix struct pointer
parent
06837e86b8
commit
148603f4f3
|
@ -14,7 +14,7 @@ func TestFilmRepo_Create(t *testing.T) {
|
||||||
defer teardown("films")
|
defer teardown("films")
|
||||||
u, err := s.Films().Create(&model.Films{
|
u, err := s.Films().Create(&model.Films{
|
||||||
Id: 11,
|
Id: 11,
|
||||||
Ru_title: "fasfa",
|
Ru_title: nil,
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, u)
|
assert.NotNil(t, u)
|
||||||
|
|
|
@ -27,7 +27,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 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 FROM films")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,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.RatingKinopoiskVoteCount, &buff.Created)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,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.Media)
|
&buff.RatingKinopoiskVoteCount, &buff.Created, &buff.Media)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ func (f *Filmsrepo) FindByName(name string) (*[]model.Films, error) {
|
||||||
err = rows.Scan(&film.Id, &film.Ru_title, &film.Orig_title, &film.Imdb_id, &film.Kinopoisk_id,
|
err = rows.Scan(&film.Id, &film.Ru_title, &film.Orig_title, &film.Imdb_id, &film.Kinopoisk_id,
|
||||||
&film.PosterUrl, &film.PosterUrlPreview, &film.Countries, &film.Genres, &film.Year,
|
&film.PosterUrl, &film.PosterUrlPreview, &film.Countries, &film.Genres, &film.Year,
|
||||||
&film.Description, &film.RatingKinopoisk, &film.RatingImdb, &film.Iframe_src, &film.RatingImdbVoteCount,
|
&film.Description, &film.RatingKinopoisk, &film.RatingImdb, &film.Iframe_src, &film.RatingImdbVoteCount,
|
||||||
&film.RatingKinopoiskVoteCount, &film.Media)
|
&film.RatingKinopoiskVoteCount, &film.Created, &film.Media)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func (f *Filmsrepo) SortByGanres(name string) (*[]model.Films, error) {
|
||||||
|
|
||||||
func (f *Filmsrepo) Pagination(offcet string) (*[]model.Films, error) {
|
func (f *Filmsrepo) Pagination(offcet string) (*[]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 FROM films ORDER BY year desc LIMIT 32 OFFSET "+offcet)
|
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 ORDER BY year desc LIMIT 32 OFFSET "+offcet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func (f *Filmsrepo) Pagination(offcet string) (*[]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.RatingKinopoiskVoteCount, &buff.Created)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ func (f *Filmsrepo) Pagination(offcet string) (*[]model.Films, error) {
|
||||||
|
|
||||||
func (f *Filmsrepo) LastItem() (*[]model.Films, error) {
|
func (f *Filmsrepo) LastItem() (*[]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, posterurl, posterurlpreview, countries, genres, year FROM films ORDER BY year desc LIMIT 8")
|
rows, err := f.db.db.Query(context.Background(), "SELECT id, ru_title, orig_title, posterurl, posterurlpreview, countries, genres, year, created FROM films ORDER BY year desc, created DESC LIMIT 8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func (f *Filmsrepo) LastItem() (*[]model.Films, error) {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var buff model.Films
|
var buff model.Films
|
||||||
err = rows.Scan(
|
err = rows.Scan(
|
||||||
&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year)
|
&buff.Id, &buff.Ru_title, &buff.Orig_title, &buff.PosterUrl, &buff.PosterUrlPreview, &buff.Countries, &buff.Genres, &buff.Year, &buff.Created)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,21 @@ package model
|
||||||
|
|
||||||
type Films struct {
|
type Films struct {
|
||||||
Id int
|
Id int
|
||||||
Ru_title string
|
Ru_title *string
|
||||||
Orig_title string
|
Orig_title *string
|
||||||
Imdb_id string
|
Imdb_id *string
|
||||||
Kinopoisk_id string
|
Kinopoisk_id *int
|
||||||
PosterUrl string
|
PosterUrl *string
|
||||||
PosterUrlPreview string
|
PosterUrlPreview *string
|
||||||
Countries interface{}
|
Countries *any
|
||||||
Genres interface{}
|
Genres *any
|
||||||
Year int
|
Year *int
|
||||||
Description string
|
Description *string
|
||||||
RatingKinopoisk int
|
RatingKinopoisk *int
|
||||||
RatingImdb int
|
RatingImdb *int
|
||||||
Iframe_src string
|
Iframe_src *string
|
||||||
RatingImdbVoteCount int
|
RatingImdbVoteCount *int
|
||||||
RatingKinopoiskVoteCount int
|
RatingKinopoiskVoteCount *int
|
||||||
Media interface{}
|
Created *string
|
||||||
|
Media *any
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,18 @@ CREATE TABLE films (
|
||||||
iframe_src VARCHAR(2000),
|
iframe_src VARCHAR(2000),
|
||||||
ratingImdbVoteCount INTEGER,
|
ratingImdbVoteCount INTEGER,
|
||||||
ratingKinopoiskVoteCount INTEGER,
|
ratingKinopoiskVoteCount INTEGER,
|
||||||
|
created VARCHAR(1500),
|
||||||
media JSON,
|
media JSON,
|
||||||
PRIMARY KEY(id)
|
PRIMARY KEY(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE users (
|
||||||
|
id INTEGER NOT NULL,
|
||||||
|
login VARCHAR(25) not NULL,
|
||||||
|
email VARCHAR(255) NOT NULL,
|
||||||
|
password VARCHAR(2500) NOT NULL,
|
||||||
|
avatar_url VARCHAR(2500),
|
||||||
|
token VARCHAR(2500) NOT NULL,
|
||||||
|
permisionLVL INTEGER NOT NULL,
|
||||||
|
PRIMARY KEY(id)
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue