Skip to content

Commit

Permalink
Merge pull request #14 from bsideproject/questionAnswer
Browse files Browse the repository at this point in the history
Question answer
  • Loading branch information
Hoon-Hub authored Aug 18, 2023
2 parents 4762829 + 22ae3eb commit 6b633c6
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<QuestionDto> grid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,4 +22,7 @@ public interface QuestionMapper {

List<QuestionAndAnswerDto> getQuestionsAndAnswersByMonthAndEmail(String email, String date);
List<QuestionAndAnswerDto> getQuestionsAndAnswersByDayAndEmail(String email, String date);

List<QuestionDto> selectListQuestion(QuestionListInDto questionListInDto);
// List<QuestionDto> selectListQuestion(int pageNo, int pageSize);
}
41 changes: 23 additions & 18 deletions src/main/java/com/bside/BSIDE/contents/web/QuestionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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<QuestionDto> 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);
}
}
10 changes: 3 additions & 7 deletions src/main/java/com/bside/BSIDE/service/QuestionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -25,4 +19,6 @@ public interface QuestionService {

List<QuestionAndAnswerDto> getQuestionsAndAnswersByMonthAndEmail(String email, String date);
List<QuestionAndAnswerDto> getQuestionsAndAnswersByDayAndEmail(String email, String date);

List<QuestionDto> selectListQuestion(QuestionListInDto input);
}
23 changes: 17 additions & 6 deletions src/main/java/com/bside/BSIDE/service/QuestionServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,5 +76,20 @@ public List<QuestionAndAnswerDto> getQuestionsAndAnswersByMonthAndEmail(String e
public List<QuestionAndAnswerDto> getQuestionsAndAnswersByDayAndEmail(String email, String date) {
return questionMapper.getQuestionsAndAnswersByDayAndEmail(email, date);
}


@Override
public List<QuestionDto> 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<QuestionDto> list = questionMapper.selectListQuestion(inDto);
System.out.println("serviceImpl ------- end");
System.out.println(list);
return list;
}

}

17 changes: 17 additions & 0 deletions src/main/resources/sqlmap/mapper/question/QuestionMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,21 @@
AND MONTH(a.a_created_at) = MONTH(#{date})
AND DAY(a.a_created_at) = DAY(#{date})
</select>

<!-- 질문목록 조회 -->
<select id="selectListQuestion"
resultType="com.bside.BSIDE.contents.domain.QuestionDto"
parameterType="com.bside.BSIDE.contents.domain.QuestionListInDto" >
SELECT
q_no as qNo
,q_question as qQuestion
, q_category as qCategory
, q_writer as qWriter
, q_created_at as qCreatedAt
FROM question
ORDER BY q_created_at DESC
LIMIT #{pageSize}
OFFSET #{pageNo} - 1
</select>

</mapper>

0 comments on commit 6b633c6

Please sign in to comment.