소스 정리
parent
daa5e28ac3
commit
f08ebaf191
@ -0,0 +1,190 @@
|
||||
package cokr.xit.fims.base;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import cokr.xit.base.web.ApplicationController;
|
||||
import cokr.xit.fims.cmmn.DirectoryStructureToJson;
|
||||
import cokr.xit.fims.cmmn.DirectoryStructureToJson.Node;
|
||||
import cokr.xit.fims.crdn.service.ImportService;
|
||||
import cokr.xit.interfaces.smg.service.SmgService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(name="최고관리자", value="/admin")
|
||||
public class AdminController extends ApplicationController {
|
||||
|
||||
@Resource(name="smgService")
|
||||
private SmgService smgService;
|
||||
|
||||
@Resource(name="importService")
|
||||
private ImportService importService;
|
||||
|
||||
|
||||
@RequestMapping(name="최고관리자 메인",value="/main.do")
|
||||
public ModelAndView adminMain(HttpServletResponse hres) {
|
||||
ModelAndView mav = new ModelAndView();
|
||||
|
||||
if(!currentUser().getInstitute().equals("default")) {
|
||||
hres.setStatus(HttpStatus.FORBIDDEN.value());
|
||||
mav.setViewName("jsonView");
|
||||
mav.addObject("message","메뉴 접근 권한이 없습니다.");
|
||||
} else {
|
||||
mav.setViewName("fims/admin-main");
|
||||
}
|
||||
|
||||
return mav;
|
||||
}
|
||||
|
||||
@RequestMapping(name="배치 수동 실행",value="/executeBatch.do")
|
||||
public ModelAndView executeBatch(String batch) {
|
||||
ModelAndView mav = new ModelAndView();
|
||||
|
||||
switch (batch) {
|
||||
case "smgReceive" : {
|
||||
smgService.receivePetitions();
|
||||
break;
|
||||
}
|
||||
case "smgSend" : {
|
||||
smgService.sendReplies();
|
||||
break;
|
||||
}
|
||||
case "epostSend" : {
|
||||
|
||||
break;
|
||||
}
|
||||
case "epostReceive" : {
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
}
|
||||
mav.setViewName("jsonView");
|
||||
return mav;
|
||||
}
|
||||
|
||||
@RequestMapping(name="업무통보 수동 실행",value="/executeAlert.do")
|
||||
public ModelAndView executeAlert(String alertName, String interfaceKey) {
|
||||
ModelAndView mav = new ModelAndView();
|
||||
|
||||
switch (alertName) {
|
||||
case "smgReceive" : {
|
||||
|
||||
if(interfaceKey == null || interfaceKey.equals("")) {
|
||||
new RuntimeException("인터페이스키 없음");
|
||||
}
|
||||
|
||||
List<String> interfaceKeys = new ArrayList<String>();
|
||||
interfaceKeys.add(interfaceKey);
|
||||
importService.createCrdns(interfaceKeys);
|
||||
|
||||
break;
|
||||
}
|
||||
case "smgSend" : {
|
||||
|
||||
break;
|
||||
}
|
||||
case "epostSend" : {
|
||||
|
||||
break;
|
||||
}
|
||||
case "epostReceive" : {
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
}
|
||||
mav.setViewName("jsonView");
|
||||
return mav;
|
||||
}
|
||||
|
||||
@RequestMapping(name="서버 파일 현황 조회",value="/getFileTree.do")
|
||||
public ModelAndView getFileTree() throws Exception {
|
||||
|
||||
ModelAndView mav = new ModelAndView();
|
||||
mav.setViewName("jsonView");
|
||||
|
||||
Node tree = DirectoryStructureToJson.getNode(new File("files"));
|
||||
mav.addObject("tree", tree);
|
||||
return mav;
|
||||
}
|
||||
|
||||
@RequestMapping(name="최고관리자 서버 폴더 생성", value="/createDirectory.do")
|
||||
public ModelAndView createDirectory(@RequestParam(value="directories[]") String... directories) throws Exception {
|
||||
|
||||
boolean saved = false;
|
||||
|
||||
String path = String.join(File.separator, directories);
|
||||
File newDir = new File(path);
|
||||
saved = newDir.mkdir();
|
||||
|
||||
ModelAndView mav = new ModelAndView();
|
||||
mav.setViewName("jsonView");
|
||||
mav.addObject("saved", saved);
|
||||
return mav;
|
||||
}
|
||||
|
||||
@RequestMapping(name="최고관리자 서버 파일 추가", value="/importFile.do")
|
||||
public ModelAndView importFile(MultipartFile newFile, @RequestParam(value="directories[]") String... directories) throws Exception {
|
||||
|
||||
boolean saved = false;
|
||||
|
||||
String path = String.join(File.separator, directories);
|
||||
path = path + File.separator + newFile.getOriginalFilename();
|
||||
|
||||
File file = new File(path);
|
||||
newFile.transferTo(file);
|
||||
|
||||
saved = file.exists();
|
||||
|
||||
ModelAndView mav = new ModelAndView();
|
||||
mav.setViewName("jsonView");
|
||||
mav.addObject("saved", saved);
|
||||
return mav;
|
||||
}
|
||||
|
||||
@RequestMapping(name="최고관리자 서버 파일 내용 보기", value="/getFileText.do")
|
||||
public ModelAndView getFileText(@RequestParam(value="directories[]") String... directories) throws Exception {
|
||||
String fileCn = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String path = String.join(File.separator, directories);
|
||||
|
||||
int inputData = 0;
|
||||
try {
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path),Charset.forName("EUC-KR")));
|
||||
|
||||
while ((inputData = br.read()) != -1) {
|
||||
sb.append((char)inputData) ;
|
||||
}
|
||||
|
||||
fileCn = sb.toString();
|
||||
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
ModelAndView mav = new ModelAndView();
|
||||
mav.setViewName("jsonView");
|
||||
mav.addObject("fileCn", fileCn);
|
||||
return mav;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue