Application.java
3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package etunicorn;
import etunicorn.entity.Permission;
import etunicorn.repository.PermissionRepository;
import etunicorn.repository.PersonneRepository;
import etunicorn.repository.RoleRepository;
import etunicorn.repository.SessionRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import javax.sql.DataSource;
/**
* etunicorn-server
* Copyright © 2017 Le Club Info Polytech Lille
* Tous droits réservés
*/
@SpringBootApplication
@EnableAutoConfiguration
@Configuration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public CommandLineRunner demo(PermissionRepository permissionRepository,
RoleRepository roleRepository,
PersonneRepository personneRepository,
SessionRepository sessionRepository) {
return (args) -> {
permissionRepository.save(new Permission("PERSONNE_ADD"));
permissionRepository.save(new Permission("PERSONNE_EDIT"));
permissionRepository.save(new Permission("PERSONNE_GET"));
permissionRepository.save(new Permission("PERSONNE_LIST"));
permissionRepository.save(new Permission("PERSONNE_REMOVE"));
permissionRepository.save(new Permission("PERSONNE_ROLE"));
permissionRepository.save(new Permission("ROLE_ADD"));
permissionRepository.save(new Permission("ROLE_DELETE"));
permissionRepository.save(new Permission("ROLE_PERMISSION_ADD"));
permissionRepository.save(new Permission("ROLE_PERMISSION_LIST"));
permissionRepository.save(new Permission("ROLE_PERMISSION_REMOVE"));
permissionRepository.save(new Permission("CONSO_ADD"));
permissionRepository.save(new Permission("CONSO_EDIT"));
permissionRepository.save(new Permission("CONSO_GET"));
permissionRepository.save(new Permission("CONSO_LIST"));
permissionRepository.save(new Permission("CONSO_REMOVE"));
permissionRepository.save(new Permission("EVNMT_ADD"));
permissionRepository.save(new Permission("EVNMT_EDIT"));
permissionRepository.save(new Permission("EVNMT_GET"));
permissionRepository.save(new Permission("EVNMT_LIST"));
permissionRepository.save(new Permission("EVNMT_REMOVE"));
// ...
//roleRepository.save(new Role("admin", (List<Permission>) permissionRepository.findAll()));
//roleRepository.save(new Role("etudiant", new ArrayList<>()));
//personneRepository.save(new Personne("546848", new Date(), "bverhaeg", roleRepository.findByNom("admin")));
//sessionRepository.save(new Session(personneRepository.findByLogin("bverhaeg"), "B", new Date(new Date().getTime() + 1000 * 60 * 10)));
};
}
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://192.168.0.28:3306/bade");
dataSource.setUsername("bade");
dataSource.setPassword("bade");
return dataSource;
}
// Properties additionalProperties() {
// Properties properties = new Properties();
// properties.setProperty("spring.jpa.hibernate.ddl-auto", "update");
// properties.setProperty("spring.jpa.database-platform", "org.hibernate.dialect.MySQL5Dialect");
// return properties;
// }
}