ThuyKhong il y a 6 ans
Parent
révision
7eb844cc9b
17 fichiers modifiés avec 565 ajouts et 0 suppressions
  1. 57
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java
  2. 80
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java
  3. 42
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java
  4. 31
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java
  5. 47
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java
  6. 30
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java
  7. 30
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/OptionCount.java
  8. 26
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/VoteResult.java
  9. 73
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/error/ErrorDetail.java
  10. 23
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/error/ValidationError.java
  11. 19
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java
  12. 55
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/exception/RestExceptionHandler.java
  13. 8
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java
  14. 7
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java
  15. 14
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java
  16. 23
    0
      src/main/resources/import.sql
  17. 0
    0
      src/main/resources/messages.properties

+ 57
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java Voir le fichier

@@ -0,0 +1,57 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import io.zipcoder.tc_spring_poll_application.dtos.OptionCount;
5
+import io.zipcoder.tc_spring_poll_application.dtos.VoteResult;
6
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.http.HttpStatus;
9
+import org.springframework.http.ResponseEntity;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestMethod;
12
+import org.springframework.web.bind.annotation.RequestParam;
13
+import org.springframework.web.bind.annotation.RestController;
14
+
15
+import java.util.ArrayList;
16
+import java.util.Collection;
17
+import java.util.HashMap;
18
+import java.util.Map;
19
+
20
+@RestController
21
+public class ComputeResultController {
22
+
23
+    private VoteRepository voteRepository;
24
+
25
+    @Autowired
26
+    public ComputeResultController(VoteRepository voteRepository) {
27
+        this.voteRepository = voteRepository;
28
+    }
29
+
30
+    @RequestMapping(value = "/computeresult", method = RequestMethod.GET)
31
+    public ResponseEntity<?> computeResult(@RequestParam Long pollId) {
32
+        VoteResult voteResult = new VoteResult();
33
+        Iterable<Vote> allVotes = voteRepository.findVotesByPoll(pollId);
34
+        Map<Long, Integer> mapOptions = new HashMap<>();
35
+        int voteCount = 0;
36
+        for(Vote vote:allVotes){
37
+            voteCount++;
38
+            if(!mapOptions.containsKey(vote.getOption().getId())){
39
+                mapOptions.put(vote.getOption().getId(),1);
40
+            }else{
41
+                int count = mapOptions.get(vote.getOption().getId());
42
+                count +=1;
43
+                mapOptions.put(vote.getOption().getId(),count);
44
+            }
45
+        }
46
+        Collection<OptionCount> optionCounts = new ArrayList<>();
47
+        for(Long l:mapOptions.keySet()){
48
+            OptionCount optionCount = new OptionCount();
49
+            optionCounts.add(optionCount);
50
+        }
51
+        voteResult.setResults(optionCounts);
52
+        voteResult.setTotalVotes(voteCount);
53
+
54
+        return new ResponseEntity<VoteResult>(voteResult, HttpStatus.OK);
55
+    }
56
+
57
+}

+ 80
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java Voir le fichier

