-
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 #94 from TecheerTeam/style#92
style: 코드 포매팅
- Loading branch information
Showing
105 changed files
with
3,707 additions
and
3,454 deletions.
There are no files selected for viewing
107 changes: 56 additions & 51 deletions
107
src/main/java/com/techeer/abandoneddog/animal/Controller/AnimalInfoController.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 |
---|---|---|
@@ -1,63 +1,68 @@ | ||
package com.techeer.abandoneddog.animal.Controller; | ||
|
||
import com.techeer.abandoneddog.animal.PetInfoDto.PetInfoResponseDto; | ||
import com.techeer.abandoneddog.animal.entity.PetInfo; | ||
import com.techeer.abandoneddog.animal.service.PetInfoService; | ||
import jakarta.persistence.EntityNotFoundException; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.math.BigInteger; | ||
import com.techeer.abandoneddog.animal.PetInfoDto.PetInfoResponseDto; | ||
import com.techeer.abandoneddog.animal.entity.PetInfo; | ||
import com.techeer.abandoneddog.animal.service.PetInfoService; | ||
|
||
import jakarta.persistence.EntityNotFoundException; | ||
|
||
@RequestMapping("/api/v1/petinfo") | ||
@RestController | ||
public class AnimalInfoController { | ||
|
||
private final PetInfoService petInfoService; | ||
|
||
public AnimalInfoController(PetInfoService petInfoService) { | ||
this.petInfoService = petInfoService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<Page<PetInfo>> getAllPetInfos( | ||
@RequestParam(name = "page", required = false, defaultValue = "0") int page, | ||
@RequestParam(name = "size", required = false, defaultValue = "10") int size) { | ||
try { | ||
Page<PetInfo> petInfos = petInfoService.getAllPetInfos(page, size); | ||
return ResponseEntity.ok(petInfos); | ||
} catch (Exception e) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
} | ||
} | ||
|
||
|
||
@GetMapping("/update")//test용 | ||
public void update() { | ||
petInfoService.updatePetInfoDaily(); | ||
|
||
} | ||
@GetMapping("/{id}") | ||
public ResponseEntity<?> getPetInfo(@PathVariable Long id) { | ||
try { | ||
PetInfoResponseDto petInfoDto = petInfoService.getPetInfoById(id); | ||
return ResponseEntity.ok(petInfoDto); | ||
} catch (EntityNotFoundException e) { | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("펫 정보를 찾을 수 없습니다."); | ||
} catch (Exception e) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("펫 정보를 조회하는 동안 오류가 발생했습니다."); | ||
} | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<?> deletePetInfo(@PathVariable Long id) { | ||
try { | ||
petInfoService.deletePetInfo(id); | ||
return ResponseEntity.ok("펫 정보를 삭제했습니다."); | ||
} catch (Exception e) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("펫 정보를 삭제할 수 없습니다."); | ||
} | ||
} | ||
private final PetInfoService petInfoService; | ||
|
||
public AnimalInfoController(PetInfoService petInfoService) { | ||
this.petInfoService = petInfoService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<Page<PetInfo>> getAllPetInfos( | ||
@RequestParam(name = "page", required = false, defaultValue = "0") int page, | ||
@RequestParam(name = "size", required = false, defaultValue = "10") int size) { | ||
try { | ||
Page<PetInfo> petInfos = petInfoService.getAllPetInfos(page, size); | ||
return ResponseEntity.ok(petInfos); | ||
} catch (Exception e) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
} | ||
} | ||
|
||
@GetMapping("/update")//test용 | ||
public void update() { | ||
petInfoService.updatePetInfoDaily(); | ||
|
||
} | ||
|
||
@GetMapping("/{id}") | ||
public ResponseEntity<?> getPetInfo(@PathVariable Long id) { | ||
try { | ||
PetInfoResponseDto petInfoDto = petInfoService.getPetInfoById(id); | ||
return ResponseEntity.ok(petInfoDto); | ||
} catch (EntityNotFoundException e) { | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("펫 정보를 찾을 수 없습니다."); | ||
} catch (Exception e) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("펫 정보를 조회하는 동안 오류가 발생했습니다."); | ||
} | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<?> deletePetInfo(@PathVariable Long id) { | ||
try { | ||
petInfoService.deletePetInfo(id); | ||
return ResponseEntity.ok("펫 정보를 삭제했습니다."); | ||
} catch (Exception e) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("펫 정보를 삭제할 수 없습니다."); | ||
} | ||
} | ||
} |
59 changes: 29 additions & 30 deletions
59
src/main/java/com/techeer/abandoneddog/animal/PetInfoDto/PetInfoDto.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 |
---|---|---|
@@ -1,39 +1,38 @@ | ||
package com.techeer.abandoneddog.animal.PetInfoDto; | ||
|
||
import com.techeer.abandoneddog.image.entity.Image; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PetInfoDto { | ||
private Long id; | ||
private Long desertionNo; | ||
private String filename; | ||
private String popfile; | ||
private String processState; | ||
private int age; | ||
private String weight; | ||
private String sexCd; | ||
private String kindCd; | ||
private String petType; | ||
private boolean isPublicApi; | ||
private List<String> images; | ||
|
||
private Long id; | ||
private Long desertionNo; | ||
private String filename; | ||
private String popfile; | ||
private String processState; | ||
private int age; | ||
private String weight; | ||
private String sexCd; | ||
private String kindCd; | ||
private String petType; | ||
private boolean isPublicApi; | ||
private List<String> images; | ||
|
||
public PetInfoDto(Long id, Long desertionNo, String filename, String popfile, String processState, int age, String weight, String sexCd, String kindCd, String petType, boolean isPublicApi, List<String> images) { | ||
public PetInfoDto(Long id, Long desertionNo, String filename, String popfile, String processState, int age, | ||
String weight, String sexCd, String kindCd, String petType, boolean isPublicApi, List<String> images) { | ||
|
||
this.id = id; | ||
this.desertionNo = desertionNo; | ||
this.filename = filename; | ||
this.popfile = popfile; | ||
this.processState = processState; | ||
this.age = age; | ||
this.weight = weight; | ||
this.sexCd = sexCd; | ||
this.kindCd = kindCd; | ||
this.petType = petType; | ||
this.isPublicApi = isPublicApi; | ||
this.images=images; | ||
} | ||
this.id = id; | ||
this.desertionNo = desertionNo; | ||
this.filename = filename; | ||
this.popfile = popfile; | ||
this.processState = processState; | ||
this.age = age; | ||
this.weight = weight; | ||
this.sexCd = sexCd; | ||
this.kindCd = kindCd; | ||
this.petType = petType; | ||
this.isPublicApi = isPublicApi; | ||
this.images = images; | ||
} | ||
} |
124 changes: 61 additions & 63 deletions
124
src/main/java/com/techeer/abandoneddog/animal/PetInfoDto/PetInfoResponseDto.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 |
---|---|---|
@@ -1,77 +1,75 @@ | ||
package com.techeer.abandoneddog.animal.PetInfoDto; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import com.techeer.abandoneddog.animal.entity.PetInfo; | ||
import com.techeer.abandoneddog.image.entity.Image; | ||
import com.techeer.abandoneddog.shelter.Dto.ShelterInfo; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
@Builder | ||
public class PetInfoResponseDto { | ||
private Long id; | ||
private Long desertionNo; | ||
private String filename; | ||
private String happenDt; | ||
private String happenPlace; | ||
private String petType; | ||
private String kindCd; | ||
private String colorCd; | ||
private int age; | ||
private String weight; | ||
private String noticeNo; | ||
private String noticeSdt; | ||
private String noticeEdt; | ||
private String popfile; | ||
private String processState; | ||
private String sexCd; | ||
private String neuterYn; | ||
private String specialMark; | ||
private boolean isPublicApi; | ||
private ShelterInfo shelter; | ||
private boolean isYoung; | ||
private List<String> images; | ||
|
||
public static PetInfoResponseDto fromEntity(PetInfo petInfo) { | ||
ShelterInfo shelterInfo = new ShelterInfo( | ||
petInfo.getShelter().getCareNm(), | ||
null, | ||
petInfo.getShelter().getCareNm(), | ||
petInfo.getShelter().getCareTel(), | ||
petInfo.getShelter().getCareAddr() | ||
); | ||
|
||
|
||
private Long id; | ||
private Long desertionNo; | ||
private String filename; | ||
private String happenDt; | ||
private String happenPlace; | ||
private String petType; | ||
private String kindCd; | ||
private String colorCd; | ||
private int age; | ||
private String weight; | ||
private String noticeNo; | ||
private String noticeSdt; | ||
private String noticeEdt; | ||
private String popfile; | ||
private String processState; | ||
private String sexCd; | ||
private String neuterYn; | ||
private String specialMark; | ||
private boolean isPublicApi; | ||
private ShelterInfo shelter; | ||
private boolean isYoung; | ||
private List<String> images; | ||
|
||
public static PetInfoResponseDto fromEntity(PetInfo petInfo) { | ||
ShelterInfo shelterInfo = new ShelterInfo( | ||
petInfo.getShelter().getCareNm(), | ||
null, | ||
petInfo.getShelter().getCareNm(), | ||
petInfo.getShelter().getCareTel(), | ||
petInfo.getShelter().getCareAddr() | ||
); | ||
|
||
return PetInfoResponseDto.builder() | ||
.id(petInfo.getId()) | ||
.desertionNo(petInfo.getDesertionNo()) | ||
.filename(petInfo.getFilename()) | ||
.happenDt(petInfo.getHappenDt()) | ||
.happenPlace(petInfo.getHappenPlace()) | ||
.petType(petInfo.getPetType()) | ||
.kindCd(petInfo.getKindCd()) | ||
.colorCd(petInfo.getColorCd()) | ||
.age(petInfo.getAge()) | ||
.weight(petInfo.getWeight()) | ||
.noticeNo(petInfo.getNoticeNo()) | ||
.noticeSdt(petInfo.getNoticeSdt()) | ||
.noticeEdt(petInfo.getNoticeEdt()) | ||
.popfile(petInfo.getPopfile()) | ||
.processState(petInfo.getProcessState()) | ||
.sexCd(petInfo.getSexCd()) | ||
.neuterYn(petInfo.getNeuterYn()) | ||
.specialMark(petInfo.getSpecialMark()) | ||
.isPublicApi(petInfo.isPublicApi()) | ||
.shelter(shelterInfo) | ||
.isYoung(petInfo.isYoung()) | ||
.images(petInfo.getImages().stream() | ||
.map(Image::getUrl) | ||
.collect(Collectors.toList())) | ||
.build(); | ||
} | ||
return PetInfoResponseDto.builder() | ||
.id(petInfo.getId()) | ||
.desertionNo(petInfo.getDesertionNo()) | ||
.filename(petInfo.getFilename()) | ||
.happenDt(petInfo.getHappenDt()) | ||
.happenPlace(petInfo.getHappenPlace()) | ||
.petType(petInfo.getPetType()) | ||
.kindCd(petInfo.getKindCd()) | ||
.colorCd(petInfo.getColorCd()) | ||
.age(petInfo.getAge()) | ||
.weight(petInfo.getWeight()) | ||
.noticeNo(petInfo.getNoticeNo()) | ||
.noticeSdt(petInfo.getNoticeSdt()) | ||
.noticeEdt(petInfo.getNoticeEdt()) | ||
.popfile(petInfo.getPopfile()) | ||
.processState(petInfo.getProcessState()) | ||
.sexCd(petInfo.getSexCd()) | ||
.neuterYn(petInfo.getNeuterYn()) | ||
.specialMark(petInfo.getSpecialMark()) | ||
.isPublicApi(petInfo.isPublicApi()) | ||
.shelter(shelterInfo) | ||
.isYoung(petInfo.isYoung()) | ||
.images(petInfo.getImages().stream() | ||
.map(Image::getUrl) | ||
.collect(Collectors.toList())) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.