Commit 790d94b46e1726c5ca5bd5b3647ccafee622f029

Authored by Geoffrey PREUD'HOMME
1 parent 9182ba39

Base de données, enfin !

Bon ok, c'est en mémoire pour l'instant mais c'est déjà ça
api.raml
... ... @@ -95,13 +95,19 @@ securitySchemes:
95 95 {
96 96 "id": 42,
97 97 "carte": "AAAAA",
98   - "naissance": "1997-02-14",
  98 + "naissance": "855874800000",
99 99 "solde": 1337,
100 100 "login": "gbontoux",
101 101 "role": "etudiant"
102 102 }
103 103 ]
104 104 /{idPersonne}:
  105 + uriParameters:
  106 + idPersonne:
  107 + type: number
  108 + required: true
  109 + description: ID de la personne
  110 + minimum: 0
105 111 get:
106 112 <<<<<<< HEAD
107 113 securedBy: [oauth_2_0]
... ... @@ -118,7 +124,7 @@ securitySchemes:
118 124 {
119 125 "id": 42,
120 126 "carte": "AAAAA",
121   - "naissance": "1997-02-14",
  127 + "naissance": "855874800000",
122 128 "solde": 1337,
123 129 "login": "gbontoux",
124 130 "role": "etudiant"
... ... @@ -143,6 +149,7 @@ securitySchemes:
143 149 naissance:
144 150 displayName: Date de naissance
145 151 type: date
  152 + example: "14-Feb-1997"
146 153 required: false
147 154 example: 1997-02-14
148 155 login:
... ...
etunicorn-server.iml
... ... @@ -9,51 +9,80 @@
9 9 </content>
10 10 <orderEntry type="inheritedJdk" />
11 11 <orderEntry type="sourceFolder" forTests="false" />
12   - <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.4.4.RELEASE" level="project" />
  12 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-rest:1.4.4.RELEASE" level="project" />
13 13 <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.4.4.RELEASE" level="project" />
14 14 <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.4.4.RELEASE" level="project" />
15 15 <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.4.4.RELEASE" level="project" />
16 16 <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.4.4.RELEASE" level="project" />
17 17 <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.9" level="project" />
18 18 <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.9" level="project" />
19   - <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.22" level="project" />
20 19 <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.22" level="project" />
21 20 <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.22" level="project" />
22 21 <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
  22 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.4.4.RELEASE" level="project" />
23 23 <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.4.4.RELEASE" level="project" />
24 24 <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.11" level="project" />
25 25 <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.11" level="project" />
26 26 <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.11" level="project" />
27 27 <orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.2.4.Final" level="project" />
28 28 <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
29   - <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
30 29 <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.3" level="project" />
31   - <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.6" level="project" />
  30 + <orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.6.RELEASE" level="project" />
  31 + <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.6.RELEASE" level="project" />
  32 + <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.6.RELEASE" level="project" />
32 33 <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.6" level="project" />
  34 + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.6" level="project" />
33 35 <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.6" level="project" />
34   - <orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.6.RELEASE" level="project" />
  36 + <orderEntry type="library" name="Maven: org.springframework.data:spring-data-rest-webmvc:2.5.7.RELEASE" level="project" />
  37 + <orderEntry type="library" name="Maven: org.springframework.data:spring-data-rest-core:2.5.7.RELEASE" level="project" />
  38 + <orderEntry type="library" name="Maven: org.springframework.hateoas:spring-hateoas:0.20.0.RELEASE" level="project" />
  39 + <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
  40 + <orderEntry type="library" name="Maven: org.atteo:evo-inflector:1.2.1" level="project" />
  41 + <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.22" level="project" />
  42 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:1.4.4.RELEASE" level="project" />
  43 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:1.4.4.RELEASE" level="project" />
35 44 <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.6.RELEASE" level="project" />
36   - <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.6.RELEASE" level="project" />
  45 + <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.9" level="project" />
  46 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:1.4.4.RELEASE" level="project" />
  47 + <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jdbc:8.5.11" level="project" />
  48 + <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.11" level="project" />
  49 + <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.6.RELEASE" level="project" />
  50 + <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.0.11.Final" level="project" />
  51 + <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
  52 + <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
  53 + <orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
  54 + <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
  55 + <orderEntry type="library" name="Maven: org.jboss:jandex:2.0.0.Final" level="project" />
  56 + <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
  57 + <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
  58 + <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" />
  59 + <orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:5.0.11.Final" level="project" />
  60 + <orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.2" level="project" />
  61 + <orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:1.10.7.RELEASE" level="project" />
  62 + <orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.12.7.RELEASE" level="project" />
  63 + <orderEntry type="library" name="Maven: org.springframework:spring-orm:4.3.6.RELEASE" level="project" />
37 64 <orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.6.RELEASE" level="project" />
38   - <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.6.RELEASE" level="project" />
39   - <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.6.RELEASE" level="project" />
40   - <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.4.4.RELEASE" level="project" />
41   - <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.4.4.RELEASE" level="project" />
42   - <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.4.4.RELEASE" level="project" />
43   - <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
44   - <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.5.0" level="project" />
45   - <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
46   - <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />
47   - <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
48   - <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
49   - <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.3.0" level="project" />
50   - <orderEntry type="library" scope="TEST" name="Maven: org.json:json:20140107" level="project" />
  65 + <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.6.RELEASE" level="project" />
  66 + <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.6.RELEASE" level="project" />
  67 + <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.3.6.RELEASE" level="project" />
  68 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-test:1.4.4.RELEASE" level="project" />
  69 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test:1.4.4.RELEASE" level="project" />
  70 + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.4.4.RELEASE" level="project" />
  71 + <orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
  72 + <orderEntry type="library" name="Maven: org.assertj:assertj-core:2.5.0" level="project" />
  73 + <orderEntry type="library" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
  74 + <orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.1" level="project" />
  75 + <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
  76 + <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
  77 + <orderEntry type="library" name="Maven: org.skyscreamer:jsonassert:1.3.0" level="project" />
  78 + <orderEntry type="library" name="Maven: org.json:json:20140107" level="project" />
51 79 <orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.6.RELEASE" level="project" />
52   - <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.6.RELEASE" level="project" />
53   - <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
54   - <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
55   - <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
56   - <orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
  80 + <orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.6.RELEASE" level="project" />
  81 + <orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
  82 + <orderEntry type="library" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
  83 + <orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
  84 + <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
57 85 <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.22" level="project" />
  86 + <orderEntry type="library" name="Maven: com.h2database:h2:1.4.193" level="project" />
58 87 </component>
59 88 </module>
60 89 \ No newline at end of file
... ...
... ... @@ -16,17 +16,23 @@
16 16 <dependencies>
17 17 <dependency>
18 18 <groupId>org.springframework.boot</groupId>
19   - <artifactId>spring-boot-starter-web</artifactId>
  19 + <artifactId>spring-boot-starter-data-rest</artifactId>
  20 + </dependency>
  21 + <dependency>
  22 + <groupId>org.springframework.boot</groupId>
  23 + <artifactId>spring-boot-starter-data-jpa</artifactId>
20 24 </dependency>
21 25 <dependency>
22 26 <groupId>org.springframework.boot</groupId>
23 27 <artifactId>spring-boot-starter-test</artifactId>
24   - <scope>test</scope>
25 28 </dependency>
26 29 <dependency>
27 30 <groupId>com.jayway.jsonpath</groupId>
28 31 <artifactId>json-path</artifactId>
29   - <scope>test</scope>
  32 + </dependency>
  33 + <dependency>
  34 + <groupId>com.h2database</groupId>
  35 + <artifactId>h2</artifactId>
30 36 </dependency>
31 37 </dependencies>
32 38  
... ...
src/main/java/etunicorn/Personne.java
1 1 package etunicorn;
2 2  
3   -import java.sql.Date;
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.GeneratedValue;
  5 +import javax.persistence.GenerationType;
  6 +import javax.persistence.Id;
  7 +import java.util.Date;
4 8  
5 9 /**
6 10 * Created by geoffrey on 28/01/17.
7 11 */
  12 +@Entity
8 13 public class Personne {
  14 +
  15 + @Id
  16 + @GeneratedValue(strategy = GenerationType.AUTO)
9 17 private int id;
  18 +
10 19 private String carte;
11 20 private Date naissance;
12 21 private String login;
13   - private Role role;
  22 + // private Role role;
14 23  
15 24 public Personne() {
16 25 }
... ... @@ -47,11 +56,11 @@ public class Personne {
47 56 this.login = login;
48 57 }
49 58  
50   - public Role getRole() {
51   - return role;
52   - }
  59 + // public Role getRole() {
  60 + // return role;
  61 + // }
53 62  
54   - public void setRole(Role role) {
55   - this.role = role;
56   - }
  63 + // public void setRole(Role role) {
  64 + // this.role = role;
  65 + // }
57 66 }
... ...
src/main/java/etunicorn/PersonneController.java
1 1 package etunicorn;
2 2  
  3 +import org.springframework.beans.factory.annotation.Autowired;
  4 +import org.springframework.http.HttpStatus;
3 5 import org.springframework.http.ResponseEntity;
4 6 import org.springframework.web.bind.annotation.PathVariable;
5 7 import org.springframework.web.bind.annotation.RequestParam;
  8 +import org.springframework.web.bind.annotation.ResponseBody;
6 9 import org.springframework.web.bind.annotation.RestController;
7 10  
  11 +import java.math.BigDecimal;
  12 +import java.text.DateFormat;
  13 +import java.text.ParseException;
  14 +import java.text.SimpleDateFormat;
8 15 import java.util.Date;
  16 +import java.util.List;
  17 +import java.util.Locale;
9 18  
10 19 /**
11 20 * Created by geoffrey on 28/01/17.
... ... @@ -13,28 +22,66 @@ import java.util.Date;
13 22  
14 23 @RestController
15 24 public class PersonneController implements etunicorn.generated.PersonneController {
  25 + @Autowired
  26 + private PersonneRepository personneRepository;
  27 +
16 28 @Override
17 29 public ResponseEntity<?> getPersonne() {
18   - return null;
  30 + return new ResponseEntity<List>((List) this.personneRepository.findAll(), HttpStatus.OK);
19 31 }
20 32  
21 33 @Override
22 34 public ResponseEntity<?> updatePersonne(@RequestParam(required = false) String carte, @RequestParam(required = false) Date naissance, @RequestParam(required = false) String login, @RequestParam(required = false, defaultValue = "etudiant") String role) {
23   - return null;
  35 + Personne personne = new Personne();
  36 + if (carte != null) {
  37 + personne.setCarte(carte);
  38 + }
  39 + if (naissance != null) {
  40 + personne.setNaissance(naissance);
  41 + }
  42 + if (login != null) {
  43 + personne.setLogin(login);
  44 + }
  45 + this.personneRepository.save(personne);
  46 + return new ResponseEntity<Object>(personne, HttpStatus.CREATED);
24 47 }
25 48  
26 49 @Override
27   - public ResponseEntity<?> getPersonneById(@PathVariable String idPersonne) {
28   - return null;
  50 + public ResponseEntity<?> getPersonneById(@PathVariable BigDecimal idPersonne) {
  51 + Personne personne = personneRepository.findById(idPersonne.intValueExact());
  52 + if (personne == null) {
  53 + return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
  54 + }
  55 + return new ResponseEntity<Object>(personne, HttpStatus.OK);
29 56 }
30 57  
31 58 @Override
32   - public ResponseEntity<?> updatePersonneById(@PathVariable String idPersonne, @RequestParam(required = false) String carte, @RequestParam(required = false) Date naissance, @RequestParam(required = false) String login, @RequestParam(required = false) String role) {
33   - return null;
  59 + public ResponseEntity<?> updatePersonneById(@PathVariable BigDecimal idPersonne, @RequestParam(required = false) String carte, @RequestParam(required = false) Date naissance, @RequestParam(required = false) String login, @RequestParam(required = false) String role) {
  60 + Personne personne = personneRepository.findById(idPersonne.intValueExact());
  61 + if (personne == null) {
  62 + return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
  63 + }
  64 + if (carte != null) {
  65 + personne.setCarte(carte);
  66 + }
  67 + if (naissance != null) {
  68 + personne.setNaissance(naissance);
  69 + }
  70 + if (login != null) {
  71 + personne.setLogin(login);
  72 + }
  73 + this.personneRepository.save(personne);
  74 + return new ResponseEntity<Object>(personne, HttpStatus.CREATED);
34 75 }
35 76  
36 77 @Override
37   - public ResponseEntity<?> deletePersonneById(@PathVariable String idPersonne) {
38   - return null;
  78 + public ResponseEntity<?> deletePersonneById(@PathVariable BigDecimal idPersonne) {
  79 + Personne personne = personneRepository.findById(idPersonne.intValueExact());
  80 + if (personne == null) {
  81 + return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
  82 + }
  83 + personneRepository.delete(personne);
  84 + return new ResponseEntity<Object>(personne, HttpStatus.NO_CONTENT);
39 85 }
  86 +
40 87 }
... ...
src/main/java/etunicorn/PersonneRepository.java 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +package etunicorn;
  2 +
  3 +import org.springframework.data.repository.CrudRepository;
  4 +
  5 +import java.math.BigDecimal;
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by geoffrey on 29/01/17.
  10 + */
  11 +public interface PersonneRepository extends CrudRepository<Personne, Long> {
  12 + Personne findByLogin(String login);
  13 + Personne findById(Integer id);
  14 +}
... ...
src/main/java/etunicorn/generated/ConsomationController.java
1 1  
2 2 package etunicorn.generated;
3 3  
4   -import org.springframework.http.ResponseEntity;
5   -import org.springframework.web.bind.annotation.*;
6   -
7 4 import java.math.BigDecimal;
  5 +import org.springframework.http.ResponseEntity;
  6 +import org.springframework.web.bind.annotation.PathVariable;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
8 11  
9 12  
10 13 /**
11 14 * No description
12 15 * (Generated with springmvc-raml-parser v.0.8.9)
  16 + *
13 17 */
14 18 @RestController
15 19 @RequestMapping("/v1/consomation")
... ... @@ -18,46 +22,51 @@ public interface ConsomationController {
18 22  
19 23 /**
20 24 * Obtenir la liste de toutes les consomations. Nécessite CONSO_ADMIN ou CONSO_ACHETER ou CONSO_REMBOURSER
  25 + *
21 26 */
22 27 @RequestMapping(value = "", method = RequestMethod.GET)
23 28 public ResponseEntity<?> getConsomation();
24 29  
25 30 /**
26 31 * Permet de creer une nouvelle consomation. Nécessite CONSO_ADMIN
  32 + *
27 33 */
28 34 @RequestMapping(value = "", method = RequestMethod.POST)
29 35 public ResponseEntity<?> updateConsomation(
30   - @RequestParam
31   - String nomConsomation,
32   - @RequestParam
33   - BigDecimal prix);
  36 + @RequestParam
  37 + String nomConsomation,
  38 + @RequestParam
  39 + BigDecimal prix);
34 40  
35 41 /**
36 42 * Permet de modifier une consommation. Nécessite CONSO_ADMIN
  43 + *
37 44 */
38 45 @RequestMapping(value = "/{consomationId}", method = RequestMethod.PUT)
39 46 public ResponseEntity<?> updateConsomationById(
40   - @PathVariable
41   - String consomationId,
42   - @RequestParam(required = false)
43   - String nomEvenement,
44   - @RequestParam(required = false)
45   - BigDecimal prix);
  47 + @PathVariable
  48 + String consomationId,
  49 + @RequestParam(required = false)
  50 + String nomEvenement,
  51 + @RequestParam(required = false)
  52 + BigDecimal prix);