@@ -0,0 +1,80 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
5
+import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.http.HttpHeaders;
8
+import org.springframework.http.HttpStatus;
9
+import org.springframework.http.ResponseEntity;
10
+import org.springframework.web.bind.annotation.*;
11
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
12
+
13
+import javax.validation.Valid;
14
+import java.net.URI;
15
+import java.util.Collection;
16
+
17
+@RestController
18
+public class PollController {
19
+
20
+    PollRepository pollRepository;
21
+
22
+    @Autowired
23
+    public PollController(PollRepository pollRepository) {
24
+        this.pollRepository = pollRepository;
25
+    }
26
+
27
+    @Valid
28
+    @RequestMapping(value = "/polls", method = RequestMethod.GET)
29
+    public ResponseEntity<Iterable<Poll>> getAllPolls() {
30
+        Iterable<Poll> allPolls = pollRepository.findAll();
31
+        return new ResponseEntity<>(allPolls, HttpStatus.OK);
32
+    }
33
+
34
+    @RequestMapping(value = "/polls", method = RequestMethod.POST)
35
+    public ResponseEntity<?> createPoll(@RequestBody Poll poll) {
36
+        poll = pollRepository.save(poll);
37
+
38
+        URI newPollUri = ServletUriComponentsBuilder
39
+                .fromCurrentRequest()
40
+                .path("/{id}")
41
+                .buildAndExpand(poll.getId())
42
+                .toUri();
43
+        HttpHeaders header = new HttpHeaders();
44
+        header.setLocation(newPollUri);
45
+        return new ResponseEntity<>(header, HttpStatus.CREATED);
46
+    }
47
+
48
+    @Valid
49
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.GET)
50
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId) {
51
+        Poll p = pollRepository.findOne(pollId);
52
+        return new ResponseEntity<> (p, HttpStatus.OK);
53
+    }
54
+
55
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.PUT)
56
+    public ResponseEntity<?> updatePoll(@RequestBody Poll poll, @PathVariable Long pollId) {
57
+        // Save the entity
58
+        Poll p = pollRepository.save(poll);
59
+        return new ResponseEntity<>(HttpStatus.OK);
60
+    }
61
+
62
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.DELETE)
63
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
64
+        pollRepository.delete(pollId);
65
+        return new ResponseEntity<>(HttpStatus.OK);
66
+    }
67
+
68
+    public void verifyPoll(Long pollId) throws ResourceNotFoundException{
69
+        Iterable<Poll> allPolls = pollRepository.findAll();
70
+        boolean verified = false;
71
+        for(Poll poll:allPolls){
72
+            if(poll.getId() ==pollId){
73
+                verified = true;
74
+            }
75
+        }
76
+        if (!verified)
77
+            throw new ResourceNotFoundException();
78
+    }
79
+
80
+}

+ 42
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java Voir le fichier

@@ -0,0 +1,42 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.http.HttpHeaders;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.web.bind.annotation.*;
10
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
11
+
12
+@RestController
13
+public class VoteController {
14
+
15
+    private VoteRepository voteRepository;
16
+
17
+    @Autowired
18
+    public VoteController(VoteRepository voteRepository) {
19
+        this.voteRepository = voteRepository;
20
+    }
21
+
22
+    @RequestMapping(value = "/polls/{pollId}/votes", method = RequestMethod.POST)
23
+    public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
24
+            vote) {
25
+        vote = voteRepository.save(vote);
26
+        // Set the headers for the newly created resource
27
+        HttpHeaders responseHeaders = new HttpHeaders();
28
+        responseHeaders.setLocation(ServletUriComponentsBuilder.
29
+                fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
30
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
31
+    }
32
+
33
+    @RequestMapping(value="/polls/votes", method=RequestMethod.GET)
34
+    public Iterable<Vote> getAllVotes() {
35
+        return voteRepository.findAll();
36
+    }
37
+
38
+    @RequestMapping(value="/polls/{pollId}/votes", method=RequestMethod.GET)
39
+    public Iterable<Vote> getVote(@PathVariable Long pollId) {
40
+        return voteRepository.findVotesByPoll(pollId);
41
+    }
42
+}

+ 31
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java Voir le fichier

@@ -0,0 +1,31 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import org.hibernate.annotations.ColumnDefault;
4
+
5
+import javax.persistence.*;
6
+
7
+@Entity
8
+public class Option {
9
+    @Id
10
+    @GeneratedValue(strategy = GenerationType.AUTO)
11
+    @Column(name = "OPTION_ID")
12
+    private Long id;
13
+    @Column(name = "OPTION_VALUE")
14
+    private String value;
15
+
16
+    public Long getId() {
17
+        return id;
18
+    }
19
+
20
+    public void setId(Long id) {
21
+        this.id = id;
22
+    }
23
+
24
+    public String getValue() {
25
+        return value;
26
+    }
27
+
28
+    public void setValue(String value) {
29
+        this.value = value;
30
+    }
31
+}

+ 47
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java Voir le fichier

