Skip to content

Commit

Permalink
Merge branch 'dev' into 698-admin-방-전체-조회-page
Browse files Browse the repository at this point in the history
  • Loading branch information
AreSain authored Mar 7, 2024
2 parents 8fddf4f + acba2df commit 20425ca
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
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();
}
}
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);
}
}
1 change: 1 addition & 0 deletions gg-utils/src/main/java/gg/utils/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public enum ErrorCode {
ROOM_REPORTED_ERROR(404, "PT103", "신고 상태로 접근이 불가능합니다."),
COMMENT_NOT_FOUND(404, "PT104", "존재하지 않는 댓글입니다."),
ROOMSTAT_NOT_FOUND(404, "PT105", "존재하지 않는 방 status입니다."),
TEMPLATE_NOT_FOUND(404, "PT106", "존재하지 않는 템플릿 입니다."),
ROOM_NOT_ENOUGH_PEOPLE(400, "PT201", "시작할 수 있는 인원이 아닙니다."),
USER_NOT_HOST(400, "PT203", "방장이 아닙니다"),
ROOM_SAME_STATUS(400, "PT204", "이미 처리된 방 입니다."),
Expand Down
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);
}
}

0 comments on commit 20425ca

Please sign in to comment.