게시판 게시물 작성 테스트

This commit is contained in:
Rinjae
2025-11-07 13:14:58 +09:00
parent 3675f40489
commit 398c76f7db
2 changed files with 19 additions and 16 deletions
+5 -13
View File
@@ -51,6 +51,11 @@
<filter-name>encodingFilter</filter-name> <filter-name>encodingFilter</filter-name>
<url-pattern>*.file</url-pattern> <url-pattern>*.file</url-pattern>
</filter-mapping> </filter-mapping>
<!-- Tomcat 에서는 필요. Weblogic 에서는 불필요함 -->
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.json</url-pattern>
</filter-mapping>
<!-- <!--
<filter> <filter>
@@ -68,19 +73,6 @@
org.springframework.web.context.ContextLoaderListener org.springframework.web.context.ContextLoaderListener
</listener-class> </listener-class>
</listener> </listener>
<!-- Weblogic 14.1.2 서블릿 설정 -->
<!--
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>weblogic.servlet.FileServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
-->
<servlet> <servlet>
<servlet-name>springapp</servlet-name> <servlet-name>springapp</servlet-name>
<servlet-class> <servlet-class>
@@ -5,9 +5,11 @@ import com.eactive.apim.portal.file.entity.FileInfo;
import com.eactive.apim.portal.file.service.FileService; import com.eactive.apim.portal.file.service.FileService;
import com.eactive.apim.portal.file.service.FileTypeContext; import com.eactive.apim.portal.file.service.FileTypeContext;
import com.eactive.apim.portal.portalNotice.entity.PortalNotice; import com.eactive.apim.portal.portalNotice.entity.PortalNotice;
import com.eactive.eai.common.util.ContainerUtil;
import com.eactive.eai.rms.common.base.BaseService; import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeService; import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeService;
import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeUISearch; import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeUISearch;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -18,19 +20,28 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Optional; import java.util.Optional;
@Service @Service
@Transactional(transactionManager = "transactionManagerForEMS") @Transactional(transactionManager = "transactionManagerForEMS")
@Slf4j
public class PortalNoticeManService extends BaseService { public class PortalNoticeManService extends BaseService {
private final PortalNoticeService portalNoticeService; private final PortalNoticeService portalNoticeService;
private final PortalNoticeUIMapper portalNoticeUIMapper; private final PortalNoticeUIMapper portalNoticeUIMapper;
private final FileService fileService; private final FileService fileService;
private String decodeString(String value) { private String decodeString(String value) {
// return new String(value.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); if (ContainerUtil.get() == ContainerUtil.TOMCAT) {
try {
return new String(value.getBytes("euc-kr"), StandardCharsets.UTF_8);
} catch (UnsupportedEncodingException e) {
log.warn("Failed euc-kr to UTF-8", e);
return value;
}
}
return new String(value.getBytes(Charset.defaultCharset()), StandardCharsets.UTF_8); return new String(value.getBytes(Charset.defaultCharset()), StandardCharsets.UTF_8);
} }
@@ -102,7 +113,7 @@ public class PortalNoticeManService extends BaseService {
if (file != null && !file.isEmpty()) { // 새로운 파일이 업로드된 경우에만 처리 if (file != null && !file.isEmpty()) { // 새로운 파일이 업로드된 경우에만 처리
String decodedFileName = decodeString(portalNoticeUI.getFileName()); String decodedFileName = decodeString(portalNoticeUI.getFileName());
FileTypeContext.setFileType("notice"); FileTypeContext.setFileType("notice");
FileInfo fileInfo = fileService.createOrUpdateSingleFile(portalNotice.getFileId(), file, decodedFileName); FileInfo fileInfo = fileService.createOrUpdateSingleFile(portalNotice.getFileId(), file, decodedFileName, true);
if (fileInfo != null) { if (fileInfo != null) {
portalNotice.setFileId(fileInfo.getFileId()); portalNotice.setFileId(fileInfo.getFileId());