@@ -0,0 +1,47 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import org.hibernate.validator.constraints.NotEmpty;
4
+
5
+import javax.persistence.*;
6
+import javax.validation.constraints.Size;
7
+import java.util.Set;
8
+
9
+@Entity
10
+public class Poll {
11
+    @Id
12
+    @GeneratedValue(strategy = GenerationType.AUTO)
13
+    @Column(name = "POLL_ID")
14
+    private Long id;
15
+    @Column(name = "QUESTION")
16
+    @NotEmpty
17
+    private String question;
18
+    @OneToMany(cascade = CascadeType.ALL)
19
+    @JoinColumn(name = "POLL_ID")
20
+    @OrderBy
21
+    @Size(min=2, max = 6)
22
+    private Set<Option> options;
23
+
24
+    public Long getId() {
25
+        return id;
26
+    }
27
+
28
+    public void setId(Long id) {
29
+        this.id = id;
30
+    }
31
+
32
+    public String getQuestion() {
33
+        return question;
34
+    }
35
+
36
+    public void setQuestion(String question) {
37
+        this.question = question;
38
+    }
39
+
40
+    public Set<Option> getOptions() {
41
+        return options;
42
+    }
43
+
44
+    public void setOptions(Set<Option> options) {
45
+        this.options = options;
46
+    }
47
+}

+ 30
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java Voir le fichier

@@ -0,0 +1,30 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import javax.persistence.*;
4
+
5
+@Entity
6
+public class Vote {
7
+    @Id
8
+    @GeneratedValue(strategy = GenerationType.AUTO)
9
+    @Column(name = "VOTE_ID")
10
+    private long id;
11
+    @ManyToOne
12
+    @JoinColumn(name = "OPTION_ID")
13
+    private Option option;
14
+
15
+    public long getId() {
16
+        return id;
17
+    }
18
+
19
+    public void setId(long id) {
20
+        this.id = id;
21
+    }
22
+
23
+    public Option getOption() {
24
+        return option;
25
+    }
26
+
27
+    public void setOption(Option option) {
28
+        this.option = option;
29
+    }
30
+}

+ 30
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/OptionCount.java Voir le fichier

@@ -0,0 +1,30 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos;
2
+
3
+public class OptionCount {
4
+    private Long optionId;
5
+    private int count;
6
+
7
+    public OptionCount(Long optionId, int count) {
8
+        this.optionId = optionId;
9
+        this.count = count;
10
+    }
11
+
12
+    public OptionCount() {
13
+    }
14
+
15
+    public Long getOptionId() {
16
+        return optionId;
17
+    }
18
+
19
+    public void setOptionId(Long optionId) {
20
+        this.optionId = optionId;
21
+    }
22
+
23
+    public int getCount() {
24
+        return count;
25
+    }
26
+
27
+    public void setCount(int count) {
28
+        this.count = count;
29
+    }
30
+}

+ 26
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/VoteResult.java Voir le fichier

@@ -0,0 +1,26 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos;
2
+
3
+import java.util.Collection;
4
+public class VoteResult {
5
+    private int totalVotes;
6
+    private Collection<OptionCount> results;
7
+
8
+
9
+    public int getTotalVotes() {
10
+        return totalVotes;
11
+    }
12
+
13
+    public void setTotalVotes(int totalVotes) {
14
+        this.totalVotes = totalVotes;
15
+    }
16
+
17
+    public Collection<OptionCount> getResults() {
18
+        return results;
19
+    }
20
+
21
+    public void setResults(Collection<OptionCount> results) {
22
+        this.results = results;
23
+    }
24
+
25
+
26
+}

+ 73
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/error/ErrorDetail.java Voir le fichier

