1 | package edu.gjoko.schedlr.controllers;
|
---|
2 |
|
---|
3 | import edu.gjoko.schedlr.entity.Stakeholder;
|
---|
4 | import edu.gjoko.schedlr.services.StakeholderService;
|
---|
5 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
6 | import org.springframework.http.MediaType;
|
---|
7 | import org.springframework.stereotype.Controller;
|
---|
8 | import org.springframework.ui.Model;
|
---|
9 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
10 | import org.springframework.web.bind.annotation.ModelAttribute;
|
---|
11 | import org.springframework.web.bind.annotation.PostMapping;
|
---|
12 |
|
---|
13 | @Controller
|
---|
14 | public class RegisterController {
|
---|
15 |
|
---|
16 | private final StakeholderService stakeholderService;
|
---|
17 |
|
---|
18 | public RegisterController(StakeholderService stakeholderService) {
|
---|
19 | this.stakeholderService = stakeholderService;
|
---|
20 | }
|
---|
21 |
|
---|
22 | @GetMapping(path ="/register_customer")
|
---|
23 | public String getCustomerRegisterPage(Model model) {
|
---|
24 | model.addAttribute("stakeholder", new Stakeholder());
|
---|
25 | return "register_customer";
|
---|
26 | }
|
---|
27 |
|
---|
28 | @PostMapping(path = "/register_customer")
|
---|
29 | public String registerCustomer(@ModelAttribute Stakeholder customer, Model model) {
|
---|
30 | Stakeholder user = stakeholderService.saveStakeholder(customer);
|
---|
31 | return "redirect:login";
|
---|
32 | }
|
---|
33 |
|
---|
34 | @GetMapping(path = "/register_business")
|
---|
35 | public String getBusinessRegisterPage(Model model) {
|
---|
36 | return "register_business";
|
---|
37 | }
|
---|
38 |
|
---|
39 | @PostMapping(value = "/register_business")
|
---|
40 | public String registerBusiness(Model model) {
|
---|
41 | return "redirect:login";
|
---|
42 | }
|
---|
43 | }
|
---|