46 53  
47 54 /**
48 55 * Obtenir la Consomation {consomationId}. Nécessite CONSO_ADMIN ou CONSO_ACHETER ou CONSO_REMBOURSER
  56 + *
49 57 */
50 58 @RequestMapping(value = "/{consomationId}", method = RequestMethod.GET)
51 59 public ResponseEntity<?> getConsomationById(
52   - @PathVariable
53   - String consomationId);
  60 + @PathVariable
  61 + String consomationId);
54 62  
55 63 /**
56 64 * Permet de supprimer la consomation {consomationId}. Nécessite CONSO_ADMIN
  65 + *
57 66 */
58 67 @RequestMapping(value = "/{consomationId}", method = RequestMethod.DELETE)
59 68 public ResponseEntity<?> deleteConsomationById(
60   - @PathVariable
61   - String consomationId);
  69 + @PathVariable
  70 + String consomationId);
62 71  
63 72 }
... ...
src/main/java/etunicorn/generated/EvenementController.java
1 1  
2 2 package etunicorn.generated;
3 3  
4   -import org.springframework.http.ResponseEntity;
5   -import org.springframework.web.bind.annotation.*;
6   -
7 4 import java.math.BigDecimal;
8 5 import java.util.Date;
  6 +import org.springframework.http.ResponseEntity;
  7 +import org.springframework.web.bind.annotation.PathVariable;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestMethod;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
9 12  
10 13  
11 14 /**
12 15 * No description
13 16 * (Generated with springmvc-raml-parser v.0.8.9)
  17 + *
14 18 */
15 19 @RestController
16 20 @RequestMapping("/v1/evenement")
... ... @@ -19,50 +23,55 @@ public interface EvenementController {
19 23  
20 24 /**
21 25 * Obtenir la liste de tout les evenements. Nécessite EVNMT_ADMIN ou EVNMT_ACHETER ou EVNMT_REMBOURSER
  26 + *
22 27 */
23 28 @RequestMapping(value = "", method = RequestMethod.GET)
24 29 public ResponseEntity<?> getEvenement();
25 30  
26 31 /**
27 32 * Permet de creer un nouvel evenement. Nécessite EVNMT_ADMIN
  33 + *
28 34 */
29 35 @RequestMapping(value = "", method = RequestMethod.POST)
30 36 public ResponseEntity<?> updateEvenement(
31   - @RequestParam
32   - String nomEvenement,
33   - @RequestParam
34   - BigDecimal prix,
35   - @RequestParam
36   - Date date);
  37 + @RequestParam
  38 + String nomEvenement,
  39 + @RequestParam
  40 + BigDecimal prix,
  41 + @RequestParam
  42 + Date date);
37 43  
38 44 /**
39 45 * Permet de modifier un évènement existant. Nécessite EVNMT_ADMIN
  46 + *
40 47 */
41 48 @RequestMapping(value = "/{evenementId}", method = RequestMethod.PUT)
42 49 public ResponseEntity<?> updateEvenementById(
43   - @PathVariable
44   - String evenementId,
45   - @RequestParam(required = false)
46   - String nomEvenement,
47   - @RequestParam(required = false)
48   - BigDecimal prix,
49   - @RequestParam(required = false)
50   - Date date);
  50 + @PathVariable
  51 + String evenementId,
  52 + @RequestParam(required = false)
  53 + String nomEvenement,
  54 + @RequestParam(required = false)
  55 + BigDecimal prix,
  56 + @RequestParam(required = false)
  57 + Date date);
51 58  
52 59 /**
53 60 * Obtenir l'evenement {evenementId}. Nécessite EVNMT_ADMIN ou EVNMT_ACHETER ou EVNMT_REMBOURSER
  61 + *
54 62 */
55 63 @RequestMapping(value = "/{evenementId}", method = RequestMethod.GET)
56 64 public ResponseEntity<?> getEvenementById(
57   - @PathVariable
58   - String evenementId);
  65 + @PathVariable
  66 + String evenementId);
59 67  
60 68 /**
61 69 * Permet de supprimer l'evenement {evenementId}. Nécessite EVNMT_ADMIN
  70 + *
62 71 */
63 72 @RequestMapping(value = "/{evenementId}", method = RequestMethod.DELETE)
64 73 public ResponseEntity<?> deleteEvenementById(
65   - @PathVariable
66   - String evenementId);
  74 + @PathVariable
  75 + String evenementId);
67 76  
68 77 }
... ...
src/main/java/etunicorn/generated/LoginController.java
... ... @@ -2,12 +2,17 @@
2 2 package etunicorn.generated;
3 3  
4 4 import org.springframework.http.ResponseEntity;
5   -import org.springframework.web.bind.annotation.*;
  5 +import org.springframework.web.bind.annotation.PathVariable;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
6 10  
7 11  
8 12 /**
9 13 * No description
10 14 * (Generated with springmvc-raml-parser v.0.8.9)
  15 + *
11 16 */
12 17 @RestController
13 18 @RequestMapping("/v1/login")
... ... @@ -16,20 +21,22 @@ public interface LoginController {
16 21  
17 22 /**
18 23 * Instancie une nouvelle connexion
  24 + *
19 25 */
20 26 @RequestMapping(value = "", method = RequestMethod.POST)
21 27 public ResponseEntity<?> updateLogin(
22   - @RequestParam
23   - String login,
24   - @RequestParam(required = false)
25   - String password);
  28 + @RequestParam
  29 + String login,
  30 + @RequestParam(required = false)
  31 + String password);
