Skip to content

Commit

Permalink
Merge pull request #200 from Funssion-SWM/develope
Browse files Browse the repository at this point in the history
feat: get memo ids api
  • Loading branch information
comolove authored Mar 9, 2024
2 parents a014142 + a1761db commit c276721
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Funssion.Inforum.common.utils.SecurityContextUtils;
import Funssion.Inforum.domain.post.memo.dto.request.MemoSaveDto;
import Funssion.Inforum.domain.post.memo.dto.response.MemoDto;
import Funssion.Inforum.domain.post.memo.dto.response.MemoIDListDto;
import Funssion.Inforum.domain.post.memo.dto.response.MemoListDto;
import Funssion.Inforum.domain.post.memo.service.MemoService;
import Funssion.Inforum.s3.dto.response.ImageDto;
Expand Down Expand Up @@ -96,4 +97,9 @@ public List<MemoListDto> getSearchedMemos(
public List<MemoListDto> getDraftMemos() {
return memoService.getDraftMemos();
}

@GetMapping("/ids")
public List<MemoIDListDto> getMemoIds() {
return memoService.getMemoIds();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Funssion.Inforum.domain.post.memo.dto.response;

import lombok.*;

@Getter
@AllArgsConstructor
@EqualsAndHashCode
@Builder
public class MemoIDListDto {
private Long memoId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public interface MemoRepository {
List<Memo> findAllByTag(String tagText, Long userId, OrderType orderType, Long pageNum, Long resultCntPerPage);
List<Memo> findAllBySeriesId(Long seriesId);
List<String> findTop3ColorsBySeriesId(Long seriesId);
List<Long> findAllIds();
Memo findById(Long id);
Memo updateContentInMemo(MemoSaveDto form, Long memoId);
Memo updateContentInMemo(MemoSaveDto form, Long memoId, Boolean isCreated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import Funssion.Inforum.domain.post.memo.exception.MemoNotFoundException;
import Funssion.Inforum.domain.tag.TagUtils;
import Funssion.Inforum.domain.tag.repository.TagRepository;
import com.amazonaws.services.s3.S3ResourceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.jdbc.core.JdbcTemplate;
Expand Down Expand Up @@ -201,6 +202,12 @@ public List<String> findTop3ColorsBySeriesId(Long seriesId) {
return template.queryForList(sql, String.class, seriesId);
}

@Override
public List<Long> findAllIds() {
String sql = "SELECT id FROM post.memo ORDER BY id desc";
return template.queryForList(sql, Long.class);
}

@Override
public Memo findById(Long id) {
String sql = "select * from post.memo where id = ?";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import Funssion.Inforum.domain.post.memo.domain.Memo;
import Funssion.Inforum.domain.post.memo.dto.request.MemoSaveDto;
import Funssion.Inforum.domain.post.memo.dto.response.MemoDto;
import Funssion.Inforum.domain.post.memo.dto.response.MemoIDListDto;
import Funssion.Inforum.domain.post.memo.dto.response.MemoListDto;
import Funssion.Inforum.domain.post.memo.repository.MemoRepository;
import Funssion.Inforum.domain.post.qna.repository.QuestionRepository;
Expand Down Expand Up @@ -332,6 +333,12 @@ private List<MemoListDto> getMemoListDtosSearchedByTag(String searchString, Long
.toList();
}

public List<MemoIDListDto> getMemoIds() {
return memoRepository.findAllIds().stream()
.map(MemoIDListDto::new)
.toList();
}

public class CannotDeleteMemoException extends BadRequestException{

public CannotDeleteMemoException(String message) {
Expand Down

0 comments on commit c276721

Please sign in to comment.