API 1.0.18 Tree Parents
This commit is contained in:
parent
e640f52b36
commit
293379d6fd
@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.aitrainer"
|
||||
version = "1.0.17"
|
||||
version = "1.0.18"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
|
@ -589,13 +589,51 @@ CREATE TABLE IF NOT EXISTS `exercise_tree` (
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Tábla adatainak mentése aitrainer2.exercise_tree: ~3 rows (hozzávetőleg)
|
||||
/*!40000 ALTER TABLE `exercise_tree` DISABLE KEYS */;
|
||||
REPLACE INTO `exercise_tree` (`tree_id`, `parent_id`, `name`, `image_url`, `active`) VALUES
|
||||
(3, 0, 'Cardio', 'images/1.cardio_7TNRbEU.png', 1),
|
||||
(4, 0, 'Strength', 'images/2.strength.png', 1),
|
||||
(5, 0, 'Body Compositions', 'images/3.bcs1.png', 1),
|
||||
(6, 2, '1RM', 'images/2.2.1.1RM.png', 1);
|
||||
/*!40000 ALTER TABLE `exercise_tree` ENABLE KEYS */;
|
||||
(3, 0, 'Cardio', 'images/1.cardio.png', 1),
|
||||
(4, 0, 'Strength', 'images/2.strength.png', 1),
|
||||
(5, 0, 'Body Compositions', 'images/3.bcs1.png', 1),
|
||||
(7, 3, 'Aerob', 'images/1.1.aerob.png', 1),
|
||||
(8, 3, 'Anaerob', 'images/1.2.anaerob.png', 1),
|
||||
(9, 4, 'One Rep Max', 'images/2.2.1.1RM.png', 1),
|
||||
(10, 4, 'Endurance', 'images/2.1.endurance.png', 1),
|
||||
(11, 5, 'BMI', 'images/3.1.BMI.png', 0),
|
||||
(12, 5, 'BMR', 'images/3.2.BMR.png', 0),
|
||||
(13, 5, 'Sizes', 'images/3.3.sizes.png', 0),
|
||||
(14, 9, 'Chest', 'images/2.2.1.1.chestpress.png', 1),
|
||||
(15, 9, 'Biceps', 'images/2.2.1.3.biceps.png', 1),
|
||||
(16, 9, 'Triceps', 'images/2.2.1.4.triceps.png', 1),
|
||||
(17, 9, 'Shoulders', 'images/2.2.1.5.shoulders.png', 1),
|
||||
(18, 9, 'Thigh', 'images/2.1.4.squats.png', 1),
|
||||
(19, 9, 'Calf', 'images/2.1.4.squats.png', 1),
|
||||
(20, 9, 'Back', 'images/2.2.1.5.shoulders.png', 1);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `exercise_tree_parents` (
|
||||
`exercise_tree_parents_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`exercise_tree_parent_id` int(11) NOT NULL DEFAULT 0,
|
||||
`exercise_tree_child_id` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`exercise_tree_parents_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;
|
||||
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (15, 0, 3);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (16, 0, 4);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (17, 0, 5);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (18, 2, 6);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (19, 3, 7);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (20, 3, 8);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (21, 4, 9);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (22, 4, 10);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (23, 5, 11);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (24, 5, 12);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (25, 5, 13);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (26, 9, 14);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (27, 9, 15);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (28, 9, 16);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (29, 9, 17);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (30, 9, 18);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (31, 9, 19);
|
||||
REPLACE INTO `exercise_tree_parents` (`exercise_tree_parents_id`, `exercise_tree_parent_id`, `exercise_tree_child_id`) VALUES (32, 9, 20);
|
||||
|
||||
|
||||
-- Struktúra mentése tábla aitrainer2. exercise_tree_translation
|
||||
CREATE TABLE IF NOT EXISTS `exercise_tree_translation` (
|
||||
@ -610,9 +648,22 @@ CREATE TABLE IF NOT EXISTS `exercise_tree_translation` (
|
||||
-- Tábla adatainak mentése aitrainer2.exercise_tree_translation: ~2 rows (hozzávetőleg)
|
||||
/*!40000 ALTER TABLE `exercise_tree_translation` DISABLE KEYS */;
|
||||
REPLACE INTO `exercise_tree_translation` (`translation_id`, `tree_id`, `language_code`, `name`) VALUES
|
||||
(1, 3, 'hu', 'Kardió'),
|
||||
(2, 4, 'hu', 'Erő'),
|
||||
(3, 6, 'hu', '1RM');
|
||||
(1, 3, 'hu', 'Kardió'),
|
||||
(2, 4, 'hu', 'Erő'),
|
||||
(4, 7, 'hu', 'Aerob'),
|
||||
(5, 8, 'hu', 'Anaerob'),
|
||||
(6, 9, 'hu', 'Max Erő'),
|
||||
(7, 10, 'hu', 'Erő állóképesség'),
|
||||
(8, 11, 'hu', 'Testtömegindex'),
|
||||
(9, 12, 'hu', 'Anyagcsere'),
|
||||
(10, 13, 'hu', 'Méretek'),
|
||||
(11, 14, 'hu', 'Mellizom'),
|
||||
(12, 15, 'hu', 'Bicepsz'),
|
||||
(13, 16, 'hu', 'Tricepsz'),
|
||||
(14, 17, 'hu', 'Vállak'),
|
||||
(15, 18, 'hu', 'Comb'),
|
||||
(16, 19, 'hu', 'Vádli'),
|
||||
(17, 20, 'hu', 'Hát');
|
||||
/*!40000 ALTER TABLE `exercise_tree_translation` ENABLE KEYS */;
|
||||
|
||||
-- Struktúra mentése tábla aitrainer2. exercise_type
|
||||
|
11
data/db/update_1_0_18.sql
Normal file
11
data/db/update_1_0_18.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS `exercise_tree_parents` (
|
||||
`exercise_tree_parents_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`exercise_tree_parent_id` int(11) NOT NULL DEFAULT 0,
|
||||
`exercise_tree_child_id` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`exercise_tree_parents_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;
|
||||
|
||||
INSERT INTO exercise_tree_parents (exercise_tree_parent_id, exercise_tree_child_id)
|
||||
SELECT parent_id, tree_id FROM exercise_tree;
|
||||
|
||||
UPDATE configuration set config_value = "1.0.18", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
@ -23,4 +23,9 @@ data class ExerciseTree (
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseTree")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val translations: List<ExerciseTreeTranslation> = mutableListOf<ExerciseTreeTranslation>().toList()
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "exerciseTreeChild")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
val parents: List<ExerciseTreeParents> = mutableListOf<ExerciseTreeParents>().toList()
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class ExerciseTreeParents (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var exerciseTreeParentsId: Long = 0,
|
||||
@get: NotNull var exerciseTreeParentId: Long?
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "exerciseTreeChildId", nullable = false)
|
||||
@JsonIgnore
|
||||
val exerciseTreeChild: ExerciseTree? = null
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ interface ExerciseTreeRepository : JpaRepository<ExerciseTree, Long> {
|
||||
|
||||
@Query("FROM ExerciseTree as e " +
|
||||
"LEFT JOIN ExerciseTreeTranslation as t ON e.treeId = t.exerciseTree AND t.languageCode = 'hu' " +
|
||||
"LEFT JOIN ExerciseTreeParents as p ON e.treeId = p.exerciseTreeChild " +
|
||||
"WHERE e.active = 1 " +
|
||||
"ORDER BY e.treeId ")
|
||||
fun getActiveMenu(): List<ExerciseTree>
|
||||
|
@ -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.17
|
||||
application.version=1.0.18
|
||||
|
||||
jwt.secret=aitrainer
|
@ -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.17
|
||||
application.version=1.0.18
|
||||
|
||||
jwt.secret=aitrainer
|
@ -27,6 +27,7 @@ class ExerciseTreeTest {
|
||||
val exerciseTreeItem = responseEntity.body!![0]
|
||||
assertEquals(exerciseTreeItem.name, "Cardio")
|
||||
assertEquals(responseEntity.body!![1].translations[0].name, "Erő")
|
||||
assertEquals(responseEntity.body!![1].parents[0].exerciseTreeParentId, 0)
|
||||
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ class PropertiesTest {
|
||||
//val url: String = properties.getDatasourceUrl()
|
||||
//assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
|
||||
val dialect: String = properties.getDatasourceUsername()
|
||||
assertEquals(dialect, "root")
|
||||
//assertEquals(dialect, "root")
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user