26 32  
27 33 /**
28 34 * Se déconnecter
  35 + *
29 36 */
30 37 @RequestMapping(value = "/{token}", method = RequestMethod.DELETE)
31 38 public ResponseEntity<?> deleteLoginByToken(
32   - @PathVariable
33   - String token);
  39 + @PathVariable
  40 + String token);
34 41  
35 42 }
... ...
src/main/java/etunicorn/generated/ParticipeController.java
... ... @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
11 11 /**
12 12 * No description
13 13 * (Generated with springmvc-raml-parser v.0.8.9)
  14 + *
14 15 */
15 16 @RestController
16 17 @RequestMapping("/v1/participe")
... ... @@ -19,22 +20,24 @@ public interface ParticipeController {
19 20  
20 21 /**
21 22 * Permet d'ajouter une personne a un evenement
  23 + *
22 24 */
23 25 @RequestMapping(value = "", method = RequestMethod.POST)
24 26 public ResponseEntity<?> updateParticipe(
25   - @RequestParam
26   - Long idPersonne,
27   - @RequestParam
28   - Long idEvenement);
  27 + @RequestParam
  28 + Long idPersonne,
  29 + @RequestParam
  30 + Long idEvenement);
29 31  
30 32 /**
31 33 * Permet de savoir si une personne participe a un evenement
  34 + *
32 35 */
33 36 @RequestMapping(value = "", method = RequestMethod.GET)
34 37 public ResponseEntity<?> getParticipe(
35   - @RequestParam
36   - Long idPersonne,
37   - @RequestParam
38   - Long idEvenement);
  38 + @RequestParam
  39 + Long idPersonne,
  40 + @RequestParam
  41 + Long idEvenement);
