Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT/A1] 샘플 데이터 추가 및 회원 상태 정지 구현, html 수정 #70

Merged
merged 62 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1bb385d
admin_list
Romangduck Sep 15, 2023
9c44196
admin_list , detail in Controller -ing
Romangduck Sep 15, 2023
b5e7945
figuring Request
Romangduck Sep 18, 2023
4a61fac
Merge branch 'dev' of https://github.com/donsonioc2010/picasso into f…
Romangduck Sep 18, 2023
8a0c801
feat : temp commit
Romangduck Sep 18, 2023
73cd0a0
Merge branch 'dev' into feat/a1
Romangduck Sep 18, 2023
2e06866
figuring JPA Entity Admin
Romangduck Sep 18, 2023
c02c008
figuring list.html with thymeleaf
Romangduck Sep 18, 2023
c0dfbd2
figuring list controller & list service
Romangduck Sep 19, 2023
e479f1a
Merge branch 'dev' of https://github.com/donsonioc2010/picasso into f…
Romangduck Sep 19, 2023
983d3ba
feat : temp commit
Romangduck Sep 19, 2023
5061d39
git merge dev branch
Romangduck Sep 19, 2023
60b267f
figuring detail controller , service & html with thymeleaf
Romangduck Sep 19, 2023
dad9f8c
figuring Approve
Romangduck Sep 20, 2023
1ecf74c
modify for exception and error
Romangduck Sep 20, 2023
c70d5d7
finished approve , detail and list figuring
Romangduck Sep 20, 2023
23fb718
Merge branch 'dev' into feat/a1
Romangduck Sep 20, 2023
01a7a2f
Merge branch 'dev' into feat/a1
Romangduck Sep 21, 2023
75865a3
Merge branch 'dev' into feat/a1
Romangduck Sep 21, 2023
bfc20b0
dev
Romangduck Sep 21, 2023
7ca061a
feat : 테이블 명 수정에 따른 쿼리 변경
Romangduck Sep 21, 2023
00fbe53
feat : AdminBackEnd완료
donsonioc2010 Sep 21, 2023
2a9a0e0
Add Modified admin's BackEnd file
Romangduck Sep 21, 2023
cf7212a
Add , modify frontEnd css&html
Romangduck Sep 21, 2023
4e2468f
Add list of Admin and etc for using it
Romangduck Sep 21, 2023
8d24fb9
Add Admin Account form & list
Romangduck Sep 22, 2023
d3a8d4e
Merge branch 'dev' into feat/a1
Romangduck Sep 22, 2023
09af3c5
feat: modal, index header, footer 수정 #45
bongsh0112 Sep 22, 2023
4ff7458
Modify html & css, need to revise detail.html&css
Romangduck Sep 22, 2023
54cbd6b
Merge branch 'dev' into feat/a1
Romangduck Sep 22, 2023
25a3d25
Merge branch 'dev' into 45/feat-exchange-ui
donsonioc2010 Sep 22, 2023
7f4fb98
Modify for dependency
Romangduck Sep 22, 2023
1d79536
feat : Login, Join Link 추가
donsonioc2010 Sep 22, 2023
3a180ac
Modify code reviewing
Romangduck Sep 22, 2023
d3ee6dc
안ìì•안쓰는 ì의존설성 정리
Romangduck Sep 22, 2023
87ffa7f
feat : footer 링크 추가 및 Project 정보 추가
donsonioc2010 Sep 23, 2023
76cb8c6
feat : Header수정, 및 Bootstrap파일 변경을 위해서 Bootstrap 직접 static에서 가져오도록 변경…
donsonioc2010 Sep 23, 2023
c5c2c14
Merge branch 'dev' into 45/feat-exchange-ui
donsonioc2010 Sep 23, 2023
c10280b
feat : 관리자 UI작업중
donsonioc2010 Sep 24, 2023
7837f9d
style : footer size 변경
donsonioc2010 Sep 24, 2023
0348871
feat : 로그아웃 li 추가, 로그인시 사용자 닉네임과 포인트 출력 추가
donsonioc2010 Sep 24, 2023
1c13a53
style : UI Header, 관리자 컷
donsonioc2010 Sep 24, 2023
d259fa8
feat : 메인페이지 UI
donsonioc2010 Sep 24, 2023
1bc6541
Merge branch 'dev' into feat/a1
Romangduck Sep 24, 2023
28df991
Modify front_end & admincontroller
Romangduck Sep 24, 2023
694b5ce
Modify Admin HTML
Romangduck Sep 25, 2023
27b44b6
feat : index 누락 태그 추가
donsonioc2010 Sep 25, 2023
bcddef7
Merge branch 'dev' into feat/a1
Romangduck Sep 25, 2023
ea0fd81
Modify & Add
Romangduck Sep 25, 2023
7438371
Modify error from memberlist.html & Start to add pagenation with JPA
Romangduck Sep 25, 2023
6b9cf5d
Merge branch 'dev' of https://github.com/donsonioc2010/picasso into dev
Romangduck Sep 26, 2023
d280177
Merge branch 'feat/a1' into dev
Romangduck Sep 26, 2023
cbc84ae
Add ExamData
Romangduck Sep 26, 2023
e1fff53
Modify Example Data
Romangduck Sep 26, 2023
b0fff07
Merge branch 'dev' of https://github.com/donsonioc2010/picasso into dev
Romangduck Sep 26, 2023
d3428ac
Merge branch 'feat/a1' into dev
Romangduck Sep 26, 2023
ec3daa4
Try to resolve conflicts
Romangduck Sep 26, 2023
da2c6ad
Merge branch 'dev' into feat/a1
Romangduck Sep 26, 2023
7d0acc5
Modify error
Romangduck Sep 26, 2023
9f94884
Merge branch 'feat/a1' of https://github.com/donsonioc2010/picasso in…
Romangduck Sep 26, 2023
f98de4f
Merge branch 'dev' into feat/a1
Romangduck Sep 26, 2023
769ffde
Merge branch 'dev' into feat/a1
donsonioc2010 Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import picasso.server.api.admin.exception.NotAdminUserException;
import picasso.server.api.admin.service.AdminService;
import picasso.server.api.user.vo.request.SignUpAdminRequestDto;
import picasso.server.api.admin.request.SignUpAdminRequestDto;
import picasso.server.domain.domains.user.entity.User;
import picasso.server.domain.domains.user.repository.UserRepository;
import picasso.server.domain.domains.user.type.UserRole;