@@ -0,0 +1,73 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos.error;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+public class ErrorDetail {
7
+
8
+    private String title;
9
+    private int status;
10
+    private String details;
11
+    private long timeStamp;
12
+    private String developerMessage;
13
+    Map<String, List<ValidationError>> errors;
14
+
15
+    public Map<String, List<ValidationError>> getErrors() {
16
+        return errors;
17
+    }
18
+
19
+    public void setErrors(Map<String, List<ValidationError>> errors) {
20
+        this.errors = errors;
21
+    }
22
+
23
+    public ErrorDetail() {
24
+    }
25
+
26
+    public ErrorDetail(String title, int status, String details, long timeStamp, String developerMessage) {
27
+        this.title = title;
28
+        this.status = status;
29
+        this.details = details;
30
+        this.timeStamp = timeStamp;
31
+        this.developerMessage = developerMessage;
32
+    }
33
+
34
+    public int getStatus() {
35
+        return status;
36
+    }
37
+
38
+    public void setStatus(int status) {
39
+        this.status = status;
40
+    }
41
+
42
+    public String getDetails() {
43
+        return details;
44
+    }
45
+
46
+    public void setDetails(String details) {
47
+        this.details = details;
48
+    }
49
+
50
+    public long getTimeStamp() {
51
+        return timeStamp;
52
+    }
53
+
54
+    public void setTimeStamp(long timeStamp) {
55
+        this.timeStamp = timeStamp;
56
+    }
57
+
58
+    public String getDeveloperMessage() {
59
+        return developerMessage;
60
+    }
61
+
62
+    public void setDeveloperMessage(String developerMessage) {
63
+        this.developerMessage = developerMessage;
64
+    }
65
+
66
+    public String getTitle() {
67
+        return title;
68
+    }
69
+
70
+    public void setTitle(String title) {
71
+        this.title = title;
72
+    }
73
+}

+ 23
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/error/ValidationError.java Voir le fichier

@@ -0,0 +1,23 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos.error;
2
+
3
+public class ValidationError {
4
+
5
+    private String code;
6
+    private String message;
7
+
8
+    public String getCode() {
9
+        return code;
10
+    }
11
+
12
+    public void setCode(String code) {
13
+        this.code = code;
14
+    }
15
+
16
+    public String getMessage() {
17
+        return message;
18
+    }
19
+
20
+    public void setMessage(String message) {
21
+        this.message = message;
22
+    }
23
+}

+ 19
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java Voir le fichier

@@ -0,0 +1,19 @@
1
+package io.zipcoder.tc_spring_poll_application.exception;
2
+
3
+import org.springframework.http.HttpStatus;
4
+import org.springframework.web.bind.annotation.ResponseStatus;
5
+
6
+@ResponseStatus(HttpStatus.NOT_FOUND)
7
+public class ResourceNotFoundException extends RuntimeException{
8
+
9
+    public ResourceNotFoundException(){
10
+    }
11
+
12
+    public ResourceNotFoundException(String message) {
13
+        super(message);
14
+    }
15
+
16
+    public ResourceNotFoundException(String message, Throwable cause) {
17
+        super(message, cause);
18
+    }
19
+}

+ 55
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/exception/RestExceptionHandler.java Voir le fichier

@@ -0,0 +1,55 @@
1
+package io.zipcoder.tc_spring_poll_application.exception;
2
+
3
+import io.zipcoder.tc_spring_poll_application.dtos.error.ErrorDetail;
4
+import io.zipcoder.tc_spring_poll_application.dtos.error.ValidationError;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.MessageSource;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.validation.FieldError;
10
+import org.springframework.web.bind.MethodArgumentNotValidException;
11
+import org.springframework.web.bind.annotation.ControllerAdvice;
12
+import org.springframework.web.bind.annotation.ExceptionHandler;
13
+
14
+import javax.servlet.http.HttpServletRequest;
15
+import java.util.ArrayList;
16
+import java.util.Date;
17
+import java.util.List;
18
+
19
+@ControllerAdvice
20
+public class RestExceptionHandler {
21
+
22
+    @Autowired
23
+    MessageSource messageSource;
24
+
25
+    @ExceptionHandler(ResourceNotFoundException.class)
26
+    public ResponseEntity<?> handleResourceNotFoundException(ResourceNotFoundException rnfe, HttpServletRequest request) {
27
+        ErrorDetail errorDetail = new ErrorDetail();
28
+        errorDetail.setTimeStamp(new Date().getTime());
29
+        errorDetail.setDeveloperMessage(rnfe.getMessage());
30
+
31
+        return new ResponseEntity<>(errorDetail, HttpStatus.NOT_FOUND);
32
+    }
33
+
34
+    @ExceptionHandler(MethodArgumentNotValidException.class)
35
+    public ResponseEntity<?> handleValidationError(  MethodArgumentNotValidException manve, HttpServletRequest request) {
36
+        ErrorDetail errorDetail = new ErrorDetail();
37
+        errorDetail.setTimeStamp(new Date().getTime());
38
+        errorDetail.setDeveloperMessage(manve.getMessage());
39
+
40
+        List<FieldError> fieldErrors =  manve.getBindingResult().getFieldErrors();
41
+            for(FieldError fe : fieldErrors) {
42
+
43
+        List<ValidationError> validationErrorList = errorDetail.getErrors().get(fe.getField());
44
+            if(validationErrorList == null) {
45
+                validationErrorList = new ArrayList<>();
46
+                errorDetail.getErrors().put(fe.getField(), validationErrorList);
47
+            }
48
+               ValidationError validationError = new ValidationError();
49
+               validationError.setCode(fe.getCode());
50
+               validationError.setMessage(messageSource.getMessage(fe, null));
51
+               validationErrorList.add(validationError);
52
+            }
53
+        return new ResponseEntity<>(errorDetail, HttpStatus.BAD_REQUEST);
54
+    }
55
+}

