[Spring][쇼핑몰 프로젝트][29] 상품 이미지 수정 - 3(서버처리)

https://kimvampa.tistory.com/237
This commit is contained in:
SeoJin Kim
2021-07-20 19:56:43 +09:00
parent b6fffe5fb1
commit 6cf31b67f2
14 changed files with 93 additions and 13 deletions

View File

@@ -33,4 +33,7 @@ public interface AdminMapper {
/* 이미지 등록 */
public void imageEnroll(AttachImageVO vo);
/* 지정 상품 이미지 전체 삭제 */
public void deleteImageAll(int bookId);
}

View File

@@ -80,13 +80,26 @@ public class AdminServiceImpl implements AdminService {
}
/* 상품 정보 수정 */
@Transactional
@Override
public int goodsModify(BookVO vo) {
int result = adminMapper.goodsModify(vo);
log.info("goodsModify........");
return adminMapper.goodsModify(vo);
if(result == 1 && vo.getImageList() != null && vo.getImageList().size() > 0) {
adminMapper.deleteImageAll(vo.getBookId());
vo.getImageList().forEach(attach -> {
attach.setBookId(vo.getBookId());
adminMapper.imageEnroll(attach);
});
}
return result;
}
/* 상품 정보 삭제 */

View File

@@ -94,5 +94,12 @@
insert into vam_image(bookId, fileName, uploadPath, uuid) values (#{bookId}, #{fileName}, #{uploadPath}, #{uuid})
</insert>
<!-- 지정 상품 이미지 전체 삭제 -->
<delete id="deleteImageAll">
delete FROM vam_image where bookId = #{bookId}
</delete>
</mapper>

View File

@@ -629,7 +629,7 @@
$("input[type='file']").on("change", function(e){
/* 이미지 존재시 삭제 */
if($(".imgDeleteBtn").length > 0){
if($("#result_card").length > 0){
deleteFile();
}

View File

@@ -19,7 +19,7 @@ public class AdminMapperTests {
private AdminMapper mapper;
/* 상품 등록 */
/*
@Test
public void bookEnrollTest() throws Exception{
@@ -43,7 +43,7 @@ public class AdminMapperTests {
System.out.println("After BookVO :" + book);
}
*/
/* 카테고리 리스트 */
/*
@@ -151,6 +151,16 @@ public class AdminMapperTests {
}
*/
/* 지정 상품 이미지 삭제 */
@Test
public void deleteImageAllTest() {
int bookId = 3124;
mapper.deleteImageAll(bookId);
}
}

View File

@@ -94,5 +94,12 @@
insert into vam_image(bookId, fileName, uploadPath, uuid) values (#{bookId}, #{fileName}, #{uploadPath}, #{uuid})
</insert>
<!-- 지정 상품 이미지 전체 삭제 -->
<delete id="deleteImageAll">
delete FROM vam_image where bookId = #{bookId}
</delete>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Tue Jul 13 15:56:55 KST 2021
#Tue Jul 20 15:40:19 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa
m2e.projectName=VamPa
groupId=com.vam

View File

@@ -33,4 +33,7 @@ public interface AdminMapper {
/* 이미지 등록 */
public void imageEnroll(AttachImageVO vo);
/* 지정 상품 이미지 전체 삭제 */
public void deleteImageAll(int bookId);
}

View File

@@ -75,14 +75,27 @@ public class AdminServiceImpl implements AdminService {
}
/* 상품 정보 수정 */
@Transactional
@Override
public int goodsModify(BookVO vo) {
int result = adminMapper.goodsModify(vo);
log.info("goodsModify........");
if(result == 1 && vo.getImageList() != null && vo.getImageList().size() > 0) {
adminMapper.deleteImageAll(vo.getBookId());
vo.getImageList().forEach(attach -> {
attach.setBookId(vo.getBookId());
adminMapper.imageEnroll(attach);
});
}
return adminMapper.goodsModify(vo);
}
return result;
}
/* 상품 정보 삭제 */
@Override

View File

@@ -84,5 +84,12 @@
insert into vam_image(bookId, fileName, uploadPath, uuid) values (#{bookId}, #{fileName}, #{uploadPath}, #{uuid})
</insert>
<!-- 지정 상품 이미지 전체 삭제 -->
<delete id="deleteImageAll">
delete FROM vam_image where bookId = #{bookId}
</delete>
</mapper>

View File

@@ -627,7 +627,7 @@
$("input[type='file']").on("change", function(e){
/* 이미지 존재시 삭제 */
if($(".imgDeleteBtn").length > 0){
if($("#result_card").length > 0){
deleteFile();
}

View File

@@ -150,4 +150,14 @@ public class AdminMapperTests {
}
*/
/* 지정 상품 이미지 삭제 */
@Test
public void deleteImageAllTest() {
int bookId = 3124;
mapper.deleteImageAll(bookId);
}
}

View File

@@ -84,5 +84,12 @@
insert into vam_image(bookId, fileName, uploadPath, uuid) values (#{bookId}, #{fileName}, #{uploadPath}, #{uuid})
</insert>
<!-- 지정 상품 이미지 전체 삭제 -->
<delete id="deleteImageAll">
delete FROM vam_image where bookId = #{bookId}
</delete>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Tue Jul 13 15:56:56 KST 2021
#Tue Jul 20 15:40:20 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL
m2e.projectName=VamPa_MySQL
groupId=com.vam