Explorar el Código

{making progress on through}

Jacqueline Joson hace 5 años
padre
commit
4b33df8cae

+ 4
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java Ver fichero

@@ -0,0 +1,4 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+public class PollController {
4
+}

+ 34
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java Ver fichero

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

+ 44
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java Ver fichero

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

+ 32
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java Ver fichero

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

+ 7
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java Ver fichero

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

+ 7
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java Ver fichero

@@ -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
+}

+ 7
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java Ver fichero

@@ -0,0 +1,7 @@
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.repository.CrudRepository;
5
+
6
+public interface VoteRepository extends CrudRepository<Vote, Long> {
7
+}