오류 및 문제점
진행 상황
1. 게시글 상세 보기
@GetMapping("/detail/{snsNo}")
public SnsDto getSnsDetail(HttpServletRequest request, @PathVariable Long snsNo) {
String obj = request.getHeader("Authorization");
Long userNo = null;
if(obj != null) {
userNo = EncodingUtil.getUserNo(request);
}
SnsVO tmpSns = srepo.findById(snsNo).orElse(null);
SnsDto sns = MakeSnsUtil.makeSnsDto(tmpSns, userNo, urepo, rrepo, hrepo, tagrepo);
return sns;
}
2. 경비 리스트
@GetMapping("/{tripNo}/list")
public JSONObject getExpList(@PathVariable Long tripNo) {
List<ExpVO> tmpExp = erepo.findAll(Sort.by("expTime"));
List<ExpSimpleDto> expList = new ArrayList<>();
Long tripExp = trepo.findById(tripNo).orElse(null).getTripExp();
Long useExp = 0L;
for(int i = 0; i < tmpExp.size(); i++) {
ExpVO exp = tmpExp.get(i);
ExpSimpleDto e = ExpSimpleDto.builder()
.expNo(exp.getExpNo())
.expTitle(exp.getExpTitle())
.expPlace(exp.getExpPlace())
.expMoney(exp.getExpMoney())
.expTime(exp.getExpTime())
.build();
expList.add(e);
useExp += exp.getExpMoney();
}
JSONObject expObj = new JSONObject();
expObj.put("tripExp", tripExp);
expObj.put("useExp", useExp);
expObj.put("remainExp", (tripExp - useExp));
expObj.put("exp", expList);
return expObj;
}
3. 경비 상세 보기
@GetMapping("/detail/{expNo}")
public ExpInfoDto getExpDetail(@PathVariable Long expNo) {
ExpVO tmpExp = erepo.findById(expNo).orElse(null);
ExpInfoDto exp = ExpInfoDto.builder()
.expNo(tmpExp.getExpNo())
.expTitle(tmpExp.getExpTitle())
.tripNo(tmpExp.getTrip().getTripNo())
.expPlace(tmpExp.getExpPlace())
.expAddress(tmpExp.getExpAddress())
.expMoney(tmpExp.getExpMoney())
.expTime(tmpExp.getExpTime())
.expWay(tmpExp.getExpWay())
.expCate(tmpExp.getExpCate())
.build();
if(tmpExp.getCard() != null) {
exp.setCardNo(tmpExp.getCard().getCardNo());
}
if(tmpExp.getSns() != null) {
exp.setSnsNo(tmpExp.getSns().getSnsNo());
}
return exp;
}
4. 게시글 이미지, 해시태그 배열로 변경
public static List<String> getSnsImages(String snsPhoto) {
List<String> photo = new ArrayList<>();
String[] images = snsPhoto.split("@");
for (int i = 0; i < images.length; i++) {
photo.add(AwsUtil.getImageURL(images[i]));
}
return photo;
}
public static List<String> getSnsHashtag(SnsVO sns, HashtagRepository tagrepo) {
List<HashtagVO> tagList = tagrepo.findBySns(sns);
List<String> tag = new ArrayList<>();
for (int i = 0; i < tagList.size(); i++) {
HashtagVO tmpTag = tagList.get(i);
tag.add("#" + tmpTag.getHtHashtag());
}
return tag;
}
5. 해시태그 검색
- 내가 팔로우하는 사용자의 게시글 중 공개 범위가 팔로워 공개인 게시글
- 내 게시글 중 공개 범위가 전체 공개가 아닌 게시글
- 전체 공개인 게시글
- 3개의 게시글을 합쳐 게시글 번호 내림차순으로 정렬 (최신 게시글이 먼저 나오도록)
@Query(value = "select sns_no from sns join trip using(trip_no) join user using(user_no) join hashtag using(sns_no) "
+ " where ht_hashtag=?1 and "
+ " ((user_no in (select user.user_no from user "
+ " join follow on (user.user_no=follow.following) "
+ " where follower = ?2) "
+ " and sns_scope = 0) "
+ " or (user_no = ?2 and sns_scope != 1) "
+ " or (sns_scope = 1)) "
+ " order by sns_no desc", nativeQuery = true)
List<SnsVO> findByTagWithSignin(String hashtag, Long userNo);
6. 팔로워, 팔로잉 리스트
@GetMapping("/{userNo}/follower/list")
public List<UserSimpleDto> getFollowerList(@PathVariable Long userNo) {
UserVO tmpFollowing = urepo.findById(userNo).orElse(null);
List<FollowVO> tmpFollowingList = frepo.findByFollowing(tmpFollowing);
List<UserSimpleDto> followingList = new ArrayList<>();
tmpFollowingList.forEach(following -> {
UserVO tmpUser = following.getFollower();
UserSimpleDto user = UserSimpleDto.builder()
.userNo(tmpUser.getUserNo())
.userNick(tmpUser.getUserNick())
.userProfile(AwsUtil.getImageURL(tmpUser.getProfile().getProfilePhoto()))
.build();
followingList.add(user);
});
return followingList;
}
7. 댓글 삭제
@DeleteMapping("/delete/{replyNo}")
public String deleteReply(@PathVariable Long replyNo) {
rrepo.findById(replyNo).ifPresent(reply -> rrepo.delete(reply));
return "OK";
}
참고 자료