feat: 들여쓰기
This commit is contained in:
@@ -15,68 +15,68 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping({"/api/animals", "/v1/api/animals"})
|
||||
public class AnimalApiController {
|
||||
|
||||
private final AnimalService animalService;
|
||||
private final AnimalService animalService;
|
||||
|
||||
/**
|
||||
* 동물 생성
|
||||
*
|
||||
* @param req 동물 생성 요청
|
||||
* @return 생성된 동물 정보
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<AnimalDto.Basic> createAnimal(@RequestBody AnimalDto.AddReq req) {
|
||||
AnimalDto.Basic created = animalService.createAnimal(req);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
/**
|
||||
* 동물 생성
|
||||
*
|
||||
* @param req 동물 생성 요청
|
||||
* @return 생성된 동물 정보
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<AnimalDto.Basic> createAnimal(@RequestBody AnimalDto.AddReq req) {
|
||||
AnimalDto.Basic created = animalService.createAnimal(req);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
/**
|
||||
* UUID로 동물 조회
|
||||
*
|
||||
* @param uuid 동물 UUID
|
||||
* @return 동물 정보
|
||||
*/
|
||||
@GetMapping("/{uuid}")
|
||||
public ResponseEntity<AnimalDto.Basic> getAnimal(@PathVariable String uuid) {
|
||||
Long id = animalService.getAnimalByUuid(uuid);
|
||||
AnimalDto.Basic animal = animalService.getAnimal(id);
|
||||
return ResponseEntity.ok(animal);
|
||||
}
|
||||
/**
|
||||
* UUID로 동물 조회
|
||||
*
|
||||
* @param uuid 동물 UUID
|
||||
* @return 동물 정보
|
||||
*/
|
||||
@GetMapping("/{uuid}")
|
||||
public ResponseEntity<AnimalDto.Basic> getAnimal(@PathVariable String uuid) {
|
||||
Long id = animalService.getAnimalByUuid(uuid);
|
||||
AnimalDto.Basic animal = animalService.getAnimal(id);
|
||||
return ResponseEntity.ok(animal);
|
||||
}
|
||||
|
||||
/**
|
||||
* UUID로 동물 삭제 (논리 삭제)
|
||||
*
|
||||
* @param uuid 동물 UUID
|
||||
* @return 삭제 성공 메시지
|
||||
*/
|
||||
@DeleteMapping("/{uuid}")
|
||||
public ResponseEntity<Void> deleteAnimal(@PathVariable String uuid) {
|
||||
Long id = animalService.getAnimalByUuid(uuid);
|
||||
animalService.deleteZoo(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
/**
|
||||
* UUID로 동물 삭제 (논리 삭제)
|
||||
*
|
||||
* @param uuid 동물 UUID
|
||||
* @return 삭제 성공 메시지
|
||||
*/
|
||||
@DeleteMapping("/{uuid}")
|
||||
public ResponseEntity<Void> deleteAnimal(@PathVariable String uuid) {
|
||||
Long id = animalService.getAnimalByUuid(uuid);
|
||||
animalService.deleteZoo(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 동물 검색 (페이징)
|
||||
*
|
||||
* @param name 동물 이름 (선택)
|
||||
* @param category 서식지 타입 (선택)
|
||||
* @param species 동물종 (선택) 개, 고양이등.
|
||||
* @param page 페이지 번호 (기본값: 0)
|
||||
* @param size 페이지 크기 (기본값: 20)
|
||||
* @param sort 정렬 조건 (예: "name,asc")
|
||||
* @return 페이징 처리된 동물 목록
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<Page<AnimalDto.Basic>> searchAnimals(
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) Category category,
|
||||
@RequestParam(required = false) Species species,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@RequestParam(required = false) String sort) {
|
||||
AnimalDto.SearchReq searchReq =
|
||||
new AnimalDto.SearchReq(name, category, species, page, size, sort);
|
||||
Page<AnimalDto.Basic> animals = animalService.search(searchReq);
|
||||
return ResponseEntity.ok(animals);
|
||||
}
|
||||
/**
|
||||
* 동물 검색 (페이징)
|
||||
*
|
||||
* @param name 동물 이름 (선택)
|
||||
* @param category 서식지 타입 (선택)
|
||||
* @param species 동물종 (선택) 개, 고양이등.
|
||||
* @param page 페이지 번호 (기본값: 0)
|
||||
* @param size 페이지 크기 (기본값: 20)
|
||||
* @param sort 정렬 조건 (예: "name,asc")
|
||||
* @return 페이징 처리된 동물 목록
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<Page<AnimalDto.Basic>> searchAnimals(
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) Category category,
|
||||
@RequestParam(required = false) Species species,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@RequestParam(required = false) String sort) {
|
||||
AnimalDto.SearchReq searchReq =
|
||||
new AnimalDto.SearchReq(name, category, species, page, size, sort);
|
||||
Page<AnimalDto.Basic> animals = animalService.search(searchReq);
|
||||
return ResponseEntity.ok(animals);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,20 +56,20 @@ public class ZooApiController {
|
||||
/**
|
||||
* 동물원 검색 (페이징)
|
||||
*
|
||||
* @param name 동물원 이름 (선택)
|
||||
* @param name 동물원 이름 (선택)
|
||||
* @param location 위치 (선택)
|
||||
* @param page 페이지 번호 (기본값: 0)
|
||||
* @param size 페이지 크기 (기본값: 20)
|
||||
* @param sort 정렬 조건 (예: "name,asc")
|
||||
* @param page 페이지 번호 (기본값: 0)
|
||||
* @param size 페이지 크기 (기본값: 20)
|
||||
* @param sort 정렬 조건 (예: "name,asc")
|
||||
* @return 페이징 처리된 동물원 목록 (각 동물원의 현재 동물 개수 포함)
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<Page<ZooDto.Detail>> searchZoos(
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String location,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@RequestParam(required = false) String sort) {
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String location,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@RequestParam(required = false) String sort) {
|
||||
ZooDto.SearchReq searchReq = new ZooDto.SearchReq(name, location, page, size, sort);
|
||||
Page<ZooDto.Detail> zoos = zooService.search(searchReq);
|
||||
return ResponseEntity.ok(zoos);
|
||||
|
||||
@@ -29,33 +29,32 @@ public class AnimalDto {
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
@JsonIgnore
|
||||
private Long id;
|
||||
@JsonIgnore private Long id;
|
||||
private String uuid;
|
||||
private Category category;
|
||||
private Species species;
|
||||
private String name;
|
||||
|
||||
@JsonFormat(
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
private ZonedDateTime createdDate;
|
||||
|
||||
@JsonFormat(
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
private ZonedDateTime modifiedDate;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
String uuid,
|
||||
String name,
|
||||
Category category,
|
||||
Species species,
|
||||
ZonedDateTime createdDate,
|
||||
ZonedDateTime modifiedDate) {
|
||||
Long id,
|
||||
String uuid,
|
||||
String name,
|
||||
Category category,
|
||||
Species species,
|
||||
ZonedDateTime createdDate,
|
||||
ZonedDateTime modifiedDate) {
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
@@ -70,16 +69,16 @@ public class AnimalDto {
|
||||
@AllArgsConstructor
|
||||
public enum Category implements EnumType {
|
||||
// @formatter:off
|
||||
MAMMALS("100", "포유류"), // 땅에 사는 동물
|
||||
BIRDS("200", "조류"), // 하늘을 나는 동물
|
||||
FISH("300", "어류"),
|
||||
AMPHIBIANS("400", "양서류"),
|
||||
REPTILES("500", "파충류"),
|
||||
INSECTS("500", "곤충"),
|
||||
INVERTEBRATES("500", "무척추동물"),
|
||||
;
|
||||
// @formatter:on
|
||||
private final String id;
|
||||
MAMMALS("100", "포유류"), // 땅에 사는 동물
|
||||
BIRDS("200", "조류"), // 하늘을 나는 동물
|
||||
FISH("300", "어류"),
|
||||
AMPHIBIANS("400", "양서류"),
|
||||
REPTILES("500", "파충류"),
|
||||
INSECTS("500", "곤충"),
|
||||
INVERTEBRATES("500", "무척추동물"),
|
||||
;
|
||||
// @formatter:on
|
||||
private final String id;
|
||||
private final String text;
|
||||
}
|
||||
|
||||
@@ -87,15 +86,15 @@ public class AnimalDto {
|
||||
@AllArgsConstructor
|
||||
public enum Species implements EnumType {
|
||||
// @formatter:off
|
||||
DOG("101", "개"),
|
||||
CAT("102", "강아지"),
|
||||
DOVE("201", "비둘기"),
|
||||
EAGLE("202", "독수리"),
|
||||
SALMON("301", "연어"),
|
||||
TUNA("302", "참치"),
|
||||
;
|
||||
// @formatter:on
|
||||
private final String id;
|
||||
DOG("101", "개"),
|
||||
CAT("102", "강아지"),
|
||||
DOVE("201", "비둘기"),
|
||||
EAGLE("202", "독수리"),
|
||||
SALMON("301", "연어"),
|
||||
TUNA("302", "참치"),
|
||||
;
|
||||
// @formatter:on
|
||||
private final String id;
|
||||
private final String text;
|
||||
}
|
||||
|
||||
@@ -120,9 +119,7 @@ public class AnimalDto {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1
|
||||
? Sort.Direction.fromString(sortParams[1])
|
||||
: Sort.Direction.ASC;
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
|
||||
@@ -27,33 +27,32 @@ public class ZooDto {
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
@JsonIgnore
|
||||
private Long id;
|
||||
@JsonIgnore private Long id;
|
||||
private String uuid;
|
||||
private String name;
|
||||
private String location;
|
||||
private String description;
|
||||
|
||||
@JsonFormat(
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
private ZonedDateTime createdDate;
|
||||
|
||||
@JsonFormat(
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
shape = JsonFormat.Shape.STRING,
|
||||
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
|
||||
timezone = "Asia/Seoul")
|
||||
private ZonedDateTime modifiedDate;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
String uuid,
|
||||
String name,
|
||||
String location,
|
||||
String description,
|
||||
ZonedDateTime createdDate,
|
||||
ZonedDateTime modifiedDate) {
|
||||
Long id,
|
||||
String uuid,
|
||||
String name,
|
||||
String location,
|
||||
String description,
|
||||
ZonedDateTime createdDate,
|
||||
ZonedDateTime modifiedDate) {
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
@@ -70,14 +69,14 @@ public class ZooDto {
|
||||
private Long activeAnimalCount;
|
||||
|
||||
public Detail(
|
||||
Long id,
|
||||
String uuid,
|
||||
String name,
|
||||
String location,
|
||||
String description,
|
||||
ZonedDateTime createdDate,
|
||||
ZonedDateTime modifiedDate,
|
||||
Long activeAnimalCount) {
|
||||
Long id,
|
||||
String uuid,
|
||||
String name,
|
||||
String location,
|
||||
String description,
|
||||
ZonedDateTime createdDate,
|
||||
ZonedDateTime modifiedDate,
|
||||
Long activeAnimalCount) {
|
||||
super(id, uuid, name, location, description, createdDate, modifiedDate);
|
||||
this.activeAnimalCount = activeAnimalCount;
|
||||
}
|
||||
@@ -103,9 +102,7 @@ public class ZooDto {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1
|
||||
? Sort.Direction.fromString(sortParams[1])
|
||||
: Sort.Direction.ASC;
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
|
||||
@@ -11,51 +11,52 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class ZooService {
|
||||
private final ZooCoreService zooCoreService;
|
||||
|
||||
// 동물원의 UUID로 id조회
|
||||
public Long getZooByUuid(String uuid) {
|
||||
return zooCoreService.getDataByUuid(uuid).getId();
|
||||
}
|
||||
private final ZooCoreService zooCoreService;
|
||||
|
||||
/**
|
||||
* 동물원 생성
|
||||
*
|
||||
* @param req 동물원 생성 요청
|
||||
* @return 생성된 동물원 정보 (동물 개수 포함)
|
||||
*/
|
||||
@Transactional
|
||||
public ZooDto.Detail createZoo(ZooDto.AddReq req) {
|
||||
return zooCoreService.create(req);
|
||||
}
|
||||
// 동물원의 UUID로 id조회
|
||||
public Long getZooByUuid(String uuid) {
|
||||
return zooCoreService.getDataByUuid(uuid).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 동물원 삭제 (논리 삭제)
|
||||
*
|
||||
* @param id 동물원 ID
|
||||
*/
|
||||
@Transactional
|
||||
public void deleteZoo(Long id) {
|
||||
zooCoreService.remove(id);
|
||||
}
|
||||
/**
|
||||
* 동물원 생성
|
||||
*
|
||||
* @param req 동물원 생성 요청
|
||||
* @return 생성된 동물원 정보 (동물 개수 포함)
|
||||
*/
|
||||
@Transactional
|
||||
public ZooDto.Detail createZoo(ZooDto.AddReq req) {
|
||||
return zooCoreService.create(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 동물원 단건 조회
|
||||
*
|
||||
* @param id 동물원 ID
|
||||
* @return 동물원 정보 (동물 개수 포함)
|
||||
*/
|
||||
public ZooDto.Detail getZoo(Long id) {
|
||||
return zooCoreService.getOneById(id);
|
||||
}
|
||||
/**
|
||||
* 동물원 삭제 (논리 삭제)
|
||||
*
|
||||
* @param id 동물원 ID
|
||||
*/
|
||||
@Transactional
|
||||
public void deleteZoo(Long id) {
|
||||
zooCoreService.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 동물원 검색 (페이징)
|
||||
*
|
||||
* @param searchReq 검색 조건
|
||||
* @return 페이징 처리된 동물원 목록 (각 동물원의 동물 개수 포함)
|
||||
*/
|
||||
public Page<ZooDto.Detail> search(ZooDto.SearchReq searchReq) {
|
||||
return zooCoreService.search(searchReq);
|
||||
}
|
||||
/**
|
||||
* 동물원 단건 조회
|
||||
*
|
||||
* @param id 동물원 ID
|
||||
* @return 동물원 정보 (동물 개수 포함)
|
||||
*/
|
||||
public ZooDto.Detail getZoo(Long id) {
|
||||
return zooCoreService.getOneById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 동물원 검색 (페이징)
|
||||
*
|
||||
* @param searchReq 검색 조건
|
||||
* @return 페이징 처리된 동물원 목록 (각 동물원의 동물 개수 포함)
|
||||
*/
|
||||
public Page<ZooDto.Detail> search(ZooDto.SearchReq searchReq) {
|
||||
return zooCoreService.search(searchReq);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user