Mdofiy 관리자페이지 게시글내역 히스토리 볼수 있도록 수정, securityConfig 순환참조 오류 수정

This commit is contained in:
Daeil Choi
2023-02-06 09:47:25 +09:00
parent b5c06cf76f
commit de564ef4fe
15 changed files with 154 additions and 47 deletions

View File

@@ -0,0 +1,29 @@
package com.example.springsecuritystudy.post;
import java.util.List;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.springsecuritystudy.user.User;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
@RequestMapping("/admin")
public class AdminController {
private final PostService postService;
@GetMapping
public String getPostForAdmin(Authentication authentication, Model model) {
User user = (User) authentication.getPrincipal();
List<Post> posts = postService.findByUser(user);
model.addAttribute("posts", posts);
return "admin/index";
}
}