Merge branch 'tibor' into 'master'

Customer: trainer, trainerId

See merge request bossanyit/aitrainer_server!13
This commit is contained in:
Bossányi Tibor 2020-09-04 14:08:08 +00:00
commit ad2784814c
9 changed files with 45 additions and 19 deletions

View File

@ -42,6 +42,8 @@ CREATE TABLE IF NOT EXISTS `customer` (
`date_change` datetime DEFAULT NULL,
`data_policy_allowed` tinyint(4) DEFAULT 1,
`admin` tinyint(4) DEFAULT 0,
`trainer` tinyint(4) DEFAULT 0,
`trainer_id` INT(11) NULL DEFAULT '0',
`birth_year` int(4) DEFAULT 0,
`weight` INT(3) NULL DEFAULT '0',
`goal` CHAR(20) NULL DEFAULT '' COLLATE 'utf8_hungarian_ci',
@ -52,21 +54,23 @@ CREATE TABLE IF NOT EXISTS `customer` (
-- Tábla adatainak mentése aitrainer.customer: ~13 rows (hozzávetőleg)
/*!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`, `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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (1, 'Átlag 13 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 137, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (2, 'Átlag 14 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (3, 'Átlag 15 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (4, 'Átlag 15 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 137, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (5, 'Átlag 16 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (6, 'Átlag 17 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (7, 'Átlag 18 éves fiú', '', '', NULL, 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `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, 0, 0, '', 'beginner', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (90, 'Bossi', 'Tib', 'sw@andio.biz', '123456789', 'm', 0, 'Y', NULL, NULL, 1, 1, 0, 137, 1972, 79, NULL, 'advanced', 'endomorph');
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (103, 'Bos', 'Kakadu', 'sw2@andio.biz', 'blabal', 'm', 0, 'N', NULL, NULL, 1, 0, 0, 0, 1972, 79, NULL, 'intermediate', NULL);
INSERT INTO `customer` (`customer_id`, `name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`, `trainer`, `trainer_id`, `birth_year`, `weight`, `goal`, `fitness_level`, `body_type`) VALUES (137, 'Robert', '', NULL, NULL, 'm', NULL, 'N', NULL, NULL, 1, 0, 1, 0, 0, 0, '', 'beginner', NULL);
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;

5
data/db/update_1_0_6.sql Normal file
View File

@ -0,0 +1,5 @@
ALTER TABLE `customer`
ADD COLUMN `trainer` TINYINT(4) NULL DEFAULT '0' AFTER `admin`,
ADD COLUMN `trainer_id` INT(11) NULL DEFAULT '0' AFTER `trainer`;
UPDATE configuration set config_value = "1.0.6" WHERE config_key = "db_version";

View File

@ -44,6 +44,11 @@ class CustomerController ( private val customerRepository: CustomerRepository )
fun getRealCustomers(active: String, @RequestHeader headers: HttpHeaders): List<Customer> =
customerRepository.findByActive(active)
@Secured
@GetMapping("/customers/trainees/{id}")
fun getCustomerListByTrainerId(@PathVariable(value = "id") trainerId: Long, @RequestHeader headers: HttpHeaders): List<Customer> =
customerRepository.findByTrainerId(trainerId)
@Secured
@PostMapping("/customers/{id}")
fun updateCustomerById(@PathVariable(value = "id") customerId: Long,

View File

@ -17,6 +17,8 @@ data class Customer (
var dateChange: String? = null,
var dataPolicyAllowed: Int = 0,
var admin: Int = 0,
var trainer: Int = 0,
var trainerId: Long = 0,
var password: String? = "",
var birthYear:Int = 0,
var weight: Int = 0,

View File

@ -9,4 +9,6 @@ interface CustomerRepository : JpaRepository<Customer, Long> {
fun findByActive( active: String? ): List<Customer>
fun findByEmail(email: String?): Customer?
fun findByTrainerId( trainerId: Long ): List<Customer>
}

View File

@ -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.5
application.version=1.0.6
jwt.secret=aitrainer

View File

@ -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.5application-prod.properties
application.version=1.0.6
jwt.secret=aitrainer

View File

@ -1,4 +1,4 @@
spring.profiles.active=dev,test,prod
spring.profiles.active=dev,test,prod,prodtest
## 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/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
@ -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.5
application.version=1.0.6
jwt.secret=aitrainer

View File

@ -39,6 +39,14 @@ class CustomerTests {
assertEquals( customer.name, "Átlag 18 éves fiú")
}
@Test
fun testTrainer() {
val id: Long = 137
val customers: List<Customer> = customerRepository.findByTrainerId( id );
assertEquals(customers.count(), 3)
assertEquals( customers[0].name, "Átlag 13 éves fiú")
}
@Test
fun testInsert() {
val newCustomer = Customer("Bossanyi", "Tibor", "", 48, "m")