39 42  
40 43 }
... ...
src/main/java/etunicorn/generated/PersonneController.java
1 1  
2 2 package etunicorn.generated;
3 3  
4   -import org.springframework.http.ResponseEntity;
5   -import org.springframework.web.bind.annotation.*;
6   -
  4 +import java.math.BigDecimal;
7 5 import java.util.Date;
  6 +import org.springframework.http.ResponseEntity;
  7 +import org.springframework.web.bind.annotation.PathVariable;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestMethod;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
8 12  
9 13  
10 14 /**
11 15 * No description
12 16 * (Generated with springmvc-raml-parser v.0.8.9)
  17 + *
13 18 */
14 19 @RestController
15 20 @RequestMapping("/v1/personne")
... ... @@ -18,54 +23,59 @@ public interface PersonneController {
18 23  
19 24 /**
20 25 * Obtenir la liste des persones. Nécessite COMPTE_ADMIN
  26 + *
21 27 */
22 28 @RequestMapping(value = "", method = RequestMethod.GET)
23 29 public ResponseEntity<?> getPersonne();
24 30  
25 31 /**
26 32 * Ajoute une nouvelle personne
  33 + *
27 34 */
28 35 @RequestMapping(value = "", method = RequestMethod.POST)
29 36 public ResponseEntity<?> updatePersonne(
30   - @RequestParam(required = false)
31   - String carte,
32   - @RequestParam(required = false)
33   - Date naissance,
34   - @RequestParam(required = false)
35   - String login,
36   - @RequestParam(required = false, defaultValue = "etudiant")
37   - String role);
  37 + @RequestParam(required = false)
  38 + String carte,
  39 + @RequestParam(required = false)
  40 + Date naissance,
  41 + @RequestParam(required = false)
  42 + String login,
  43 + @RequestParam(required = false, defaultValue = "etudiant")
  44 + String role);
38 45  
39 46 /**
40 47 * Obtenir les infos sur une personne. Nécessite COMPTE_ADMIN
  48 + *
41 49 */
42 50 @RequestMapping(value = "/{idPersonne}", method = RequestMethod.GET)
43 51 public ResponseEntity<?> getPersonneById(
44   - @PathVariable
45   - String idPersonne);
  52 + @PathVariable
  53 + BigDecimal idPersonne);
46 54  
47 55 /**
48 56 * Modifer les infos d'une personne. Nécessite COMPTE_ADMIN
  57 + *
49 58 */
50 59 @RequestMapping(value = "/{idPersonne}", method = RequestMethod.PUT)
51 60 public ResponseEntity<?> updatePersonneById(
52   - @PathVariable
53   - String idPersonne,
54   - @RequestParam(required = false)
55   - String carte,
56   - @RequestParam(required = false)
57   - Date naissance,
58   - @RequestParam(required = false)
59   - String login,
60   - @RequestParam(required = false)
61   - String role);
  61 + @PathVariable
  62 + BigDecimal idPersonne,
  63 + @RequestParam(required = false)
  64 + String carte,
  65 + @RequestParam(required = false)
  66 + Date naissance,
  67 + @RequestParam(required = false)
  68 + String login,
  69 + @RequestParam(required = false)
  70 + String role);
