Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

import com.newdeal.ledger.inquiry.dto.InquiryDto;
import com.newdeal.ledger.inquiry.service.InquiryService;
import org.eclipse.tags.shaded.org.apache.xpath.operations.Mod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.Map;

@Controller

public class IController {
@Autowired
private InquiryService inquiryService;
public class IController{
//@Autowired private InquiryService inquiryService; ← :스프링 의존성 주입방식 : 필드주입 방식
//▼(스프링 의존성 주입 방식: 생성자 주입방식)
private final InquiryService inquiryService;
public IController(InquiryService inquiryService){
this.inquiryService=inquiryService;
} //생성자 주입 방식


/**
* 문의 게시판 페이지
Expand All @@ -24,14 +31,28 @@ public class IController {
@GetMapping("/index")
public String index(Model model, @RequestParam (defaultValue = "1") int page) {

ArrayList<InquiryDto> list = inquiryService.iSelectAll(page);
// ▼ service 연결
Map<String,Object> map = inquiryService.iSelectAll(page); //ArrayList에서 Map으로 변경 됨

// ▽ model저장 후 전송
model.addAttribute("map",map);

//▼model저장 후 전송
model.addAttribute("list",list);

return "index"; // 수정
}//index
}//index(문의 게시판 전체리스트 보기)

@GetMapping("/iView")
public String iView(Model model, @RequestParam(defaultValue = "1") int qbno){

// ▼ service 연결
InquiryDto ibdto = inquiryService.iSelectOne(qbno);
System.out.println("확인 : " + ibdto);

// ▽ model저장 후 전송
model.addAttribute("idto",ibdto);

return "iView";
}//iView(문의 게시물 1개보기)


}//IController
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Data
public class InquiryDto {

private int cno;
private int qbno;
private String email;
private String qtitle;
private String qcontent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
@Mapper
public interface InquiryMapper {
//1.문의 게시판 전체리스트 가져오기
ArrayList<InquiryDto> iSelectAll(); //문의 게시판 전체리스트 가져오기
ArrayList<InquiryDto> iSelectAll(int startContRowNum, int endContRowNum); //문의 게시판 전체리스트 가져오기

//1-ⓐ회원정보 리스트 총갯수
int iSelectCountAll();


//2.문의 게시판 게시글 1개 가져오기
InquiryDto IselectOne(int qbno);
}//InquiryMapper
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.newdeal.ledger.inquiry.dto.InquiryDto;

import java.util.ArrayList;
import java.util.Map;

public interface InquiryService {

//1.문의 게시판 전체 리스트 가져오기
ArrayList<InquiryDto> iSelectAll(int page);
//1.문의 게시판_전체 리스트 가져오기
Map<String, Object> iSelectAll(int page);

//2.문의 게시판_게시글 1개 가져오기
InquiryDto iSelectOne(int qbno);
}//InquiryService //서비스
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@Service
public class InquiryServiceImpl implements InquiryService {

@Autowired
InquiryMapper inquiryMapper;
//@Autowired InquiryMapper inquiryMapper; ← :스프링 의존성 주입방식 : 필드주입 방식
//▼(스프링 의존성 주입 방식: 생성자 주입방식)
private final InquiryMapper inquiryMapper;

public InquiryServiceImpl(InquiryMapper inquiryMapper) {
this.inquiryMapper = inquiryMapper;
} //생성자 주입 방식

//1.문의 게시판_전체 리스트 가져오기
@Override
public ArrayList<InquiryDto> iSelectAll(int page) {
public Map<String, Object> iSelectAll(int page) {

//1. 페이지 넘버링 - ②번째
if(page <=0)
Expand All @@ -31,8 +39,27 @@ public ArrayList<InquiryDto> iSelectAll(int page) {
int startContRowNum = (page - 1) * contentCount + 1; //page 시작 게시판 번호
int endContRowNum = startContRowNum + contentCount - 1; // page 마지막 게시판 번호

//2.문의 게시판 전체리스트 가져오기 - ①번째
ArrayList<InquiryDto> list = inquiryMapper.iSelectAll();
return list;
}//selectAll
//2.문의 게시판_전체리스트 가져오기 - ①번째
ArrayList<InquiryDto> list = inquiryMapper.iSelectAll(startContRowNum,endContRowNum);
System.out.println("list정보 : " + list);
//retrun타입 ArrayList → Map으로 변경 - ③번째
Map<String, Object> map = new HashMap<>();
map.put("list",list);
map.put("page",page);
map.put("maxPage",maxPage);
map.put("startPageNum",startPageNum);
map.put("endPageNum",endPageNum);

return map;
}//selectAll(page) : 문의게시판 전체 리스트 가저오기

//2.문의 게시판_게시글 1개 가져오기
@Override
public InquiryDto iSelectOne(int qbno) {

//게시글 1개가져오기(현재글)
InquiryDto ibdto = inquiryMapper.IselectOne(qbno);

return ibdto;
}//iSelectOne(qbno) : 문의게시판 게시글 1개 가져오기
}//InquiryServiceImpl //서비스 임플
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@

<mapper namespace="com.newdeal.ledger.inquiry.mapper.InquiryMapper">

<!--1. 문의게시판 전체리스크 가져오기 -->
<!--1. 문의게시판_전체리스크 가져오기 -->
<select id="iSelectAll" resultType="com.newdeal.ledger.inquiry.dto.InquiryDto">

SELECT * FROM qboard ORDER BY qbno DESC LIMIT #{endContRowNum} OFFSET #{startContRowNum}
</select>

<!--1-ⓐ. 문의게시판 전체리스크 총갯수 -->
<select id="iSelectCountAll" resultType="int">
select count(*) from qboard
</select>

<!--2. 문의게시판 게시글 1개 가져오기 -->
<select id="iSelectOne" parameterType="String" resultType="com.newdeal.ledger.inquiry.dto.InquiryDto">
select * from qboard where qbno =#{qbno}
</select>
</mapper>
63 changes: 16 additions & 47 deletions src/main/webapp/WEB-INF/views/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@

<hr style="border: 2px solid blue; margin-bottom: 20px;">
<table style="border-top: 5px solid blue;">

<thead>
<colgroup>
<col width="7%">
Expand All @@ -137,48 +138,18 @@
</tr>
</thead>
<tbody style="border-bottom: 5px solid blue;">
<tr>
<td>1005</td>
<td>회원가입이 안돼요! 답변좀!</td>
<td>java_com12</td>
<td style="font-weight: 700; color: red;">답변대기</td>
<td>2024-07-01</td>
</tr>
<tr>
<td>1004</td>
<td>이메일 인증번호 수신이 안되었어요</td>
<td>python123</td>
<td style="font-weight: 700; color: blue;">답변완료</td>
<td>2024-07-01</td>
</tr>
<tr>
<td>1003</td>
<td>계좌를 개설하는 방법을 모르겠어요.</td>
<td>java_com12</td>
<td style="font-weight: 700; color: red;">답변대기</td>
<td>2024-07-01</td>
</tr>
<tr>
<td>1002</td>
<td>아이디 비밀번호를 분실했어요</td>
<td>node77</td>
<td style="font-weight: 700; color: blue;">답변완료</td>
<td>2024-07-01</td>
</tr>
<tr>
<td>1001</td>
<td>회원가입이 안돼요! 답변좀!</td>
<td>react123</td>
<td style="font-weight: 700; color: blue;">답변완료</td>
<td>2024-07-01</td>
</tr>
<tr>
<td>1000</td>
<td>회원가입이 안돼요! 답변좀!</td>
<td>java_com12</td>
<td style="font-weight: 700; color: red;">답변대기</td>
<td>2024-07-01</td>
</tr>
<c:forEach var="idto" items="${map.list}">
<tr>
<td>${idto.qbno}</td>
<td>${idto.qtitle}</td>
<td>${idto.email}</td>
<td>
<c:if test="${idto.qstatus<=0 }"><strong style="color:red">답변대기</strong></c:if>
<c:if test="${idto.qstatus>0 }"><strong style="color: blue">답변완료</strong></c:if>
</td>
<td><fmt:formatDate value="${idto.qdate}" pattern="YYYY-MM-dd"/> </td>
</tr>
</c:forEach>
</tbody>
</table>

Expand All @@ -191,11 +162,9 @@
<li class="num"><i class="fa fa-chevron-circle-left" aria-hidden="true"></i></li>

<!--페이지 넘버링-->
<a href="#" style="text-decoration: none;"><li class="num">1</li></a>
<a href="#" style="text-decoration: none;"><li class="num">2</li></a>
<a href="#" style="text-decoration: none;"><li class="num">3</li></a>
<a href="#" style="text-decoration: none;"><li class="num">4</li></a>
<a href="#" style="text-decoration: none;"><li class="num">5</li></a>
<c:forEach var="i" begin="${map.startPageNum}" end="${map.endPageNum }" step="1">
<a href="#" style="text-decoration: none;"><li class="num">${i}</li></a>
</c:forEach>
<!--페이지 넘버링-->

<!--다음 페이지-->
Expand Down