import java.util.List;

import static java.time.LocalDateTime.now;


@Controller
Expand All @@ -34,7 +28,7 @@ public class AdminController {
public String approvePicture(@PathVariable Long pictureId, HttpSession session) {
isSessionUserAdmin(session);
adminService.approvePicture(pictureId);
return "redirect:/admin/list";
return "redirect:/admin/approvelist";
}

/**
Expand All @@ -45,11 +39,11 @@ public String approvePicture(@PathVariable Long pictureId, HttpSession session)
* @return
*/

@GetMapping("/list")
public String list(Model model, HttpSession session) {
@GetMapping("/approvelist")
public String approvelist(Model model, HttpSession session) {
isSessionUserAdmin(session);
model.addAttribute("pictures", adminService.findAll());
return "admin/list";
model.addAttribute("pictures", adminService.findAllPicture());
return "admin/approvelist";
}

/**
Expand All @@ -71,10 +65,6 @@ public String detail(@PathVariable Long pictureId, Model model, HttpSession sess
}


/**
* Session에 현재 로그인된 사용자가 관리자인지를 판단한다.
* @param session
*/
private void isSessionUserAdmin(HttpSession session) {
User user = (User) session.getAttribute("loginUser");
if (user == null || !user.getUserRole().equals(UserRole.ADMIN)) {
Expand All @@ -86,7 +76,7 @@ private void isSessionUserAdmin(HttpSession session) {

@GetMapping("/form")
public String AdminForm(HttpSession session) {
// isSessionUserAdmin(session);
isSessionUserAdmin(session);
return "admin/form";
}

Expand All @@ -99,36 +89,51 @@ public String AdminForm(HttpSession session) {
*/
@PostMapping("/form")
public String addAdmin(SignUpAdminRequestDto dto, HttpSession session) {
// isSessionUserAdmin(session);
isSessionUserAdmin(session);
User user = User.builder()
.email(dto.getEmail())
.password(dto.getPassword())
.nickName(dto.getNickName())
.userRole(UserRole.ADMIN)
.updatedAt(now())
.createdAt(now())
.loginAt(now())
.profile("https://www.example.com/default-profile-image.jpg")
.build();

userRepository.save(user);

return "auth/login";
}

/**
* 관리자 계정 조회
*
* @param model
* @param session
* @param userRole
* @return
*/


@GetMapping("/user/list")
public String AdminList(HttpSession session, Model model) {
public String adminUserList(@RequestParam(name = "userRole", defaultValue = "ADMIN") String userRole, HttpSession session, Model model) {
isSessionUserAdmin(session);
List<User> adminUsers = adminService.findAllAdmin();
model.addAttribute("users", adminUsers);

if ("ADMIN".equals(userRole)) {
model.addAttribute("users", adminService.findAllAdmin());
} else if ("USER".equals(userRole)) {
model.addAttribute("users", adminService.findAllUser());
}

return "admin/memberList";
}
}


@PostMapping("/suspend/{userId}")

public String suspendUser(@PathVariable Long userId, HttpSession session) {
isSessionUserAdmin(session);
adminService.suspendUser(userId);
return "redirect:/admin/user/list?status=USER";


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package picasso.server.api.admin.exception;

import picasso.server.common.exception.BaseException;

import java.io.NotActiveException;

import static picasso.server.common.exception.GlobalException.USER_STATUS_NOT_ACTIVE;

public class NotActiveStatusException extends BaseException {
public static final BaseException EXCEPTION = new NotActiveStatusException();
private NotActiveStatusException() {super (USER_STATUS_NOT_ACTIVE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package picasso.server.api.admin.exception;

import picasso.server.common.exception.BaseException;

import static picasso.server.common.exception.GlobalException.NOT_FOUND_USER_ERROR;

public class NotFoundUserException extends BaseException {
public static final BaseException EXCEPTION = new NotFoundUserException();

public NotFoundUserException() { super(NOT_FOUND_USER_ERROR);}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package picasso.server.api.user.vo.request;
package picasso.server.api.admin.request;

import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import picasso.server.api.admin.exception.AlreadyChangePictureException;
import picasso.server.api.admin.exception.NotActiveStatusException;
import picasso.server.api.admin.exception.NotFoundUserException;
import picasso.server.api.mail.service.SendMailService;
import picasso.server.common.exception.NotFoundException;
import picasso.server.domain.domains.picture.items.Picture;
Expand All @@ -18,6 +20,8 @@

import static picasso.server.domain.domains.picture.items.PictureStatus.AFTER_APPROVE;
import static picasso.server.domain.domains.picture.items.PictureStatus.BEFORE_APPROVE;
import static picasso.server.domain.domains.user.type.UserStatus.ACTIVE;
import static picasso.server.domain.domains.user.type.UserStatus.SUSPENSION;

@Slf4j
@Service
Expand All @@ -30,7 +34,7 @@ public class AdminService {

// TODO : 추후 Pagenation으로의 수정 필요함.
@Transactional(readOnly = true)
public List<Picture> findAll() {
public List<Picture> findAllPicture() {
return pictureRepository.findAll();
}

Expand All @@ -47,6 +51,7 @@ public Picture getBeforeApproveStatusPictureDetailById(Long id) {

/**
* 관리자 승인전의 게시물을 관리자 승인 상태로 변경 하는 기능
*
* @param pictureId
*/
public void approvePicture(Long pictureId) {
Expand All @@ -69,11 +74,39 @@ public void approvePicture(Long pictureId) {
throw NotFoundException.EXCEPTION;
}


@Transactional(readOnly = true)
public List<User> findAllAdmin() {
return userRepository.findByUserRole(UserRole.ADMIN);
}
@Transactional(readOnly = true)
public List<User> findAllUser() {
return userRepository.findByUserRole(UserRole.USER);
}

/**
* 관리자가 멤버의 상태를 정지로 변환시킬 수 있는 기능
*
* @param userId
*/
public void suspendUser(Long userId) {
Optional<User> optionalUser = userRepository.findById(userId);
if (optionalUser.isPresent()) {
User user = optionalUser.get();
if (user.getUserStatus().equals(ACTIVE)) {
user.setUserStatus(SUSPENSION);
userRepository.save(user);
log.info("SuspendUser Success >>> User ID : {}, Title : {}",
user.getId(), user.getEmail());
return;

} log.warn("SuspendUser Failure >>> User Id : {}, Title : {}",
user.getId(), user.getEmail());
throw NotActiveStatusException.EXCEPTION;
}
throw NotFoundUserException.EXCEPTION;
}


}


Expand Down
7 changes: 7 additions & 0 deletions Api/src/main/resources/static/css/adminform.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ body {
margin: 20px;
}



h2 {
color: #333;
}
Expand All @@ -29,13 +31,18 @@ input {
}

button {
display: block;
margin: 20px auto;
padding: 10px 20px;
font-size: 18px;
padding: 10px 20px;
background-color: #3498db;
border: none;
color: white;
cursor: pointer;
}


button:hover {
background-color: #2980b9;
}
3 changes: 2 additions & 1 deletion Api/src/main/resources/static/css/adminlist.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ div.admin-title-row{

form>div.row {
margin-bottom: 5px;
}
}

11 changes: 11 additions & 0 deletions Api/src/main/resources/static/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ swiper-slide.no-pictures{
align-items: center;
}

swiper-slide.no-pictures{
width:936px;
height:600px;
text-align: center;
font-size: 18px;
background: #fff;
display: flex;
justify-content: center;
align-items: center;
}

swiper-slide div.box {
width: 100%;
height: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h1>관리자 대쉬보드</h1>
<td th:text="${picture.pictureStatus}"></td>
<td>
<form th:action="@{'/admin/approve/' + ${picture.pictureId}}" method="post">
<button type="submit">Approve</button>
<button type="submit" class="btn btn-success" >Approve</button>
</form>
</td>
</tr>
Expand Down
Loading
Loading