|
|
|
|
@ -12,63 +12,62 @@ import com.dbnt.faisp.util.Utils;
|
|
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
|
|
import org.json.simple.JSONArray;
|
|
|
|
|
import org.json.simple.JSONObject;
|
|
|
|
|
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("${site.domain}")
|
|
|
|
|
protected String siteDomain;
|
|
|
|
|
|
|
|
|
|
@Value("${file.dir}")
|
|
|
|
|
protected String fileDir;
|
|
|
|
|
|
|
|
|
|
@Value("${file.dir.editor}")
|
|
|
|
|
protected String editorPath;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private Environment env;
|
|
|
|
|
@Value("${editor.img.view}")
|
|
|
|
|
protected String imgView;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/Crosseditor/uploadImg")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ParamMap uploadImg(Model model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
|
|
|
|
ParamMap result = new ParamMap();
|
|
|
|
|
public @ResponseBody JSONObject uploadImg(Model model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
JSONArray req_array = new JSONArray();
|
|
|
|
|
|
|
|
|
|
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 imageKind = request.getParameter("imageKind");
|
|
|
|
|
String editorFrame = request.getParameter("editorFrame");
|
|
|
|
|
|
|
|
|
|
//파일 타입
|
|
|
|
|
String extNm = "." + attach_file_Name.substring( attach_file_Name.lastIndexOf( "." ) + 1, attach_file_Name.length());
|
|
|
|
|
@ -93,70 +92,35 @@ public class EditorController {
|
|
|
|
|
System.out.println("Directory already exists");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
File file = new File(fileDir+File.separator+editorPath, attach_save_Name + extNm);
|
|
|
|
|
|
|
|
|
|
File file = new File(fileDir+File.separator+editorPath, attach_save_Name + extNm);
|
|
|
|
|
FileCopyUtils.copy(mFile.getBytes(), file);
|
|
|
|
|
String webPath = "http://localhost:8080/file/editorFileDisplay?fileNm=" + 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);
|
|
|
|
|
|
|
|
|
|
String webPath = siteDomain+ imgView + attach_save_Name + extNm;
|
|
|
|
|
|
|
|
|
|
jsonObject.put("result","success");
|
|
|
|
|
data.put("imageURL",webPath);
|
|
|
|
|
data.put("imageKind", imageKind);
|
|
|
|
|
data.put("editorFrame", editorFrame);
|
|
|
|
|
req_array.add(data);
|
|
|
|
|
jsonObject.put("addmsg", req_array);
|
|
|
|
|
|
|
|
|
|
} 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;
|
|
|
|
|
|
|
|
|
|
return jsonObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getCurrentProfile() {
|
|
|
|
|
String[] profiles = env.getActiveProfiles();
|
|
|
|
|
|
|
|
|
|
if( profiles.length == 0 ) profiles = env.getDefaultProfiles();
|
|
|
|
|
|
|
|
|
|
return profiles[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|