62 71  
63 72 /**
64 73 * Obtenir les infos sur une personne. Nécessite COMPTE_ADMIN
  74 + *
65 75 */
66 76 @RequestMapping(value = "/{idPersonne}", method = RequestMethod.DELETE)
67 77 public ResponseEntity<?> deletePersonneById(
68   - @PathVariable
69   - String idPersonne);
  78 + @PathVariable
  79 + BigDecimal idPersonne);
70 80  
71 81 }
... ...
src/main/java/etunicorn/generated/RoleController.java
... ... @@ -2,12 +2,17 @@
2 2 package etunicorn.generated;
3 3  
4 4 import org.springframework.http.ResponseEntity;
5   -import org.springframework.web.bind.annotation.*;
  5 +import org.springframework.web.bind.annotation.PathVariable;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
6 10  
7 11  
8 12 /**
9 13 * No description
10 14 * (Generated with springmvc-raml-parser v.0.8.9)
  15 + *
11 16 */
12 17 @RestController
13 18 @RequestMapping("/v1/role")
... ... @@ -16,48 +21,54 @@ public interface RoleController {
16 21  
17 22 /**
18 23 * Liste les rôles. Nécessite ROLE_ADMIN
  24 + *
19 25 */
20 26 @RequestMapping(value = "", method = RequestMethod.GET)
21 27 public ResponseEntity<?> getRole();
22 28  
23 29 /**
24 30 * Ajoute un nouveau rôle. Nécessite ROLE_ADMIN
  31 + *
25 32 */
26 33 @RequestMapping(value = "", method = RequestMethod.POST)
27 34 public ResponseEntity<?> updateRole(
28   - @RequestParam
29   - String nom);
  35 + @RequestParam
  36 + String nom);
30 37  
31 38 /**
32 39 * Supprime un rôle. Nécessite ROLE_ADMIN
  40 + *
33 41 */
34 42 @RequestMapping(value = "/{nomRole}", method = RequestMethod.DELETE)
35 43 public ResponseEntity<?> deleteRoleById(
36   - @PathVariable
37   - String nomRole);
  44 + @PathVariable
  45 + String nomRole);
38 46  
39 47 /**
40 48 * Ajoute une permission à un rôle. Nécessite ROLE_ADMIN
  49 + *
41 50 */
42 51 @RequestMapping(value = "/{nomRole}", method = RequestMethod.POST)
43 52 public ResponseEntity<?> updateRoleById(
44   - @PathVariable
45   - String nomRole,
46   - @RequestParam
47   - String nom);
  53 + @PathVariable
  54 + String nomRole,
  55 + @RequestParam
  56 + String nom);
48 57  
49 58 /**
50 59 * Enlève la permission du rôle. Nécessite ROLE_ADMIN
  60 + *
51 61 */
52 62 @RequestMapping(value = "/{nomRole}/{nomPermission}", method = RequestMethod.DELETE)
53 63 public ResponseEntity<?> deleteRoleByNomPermission(
54   - @PathVariable
55   - String nomPermission,
56   - @PathVariable
57   - String nomRole);
  64 + @PathVariable
  65 + String nomPermission,
  66 + @PathVariable
  67 + String nomRole);
58 68  
59 69 /**
60 70 * Liste les permissions. Nécessite ROLE_ADMIN
  71 + *
61 72 */
62 73 @RequestMapping(value = "/permission", method = RequestMethod.GET)
63 74 public ResponseEntity<?> getPermission();
... ...
src/main/java/etunicorn/generated/TransactionController.java
1 1  
2 2 package etunicorn.generated;
3 3  
4   -import org.springframework.http.ResponseEntity;
5   -import org.springframework.web.bind.annotation.*;
6   -
7 4 import java.math.BigDecimal;
  5 +import org.springframework.http.ResponseEntity;
  6 +import org.springframework.web.bind.annotation.PathVariable;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
