fix:에디터 그림넣기 작업중
parent
082f55756c
commit
54c7d41d9c
|
|
@ -0,0 +1,160 @@
|
|||
package com.dbnt.faisp.config;
|
||||
|
||||
import com.dbnt.faisp.main.menuMgt.service.MenuMgtService;
|
||||
import org.springframework.core.env.Environment;
|
||||
import com.dbnt.faisp.main.organMgt.service.OrganConfigService;
|
||||
import com.dbnt.faisp.main.userInfo.model.UserInfo;
|
||||
import com.dbnt.faisp.main.codeMgt.service.CodeMgtService;
|
||||
|
||||
import com.dbnt.faisp.main.userInfo.service.UserInfoService;
|
||||
import com.dbnt.faisp.util.ParamMap;
|
||||
import com.dbnt.faisp.util.Utils;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class EditorController {
|
||||
|
||||
private final CodeMgtService codeMgtService;
|
||||
private final OrganConfigService organConfigService;
|
||||
private final MenuMgtService menuMgtService;
|
||||
private final UserInfoService userInfoService;
|
||||
|
||||
SimpleDateFormat sDate = new SimpleDateFormat("yyyyMM");
|
||||
// 현재년월
|
||||
String year = sDate.format(new Date()) + "/";
|
||||
|
||||
@Value("${file.dir}")
|
||||
protected String fileDir;
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@PostMapping("/Crosseditor/uploadImg")
|
||||
@ResponseBody
|
||||
public ParamMap uploadImg(Model model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
||||
ParamMap result = new ParamMap();
|
||||
|
||||
try {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
|
||||
MultipartFile mFile = multipartRequest.getFile("imageFile");
|
||||
if(!"".equals(mFile.getOriginalFilename())){
|
||||
|
||||
long attach_file_Size = mFile.getSize();
|
||||
String attach_file_Name = mFile.getOriginalFilename();
|
||||
String attach_save_Name = Utils.generationSaveName();
|
||||
|
||||
//파일 타입
|
||||
String extNm = "." + attach_file_Name.substring( attach_file_Name.lastIndexOf( "." ) + 1, attach_file_Name.length());
|
||||
if(".jpg,.png,.jpeg".indexOf(extNm.toLowerCase()) > -1) {
|
||||
|
||||
File dir = new File(fileDir + year);
|
||||
if (!dir.exists()) {
|
||||
try{
|
||||
|
||||
// 생성
|
||||
boolean result2 = dir.mkdir();
|
||||
if (result2) {
|
||||
System.out.println("Directory is created.");
|
||||
} else {
|
||||
System.out.println("Failed to create directory.");
|
||||
}
|
||||
} catch(Exception e){
|
||||
System.out.println("Exception occurred.");
|
||||
e.getStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("Directory already exists");
|
||||
}
|
||||
|
||||
File file = new File(fileDir + year, attach_save_Name + extNm);
|
||||
|
||||
FileCopyUtils.copy(mFile.getBytes(), file);
|
||||
String webPath = "http://localhost:8080/" + fileDir + year + attach_save_Name + extNm;
|
||||
|
||||
result.set("result", "success");
|
||||
List<ParamMap> addmsg = new ArrayList<>();
|
||||
ParamMap imgInfo = new ParamMap();
|
||||
imgInfo.set("imageURL", webPath);
|
||||
imgInfo.set("imageTitle", "");
|
||||
imgInfo.set("imageAlt", "");
|
||||
imgInfo.set("imageWidth", "");
|
||||
imgInfo.set("imageWidthUnit", "px");
|
||||
imgInfo.set("imageHeight", "");
|
||||
imgInfo.set("imageHeightUnit", "");
|
||||
imgInfo.set("imageSize", attach_file_Size);
|
||||
imgInfo.set("imageMarginLeft", "");
|
||||
imgInfo.set("imageMarginLeftUnit", "px");
|
||||
imgInfo.set("imageMarginRight", "");
|
||||
imgInfo.set("imageMarginRightUnit", "px");
|
||||
imgInfo.set("imageMarginTop", "");
|
||||
imgInfo.set("imageMarginTopUnit", "px");
|
||||
imgInfo.set("imageMarginBottom", "");
|
||||
imgInfo.set("imageMarginBottomUnit", "px");
|
||||
imgInfo.set("imageAlign", "imageAlign");
|
||||
imgInfo.set("imageId", "");
|
||||
imgInfo.set("imageClass", "");
|
||||
imgInfo.set("imageBorder", 0);
|
||||
imgInfo.set("imageKind", "image");
|
||||
imgInfo.set("imageOrgPath", attach_save_Name + extNm+"|"+webPath);
|
||||
imgInfo.set("imageOrgWidth", 1893);
|
||||
imgInfo.set("imageOrgHeight", 857);
|
||||
imgInfo.set("editorFrame", "NamoSE_editorframe_crosseditor4");
|
||||
addmsg.add(imgInfo);
|
||||
result.set("addmsg", addmsg);
|
||||
|
||||
} else {
|
||||
result.set("uploaded", 0);
|
||||
ParamMap error = new ParamMap();
|
||||
error.set("message", "Check File Extentions.");
|
||||
result.set("error", error);
|
||||
}
|
||||
} else {
|
||||
result.set("uploaded", 0);
|
||||
ParamMap error = new ParamMap();
|
||||
error.set("message", "Check File Extentions.");
|
||||
result.set("error", error);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.set("uploaded", 0);
|
||||
ParamMap error = new ParamMap();
|
||||
error.set("message", "Check File Extentions.");
|
||||
result.set("error", error);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getCurrentProfile() {
|
||||
String[] profiles = env.getActiveProfiles();
|
||||
|
||||
if( profiles.length == 0 ) profiles = env.getDefaultProfiles();
|
||||
|
||||
return profiles[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -104,7 +104,8 @@ public class SecurityConfig{
|
|||
"/css/**",
|
||||
"/img/**",
|
||||
"/js/**",
|
||||
"/vendor/**"
|
||||
"/vendor/**",
|
||||
"/Crosseditor/uploadImg"
|
||||
).permitAll() // 로그인 페이지는 권한 없이 접근 허용
|
||||
.and() // 로그인 설정
|
||||
.formLogin().loginPage("/login") // Custom login form 사용
|
||||
|
|
@ -127,6 +128,7 @@ public class SecurityConfig{
|
|||
// 나모 에디터 'X-Frame-Options' to 'DENY' 오류로 인하여 추가.
|
||||
// https://computer-science-student.tistory.com/497
|
||||
http.headers().frameOptions().sameOrigin();
|
||||
http.csrf().ignoringAntMatchers("/Crosseditor/uploadImg");//csrf예외처리
|
||||
return http.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ file.dir.part=/part
|
|||
file.dir.equip=/equip
|
||||
file.dir.sailor=sailor
|
||||
file.dir.affair=affair
|
||||
file.dir.editor=editor
|
||||
|
||||
|
||||
#thymeleaf
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
<Info></Info>
|
||||
</Product>
|
||||
<General>
|
||||
<WebServerOS>LINUX</WebServerOS>
|
||||
<WebServerOS>WINDOW</WebServerOS>
|
||||
<WebServerInfo>Tomcat</WebServerInfo>
|
||||
<WebLanguage>ETC</WebLanguage>
|
||||
<WebLanguage>HTML</WebLanguage>
|
||||
<ImageSavePath></ImageSavePath>
|
||||
<Width>730</Width>
|
||||
<Height>450</Height>
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ function getEditModal(publicKey, publicType){
|
|||
CrossEditor.params.Width = "100%";
|
||||
CrossEditor.params.UserLang = "auto";
|
||||
CrossEditor.params.NewToolbar = true;
|
||||
CrossEditor.params.UploadFileExecutePath = "/Crosseditor/uploadImg";
|
||||
|
||||
|
||||
CrossEditor.params.FullScreen = false;
|
||||
|
|
@ -108,6 +109,8 @@ function getEditModal(publicKey, publicType){
|
|||
e.editorTarget.SetBodyValue(document.getElementById("pe_bhr").value);
|
||||
})*/
|
||||
CrossEditor.EditorStart();
|
||||
|
||||
|
||||
|
||||
$("#editModal").modal('show');
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue