-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package umc.forgrad.controller; | ||
|
||
import umc.forgrad.domain.common.Free; | ||
import umc.forgrad.service.FreeService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
import java.util.List; | ||
|
||
@Controller | ||
public class FreeController { | ||
|
||
private final FreeService freeService; | ||
|
||
@Autowired | ||
public FreeController(FreeService freeService) { | ||
this.freeService = freeService; | ||
} | ||
|
||
@PostMapping(value = "/plans/memo") | ||
public String create(FreeFrom form) { | ||
|
||
Free free = new Free(); | ||
free.setMemo(form.getMemo()); | ||
|
||
freeService.addMemo(free); | ||
|
||
return "redirect:/"; | ||
} | ||
|
||
@GetMapping(value = "/plans/memo") | ||
public String list(Model model) { | ||
List<Free> memos = memoService.findMemos(); | ||
model.addAttribute("memos", memos); | ||
return "memos/memoList"; //resources/templates/memos/memoList.html | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package umc.forgrad.controller; | ||
|
||
public class FreeForm { | ||
private String name; | ||
public String getMemo() { | ||
return memo; | ||
} | ||
public void setMemo(String memo) { | ||
this.memo = memo; | ||
} | ||
} |