diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c1e2c64 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/src/main/java/com/pixels/HelloServlet.java b/src/main/java/com/pixels/HelloServlet.java deleted file mode 100644 index 42af07d..0000000 --- a/src/main/java/com/pixels/HelloServlet.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.pixels; - -import java.io.IOException; -import java.io.PrintWriter; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet(name = "HelloServlet", urlPatterns = { "hello" }, loadOnStartup = 1) -public class HelloServlet extends HttpServlet { - - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - response.getWriter().print("Hello, World!"); - } - - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - String name = request.getParameter("name"); - if (name == null) - name = "World"; - PrintWriter out = response.getWriter(); - out.println("Hello " + name); - } -} \ No newline at end of file diff --git a/src/main/java/com/pixels/beans/Groupe.java b/src/main/java/com/pixels/beans/Groupe.java index 3aac979..d8b0e2e 100644 --- a/src/main/java/com/pixels/beans/Groupe.java +++ b/src/main/java/com/pixels/beans/Groupe.java @@ -1,8 +1,10 @@ package com.pixels.beans; import javax.persistence.*; +import javax.validation.constraints.NotBlank; import lombok.Data; +import lombok.NonNull; import java.io.Serializable; @@ -16,8 +18,10 @@ public class Groupe implements Serializable { private Long id; // nom du groupe + @NonNull + @NotBlank private String name; @OneToOne // le wallet commun à tous les membres du groupe private Wallet wallet; -} \ No newline at end of file +} diff --git a/src/main/java/com/pixels/beans/Permission.java b/src/main/java/com/pixels/beans/Permission.java index 0185a60..addcea7 100644 --- a/src/main/java/com/pixels/beans/Permission.java +++ b/src/main/java/com/pixels/beans/Permission.java @@ -3,6 +3,7 @@ package com.pixels.beans; import javax.persistence.*; import lombok.Data; +import lombok.NonNull; import java.io.Serializable; @@ -16,5 +17,6 @@ public class Permission implements Serializable { private Long id; // type de la permission - private int type; -} \ No newline at end of file + @NonNull + private Integer type; +} diff --git a/src/main/java/com/pixels/beans/Pixel.java b/src/main/java/com/pixels/beans/Pixel.java index c4db324..94e02d4 100644 --- a/src/main/java/com/pixels/beans/Pixel.java +++ b/src/main/java/com/pixels/beans/Pixel.java @@ -3,6 +3,9 @@ package com.pixels.beans; import javax.persistence.*; import lombok.Data; +import lombok.NonNull; + +import java.awt.Color; import java.io.Serializable; import java.util.List; @@ -17,12 +20,15 @@ public class Pixel implements Serializable { private Long id; // prix du pixel à l'achat - private int price; + @NonNull + private Integer price; // couleur du pixel sur la peinture - private int color; + @NonNull + private Color color; // petit mot écrit par le user + @NonNull private String description; // propriétaire actuel du pixel diff --git a/src/main/java/com/pixels/beans/Role.java b/src/main/java/com/pixels/beans/Role.java index 8ed5b33..97b55f2 100644 --- a/src/main/java/com/pixels/beans/Role.java +++ b/src/main/java/com/pixels/beans/Role.java @@ -3,6 +3,7 @@ package com.pixels.beans; import javax.persistence.*; import lombok.Data; +import lombok.NonNull; import java.io.Serializable; @@ -16,5 +17,6 @@ public class Role implements Serializable { private Long id; // type du role - private int type; -} \ No newline at end of file + @NonNull + private Integer type; +} diff --git a/src/main/java/com/pixels/beans/Transaction.java b/src/main/java/com/pixels/beans/Transaction.java index 94ce72e..eab4a0c 100644 --- a/src/main/java/com/pixels/beans/Transaction.java +++ b/src/main/java/com/pixels/beans/Transaction.java @@ -2,7 +2,10 @@ package com.pixels.beans; import javax.persistence.*; +import java.awt.Color; + import lombok.Data; +import lombok.NonNull; import java.io.Serializable; import java.util.Date; @@ -16,13 +19,16 @@ public class Transaction implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - // prix de la transaction - private int price; + // prix de la transaction* + @NonNull + private Integer price; // couleur du pixel de la transaction - private int color; + @NonNull + private Color color; // date de la transaction + @NonNull private Date time; @ManyToOne // wallet acheteur @@ -30,4 +36,4 @@ public class Transaction implements Serializable { @ManyToOne // pixel acheté private Pixel pixel; -} \ No newline at end of file +} diff --git a/src/main/java/com/pixels/beans/User.java b/src/main/java/com/pixels/beans/User.java index c0fe7a4..40811bf 100644 --- a/src/main/java/com/pixels/beans/User.java +++ b/src/main/java/com/pixels/beans/User.java @@ -1,10 +1,12 @@ package com.pixels.beans; import javax.persistence.*; +import javax.validation.constraints.NotBlank; import com.pixels.utils.Hash; import lombok.Data; +import lombok.NonNull; import java.io.Serializable; import java.util.List; @@ -19,12 +21,18 @@ public class User implements Serializable { private Long id; // nom d'utilisateur + @NonNull + @NotBlank private String userName; // addresse mail de l'utilisateur + @NonNull + @NotBlank private String email; // mot de passe hashé en sha256 + @NonNull + @NotBlank private String hashPassword; @OneToOne // portefeuille diff --git a/src/main/java/com/pixels/beans/Wallet.java b/src/main/java/com/pixels/beans/Wallet.java index 4ccb787..62fedbe 100644 --- a/src/main/java/com/pixels/beans/Wallet.java +++ b/src/main/java/com/pixels/beans/Wallet.java @@ -1,8 +1,10 @@ package com.pixels.beans; import javax.persistence.*; +import javax.validation.constraints.NotBlank; import lombok.Data; +import lombok.NonNull; import java.io.Serializable; import java.util.List; @@ -17,7 +19,9 @@ public class Wallet implements Serializable { private Long id; // solde du wallet - private int balance; + @NonNull + @NotBlank + private Integer balance; @OneToMany(mappedBy = "wallet") // transactions associées au wallet private List transactions; diff --git a/src/main/java/com/pixels/services/PixelService.java b/src/main/java/com/pixels/services/PixelService.java index 3b19b93..52b73e7 100644 --- a/src/main/java/com/pixels/services/PixelService.java +++ b/src/main/java/com/pixels/services/PixelService.java @@ -2,6 +2,8 @@ package com.pixels.services; import java.util.List; +import java.awt.Color; + import javax.ejb.Singleton; import javax.json.Json; import javax.json.JsonObject; @@ -41,11 +43,11 @@ public class PixelService { JsonObjectBuilder response = Json.createObjectBuilder(); - Pixel pixel = new Pixel(); + Pixel pixel = new Pixel(10, new Color(255, 0, 0), "un pixel Poog"); em.persist(pixel); response.add("status", "pixel created !"); return response.build(); } -} \ No newline at end of file +}