Merge branch 'tibor' into 'master'

ExerciseType extension with Images and Translations

See merge request bossanyit/aitrainer_server!9
This commit is contained in:
Bossányi Tibor 2020-08-01 14:25:52 +00:00
commit f34c7e6f3d
15 changed files with 346 additions and 57 deletions

View File

@ -11,7 +11,7 @@ plugins {
}
group = "com.aitrainer"
version = "0.0.5"
version = "1.0.5"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {

View File

@ -12,6 +12,22 @@
use aitrainer;
CREATE TABLE `configuration` (
`configuration_id` INT(11) NOT NULL AUTO_INCREMENT,
`config_key` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`config_value` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`date_add` DATETIME NULL DEFAULT NULL,
`date_change` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`configuration_id`) USING BTREE
)
COLLATE='utf8_hungarian_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2
;
INSERT INTO `configuration` (`configuration_id`, `config_key`, `config_value`, `date_add`, `date_change`) VALUES (1, 'db_version', '1.0.5', '2020-05-30 07:00:00', '2020-08-01 17:18:54');
-- Struktúra mentése tábla aitrainer. customer
CREATE TABLE IF NOT EXISTS `customer` (
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
@ -117,47 +133,135 @@ CREATE TABLE IF NOT EXISTS `exercise_evaluation` (
/*!40000 ALTER TABLE `exercise_evaluation` ENABLE KEYS */;
-- Struktúra mentése tábla aitrainer. exercise_type
CREATE TABLE IF NOT EXISTS `exercise_type` (
`exercise_type_id` int(11) NOT NULL AUTO_INCREMENT,
`name` char(100) COLLATE utf8_hungarian_ci NOT NULL,
`description` varchar(1000) COLLATE utf8_hungarian_ci DEFAULT NULL,
`video` mediumblob DEFAULT NULL,
`unit` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`unit_quantity` TINYINT(1) NULL DEFAULT NULL,
`unit_quantity_unit` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
PRIMARY KEY (`exercise_type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;
CREATE TABLE `exercise_type` (
`exercise_type_id` INT(11) NOT NULL AUTO_INCREMENT,
`tree_id` INT(11) NOT NULL DEFAULT 0,
`name` CHAR(100) NOT NULL COLLATE 'utf8_hungarian_ci',
`description` VARCHAR(1000) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`unit` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`unit_quantity` TINYINT(4) NULL DEFAULT NULL,
`unit_quantity_unit` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`active` TINYINT(1) NULL DEFAULT '1',
PRIMARY KEY (`exercise_type_id`) USING BTREE
-- Tábla adatainak mentése aitrainer.exercise_type: ~11 rows (hozzávetőleg)
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (1, 0, 'Melső fekvőtámasz 1 perc', 'Ezt igazolja a 2016 márciusában beállított guinness rekord is,\r\namelyben KJ Joseph 1 perc alatt 82 szabályos karhajlítás-nyújtást\r\nvégzett.', 'repeat', 60, 'second', NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (2, 0, 'Húzódzkodás', 'Ennek a gyakorlatnak a 24 órás csúcstartója Joonas Mäkipelto 5050\r\ngyakorlattal.', 'repeat', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (3, 0, 'Melső fekvőtámasz 30mp', 'A gyakorlatot 30 másodperc alatt olyan sokszor kell végrehajtani, ahányszor a\r\nfelvételiző képes rá. Azonban törekedni kell a szabályos végrehajtásra, ugyanis csak azokat\r\nszámolják. A nők esetében 20, a férfiak esetében 35 gyakorlatot kell végrehajtani a maximális\r\npont megszerzéséért. A gyakorlat akkor sikeres, ha a női legalább 1, a férfi felvételiző\r\nlegalább 11 gyakorlatot képes végrehajtani.', 'repeat', 30, 'second', NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (4, 0, 'Melső fekvőtámasz 2perc', 'Magyar Honvédség: A gyakorlat végrehajtására 2 perc áll rendelkezésre. Ennek során csak a szabályosan a\r\nfentiekben leírt módon végrehajtott gyakorlat értékelhető. Férfiaknál 70 karhajlítás nyújtást\r\nkell végrehajtani a maximális pontért.', 'repeat', 120, 'second', NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (5, 0, 'Hajlított karú függés', 'A gyakorlat addig tart, amíg a végrehajtó szemmagassága a kiinduló helyzettől\r\nsüllyedve a keresztvas alá nem kerül. Az értékeléshez stopperórát alkalmaznak, és az\r\neredmény másodperc pontossággal kerül megállapításra. Nők esetében 45, férfiak\r\ntekintetében 73 másodperctől jár a maximális pontszám. A gyakorlat sikeres végrehajtásához\r\nlegalább 8, 10 másodpercig kell megtartaniuk a kiinduló helyzetet a női és a férfi\r\nfelvételizőknek.\r\n\r\nA NKE-RTK-án lévő hallgatók egyéni rekordjai Iván Viktor 90s, Kiss Regina 74s', 'second', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (6, 0, 'Fekvenyomás', '2015-ben a fekvenyomó világbajnokságot Smulter Fredrik finn súlyemelő 401 Kg-al nyerte.\r\nA súlyzó tömege nők esetében 25 kg, a férfiak esetében 60 kg a rúddal együtt. Az\r\nértékelésénél a szabályosan végrehajtott gyakorlatokat értékelik csak.\r\nA legtöbb pontért 25 gyakorlatot kell végezni mind a nőknek, mind a férfiaknak. A minimum:\r\negy gyakorlat mindkét nem esetében.', 'repeat', NULL, 'kg', NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (7, 0, '4x10m-es ingafutás', 'A legjobb pontszámért 9,4 s illetve 8,8s alatt kell teljesíteni a nőknek, férfiaknak. A\r\ngyakorlat sikertelen 11,8 s illetve 11,2 s-on túl.', 'second', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (8, 0, 'Helyből távolugrás', 'Byron Jones 2015-ben a 3,73 méteres ugrásával érte el a világcsúcsot.\r\nA nőknek 220 cm-re, a férfiak 250 cm-re kell ugraniuk a maximális pontért. A\r\nminimális távolság 172cm illetve 198 cm.', 'meter', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (9, 0, 'Felülés hanyattfekvésből', 'Az NKE-RTK hallgatói közül Papp Zsófia 66 db-ot, Gál Valentin 80\r\ndb-ot csinált 1 perc leforgása alatt.\r\nElső ütemre megtörténik a felülés, ami akkor szabályos, ha valamelyik könyök érinti a\r\ntérdet. Második ütemre vissza kell térni a kiinduló helyzetbe. A maximális pont eléréséhez 1\r\nperc alatt 45 illetve 55 ismétlést kell végezni a nőknek illetve a férfiaknak. A minimumhoz 7\r\nés 25 ismétlés szükséges.', 'repeat', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (10, 0, 'Felülés hajlított térddel', 'Magyar Honvédség: A kiinduló helyzet hajlított ülés, ennek során a sarkak a talajon, a térd 90 fokban meghajlítva\r\nvan.\r\nA gyakorlat végrehajtására két perc áll rendelkezésre. Ennek során csak a szabályosan,\r\na fentiekben leírt módon végrehajtott gyakorlat értékelhető. Férfiaknál, nőknél egyaránt 90\r\ngyakorlatot kell végrehajtani a maximális pontért. Amennyiben a megadott időkeret alatt nem\r\nsikerül legalább 25 szabályos gyakorlatot végrehajtani, úgy az sikertelennek minősül.', 'repeat', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (11, 0, 'Síkfutás 2000m', 'A maximálisan megszerezhető pontot az a felvételiző gyűjtheti be, aki a távot nők\r\nesetében 10:00 perc alatt, férfiak esetében 7:35 perc alatt teljesíti. A gyakorlat sikeres\r\nteljesítésére nők esetében maximum 16:00 perc, férfiak esetében 13:30 perc áll rendelkezésre.', 'second', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (30, 0, 'Cooper', '12 minutes run, how many meters', 'meter', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (31, 0, '300m', NULL, 'second', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (32, 0, '400m', NULL, 'second', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (33, 0, 'Pushups', '', 'repeat', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (34, 0, 'Timed Pushups', NULL, 'repeat', 1, 'second', NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (35, 0, 'Squats', NULL, 'repeat', 1, 'kg', NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (36, 0, 'Sit-ups', NULL, 'repeat', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (37, 0, 'Chest Press', '', 'repeat', 1, 'kg', 1);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (38, 0, 'Pull Ups', NULL, 'repeat', NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (39, 0, 'Biceps', '', 'repeat', 1, 'kg', 1);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (40, 4, 'Triceps', 'Triceps', 'repeat', 1, 'kg', 1);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (41, 0, 'Shoulders', '', 'repeat', 1, 'kg', 1);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (42, 5, 'BMI', '', 'percent', 0, NULL, 1);
INSERT INTO `exercise_type` (`exercise_type_id`, `tree_id`, `name`, `description`, `unit`, `unit_quantity`, `unit_quantity_unit`, `active`) VALUES (43, 0, 'BMR', '', 'calorie', NULL, NULL, NULL);
/*!40000 ALTER TABLE `exercise_type` DISABLE KEYS */;
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (1, 'Melső fekvőtámasz 1 perc', 'Ezt igazolja a 2016 márciusában beállított guinness rekord is,\r\namelyben KJ Joseph 1 perc alatt 82 szabályos karhajlítás-nyújtást\r\nvégzett.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (2, 'Húzódzkodás', 'Ennek a gyakorlatnak a 24 órás csúcstartója Joonas Mäkipelto 5050\r\ngyakorlattal.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (3, 'Melső fekvőtámasz 30mp', 'A gyakorlatot 30 másodperc alatt olyan sokszor kell végrehajtani, ahányszor a\r\nfelvételiző képes rá. Azonban törekedni kell a szabályos végrehajtásra, ugyanis csak azokat\r\nszámolják. A nők esetében 20, a férfiak esetében 35 gyakorlatot kell végrehajtani a maximális\r\npont megszerzéséért. A gyakorlat akkor sikeres, ha a női legalább 1, a férfi felvételiző\r\nlegalább 11 gyakorlatot képes végrehajtani.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (4, 'Melső fekvőtámasz 2perc', 'Magyar Honvédség: A gyakorlat végrehajtására 2 perc áll rendelkezésre. Ennek során csak a szabályosan a\r\nfentiekben leírt módon végrehajtott gyakorlat értékelhető. Férfiaknál 70 karhajlítás nyújtást\r\nkell végrehajtani a maximális pontért.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (5, 'Hajlított karú függés', 'A gyakorlat addig tart, amíg a végrehajtó szemmagassága a kiinduló helyzettől\r\nsüllyedve a keresztvas alá nem kerül. Az értékeléshez stopperórát alkalmaznak, és az\r\neredmény másodperc pontossággal kerül megállapításra. Nők esetében 45, férfiak\r\ntekintetében 73 másodperctől jár a maximális pontszám. A gyakorlat sikeres végrehajtásához\r\nlegalább 8, 10 másodpercig kell megtartaniuk a kiinduló helyzetet a női és a férfi\r\nfelvételizőknek.\r\n\r\nA NKE-RTK-án lévő hallgatók egyéni rekordjai Iván Viktor 90s, Kiss Regina 74s', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (6, 'Fekvenyomás', '2015-ben a fekvenyomó világbajnokságot Smulter Fredrik finn súlyemelő 401 Kg-al nyerte.\r\nA súlyzó tömege nők esetében 25 kg, a férfiak esetében 60 kg a rúddal együtt. Az\r\nértékelésénél a szabályosan végrehajtott gyakorlatokat értékelik csak.\r\nA legtöbb pontért 25 gyakorlatot kell végezni mind a nőknek, mind a férfiaknak. A minimum:\r\negy gyakorlat mindkét nem esetében.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (7, '4x10m-es ingafutás', 'A legjobb pontszámért 9,4 s illetve 8,8s alatt kell teljesíteni a nőknek, férfiaknak. A\r\ngyakorlat sikertelen 11,8 s illetve 11,2 s-on túl.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (8, 'Helyből távolugrás', 'Byron Jones 2015-ben a 3,73 méteres ugrásával érte el a világcsúcsot.\r\nA nőknek 220 cm-re, a férfiak 250 cm-re kell ugraniuk a maximális pontért. A\r\nminimális távolság 172cm illetve 198 cm.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (9, 'Felülés hanyattfekvésből', 'Az NKE-RTK hallgatói közül Papp Zsófia 66 db-ot, Gál Valentin 80\r\ndb-ot csinált 1 perc leforgása alatt.\r\nElső ütemre megtörténik a felülés, ami akkor szabályos, ha valamelyik könyök érinti a\r\ntérdet. Második ütemre vissza kell térni a kiinduló helyzetbe. A maximális pont eléréséhez 1\r\nperc alatt 45 illetve 55 ismétlést kell végezni a nőknek illetve a férfiaknak. A minimumhoz 7\r\nés 25 ismétlés szükséges.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (10, 'Felülés hajlított térddel', 'Magyar Honvédség: A kiinduló helyzet hajlított ülés, ennek során a sarkak a talajon, a térd 90 fokban meghajlítva\r\nvan.\r\nA gyakorlat végrehajtására két perc áll rendelkezésre. Ennek során csak a szabályosan,\r\na fentiekben leírt módon végrehajtott gyakorlat értékelhető. Férfiaknál, nőknél egyaránt 90\r\ngyakorlatot kell végrehajtani a maximális pontért. Amennyiben a megadott időkeret alatt nem\r\nsikerül legalább 25 szabályos gyakorlatot végrehajtani, úgy az sikertelennek minősül.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (11, 'Síkfutás 2000m', 'A maximálisan megszerezhető pontot az a felvételiző gyűjtheti be, aki a távot nők\r\nesetében 10:00 perc alatt, férfiak esetében 7:35 perc alatt teljesíti. A gyakorlat sikeres\r\nteljesítésére nők esetében maximum 16:00 perc, férfiak esetében 13:30 perc áll rendelkezésre.', NULL, NULL, NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (30, 'Cooper', '12 minutes run, how many meters', NULL, 'meter', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (31, '300m', NULL, NULL, 'second', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (32, '400m', NULL, NULL, 'second', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (33, 'Pushup', NULL, NULL, 'repeat', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (34, 'Timed Pushup', NULL, NULL, 'repeat', 1, 'second');
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (35, 'Squats', NULL, NULL, 'repeat', 1, 'kg');
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (36, 'Sit-Ups', NULL, NULL, 'repeat', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (37, 'Chest Press', NULL, NULL, 'repeat', 1, 'kg');
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (38, 'Pull Ups', NULL, NULL, 'repeat', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (39, 'Biceps', NULL, NULL, 'repeat', 1, 'kg');
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (40, 'Triceps', NULL, NULL, 'repeat', 1, 'kg');
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (41, 'Shoulders', NULL, NULL, 'repeat', 1, 'kg');
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (42, 'BMI', NULL, NULL, 'percent', NULL, NULL);
INSERT INTO `exercise_type` (`exercise_type_id`, `name`, `description`, `video`, `unit`, `unit_quantity`, `unit_quantity_unit`) VALUES (43, 'BMR', NULL, NULL, NULL, NULL, NULL);
CREATE TABLE `exercise_type_image` (
`image_id` INT(13) NOT NULL AUTO_INCREMENT,
`exercise_type_id` INT(13) NULL DEFAULT '0',
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`url` CHAR(200) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
`type` ENUM('menu','image','video') NULL DEFAULT 'image' COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`image_id`) USING BTREE
)
COLLATE='utf8_hungarian_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_type_translation` (
`translation_id` INT(13) NOT NULL AUTO_INCREMENT,
`language_code` CHAR(2) NOT NULL DEFAULT 'en' COLLATE 'utf8mb4_general_ci',
`exercise_type_id` INT(13) NOT NULL DEFAULT '0',
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`description` MEDIUMTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`translation_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_tree` (
`item_id` INT(11) NOT NULL AUTO_INCREMENT,
`parent_id` INT(11) NOT NULL DEFAULT '0',
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`image_url` CHAR(200) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`active` TINYINT(1) NULL DEFAULT '1',
PRIMARY KEY (`item_id`) USING BTREE,
INDEX `parent_id` (`parent_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_tree_translation` (
`translation_id` INT(13) NOT NULL AUTO_INCREMENT,
`tree_id` INT(13) NOT NULL DEFAULT '0',
`language_code` CHAR(2) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`name` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`translation_id`) USING BTREE,
INDEX `tree_id` (`tree_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_plan` (
`exercise_plan_id` INT(11) NOT NULL AUTO_INCREMENT,
`name` CHAR(50) NULL DEFAULT '0' COLLATE 'utf8mb4_general_ci',
`description` TEXT(65535) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`exercise_plan_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_plan_detail` (
`exercise_plan_detail_id` INT(11) NOT NULL AUTO_INCREMENT,
`exercise_plan_id` INT(11) NOT NULL DEFAULT '0',
`exercise_type_id` INT(11) NOT NULL DEFAULT '0',
`serie` INT(11) NOT NULL DEFAULT '0',
`repeat` INT(11) NULL DEFAULT NULL,
`weight_equation` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`exercise_plan_detail_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_plan_translation` (
`translation_id` INT(11) NOT NULL AUTO_INCREMENT,
`language_code` CHAR(2) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_general_ci',
`name` CHAR(50) NULL DEFAULT '0' COLLATE 'utf8mb4_general_ci',
`description` TEXT(65535) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`exercise_plan_id` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`translation_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
/*!40000 ALTER TABLE `exercise_type` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

93
data/db/update_1_0_5.sql Normal file
View File

@ -0,0 +1,93 @@
ALTER TABLE `exercise_type`
ADD COLUMN `tree_id` INT(12) DEFAULT 0 AFTER `exercise_type_id`;
ADD COLUMN `active` TINYINT(1) NULL DEFAULT NULL AFTER `unit_quantity_unit`;
ALTER TABLE `exercise_type`
DROP COLUMN `video`;
CREATE TABLE `exercise_type_image` (
`image_id` INT(13) NOT NULL AUTO_INCREMENT,
`exercise_type_id` INT(13) NULL DEFAULT '0',
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`url` CHAR(200) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`type` ENUM('menu','image','video') NULL DEFAULT 'image' COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`image_id`)
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_type_translation` (
`translation_id` INT(13) NOT NULL AUTO_INCREMENT,
`language_code` CHAR(2) NOT NULL DEFAULT 'en' COLLATE 'utf8mb4_general_ci',
`exercise_type_id` INT(13) NOT NULL DEFAULT '0',
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`description` MEDIUMTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`translation_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_tree` (
`item_id` INT(11) NOT NULL AUTO_INCREMENT,
`parent_id` INT(11) NOT NULL DEFAULT '0',
`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`image_url` CHAR(200) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`active` TINYINT(1) NULL DEFAULT '1',
PRIMARY KEY (`item_id`) USING BTREE,
INDEX `parent_id` (`parent_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_tree_translation` (
`translation_id` INT(13) NOT NULL AUTO_INCREMENT,
`tree_id` INT(13) NOT NULL DEFAULT '0',
`language_code` CHAR(2) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`name` CHAR(100) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`translation_id`) USING BTREE,
INDEX `tree_id` (`tree_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
CREATE TABLE `exercise_plan` (
`exercise_plan_id` INT(11) NOT NULL AUTO_INCREMENT,
`name` CHAR(50) NULL DEFAULT '0' COLLATE 'utf8mb4_general_ci',
`description` TEXT(65535) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`exercise_plan_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=5
;
CREATE TABLE `exercise_plan_detail` (
`exercise_plan_detail_id` INT(11) NOT NULL AUTO_INCREMENT,
`exercise_plan_id` INT(11) NOT NULL DEFAULT '0',
`exercise_type_id` INT(11) NOT NULL DEFAULT '0',
`serie` INT(11) NOT NULL DEFAULT '0',
`repeat` INT(11) NULL DEFAULT NULL,
`weight_equation` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`exercise_plan_detail_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=4
;
CREATE TABLE `exercise_plan_translation` (
`translation_id` INT(11) NOT NULL AUTO_INCREMENT,
`language_code` CHAR(2) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_general_ci',
`name` CHAR(50) NULL DEFAULT '0' COLLATE 'utf8mb4_general_ci',
`description` TEXT(65535) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`exercise_plan_id` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`translation_id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=3
;

View File

@ -39,10 +39,17 @@ class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeR
/*
@GetMapping("/exercise_type/name/{name}")
fun getExerciseTypeByName(@PathVariable(value = "name") name: String): ResponseEntity<ExerciseType> {
return exerciseTypeRepository.findByName(name).map { exerciseType ->
return exerciseTypeRepository.findByName(name).map { exerciseType ->
ResponseEntity.ok(exerciseType)
}.orElse(ResponseEntity.notFound().build())
}*/
}*/
@GetMapping("exercise_type/active")
fun getActiveExerciseType(): List<ExerciseType> {
val list: List<ExerciseType> = exerciseTypeRepository.getActiveExerciseTypes()
logger.info("-- Get Active Exercise Types with Images and Translation -- ")
return list
}
@PostMapping("/exercise_type/{id}")
fun updateExerciseTypesById(@PathVariable(value = "id") exerciseTypeId: Long,
@ -52,7 +59,7 @@ class ExerciseTypeController ( private val exerciseTypeRepository: ExerciseTypeR
val updatedExerciseType: ExerciseType = existingExerciseType
.copy(name = newExerciseType.name,
description = newExerciseType.description,
video = newExerciseType.video)
treeId = newExerciseType.treeId)
ResponseEntity.ok().body(exerciseTypeRepository.save(updatedExerciseType))
}.orElse(ResponseEntity.notFound().build())

View File

@ -1,24 +1,32 @@
package com.aitrainer.api.model
import org.hibernate.type.BinaryType
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import org.hibernate.annotations.FetchMode
import org.hibernate.annotations.Fetch
import org.springframework.lang.NonNull
import javax.persistence.*
import javax.validation.constraints.NotBlank
import javax.validation.constraints.Null
@Entity
data class ExerciseType (
@get: NotBlank var name: String = "",
data class ExerciseType(
@get: NonNull var treeId: Int,
@get: NotBlank var name: String = "",
@get: NotBlank var description: String = "",
@get: Null var video: BinaryType?,
@get: Null var unit: String?,
@get: Null var unitQuantity: String?,
@get: Null var unitQuantityUnit: String?,
@get: NonNull var active: Boolean?,
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
val exerciseTypeId: Long = 0
val exerciseTypeId: Long = 0,
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
@Fetch(value = FetchMode.SUBSELECT)
val images: List<ExerciseTypeImage> = mutableListOf<ExerciseTypeImage>().toList(),
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseType")
@Fetch(value = FetchMode.SUBSELECT)
val translations: List<ExerciseTypeTranslation> = mutableListOf<ExerciseTypeTranslation>().toList()
)

View File

@ -0,0 +1,24 @@
package com.aitrainer.api.model
import org.springframework.lang.NonNull
import javax.persistence.*
import javax.validation.constraints.NotBlank
@Entity
data class ExerciseTypeImage (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val imageId: Long = 0,
//@get: NonNull var exerciseTypeId: Integer?,
@get: NotBlank var name: String = "",
@get: NotBlank var type: String = "",
@get: NotBlank var url: String = ""
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name="exerciseTypeId", nullable=false)
val exerciseType: ExerciseType? = null
}

View File

@ -0,0 +1,22 @@
package com.aitrainer.api.model
import org.springframework.lang.NonNull
import javax.persistence.*
import javax.validation.constraints.NotBlank
@Entity
data class ExerciseTypeTranslation (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val translationId: Long = 0,
//@get: NonNull var exerciseTypeId: Integer?,
@get: NotBlank var languageCode: String?,
@get: NotBlank var name: String = "",
@get: NotBlank var description: String = ""
) {
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "exerciseTypeId", nullable = false)
val exerciseType: ExerciseType? = null
}

View File

@ -1,12 +1,25 @@
package com.aitrainer.api.repository
import com.aitrainer.api.model.ExerciseType
import com.aitrainer.api.model.Exercises
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import javax.persistence.NamedQuery
@Repository
interface ExerciseTypeRepository : JpaRepository<ExerciseType, Long>{
fun findByName(name: String): ExerciseType
@Query("FROM ExerciseType as e " +
"LEFT JOIN ExerciseTypeImage as i ON e.exerciseTypeId = i.exerciseType " +
"LEFT JOIN ExerciseTypeTranslation as t ON e.exerciseTypeId = t.exerciseType " +
"WHERE e.active = 1 " +
"AND t.languageCode = 'hu' " +
"AND i.type = 'menu' " +
"ORDER BY e.exerciseTypeId ")
fun getActiveExerciseTypes(): List<ExerciseType>
}

View File

@ -1,7 +1,7 @@
spring.profiles.active=dev
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
#spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
spring.datasource.username = aitrainer
spring.datasource.password = andio2009

View File

@ -1,7 +1,6 @@
spring.profiles.active=prod
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
#spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&allowMultiQueries=true
spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&allowMultiQueries=true
spring.datasource.username = aitrainer
spring.datasource.password = andio2009

View File

@ -1,7 +1,7 @@
spring.profiles.active=dev,test,prod
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
#spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
spring.datasource.username = aitrainer
spring.datasource.password = andio2009
@ -16,6 +16,6 @@ logging.config=classpath:logback-spring.xml
logging.file=logs
# if the database structure has been changed, increment this version number
application.version=1.0.4
application.version=1.0.5
jwt.secret=aitrainer

View File

@ -24,7 +24,7 @@ class ApplicationStartTest {
var foundTable = false
val rs: ResultSet = Singleton.execQuery("Show tables;")
while ( rs.next() ) {
if ( rs.getString("tables_in_aitrainer") == "customer_information" ) {
if ( rs.getString("tables_in_aitrainer2") == "customer_information" ) {
foundTable = true
}
}

View File

@ -115,6 +115,7 @@ class CustomerTests {
assertEquals(response.statusCode, HttpStatus.OK)
assertEquals(newCustomer?.weight, 79)
assertEquals(newCustomer?.password, "123456789")
assertEquals(newCustomer?.firstname, "Tib")
// test not found
id = 1000
@ -125,10 +126,14 @@ class CustomerTests {
// update Password
id = 103
customer.password = "blabal"
customer.firstname = "Kakadu"
customer.name = "Bos"
response = customerController.updateCustomerById(id, customer, HttpHeaders.readOnlyHttpHeaders(HttpHeaders.EMPTY) )
assertEquals(response.statusCode, HttpStatus.OK)
newCustomer = response.body as Customer
assertEquals(newCustomer.password, "blabal")
assertEquals(newCustomer.firstname, "Kakadu")
assertEquals(newCustomer.name, "Bos")
}

View File

@ -1,5 +1,7 @@
package com.aitrainer.api.test
import com.aitrainer.api.controller.CustomerController
import com.aitrainer.api.controller.ExerciseTypeController
import com.aitrainer.api.model.ExerciseType
import com.aitrainer.api.repository.ExerciseTypeRepository
import org.junit.jupiter.api.Test
@ -48,7 +50,7 @@ class ExerciseTypeTest {
@Test
fun testInsert(){
logger.info("Add 'Húzodszkodás 2")
val newEx = ExerciseType( "Húzodszkodás 2", " A legtöbb húzodszkodást 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null, null, null , null)
val newEx = ExerciseType( 0,"Húzodszkodás 2", " A legtöbb húzodszkodást 24 óra alatt John Ort érte el 7600-al 2016-ban. ", null, null, null ,true)
val savedEx: ExerciseType = exerciseTypeRepository.save(newEx)
assertEquals(savedEx.name, "Húzodszkodás 2")
@ -61,4 +63,16 @@ class ExerciseTypeTest {
logger.info("Delete 'Húzodszkodás 2")
exerciseTypeRepository.delete(extype)
}
@Test
fun testActiveExercises() {
val exerciseTypeController = ExerciseTypeController(exerciseTypeRepository)
val exerciseTypes = exerciseTypeController.getActiveExerciseType()
val exerciseType = exerciseTypes[0]
assertEquals(exerciseType.name, "Chest Press")
assertEquals(exerciseType.images[0].url, "images/2.2.1.1.chestpress.png")
assertEquals(exerciseTypes[2].translations[0].name, "Tricepsz")
}
}

View File

@ -15,7 +15,7 @@ class PropertiesTest {
@Test
fun testDatasourceUrl() {
val url: String = properties.getDatasourceUrl()
assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
}
}