Merge branch 'tibor' into 'master'
1.0.4: customer fields extensions, tests See merge request bossanyit/aitrainer_server!6
This commit is contained in:
commit
31b33d85bc
@ -26,25 +26,32 @@ CREATE TABLE IF NOT EXISTS `customer` (
|
|||||||
`date_change` datetime DEFAULT NULL,
|
`date_change` datetime DEFAULT NULL,
|
||||||
`data_policy_allowed` tinyint(4) DEFAULT 1,
|
`data_policy_allowed` tinyint(4) DEFAULT 1,
|
||||||
`admin` tinyint(4) DEFAULT 0,
|
`admin` tinyint(4) DEFAULT 0,
|
||||||
|
`birth_year` int(4) DEFAULT 0,
|
||||||
|
`weight` INT(3) NULL DEFAULT '0',
|
||||||
|
`goal` CHAR(20) NULL DEFAULT '' COLLATE 'utf8_hungarian_ci',
|
||||||
|
`fitness_level` ENUM('beginner','intermediate','advanced','professional') NOT NULL DEFAULT 'beginner' COLLATE 'utf8_hungarian_ci',
|
||||||
|
`body_type` ENUM('ectomorph','mesomorph','endomorph') NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
|
||||||
PRIMARY KEY (`customer_id`)
|
PRIMARY KEY (`customer_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;
|
||||||
|
|
||||||
-- Tábla adatainak mentése aitrainer.customer: ~13 rows (hozzávetőleg)
|
-- Tábla adatainak mentése aitrainer.customer: ~13 rows (hozzávetőleg)
|
||||||
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
|
||||||
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`) VALUES
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (1, 'Átlag 13 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(1, 'Átlag 13 éves fiú', '', NULL, NULL, 'm', 13, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (2, 'Átlag 14 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(2, 'Átlag 14 éves fiú', '', NULL, NULL, 'm', 14, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (3, 'Átlag 15 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(3, 'Átlag 15 éves fiú', '', NULL, NULL, 'm', 15, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (4, 'Átlag 15 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(4, 'Átlag 15 éves fiú', '', NULL, NULL, 'm', 15, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (5, 'Átlag 16 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(5, 'Átlag 16 éves fiú', '', NULL, NULL, 'm', 16, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (6, 'Átlag 17 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(6, 'Átlag 17 éves fiú', '', NULL, NULL, 'm', 17, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (7, 'Átlag 18 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(7, 'Átlag 18 éves fiú', '', NULL, NULL, 'm', 18, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (8, 'Átlag 13 éves lány', '', '', NULL, 'w', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(8, 'Átlag 13 éves lány', '', NULL, NULL, 'w', 13, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (9, 'Átlag 14 éves lány', '', '', NULL, 'w', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(9, 'Átlag 14 éves lány', '', NULL, NULL, 'w', 14, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (10, 'Átlag 15 éves lány', '', '', NULL, 'w', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(10, 'Átlag 15 éves lány', '', NULL, NULL, 'w', 15, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (11, 'Átlag 16 éves lány', '', '', NULL, 'w', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(11, 'Átlag 16 éves lány', '', NULL, NULL, 'w', 16, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (12, 'Átlag 17 éves lány', '', '', NULL, 'w', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(12, 'Átlag 17 éves lány', '', NULL, NULL, 'w', 17, 'N', NULL, NULL, 1, 0),
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (13, 'Átlag 18 éves lány', '', '', NULL, 'w', 0, 'N', NULL, NULL, 1, 0, 0, 0, '', 'beginner', NULL);
|
||||||
(13, 'Átlag 18 éves lány', '', NULL, NULL, 'w', 18, 'N', NULL, NULL, 1, 0);
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (54, 'Dummy User', '', 'bosi', '$2a$10$thOc8jS750c7xe9U9Qq3GuSPs/H0Pt2Ads05yzUlyzQBIj.Rk9QCy', 'm', 0, 'N', NULL, NULL, 1, 1, 0, 0, '', 'beginner', NULL);
|
||||||
|
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (90, 'Bossi', 'Tib', 'sw@andio.biz', '', 'm', 0, 'Y', NULL, NULL, 1, 1, 0, 0, '', 'beginner', NULL);
|
||||||
|
|
||||||
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
|
||||||
|
|
||||||
-- Struktúra mentése tábla aitrainer. customer_information
|
-- Struktúra mentése tábla aitrainer. customer_information
|
||||||
@ -86,7 +93,7 @@ CREATE TABLE IF NOT EXISTS `exercises` (
|
|||||||
-- Tábla adatainak mentése aitrainer.exercises: ~0 rows (hozzávetőleg)
|
-- Tábla adatainak mentése aitrainer.exercises: ~0 rows (hozzávetőleg)
|
||||||
/*!40000 ALTER TABLE `exercises` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `exercises` DISABLE KEYS */;
|
||||||
INSERT INTO `exercises` (`exercise_id`, `exercise_type_id`, `customer_id`, `date_add`, `quantity`, `unit`, `rest_time`) VALUES
|
INSERT INTO `exercises` (`exercise_id`, `exercise_type_id`, `customer_id`, `date_add`, `quantity`, `unit`, `rest_time`) VALUES
|
||||||
(1, 1, 1, '2020-05-01 00:00:00', 12, 'repeat', NULL);
|
(1, 1, 1, '2020-05-01 00:00:00', 12, 'repeat', NULL, NULL);
|
||||||
/*!40000 ALTER TABLE `exercises` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `exercises` ENABLE KEYS */;
|
||||||
|
|
||||||
-- Struktúra mentése tábla aitrainer. exercise_evaluation
|
-- Struktúra mentése tábla aitrainer. exercise_evaluation
|
||||||
|
12
data/db/update_1_0_4.sql
Normal file
12
data/db/update_1_0_4.sql
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
ALTER TABLE `customer`
|
||||||
|
ADD COLUMN `birth_year` INT(4) NULL DEFAULT '0' AFTER `admin`,
|
||||||
|
ADD COLUMN `weight` INT(3) NULL DEFAULT '0' AFTER `birth_year`,
|
||||||
|
ADD COLUMN `goal` CHAR(20) NULL DEFAULT '' AFTER `weight`,
|
||||||
|
ADD COLUMN `fitness_level` ENUM('beginner','intermediate', 'advanced', 'professional') NOT NULL DEFAULT 'beginner' COLLATE 'utf8_hungarian_ci' after `goal`,
|
||||||
|
ADD COLUMN `body_type` ENUM('ectomorph','mesomorph', 'endomorph') NULL COLLATE 'utf8_hungarian_ci' after `fitness_level`;
|
||||||
|
|
||||||
|
ALTER TABLE `exercises`
|
||||||
|
CHANGE COLUMN `quantity` `quantity` DOUBLE NULL DEFAULT NULL AFTER `date_add`,
|
||||||
|
CHANGE COLUMN `unit_quantity` `unit_quantity` DOUBLE NULL DEFAULT NULL AFTER `unit`;
|
||||||
|
|
||||||
|
UPDATE configuration set config_value = "1.0.4" WHERE config_key = "db_version";
|
@ -1,4 +1,4 @@
|
|||||||
#aitrainer server API v0.0.5
|
#aitrainer server API v1.0.4
|
||||||
|
|
||||||
connects the MYSQL Database
|
connects the MYSQL Database
|
||||||
provide a RESTful API for the mobile app
|
provide a RESTful API for the mobile app
|
||||||
|
@ -43,6 +43,8 @@ object Singleton {
|
|||||||
this.dbVersion = dbConfig.configValue
|
this.dbVersion = dbConfig.configValue
|
||||||
this.appVersion = applicationVersion
|
this.appVersion = applicationVersion
|
||||||
|
|
||||||
|
logger.info("DBVersion: " + this.dbVersion + " App version: " + this.appVersion)
|
||||||
|
|
||||||
if ( dbConfig.configValue != applicationVersion ) {
|
if ( dbConfig.configValue != applicationVersion ) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -10,7 +10,7 @@ data class Customer (
|
|||||||
var name: String = "",
|
var name: String = "",
|
||||||
var firstname: String = "",
|
var firstname: String = "",
|
||||||
var email: String = "",
|
var email: String = "",
|
||||||
var age: Int = 0,
|
var age: Int? = 0,
|
||||||
var sex: String = "m",
|
var sex: String = "m",
|
||||||
var active: String = "N",
|
var active: String = "N",
|
||||||
var dateAdd: String? = null,
|
var dateAdd: String? = null,
|
||||||
@ -18,7 +18,12 @@ data class Customer (
|
|||||||
var dataPolicyAllowed: Int = 0,
|
var dataPolicyAllowed: Int = 0,
|
||||||
var admin: Int = 0,
|
var admin: Int = 0,
|
||||||
var password: String = "",
|
var password: String = "",
|
||||||
|
var birthYear:Int = 0,
|
||||||
|
var weight: Int = 0,
|
||||||
|
var goal: String? = null,
|
||||||
|
var fitnessLevel: String = "beginner",
|
||||||
|
var bodyType: String? = null,
|
||||||
|
|
||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
val customer_id: Long = 0
|
var customerId: Long = 0
|
||||||
)
|
)
|
||||||
|
@ -12,7 +12,7 @@ data class Exercises (
|
|||||||
@get: NonNull var exerciseTypeId: Long = 0,
|
@get: NonNull var exerciseTypeId: Long = 0,
|
||||||
@get: NonNull var customerId: Long = 0,
|
@get: NonNull var customerId: Long = 0,
|
||||||
@get: NonNull var dateAdd: String? = null,
|
@get: NonNull var dateAdd: String? = null,
|
||||||
@get: NonNull var quantity: Int = 0,
|
@get: NonNull var quantity: Double? = null,
|
||||||
@get: Null var restTime: Int?, // in seconds
|
@get: Null var restTime: Int?, // in seconds
|
||||||
@get: NonNull var unit: String? = null,
|
@get: NonNull var unit: String? = null,
|
||||||
@get: NonNull var unitQuantity: Double? = null,
|
@get: NonNull var unitQuantity: Double? = null,
|
||||||
|
@ -16,6 +16,6 @@ logging.config=classpath:logback-spring.xml
|
|||||||
logging.file=logs
|
logging.file=logs
|
||||||
|
|
||||||
# if the database structure has been changed, increment this version number
|
# if the database structure has been changed, increment this version number
|
||||||
application.version=0.0.3
|
application.version=1.0.4
|
||||||
|
|
||||||
jwt.secret=aitrainer
|
jwt.secret=aitrainer
|
@ -44,12 +44,12 @@ class CustomerTests {
|
|||||||
val savedCustomer: Customer = customerRepository.save(newCustomer)
|
val savedCustomer: Customer = customerRepository.save(newCustomer)
|
||||||
assertEquals(savedCustomer.age, 48)
|
assertEquals(savedCustomer.age, 48)
|
||||||
|
|
||||||
this.insertedId = savedCustomer.customer_id
|
this.insertedId = savedCustomer.customerId
|
||||||
|
|
||||||
val customer: Customer = customerRepository.findById( savedCustomer.customer_id ).orElse(null)
|
val customer: Customer = customerRepository.findById( savedCustomer.customerId ).orElse(null)
|
||||||
assertEquals( customer.firstname, "Tibor")
|
assertEquals( customer.firstname, "Tibor")
|
||||||
|
|
||||||
this.testUpdate(savedCustomer.customer_id)
|
this.testUpdate(savedCustomer.customerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testUpdate( customerId: Long ) {
|
fun testUpdate( customerId: Long ) {
|
||||||
@ -67,6 +67,30 @@ class CustomerTests {
|
|||||||
customerRepository.delete(updatedCustomer)
|
customerRepository.delete(updatedCustomer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testUpdateCustomer() {
|
||||||
|
var id:Long = 90
|
||||||
|
|
||||||
|
val customer: Customer = customerRepository.findById( id ).orElse(null)
|
||||||
|
|
||||||
|
customer.customerId = id
|
||||||
|
customer.firstname = "Tib"
|
||||||
|
customer.name = "Bossi"
|
||||||
|
customer.admin = 1
|
||||||
|
customer.active = "Y"
|
||||||
|
customer.sex = "m"
|
||||||
|
|
||||||
|
customer.birthYear = 1972
|
||||||
|
customer.bodyType = "endomorph"
|
||||||
|
customer.dataPolicyAllowed = 1
|
||||||
|
customer.fitnessLevel = "advanced"
|
||||||
|
|
||||||
|
val updatedCustomer = customerRepository.save(customer)
|
||||||
|
assertEquals(updatedCustomer.customerId, 90)
|
||||||
|
assertEquals(updatedCustomer.birthYear, 1972)
|
||||||
|
assertEquals(updatedCustomer.fitnessLevel, "advanced")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testRegistration() {
|
fun testRegistration() {
|
||||||
val json = "{\"username\":\"bosi@example.com\",\"password\":\"94385\"}"
|
val json = "{\"username\":\"bosi@example.com\",\"password\":\"94385\"}"
|
||||||
|
@ -19,7 +19,7 @@ class ExerciseTest {
|
|||||||
var id: Long = 1
|
var id: Long = 1
|
||||||
|
|
||||||
val exercises: List<Exercises> = exerciseRepository.getAllByCustomerId( id )
|
val exercises: List<Exercises> = exerciseRepository.getAllByCustomerId( id )
|
||||||
assertEquals( exercises[0].quantity, 12)
|
assertEquals( exercises[0].quantity, 12.2)
|
||||||
|
|
||||||
id = 100000
|
id = 100000
|
||||||
val exercises2: List<Exercises> = exerciseRepository.getAllByCustomerId( id )
|
val exercises2: List<Exercises> = exerciseRepository.getAllByCustomerId( id )
|
||||||
@ -29,17 +29,30 @@ class ExerciseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testInsert() {
|
fun testInsert() {
|
||||||
val exercise = Exercises(
|
var exercise = Exercises(
|
||||||
exerciseTypeId = 3,
|
exerciseTypeId = 3,
|
||||||
customerId = 11,
|
customerId = 11,
|
||||||
quantity = 100,
|
quantity = 100.0,
|
||||||
dateAdd = "2020-05-13 04:32:00",
|
dateAdd = "2020-05-13 04:32:00",
|
||||||
unit = "repeat",
|
unit = "repeat",
|
||||||
unitQuantity = 30.0,
|
unitQuantity = 30.0,
|
||||||
restTime = null
|
restTime = null
|
||||||
)
|
)
|
||||||
val exerciseNew = exerciseRepository.save(exercise)
|
var exerciseNew = exerciseRepository.save(exercise)
|
||||||
assertTrue(exerciseNew.exerciseId > 2)
|
assertTrue(exerciseNew.exerciseId > 2)
|
||||||
exerciseRepository.delete(exercise)
|
exerciseRepository.delete(exercise)
|
||||||
|
|
||||||
|
exercise = Exercises(
|
||||||
|
exerciseTypeId = 40,
|
||||||
|
customerId = 11,
|
||||||
|
quantity = 32.5,
|
||||||
|
dateAdd = "2020-07-05 04:32:00",
|
||||||
|
unit = "repeat",
|
||||||
|
unitQuantity = 32.6,
|
||||||
|
restTime = null
|
||||||
|
)
|
||||||
|
exerciseNew = exerciseRepository.save(exercise)
|
||||||
|
assertTrue(exerciseNew.exerciseId > 3)
|
||||||
|
exerciseRepository.delete(exercise)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,7 +40,7 @@ class ExerciseTypeTest {
|
|||||||
assertEquals(exerciseTypes[0].exerciseTypeId, 1)
|
assertEquals(exerciseTypes[0].exerciseTypeId, 1)
|
||||||
assertEquals(exerciseTypes[0].name, "Melső fekvőtámasz 1 perc")
|
assertEquals(exerciseTypes[0].name, "Melső fekvőtámasz 1 perc")
|
||||||
|
|
||||||
assertEquals(exerciseTypes[15].name, "Timed Pushup")
|
assertEquals(exerciseTypes[15].name, "Timed Pushups")
|
||||||
assertEquals(exerciseTypes[15].unit, "repeat")
|
assertEquals(exerciseTypes[15].unit, "repeat")
|
||||||
assertEquals(exerciseTypes[15].unitQuantityUnit, "second")
|
assertEquals(exerciseTypes[15].unitQuantityUnit, "second")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user