[Spring][쇼핑몰 프로젝트][28] 상품 상세 페이지 이미지 출력 - 1

https://kimvampa.tistory.com/233
This commit is contained in:
SeoJin Kim
2021-07-04 23:58:15 +09:00
parent bb8db75b6a
commit 3ba8743632
16 changed files with 260 additions and 3 deletions

View File

@@ -3,11 +3,14 @@ package com.vam.controller;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
@@ -15,11 +18,17 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.vam.mapper.AttachMapper;
import com.vam.model.AttachImageVO;
@Controller
public class BookController {
private static final Logger logger = LoggerFactory.getLogger(BookController.class);
@Autowired
private AttachMapper attachMapper;
//메인 페이지 이동
@RequestMapping(value="/main", method = RequestMethod.GET)
public void mainPageGET() {
@@ -53,4 +62,17 @@ public class BookController {
}
/* 이미지 정보 반환 */
@GetMapping(value="/getAttachList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<AttachImageVO>> getAttachList(int bookId){
logger.info("getAttachList.........." + bookId);
return new ResponseEntity<List<AttachImageVO>>(attachMapper.getAttachList(bookId), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,12 @@
package com.vam.mapper;
import java.util.List;
import com.vam.model.AttachImageVO;
public interface AttachMapper {
/* 이미지 데이터 반환 */
public List<AttachImageVO> getAttachList(int bookId);
}

View File

@@ -0,0 +1,12 @@
package com.vam.service;
import java.util.List;
import com.vam.model.AttachImageVO;
public interface AttachService {
/* 이미지 데이터 반환 */
public List<AttachImageVO> getAttachList(int bookId);
}

View File

@@ -0,0 +1,31 @@
package com.vam.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vam.mapper.AttachMapper;
import com.vam.model.AttachImageVO;
import lombok.extern.log4j.Log4j;
@Service
@Log4j
public class AttachServiceImpl implements AttachService{
@Autowired
private AttachMapper attachMapper;
/* 이미지 데이터 반환 */
@Override
public List<AttachImageVO> getAttachList(int bookId) {
log.info("getAttachList.........");
return attachMapper.getAttachList(bookId);
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vam.mapper.AttachMapper">
<select id="getAttachList" resultType="com.vam.model.AttachImageVO">
select * from vam_image where bookId = #{bookId}
</select>
</mapper>

View File

@@ -0,0 +1,27 @@
package com.vam.mapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
public class AttachMapperTests {
@Autowired
private AttachMapper attachMapper;
/*이미지 정보 반환*/
@Test
public void getAttachListTests() {
int bookId = 3125;
System.out.println("이미지 정보 : " + attachMapper.getAttachList(bookId));
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vam.mapper.AttachMapper">
<select id="getAttachList" resultType="com.vam.model.AttachImageVO">
select * from vam_image where bookId = #{bookId}
</select>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Sun Jun 13 17:29:35 KST 2021
#Sun Jul 04 23:43:48 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa
m2e.projectName=VamPa
groupId=com.vam

View File

@@ -3,11 +3,14 @@ package com.vam.controller;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
@@ -15,11 +18,17 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.vam.mapper.AttachMapper;
import com.vam.model.AttachImageVO;
@Controller
public class BookController {
private static final Logger logger = LoggerFactory.getLogger(BookController.class);
@Autowired
private AttachMapper attachMapper;
//메인 페이지 이동
@RequestMapping(value="/main", method = RequestMethod.GET)
public void mainPageGET() {
@@ -52,6 +61,16 @@ public class BookController {
return result;
}
/* 이미지 정보 반환 */
@GetMapping(value="/getAttachList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<AttachImageVO>> getAttachList(int bookId){
logger.info("getAttachList.........." + bookId);
return new ResponseEntity<List<AttachImageVO>>(attachMapper.getAttachList(bookId), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,12 @@
package com.vam.mapper;
import java.util.List;
import com.vam.model.AttachImageVO;
public interface AttachMapper {
/* 이미지 데이터 반환 */
public List<AttachImageVO> getAttachList(int bookId);
}

View File

@@ -0,0 +1,12 @@
package com.vam.service;
import java.util.List;
import com.vam.model.AttachImageVO;
public interface AttachService {
/* 이미지 데이터 반환 */
public List<AttachImageVO> getAttachList(int bookId);
}

View File

@@ -0,0 +1,31 @@
package com.vam.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vam.mapper.AttachMapper;
import com.vam.model.AttachImageVO;
import lombok.extern.log4j.Log4j;
@Service
@Log4j
public class AttachServiceImpl implements AttachService{
@Autowired
private AttachMapper attachMapper;
/* 이미지 데이터 반환 */
@Override
public List<AttachImageVO> getAttachList(int bookId) {
log.info("getAttachList.........");
return attachMapper.getAttachList(bookId);
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vam.mapper.AttachMapper">
<select id="getAttachList" resultType="com.vam.model.AttachImageVO">
select * from vam_image where bookId = #{bookId}
</select>
</mapper>

View File

@@ -0,0 +1,27 @@
package com.vam.mapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
public class AttachMapperTests {
@Autowired
private AttachMapper attachMapper;
/*이미지 정보 반환*/
@Test
public void getAttachListTests() {
int bookId = 3076;
System.out.println("이미지 정보 : " + attachMapper.getAttachList(bookId));
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vam.mapper.AttachMapper">
<select id="getAttachList" resultType="com.vam.model.AttachImageVO">
select * from vam_image where bookId = #{bookId}
</select>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Sun Jun 13 18:53:10 KST 2021
#Sun Jul 04 23:43:44 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL
m2e.projectName=VamPa_MySQL
groupId=com.vam