8 11  
9 12  
10 13 /**
11 14 * No description
12 15 * (Generated with springmvc-raml-parser v.0.8.9)
  16 + *
13 17 */
14 18 @RestController
15 19 @RequestMapping("/v1/transaction")
... ... @@ -18,65 +22,71 @@ public interface TransactionController {
18 22  
19 23 /**
20 24 * Permet de recuperer la liste des transaction
  25 + *
21 26 */
22 27 @RequestMapping(value = "", method = RequestMethod.GET)
23 28 public ResponseEntity<?> getTransaction();
24 29  
25 30 /**
26 31 * Permet de faire payer ou de crediter un Compte. >0 la personne a crediter de l'argent. <0 la personne a été débité.
  32 + *
27 33 */
28 34 @RequestMapping(value = "/consomation", method = RequestMethod.POST)
29 35 public ResponseEntity<?> updateConsomation(
30   - @RequestParam
31   - Long participant,
32   - @RequestParam
33   - Long id);
  36 + @RequestParam
  37 + Long participant,
  38 + @RequestParam
  39 + Long id);
34 40  
35 41 /**
36   - *
37   - *
  42 + *
  43 + *
38 44 */
39 45 @RequestMapping(value = "/evenement", method = RequestMethod.POST)
40 46 public ResponseEntity<?> updateEvenement(
41   - @RequestParam
42   - Long participant,
43   - @RequestParam
44   - Long id);
  47 + @RequestParam
  48 + Long participant,
  49 + @RequestParam
  50 + Long id);
45 51  
46 52 /**
47 53 * Permet de recharger un compte
  54 + *
48 55 */
49 56 @RequestMapping(value = "/evenement/credit", method = RequestMethod.POST)
50 57 public ResponseEntity<?> updateEvenementCredit(
51   - @RequestParam
52   - Long participant,
53   - @RequestParam
54   - BigDecimal prix);
  58 + @RequestParam
  59 + Long participant,
  60 + @RequestParam
  61 + BigDecimal prix);
55 62  
56 63 /**
57 64 * Permet de debiter la carte
  65 + *
58 66 */
59 67 @RequestMapping(value = "/evenement/debit", method = RequestMethod.POST)
60 68 public ResponseEntity<?> updateEvenementDebit(
61   - @RequestParam
62   - Long participant,
63   - @RequestParam
64   - BigDecimal prix);
  69 + @RequestParam
  70 + Long participant,
  71 + @RequestParam
  72 + BigDecimal prix);
65 73  
66 74 /**
67 75 * Permet de recuperer la liste des transaction d'une personne
  76 + *
68 77 */
69 78 @RequestMapping(value = "/participant/{idPersonne}", method = RequestMethod.GET)
70 79 public ResponseEntity<?> getParticipantByIdPersonne(
71   - @PathVariable
72   - String idPersonne);
  80 + @PathVariable
  81 + String idPersonne);
73 82  
74 83 /**
75 84 * Permet de recuperer la liste des transaction d'une personne
  85 + *
76 86 */
77 87 @RequestMapping(value = "/acteur/{idPersonne}", method = RequestMethod.GET)
78 88 public ResponseEntity<?> getActeurByIdPersonne(
79   - @PathVariable
80   - String idPersonne);
  89 + @PathVariable
  90 + String idPersonne);
81 91  
82 92 }
... ...
src/main/main.iml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <module type="JAVA_MODULE" version="4">
  3 + <component name="FacetManager">
  4 + <facet type="Spring" name="Spring">
  5 + <configuration />
  6 + </facet>
  7 + </component>
3 8 <component name="NewModuleRootManager" inherit-compiler-output="true">
4 9 <exclude-output />
5 10 <content url="file://$MODULE_DIR$">
... ... @@ -14,5 +19,11 @@
14 19 <orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.12.7.RELEASE" level="project" />
15 20 <orderEntry type="library" name="Maven: org.springframework.data:spring-data-rest-core:2.5.7.RELEASE" level="project" />
16 21 <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.6.RELEASE" level="project" />
  22 + <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.11" level="project" />
  23 + <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.6.RELEASE" level="project" />
  24 + <orderEntry type="library" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
  25 + <orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.6.RELEASE" level="project" />
  26 + <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.9" level="project" />
  27 + <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.22" level="project" />
17 28 </component>
18 29 </module>
19 30 \ No newline at end of file
... ...