Skip to content

Commit

Permalink
회원 조회 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoochanhong committed Mar 20, 2023
1 parent adeaeab commit 4cb481e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import com.example.MemberManagementExample.service.MemberService;
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 MemberController {

Expand All @@ -18,17 +21,25 @@ public MemberController(MemberService memberService) {
}

@GetMapping("/members/new")
public String createForm(){
public String createForm() {
return "members/createMembersForm";
}

@PostMapping("/members/new")
public String caeate(MemberForm memberForm) {
public String create(MemberForm memberForm) {
Member member = new Member();
member.setName(memberForm.getName());

memberService.join(member);
return "redirect:/";
}


@GetMapping("/members")
public String list(Model model) {
List<Member> members = memberService.findMembers();
model.addAttribute("members", members);
return "members/memberList";
}

}

0 comments on commit 4cb481e

Please sign in to comment.