diff --git a/src/main/java/com/bside/BSIDE/contents/domain/QuestionListInDto.java b/src/main/java/com/bside/BSIDE/contents/domain/QuestionListInDto.java new file mode 100644 index 0000000..e6df7ad --- /dev/null +++ b/src/main/java/com/bside/BSIDE/contents/domain/QuestionListInDto.java @@ -0,0 +1,13 @@ +package com.bside.BSIDE.contents.domain; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class QuestionListInDto { + @Schema(description = "페이지 번호", example = "1") + private int pageNo; + + @Schema(description = "페이지당 들어갈 컬럼 수", example = "20") + private int pageSize; +} diff --git a/src/main/java/com/bside/BSIDE/contents/domain/QuestionListOutDto.java b/src/main/java/com/bside/BSIDE/contents/domain/QuestionListOutDto.java new file mode 100644 index 0000000..2ebaad4 --- /dev/null +++ b/src/main/java/com/bside/BSIDE/contents/domain/QuestionListOutDto.java @@ -0,0 +1,18 @@ +package com.bside.BSIDE.contents.domain; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +public class QuestionListOutDto { + @Schema(description = "현재 페이지 번호", example = "1", nullable = false) + private Integer pageNo; + + @Schema(description = "페이지당 들어갈 컬럼 수", example = "20", nullable = false) + private Integer pageSize; + + @Schema(description = "질문 contents", nullable = true) + private List grid; +} diff --git a/src/main/java/com/bside/BSIDE/contents/persistence/QuestionMapper.java b/src/main/java/com/bside/BSIDE/contents/persistence/QuestionMapper.java index eb58909..a3bea50 100644 --- a/src/main/java/com/bside/BSIDE/contents/persistence/QuestionMapper.java +++ b/src/main/java/com/bside/BSIDE/contents/persistence/QuestionMapper.java @@ -2,14 +2,8 @@ import java.util.List; +import com.bside.BSIDE.contents.domain.*; import org.apache.ibatis.annotations.Mapper; -import org.springframework.data.domain.Page; - -import com.bside.BSIDE.contents.domain.CountAnsweredQuestionsByMonthDto; -import com.bside.BSIDE.contents.domain.QuestionAndAnswerDto; -import com.bside.BSIDE.contents.domain.QuestionCountDto; -import com.bside.BSIDE.contents.domain.QuestionDto; - @Mapper @@ -28,4 +22,7 @@ public interface QuestionMapper { List getQuestionsAndAnswersByMonthAndEmail(String email, String date); List getQuestionsAndAnswersByDayAndEmail(String email, String date); + + List selectListQuestion(QuestionListInDto questionListInDto); +// List selectListQuestion(int pageNo, int pageSize); } diff --git a/src/main/java/com/bside/BSIDE/contents/web/QuestionController.java b/src/main/java/com/bside/BSIDE/contents/web/QuestionController.java index 4fce33b..cea338e 100644 --- a/src/main/java/com/bside/BSIDE/contents/web/QuestionController.java +++ b/src/main/java/com/bside/BSIDE/contents/web/QuestionController.java @@ -3,26 +3,10 @@ import java.util.List; import java.util.Map; -import org.springframework.data.domain.Page; -import org.springframework.http.HttpStatus; +import com.bside.BSIDE.contents.domain.*; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.bside.BSIDE.contents.domain.CountAnsweredQuestionsByMonthDto; -import com.bside.BSIDE.contents.domain.PagedResponse; -import com.bside.BSIDE.contents.domain.QuestionAndAnswerDto; -import com.bside.BSIDE.contents.domain.QuestionCountDto; -import com.bside.BSIDE.contents.domain.QuestionDto; -import com.bside.BSIDE.service.AnswerService; +import org.springframework.web.bind.annotation.*; import com.bside.BSIDE.service.QuestionService; - import io.swagger.v3.oas.annotations.Operation; /** @@ -176,4 +160,25 @@ else if (dateArr.length == 2) { } } + + + @PostMapping("/getETCQuestionList") + @ResponseBody + @Operation(summary = "등록되어져 있는 질문 목록 조회") + public ResponseEntity selectListQuestion(@RequestBody QuestionListInDto questionListInDto) { + System.out.println("------- questionListInDto :: ---- " + questionListInDto); + List outDto; + QuestionListOutDto output = new QuestionListOutDto(); + try { + outDto = questionService.selectListQuestion(questionListInDto); + System.out.println(outDto); + output.setGrid(outDto); +// output.getClass().getField("grid").set(outDto); + } catch (Exception e) { +// return ResponseEntity.ok(e); + System.out.println(e); + return ResponseEntity.status(400).build(); + } + return ResponseEntity.ok(output); + } } diff --git a/src/main/java/com/bside/BSIDE/service/QuestionService.java b/src/main/java/com/bside/BSIDE/service/QuestionService.java index b3e7052..f0ee802 100644 --- a/src/main/java/com/bside/BSIDE/service/QuestionService.java +++ b/src/main/java/com/bside/BSIDE/service/QuestionService.java @@ -2,13 +2,7 @@ import java.util.List; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - -import com.bside.BSIDE.contents.domain.CountAnsweredQuestionsByMonthDto; -import com.bside.BSIDE.contents.domain.QuestionAndAnswerDto; -import com.bside.BSIDE.contents.domain.QuestionCountDto; -import com.bside.BSIDE.contents.domain.QuestionDto; +import com.bside.BSIDE.contents.domain.*; public interface QuestionService { void insertQuestion(QuestionDto questionDto); @@ -25,4 +19,6 @@ public interface QuestionService { List getQuestionsAndAnswersByMonthAndEmail(String email, String date); List getQuestionsAndAnswersByDayAndEmail(String email, String date); + + List selectListQuestion(QuestionListInDto input); } diff --git a/src/main/java/com/bside/BSIDE/service/QuestionServiceImpl.java b/src/main/java/com/bside/BSIDE/service/QuestionServiceImpl.java index ee25d18..266114b 100644 --- a/src/main/java/com/bside/BSIDE/service/QuestionServiceImpl.java +++ b/src/main/java/com/bside/BSIDE/service/QuestionServiceImpl.java @@ -2,13 +2,9 @@ import java.util.List; -import org.springframework.data.domain.Page; +import com.bside.BSIDE.contents.domain.*; import org.springframework.stereotype.Service; -import com.bside.BSIDE.contents.domain.CountAnsweredQuestionsByMonthDto; -import com.bside.BSIDE.contents.domain.QuestionAndAnswerDto; -import com.bside.BSIDE.contents.domain.QuestionCountDto; -import com.bside.BSIDE.contents.domain.QuestionDto; import com.bside.BSIDE.contents.persistence.QuestionMapper; @Service @@ -80,5 +76,20 @@ public List getQuestionsAndAnswersByMonthAndEmail(String e public List getQuestionsAndAnswersByDayAndEmail(String email, String date) { return questionMapper.getQuestionsAndAnswersByDayAndEmail(email, date); } - + + @Override + public List selectListQuestion(QuestionListInDto input) { + int pageNo = input.getPageNo(); + int pageSize = input.getPageSize(); + QuestionListInDto inDto = new QuestionListInDto(); + inDto.setPageNo(pageNo); + inDto.setPageSize(pageSize); + System.out.println("serviceImpl ------- pageNo: " + pageNo + " pageSize: " + pageSize); + List list = questionMapper.selectListQuestion(inDto); + System.out.println("serviceImpl ------- end"); + System.out.println(list); + return list; + } + } + diff --git a/src/main/resources/sqlmap/mapper/question/QuestionMapper.xml b/src/main/resources/sqlmap/mapper/question/QuestionMapper.xml index 15ca663..8e002a9 100644 --- a/src/main/resources/sqlmap/mapper/question/QuestionMapper.xml +++ b/src/main/resources/sqlmap/mapper/question/QuestionMapper.xml @@ -151,4 +151,21 @@ AND MONTH(a.a_created_at) = MONTH(#{date}) AND DAY(a.a_created_at) = DAY(#{date}) + + + + \ No newline at end of file