From 6fc1d04a1d2e112464347b5c856e9f34274f8326 Mon Sep 17 00:00:00 2001 From: srh-golubski Date: Mon, 16 May 2022 20:12:09 -0500 Subject: [PATCH 1/4] Finished work on Thymeleaf Studio --- .../spaday/controllers/SpaDayController.java | 8 +++++ src/main/resources/templates/menu.html | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/org/launchcode/spaday/controllers/SpaDayController.java b/src/main/java/org/launchcode/spaday/controllers/SpaDayController.java index a30c8add..35721d7e 100644 --- a/src/main/java/org/launchcode/spaday/controllers/SpaDayController.java +++ b/src/main/java/org/launchcode/spaday/controllers/SpaDayController.java @@ -22,6 +22,8 @@ else if (skinType.equals("dry")) { else { return true; } + + } @GetMapping(value="") @@ -41,6 +43,7 @@ public String customerForm () { "
" + "" + ""; @@ -63,6 +66,11 @@ public String spaMenu(@RequestParam String name, @RequestParam String skintype, } } + model.addAttribute("name", name); + model.addAttribute("skintype", skintype); + model.addAttribute("manipedi", manipedi); + model.addAttribute("appropriateFacials", appropriateFacials); + return "menu"; } } diff --git a/src/main/resources/templates/menu.html b/src/main/resources/templates/menu.html index b94b513f..fcee65a4 100644 --- a/src/main/resources/templates/menu.html +++ b/src/main/resources/templates/menu.html @@ -8,8 +8,41 @@

My Super Fancy Spa

+

My Profile

+

+

+

+
+

Facial Treatments

+

The facial treatments below are recommended by our estheticians for your given skin type

+ + + + + + + +
+
+ +

Manicure

+

+
+ + +

Pedicure

+

+
+ + +

Manicure and Pedicure

+

+

+
+
+
\ No newline at end of file From 43c290425c3d54e6a99488da07d8aa29a92accb7 Mon Sep 17 00:00:00 2001 From: srh-golubski Date: Mon, 23 May 2022 22:20:25 -0500 Subject: [PATCH 2/4] Finished work on Spa Day User Signup Studio --- .../spaday/controllers/UserController.java | 30 +++++++ .../org/launchcode/spaday/models/Client.java | 82 +++++++++++++++++++ .../org/launchcode/spaday/models/User.java | 38 +++++++++ .../resources/templates/serviceSelection.html | 30 +++++++ src/main/resources/templates/user/add.html | 27 ++++++ src/main/resources/templates/user/index.html | 11 +++ 6 files changed, 218 insertions(+) create mode 100644 src/main/java/org/launchcode/spaday/controllers/UserController.java create mode 100644 src/main/java/org/launchcode/spaday/models/Client.java create mode 100644 src/main/java/org/launchcode/spaday/models/User.java create mode 100644 src/main/resources/templates/serviceSelection.html create mode 100644 src/main/resources/templates/user/add.html create mode 100644 src/main/resources/templates/user/index.html diff --git a/src/main/java/org/launchcode/spaday/controllers/UserController.java b/src/main/java/org/launchcode/spaday/controllers/UserController.java new file mode 100644 index 00000000..b082adc5 --- /dev/null +++ b/src/main/java/org/launchcode/spaday/controllers/UserController.java @@ -0,0 +1,30 @@ +package org.launchcode.spaday.controllers; + +import org.launchcode.spaday.models.User; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("user") +public class UserController { + + @GetMapping("add") + public String displayAddUserForm () { + return "user/add"; + } + + @PostMapping("add") + public String processAddUserForm(Model model, @ModelAttribute User user, String verify) { + model.addAttribute("user", user); + if (!user.getPassword().equals(verify)) { + model.addAttribute("error", "Passwords do not match!"); + return "user/add"; + } + + return "user/index"; + } +} diff --git a/src/main/java/org/launchcode/spaday/models/Client.java b/src/main/java/org/launchcode/spaday/models/Client.java new file mode 100644 index 00000000..e0d64bdd --- /dev/null +++ b/src/main/java/org/launchcode/spaday/models/Client.java @@ -0,0 +1,82 @@ +package org.launchcode.spaday.models; + +import java.util.ArrayList; + +public class Client { + + private String skinType; + private String nailService; + private ArrayList appropriateFacials = new ArrayList<>(); + + public Client(String skinType, String nailService) { + this.skinType = skinType; + this.nailService = nailService; + } + + public String getSkinType() { + return skinType; + } + + public void setSkinType(String skinType) { + this.skinType = skinType; + } + + public String getNailService() { + return nailService; + } + + public void setNailService(String nailService) { + this.nailService = nailService; + } + + public ArrayList getAppropriateFacials() { + return appropriateFacials; + } + + private boolean checkSkinType(String skinType, String facialType) { + if (skinType.equals("oily")) { + if (facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating")) { + return true; + } + else { + return false; + } + } + else if (skinType.equals("combination")) { + if (facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating") || facialType.equals("Enzyme Peel")) { + return true; + } + else { + return false; + } + } + else if (skinType.equals("normal")) { + return true; + } + else if (skinType.equals("dry")) { + if (facialType.equals("Rejuvenating") || facialType.equals("Hydrofacial")) { + return true; + } + else { + return false; + } + } + else { + return true; + } + } + + public void setAppropriateFacials(String skinType) { + ArrayList facials = new ArrayList(); + facials.add("Microdermabrasion"); + facials.add("Hydrofacial"); + facials.add("Rejuvenating"); + facials.add("Enzyme Peel"); + + for (int i = 0; i < facials.size(); i ++) { + if (checkSkinType(skinType,facials.get(i))) { + appropriateFacials.add(facials.get(i)); + } + } + } +} diff --git a/src/main/java/org/launchcode/spaday/models/User.java b/src/main/java/org/launchcode/spaday/models/User.java new file mode 100644 index 00000000..96b86eb0 --- /dev/null +++ b/src/main/java/org/launchcode/spaday/models/User.java @@ -0,0 +1,38 @@ +package org.launchcode.spaday.models; + +public class User { + + private String username; + private String email; + private String password; + + public User(String username, String email, String password) { + this.username = username; + this.email = email; + this.password = password; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/main/resources/templates/serviceSelection.html b/src/main/resources/templates/serviceSelection.html new file mode 100644 index 00000000..7bdea3e7 --- /dev/null +++ b/src/main/resources/templates/serviceSelection.html @@ -0,0 +1,30 @@ + + + + + Select Your Spa Services + + + +
+ + + + +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/user/add.html b/src/main/resources/templates/user/add.html new file mode 100644 index 00000000..0f5cafb4 --- /dev/null +++ b/src/main/resources/templates/user/add.html @@ -0,0 +1,27 @@ + + + + + Title + + + +
+ + + + + +
+ +

+ + \ No newline at end of file diff --git a/src/main/resources/templates/user/index.html b/src/main/resources/templates/user/index.html new file mode 100644 index 00000000..c100b515 --- /dev/null +++ b/src/main/resources/templates/user/index.html @@ -0,0 +1,11 @@ + + + + + Title + + +

+Return to Service Selection + + \ No newline at end of file From 4246659aef9088f2367d8c3f50fadacc14bc8846 Mon Sep 17 00:00:00 2001 From: srh-golubski <98133855+srh-golubski@users.noreply.github.com> Date: Tue, 13 Sep 2022 12:05:31 -0500 Subject: [PATCH 3/4] Create README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..20b5d23d --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# spa-day-starter-code + +After all of the hard work we have put into learning about Thymeleaf, it is time for a spa day! First, we need to put our knowledge of Thymeleaf to the test. Instead of heading out to our favorite spa, let’s make an application for the owners! + +Our application needs to do the following: + +Display the user’s name and skin type under their customer profile. +Display the appropriate facial treatments for their skin type. +Display the description of the spa’s manicures or pedicures depending on the user’s interest. +As always, read through the whole page before starting to code. + From 141c8f0ed48bdda0ab19c67689bff15e303c2ac1 Mon Sep 17 00:00:00 2001 From: srh-golubski <98133855+srh-golubski@users.noreply.github.com> Date: Tue, 13 Sep 2022 12:07:00 -0500 Subject: [PATCH 4/4] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 20b5d23d..930522a5 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,13 @@ Display the appropriate facial treatments for their skin type. Display the description of the spa’s manicures or pedicures depending on the user’s interest. As always, read through the whole page before starting to code. +-------- + +For this studio you will add functionality to allow users to sign up for your spa-day app. + +The starter code has been modified from where you left off last class. Grab the refactored code on the user-signup-starter branch. + +You’ll notice in this branch that the name field has been removed from the service selection form. Once we implement user-signup functionality, we can use a given user’s name to identify the spa client. We’ve also moved data into a Client model and out of the SpaDayController class. + +In this studio, we’ll ask you to write another model, User. User and Client may at first appear redundant, but in the future as you develop your spa application, you may find a scenario where a user is logging in who is not also Client. +