-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from UMC-WOWMARKET/feat/MyOrderManage-137
[feat] 수요조사 등록폼 수정, 등록폼 receiveAddress 추가, 유저 role 변경
- Loading branch information
Showing
13 changed files
with
172 additions
and
35 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../wowmarket/wow_server/admin/adminAccount/controller/AdminAccountManagementController.java
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,31 @@ | ||
package wowmarket.wow_server.admin.adminAccount.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import wowmarket.wow_server.admin.adminAccount.dto.ChangeRoleRequestDto; | ||
import wowmarket.wow_server.admin.adminAccount.service.AdminAccountManagementService; | ||
import wowmarket.wow_server.domain.User; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/admin") | ||
public class AdminAccountManagementController { | ||
private final AdminAccountManagementService adminAccountManagementService; | ||
|
||
@PutMapping("/role/admin") | ||
public ResponseEntity giveAdminRole(@RequestBody ChangeRoleRequestDto requestDto, @AuthenticationPrincipal User user){ | ||
return adminAccountManagementService.giveAdminRole(requestDto, user); | ||
} | ||
|
||
@PutMapping("/role/user") | ||
public ResponseEntity giveUserRole(@RequestBody ChangeRoleRequestDto requestDto, @AuthenticationPrincipal User user){ | ||
return adminAccountManagementService.giveUserRole(requestDto, user); | ||
} | ||
|
||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/wowmarket/wow_server/admin/adminAccount/dto/ChangeRoleRequestDto.java
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,8 @@ | ||
package wowmarket.wow_server.admin.adminAccount.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ChangeRoleRequestDto { | ||
private String email; | ||
} |
43 changes: 43 additions & 0 deletions
43
...n/java/wowmarket/wow_server/admin/adminAccount/service/AdminAccountManagementService.java
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,43 @@ | ||
package wowmarket.wow_server.admin.adminAccount.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import wowmarket.wow_server.admin.adminAccount.dto.ChangeRoleRequestDto; | ||
import wowmarket.wow_server.domain.Role; | ||
import wowmarket.wow_server.domain.User; | ||
import wowmarket.wow_server.repository.UserRepository; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AdminAccountManagementService { | ||
private final UserRepository userRepository; | ||
|
||
@Transactional | ||
public ResponseEntity giveAdminRole(ChangeRoleRequestDto requestDto, User user){ | ||
// if (!user.getRole().equals("ROLE_ADMIN")){ | ||
// throw new ResponseStatusException(HttpStatus.BAD_REQUEST); | ||
// } 관리자만 변경 가능하도록 (그 전에 admin페이지는 관리자만 접근 가능하도록 설정 필요) | ||
User reqUser = userRepository.findByEmail(requestDto.getEmail()).orElseThrow(()->new IllegalArgumentException("존재하지 않는 email 입니다.")); | ||
Role roleAdmin = Role.ROLE_ADMIN; | ||
reqUser.updateUserRole(roleAdmin); | ||
userRepository.save(reqUser); | ||
|
||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
|
||
@Transactional | ||
public ResponseEntity giveUserRole(ChangeRoleRequestDto requestDto, User user){ | ||
// if (!user.getRole().equals("ROLE_ADMIN")){ | ||
// throw new ResponseStatusException(HttpStatus.BAD_REQUEST); | ||
// } 관리자만 변경 가능하도록 (그 전에 admin페이지는 관리자만 접근 가능하도록 설정 필요) | ||
User reqUser = userRepository.findByEmail(requestDto.getEmail()).orElseThrow(()->new IllegalArgumentException("존재하지 않는 email 입니다.")); | ||
Role roleUser = Role.ROLE_USER; | ||
reqUser.updateUserRole(roleUser); | ||
userRepository.save(reqUser); | ||
|
||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package wowmarket.wow_server.domain; | ||
|
||
import lombok.Builder; | ||
|
||
public enum Role { | ||
ROLE_USER, ROLE_ADMIN; | ||
|
||
} |
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
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
25 changes: 25 additions & 0 deletions
25
...rket/wow_server/mypage/myproject/MyDemandProject/dto/MyDemandProjectModifyRequestDto.java
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,25 @@ | ||
package wowmarket.wow_server.mypage.myproject.MyDemandProject.dto; | ||
|
||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
public class MyDemandProjectModifyRequestDto { | ||
private String projectName; | ||
private String description; | ||
private String sellerName; | ||
private String sellerPhoneNumber; | ||
private String sellerEmail; | ||
private String sellerEtc; | ||
private String thumbnail; | ||
private Long categoryId; | ||
private String image1; | ||
private String image2; | ||
private String image3; | ||
private List<MyDemandItemDto> itemList; | ||
private LocalDateTime startDate; | ||
private LocalDateTime endDate; | ||
|
||
} |
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
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
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
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