용어집 에디터 이미지 파일 매핑 및 삭제 로직 추가
All checks were successful
LOCALNET-DEV/pipeline/head This commit looks good
All checks were successful
LOCALNET-DEV/pipeline/head This commit looks good
This commit is contained in:
parent
58f7679775
commit
5991a59e48
@ -37,4 +37,10 @@ public interface worddictyMapper {
|
|||||||
|
|
||||||
List<MapDto> selectIndexCategory();
|
List<MapDto> selectIndexCategory();
|
||||||
|
|
||||||
|
int updateBoardIndexToFile(MapDto map);
|
||||||
|
|
||||||
|
List<String> selectDelFileInfo(String[] array);
|
||||||
|
|
||||||
|
void deleteFileInfo(String[] array);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import java.math.BigInteger;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
@ -164,9 +163,9 @@ public class localbordService {
|
|||||||
private void deleteBoardFiles(MapDto map) {
|
private void deleteBoardFiles(MapDto map) {
|
||||||
List<FileVo> list = this.selectFilesInfo(map); // 삭제 파일 정보 조회
|
List<FileVo> list = this.selectFilesInfo(map); // 삭제 파일 정보 조회
|
||||||
for(FileVo vo : list) {
|
for(FileVo vo : list) {
|
||||||
String fileName = vo.getCMNFLENAM();
|
String fileName = vo.getCMNFLEPAT();
|
||||||
if(!fileName.contains(vo.getCMNFLEEXT())) fileName = fileName + vo.getCMNFLEEXT();
|
//if(!fileName.contains(vo.getCMNFLEEXT())) fileName = fileName + vo.getCMNFLEEXT();
|
||||||
fileService.removeBoardFile(fileName); // 파일 삭제
|
fileService.removeFile(fileName); // 파일 삭제
|
||||||
}
|
}
|
||||||
this.deleteFiles(map); // 파일 데이터 삭제
|
this.deleteFiles(map); // 파일 데이터 삭제
|
||||||
}
|
}
|
||||||
@ -420,6 +419,7 @@ public class localbordService {
|
|||||||
map.put("CMNFLEREG", userId);
|
map.put("CMNFLEREG", userId);
|
||||||
map.put("list", list);
|
map.put("list", list);
|
||||||
boardMapper.insertAttachments(map); // 파일 정보 DB 적재
|
boardMapper.insertAttachments(map); // 파일 정보 DB 적재
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 제거 첨부파일 삭제
|
// 제거 첨부파일 삭제
|
||||||
@ -455,7 +455,7 @@ public class localbordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 실제 파일 삭제 및 db 데이터 제거
|
* 파일 삭제 및 db 데이터 제거
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array
|
||||||
*/
|
*/
|
||||||
@ -560,10 +560,10 @@ public class localbordService {
|
|||||||
List<FileVo> list = this.selectFilesBoardIndexIsNull();
|
List<FileVo> list = this.selectFilesBoardIndexIsNull();
|
||||||
|
|
||||||
for(FileVo file : list) {
|
for(FileVo file : list) {
|
||||||
String fileName = file.getCMNFLENAM();
|
String fileName = file.getCMNFLEPAT();
|
||||||
if(!fileName.contains(file.getCMNFLEEXT())) fileName = fileName + file.getCMNFLEEXT();
|
//if(!fileName.contains(file.getCMNFLEEXT())) fileName = fileName + file.getCMNFLEEXT();
|
||||||
|
|
||||||
boolean deleteResult = fileService.removeBoardFile(fileName);
|
boolean deleteResult = fileService.removeFile(fileName);
|
||||||
if(deleteResult) this.deleteTrashFileData(file);
|
if(deleteResult) this.deleteTrashFileData(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
import io.company.localhost.mapper.commoncodMapper;
|
import io.company.localhost.mapper.commoncodMapper;
|
||||||
@ -32,6 +33,7 @@ public class worddictyService {
|
|||||||
|
|
||||||
private final worddictyMapper worddictymapper;
|
private final worddictyMapper worddictymapper;
|
||||||
private final commoncodMapper commoncodmapper;
|
private final commoncodMapper commoncodmapper;
|
||||||
|
private final FileService fileService;
|
||||||
|
|
||||||
public List<MapDto> selectWordList(MapDto map) {
|
public List<MapDto> selectWordList(MapDto map) {
|
||||||
List<MapDto> wordList = worddictymapper.selectWordList(map);
|
List<MapDto> wordList = worddictymapper.selectWordList(map);
|
||||||
@ -66,6 +68,7 @@ public class worddictyService {
|
|||||||
}
|
}
|
||||||
return processedList;
|
return processedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long insertWord(MapDto map) {
|
public Long insertWord(MapDto map) {
|
||||||
Long result = 1L;
|
Long result = 1L;
|
||||||
|
|
||||||
@ -75,10 +78,80 @@ public class worddictyService {
|
|||||||
}
|
}
|
||||||
worddictymapper.insertWord(map);
|
worddictymapper.insertWord(map);
|
||||||
|
|
||||||
|
//에디터 첨부 이미지 게시글 번호 업데이트
|
||||||
|
if(map.get("editorUploadedImgList") != null) {
|
||||||
|
ArrayList<String> editorUploadedImgList = (ArrayList<String>) map.getList("editorUploadedImgList", String.class);
|
||||||
|
map.put("editorImgList", editorUploadedImgList);
|
||||||
|
this.updateBoardIndexToFile(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 에디터 수정 시 업로드 된 에디터 이미지 삭제
|
||||||
|
if(map.get("editorDeleteImgList") != null) {
|
||||||
|
ArrayList<String> editorDeleteImgList = (ArrayList<String>) map.getList("editorDeleteImgList", String.class);
|
||||||
|
String[] array = editorDeleteImgList.stream().toArray(String[]::new);
|
||||||
|
this.deleteFileAndData(array);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 실제 파일 삭제 및 db 데이터 제거
|
||||||
|
*
|
||||||
|
* @param array
|
||||||
|
*/
|
||||||
|
private void deleteFileAndData(String[] array) {
|
||||||
|
List<String> delListInfo = this.selectDelFileInfo(array); // 삭제할 파일 정보 조회
|
||||||
|
for(String item : delListInfo) {
|
||||||
|
fileService.removeFile(item); // 파일 삭제
|
||||||
|
}
|
||||||
|
this.deleteFileInfo(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 삭제 첨부파일 정보 조회
|
||||||
|
*
|
||||||
|
* @param array
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<String> selectDelFileInfo(String[] array) {
|
||||||
|
return worddictymapper.selectDelFileInfo(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 첨부파일 데이터 삭제
|
||||||
|
*
|
||||||
|
* @param array
|
||||||
|
*/
|
||||||
|
private void deleteFileInfo(String[] array) {
|
||||||
|
worddictymapper.deleteFileInfo(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int updateBoardIndexToFile(MapDto map) {
|
||||||
|
return worddictymapper.updateBoardIndexToFile(map);
|
||||||
|
}
|
||||||
public Long updateWord(MapDto map) {
|
public Long updateWord(MapDto map) {
|
||||||
return worddictymapper.updateWord(map);
|
|
||||||
|
Long result = worddictymapper.updateWord(map);
|
||||||
|
|
||||||
|
if(result == 1) {
|
||||||
|
map.put("id", map.get("WRDDICSEQ"));
|
||||||
|
//에디터 첨부 이미지 게시글 번호 업데이트
|
||||||
|
if(map.get("editorUploadedImgList") != null) {
|
||||||
|
ArrayList<String> editorUploadedImgList = (ArrayList<String>) map.getList("editorUploadedImgList", String.class);
|
||||||
|
map.put("editorImgList", editorUploadedImgList);
|
||||||
|
this.updateBoardIndexToFile(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 에디터 수정 시 업로드 된 에디터 이미지 삭제
|
||||||
|
if(map.get("editorDeleteImgList") != null) {
|
||||||
|
ArrayList<String> editorDeleteImgList = (ArrayList<String>) map.getList("editorDeleteImgList", String.class);
|
||||||
|
String[] array = editorDeleteImgList.stream().toArray(String[]::new);
|
||||||
|
this.deleteFileAndData(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
public MapDto selectWordDetail(MapDto map) {
|
public MapDto selectWordDetail(MapDto map) {
|
||||||
return worddictymapper.selectWordDetail(map);
|
return worddictymapper.selectWordDetail(map);
|
||||||
|
|||||||
@ -172,7 +172,7 @@
|
|||||||
ORDER BY CMNFLERDT DESC
|
ORDER BY CMNFLERDT DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 파일 목록 조회 -->
|
<!-- 게시글 삭제 파일 목록 조회 -->
|
||||||
<select id="selectFilesInfo" resultType="io.company.localhost.vo.FileVo">
|
<select id="selectFilesInfo" resultType="io.company.localhost.vo.FileVo">
|
||||||
SELECT
|
SELECT
|
||||||
CMNFLESEQ,
|
CMNFLESEQ,
|
||||||
@ -187,6 +187,7 @@
|
|||||||
COMMONFIL
|
COMMONFIL
|
||||||
WHERE
|
WHERE
|
||||||
CMNBRDSEQ = #{LOCBRDSEQ}
|
CMNBRDSEQ = #{LOCBRDSEQ}
|
||||||
|
AND CMNFLETYP IN (1, 2)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 파일 목록 조회 -->
|
<!-- 파일 목록 조회 -->
|
||||||
|
|||||||
@ -190,6 +190,9 @@
|
|||||||
<include refid="searchConditions"/>
|
<include refid="searchConditions"/>
|
||||||
</select>
|
</select>
|
||||||
<insert id="insertWord" parameterType="map">
|
<insert id="insertWord" parameterType="map">
|
||||||
|
<selectKey keyProperty="id" order="AFTER" resultType="long">
|
||||||
|
SELECT LAST_INSERT_ID()
|
||||||
|
</selectKey>
|
||||||
insert into worddicty
|
insert into worddicty
|
||||||
(
|
(
|
||||||
WRDDICCAT
|
WRDDICCAT
|
||||||
@ -217,6 +220,47 @@
|
|||||||
</if>
|
</if>
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- 삭제 파일 정보 조회 -->
|
||||||
|
<select id="selectDelFileInfo" >
|
||||||
|
SELECT
|
||||||
|
CMNFLEPAT
|
||||||
|
FROM
|
||||||
|
commonfil
|
||||||
|
WHERE
|
||||||
|
CMNFLESEQ in
|
||||||
|
<foreach collection="array" item="item" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
AND CMNFLETYP = 3
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 파일 정보 삭제 -->
|
||||||
|
<delete id="deleteFileInfo" >
|
||||||
|
DELETE FROM
|
||||||
|
commonfil
|
||||||
|
WHERE
|
||||||
|
CMNFLESEQ in
|
||||||
|
<foreach collection="array" item="item" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="updateBoardIndexToFile">
|
||||||
|
/* 용어집 인덱스와 에디터 이미지 매핑 */
|
||||||
|
UPDATE
|
||||||
|
COMMONFIL
|
||||||
|
SET
|
||||||
|
CMNBRDSEQ = #{id},
|
||||||
|
CMNFLETYP = 3
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
CMNFLESEQ IN
|
||||||
|
<foreach collection="editorImgList" item="item" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateWord" parameterType="map">
|
<update id="updateWord" parameterType="map">
|
||||||
update
|
update
|
||||||
worddicty
|
worddicty
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user