[
{"name": "Parent 1",
"child": [
{"name": "Child 1-1"},
{"name": "Child 1-2"},
{"name": "Child 1-3"}
]},
{"name": "Parent 2",
"child": [
{"name": "Child 2-1"},
{"name": "Child 2-2"},
{"name": "Child 2-3"
,"child": [
{"name": "Child 2-3-1"},
{"name": "Child 2-3-2"}
]
}
]
}
];
status -- можно переназвать в active (Если нужно будет скрыть категорию)
top -- для отображения категории в блоке "Популярные категории"
INSERT INTO ... ON DUPLICATE KEY UPDATE
DEFAULT NOW();
| price | supplier_id | product_id | datetime |
| 162 | 1 | 1 | 26.01.18 |
| 158 | 2 | 1 | 26.01.18 |
| 160 | 1 | 1 | 27.01.18 |
| 202 | 1 | 1 | 28.01.18 |
| 193 | 2 | 1 | 28.01.18 |
CREATE TABLE supplier (
id TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
address VARCHAR(255) NOT NULL,
phone VARCHAR(15) NOT NULL,
website VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
Теперь товары поставщиков:CREATE TABLE product_supplier (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
supplier_id TINYINT(3) UNSIGNED NOT NULL,
brand INT(10) UNSIGNED NOT NULL,
mpn_number VARCHAR(64) NOT NULL COMMENT 'Артикул товара',
warehouse VARCHAR(255) NOT NULL COMMENT 'Склад (Адрес)',
PRIMARY KEY (`id`),
CONSTRAINT FK_supplier_id FOREIGN KEY (`supplier_id`) REFERENCES supplier(`id`),
CONSTRAINT FK_brand_id FOREIGN KEY (`brand`) REFERENCES product__brands(`id`)
) ENGINE=InnoDB;
И последнее история ценCREATE TABLE product_price (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
price DECIMAL(13,6) NOT NULL,
supplier_id TINYINT(3) UNSIGNED NOT NULL,
product_id INT(10) UNSIGNED NOT NULL,
date DATETIME NOT NULL DEFAULT NOW(),
PRIMARY KEY (`id`),
CONSTRAINT FK_supplier_id FOREIGN KEY (`supplier_id`) REFERENCES supplier(`id`),
CONSTRAINT FK_product_id FOREIGN KEY (`product_id`) REFERENCES product(`id`)
) ENGINE=InnoDB;
-- Связь (Товар<->Категория)
CREATE TABLE category__product (
product_id INT(10) UNSIGNED NOT NULL,
category_id INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`product_id`,`category_id`),
CONSTRAINT FK_category_produc_pid FOREIGN KEY (`product_id`) REFERENCES product(`id`),
CONSTRAINT FK_category_produc_cid FOREIGN KEY (`category_id`) REFERENCES category(`id`)
) ENGINE=InnoDB;
System.out.println(authorRepository.findByFioContainingIgnoreCaseOrderByFio("ча"));
System.out.println(authorRepository.findOne(25L));
System.out.println(bookRepository.findOne(20L));
System.out.println(authorRepository.findByFioContainingIgnoreCaseOrderByFio("чо"));
2018-01-20T04:02:37.615823Z 754 Query /* select generatedAlias0 from Author as generatedAlias0 where upper(generatedAlias0.fio) like upper(:param0) order by generatedAlias0.fio asc */ select author0_.id as id1_0_, author0_.birthday as birthday2_0_, author0_.fio as fio3_0_ from library.author author0_ where upper(author0_.fio) like upper('%??%') order by author0_.fio asc
2018-01-20T04:02:37.616909Z 754 Query set session transaction read only
2018-01-20T04:02:37.617245Z 754 Query SET autocommit=0
2018-01-20T04:02:37.618412Z 754 Query select author0_.id as id1_0_0_, author0_.birthday as birthday2_0_0_, author0_.fio as fio3_0_0_ from library.author author0_ where author0_.id=25
2018-01-20T04:02:37.621222Z 754 Query commit
2018-01-20T04:02:37.621710Z 754 Query SET autocommit=1
2018-01-20T04:02:37.622159Z 754 Query select @@session.tx_read_only
2018-01-20T04:02:37.622970Z 754 Query set session transaction read write
2018-01-20T04:02:37.623650Z 754 Query set session transaction read only
2018-01-20T04:02:37.624843Z 754 Query SET autocommit=0
2018-01-20T04:02:37.627488Z 754 Query select book0_.id as id1_1_0_, book0_.author_id as author_13_1_0_, book0_.avg_rating as avg_rati2_1_0_, book0_.content as content3_1_0_, book0_.descr as descr4_1_0_, book0_.genre_id as genre_i14_1_0_, book0_.image as image5_1_0_, book0_.isbn as isbn6_1_0_, book0_.name as name7_1_0_, book0_.page_count as page_cou8_1_0_, book0_.publish_year as publish_9_1_0_, book0_.publisher_id as publish15_1_0_, book0_.total_rating as total_r10_1_0_, book0_.total_vote_count as total_v11_1_0_, book0_.view_count as view_co12_1_0_, author1_.id as id1_0_1_, author1_.birthday as birthday2_0_1_, author1_.fio as fio3_0_1_, genre2_.id as id1_2_2_, genre2_.name as name2_2_2_, publisher3_.id as id1_3_3_, publisher3_.name as name2_3_3_ from library.book book0_ left outer join library.author author1_ on book0_.author_id=author1_.id left outer join library.genre genre2_ on book0_.genre_id=genre2_.id left outer join library.publisher publisher3_ on book0_.publisher_id=publisher3_.id where book0_.id=20
2018-01-20T04:02:37.635220Z 754 Query commit
2018-01-20T04:02:37.635841Z 754 Query SET autocommit=1
2018-01-20T04:02:37.638517Z 754 Query select @@session.tx_read_only
2018-01-20T04:02:37.639451Z 754 Query set session transaction read write
2018-01-20T04:02:37.641171Z 754 Query /* select generatedAlias0 from Author as generatedAlias0 where upper(generatedAlias0.fio) like upper(:param0) order by generatedAlias0.fio asc */ select author0_.id as id1_0_, author0_.birthday as birthday2_0_, author0_.fio as fio3_0_ from library.author author0_ where upper(author0_.fio) like upper('%??%') order by author0_.fio asc
я скажу точно каким образом происходит детект
Возможно расширение экрана