-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 698-admin-방-전체-조회-page
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...ng-api/src/main/java/gg/party/api/admin/templates/controller/TemplateAdminController.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,27 @@ | ||
package gg.party.api.admin.templates.controller; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.party.api.admin.templates.service.TemplateAdminService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/party/admin/templates") | ||
public class TemplateAdminController { | ||
private final TemplateAdminService templateAdminService; | ||
|
||
/** | ||
* 템플릿 삭제 | ||
* return 204 status code(성공적인 삭제 status) | ||
*/ | ||
@DeleteMapping("/{templateId}") | ||
public ResponseEntity<Void> removeTemplate(@PathVariable Long templateId) { | ||
templateAdminService.removeTemplate(templateId); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
gg-pingpong-api/src/main/java/gg/party/api/admin/templates/service/TemplateAdminService.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 gg.party.api.admin.templates.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import gg.repo.party.TemplateRepository; | ||
import gg.utils.exception.party.TemplateNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TemplateAdminService { | ||
private final TemplateRepository templateRepository; | ||
|
||
/** | ||
* 템플릿 삭제 | ||
*/ | ||
@Transactional | ||
public void removeTemplate(Long templateId) { | ||
if (!templateRepository.existsById(templateId)) { | ||
throw new TemplateNotFoundException(); | ||
} | ||
templateRepository.deleteById(templateId); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
gg-utils/src/main/java/gg/utils/exception/party/TemplateNotFoundException.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,10 @@ | ||
package gg.utils.exception.party; | ||
|
||
import gg.utils.exception.ErrorCode; | ||
import gg.utils.exception.custom.NotExistException; | ||
|
||
public class TemplateNotFoundException extends NotExistException { | ||
public TemplateNotFoundException() { | ||
super(ErrorCode.TEMPLATE_NOT_FOUND.getMessage(), ErrorCode.TEMPLATE_NOT_FOUND); | ||
} | ||
} |