+ 8
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java Voir le fichier

@@ -0,0 +1,8 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import org.springframework.data.repository.CrudRepository;
5
+
6
+public interface OptionRepository extends CrudRepository<Poll,Long> {
7
+
8
+}

+ 7
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java Voir le fichier

@@ -0,0 +1,7 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import org.springframework.data.repository.CrudRepository;
5
+
6
+public interface PollRepository extends CrudRepository<Poll,Long> {
7
+}

+ 14
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java Voir le fichier

@@ -0,0 +1,14 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import org.springframework.data.jpa.repository.Query;
5
+import org.springframework.data.repository.CrudRepository;
6
+
7
+public interface VoteRepository extends CrudRepository<Vote,Long> {
8
+
9
+    @Query(value = "SELECT v.* " +
10
+            "FROM Option o, Vote v " +
11
+            "WHERE o.POLL_ID = ?1 " +
12
+            "AND v.OPTION_ID = o.OPTION_ID", nativeQuery = true)
13
+    public Iterable<Vote> findVotesByPoll(Long pollId);
14
+}

+ 23
- 0
src/main/resources/import.sql Voir le fichier

@@ -0,0 +1,23 @@
1
+insert into poll (poll_id, question) values (1, 'What is your favorite color?');
2
+insert into option (option_id, option_value, poll_id) values (1, 'Red', 1);
3
+insert into option (option_id, option_value, poll_id) values (2, 'Blue', 1);
4
+insert into option (option_id, option_value, poll_id) values (3, 'Yellow', 1);
5
+insert into option (option_id, option_value, poll_id) values (4, 'Green', 1);
6
+
7
+insert into poll (poll_id, question) values (2, 'What is your favorite breakfast food?');
8
+insert into option (option_id, option_value, poll_id) values (5, 'Pancake', 2);
9
+insert into option (option_id, option_value, poll_id) values (6, 'Waffles', 2);
10
+insert into option (option_id, option_value, poll_id) values (7, 'Cereal', 2);
11
+insert into option (option_id, option_value, poll_id) values (8, 'Eggs', 2);
12
+
13
+insert into poll (poll_id, question) values (3, 'What is your favorite season?');
14
+insert into option (option_id, option_value, poll_id) values (9, 'Spring', 3);
15
+insert into option (option_id, option_value, poll_id) values (10, 'Summer', 3);
16
+insert into option (option_id, option_value, poll_id) values (11, 'Autumn', 3);
17
+insert into option (option_id, option_value, poll_id) values (12, 'Winter', 3);
18
+
19
+insert into poll (poll_id, question) values (4, 'What is your favorite drink?');
20
+insert into option (option_id, option_value, poll_id) values (13, 'Water', 4);
21
+insert into option (option_id, option_value, poll_id) values (14, 'Soda', 4);
22
+insert into option (option_id, option_value, poll_id) values (15, 'Juice', 4);
23
+insert into option (option_id, option_value, poll_id) values (16, 'Coffee', 4);

+ 0
- 0
src/main/resources/messages.properties Voir le fichier