diff --git a/src/main/java/cokr/xit/fims/base/AdminController.java b/src/main/java/cokr/xit/fims/base/AdminController.java new file mode 100644 index 00000000..d7d3e700 --- /dev/null +++ b/src/main/java/cokr/xit/fims/base/AdminController.java @@ -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 interfaceKeys = new ArrayList(); + 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; + } +} diff --git a/src/main/java/cokr/xit/fims/base/UserController.java b/src/main/java/cokr/xit/fims/base/UserController.java index a8902606..9c9c7a9d 100644 --- a/src/main/java/cokr/xit/fims/base/UserController.java +++ b/src/main/java/cokr/xit/fims/base/UserController.java @@ -1,21 +1,11 @@ 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.code.service.CodeQuery; @@ -23,14 +13,10 @@ import cokr.xit.base.code.service.bean.CodeBean; import cokr.xit.base.security.SecuredUserInfo; import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.service.UserService; -import cokr.xit.fims.cmmn.DirectoryStructureToJson; -import cokr.xit.fims.cmmn.DirectoryStructureToJson.Node; import cokr.xit.fims.cmmn.dao.FactionMapper; import cokr.xit.fims.cmmn.service.bean.FactionBean; import cokr.xit.fims.cmmn.service.bean.StngBean; -import cokr.xit.fims.crdn.service.bean.ImportServiceBean; import cokr.xit.foundation.data.DataObject; -import cokr.xit.interfaces.smg.service.bean.SmgServiceBean; @Controller public class UserController extends cokr.xit.base.user.web.UserController { @@ -38,26 +24,20 @@ public class UserController extends cokr.xit.base.user.web.UserController interfaceKeys = new ArrayList(); - interfaceKeys.add(interfaceKey); - importServiceBean.createCrdns(interfaceKeys); - - break; - } - case "smgSend" : { - break; - } - case "epostSend" : { - - break; - } - case "epostReceive" : { - - break; - } - default: - - } - mav.setViewName("jsonView"); - return mav; - } - - @RequestMapping(name="서버 파일 현황 조회",value="/superUser/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="/superUser/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="/superUser/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="/superUser/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; - } @RequestMapping(name="사용자 검색",value="/user02/010/main.do") public ModelAndView findUserMain(String callbackFuncName) { diff --git a/src/main/java/cokr/xit/fims/base/service/bean/UserBean.java b/src/main/java/cokr/xit/fims/base/service/bean/UserBean.java index 4feeb01d..a88b5972 100644 --- a/src/main/java/cokr/xit/fims/base/service/bean/UserBean.java +++ b/src/main/java/cokr/xit/fims/base/service/bean/UserBean.java @@ -4,7 +4,7 @@ import org.springframework.stereotype.Component; import cokr.xit.foundation.User; -@Component("user2Bean") +@Component("userBean2") public class UserBean extends cokr.xit.base.user.service.bean.UserBean { public boolean confirmPassword(String password) { diff --git a/src/main/webapp/WEB-INF/jsp/fims/superUser-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp similarity index 95% rename from src/main/webapp/WEB-INF/jsp/fims/superUser-main.jsp rename to src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp index c2cfc00d..17d84765 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/superUser-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp @@ -77,7 +77,7 @@ */ function executeBatch(batch){ ajax.get({ - url : wctx.url("/user/superUser/executeBatch.do"), + url : wctx.url("/admin/executeBatch.do"), data : { batch : batch}, success : resp => { dialog.alert("실행되었습니다."); @@ -97,7 +97,7 @@ function exceuteAlert(alertName){ } ajax.post({ - url : wctx.url("/user/superUser/executeAlert.do"), + url : wctx.url("/admin/executeAlert.do"), data : { alertName : alertName, interfaceKey : interfaceKey @@ -129,7 +129,7 @@ function customContextMenu(node){ pathArray.push(directoryName); ajax.post({ - url : wctx.url("/user/superUser/createDirectory.do"), + url : wctx.url("/admin/createDirectory.do"), data : { directories : pathArray }, @@ -164,7 +164,7 @@ function customContextMenu(node){ var pathArray = $("#fileTree").jstree("get_path", obj.id); ajax.post({ - url : wctx.url("/user/superUser/getFileText.do"), + url : wctx.url("/admin/getFileText.do"), data : { directories : pathArray }, @@ -219,7 +219,7 @@ $("#fileTree").bind("refresh.jstree", function(){ */ function getFileTree(){ ajax.get({ - url : wctx.url("/user/superUser/getFileTree.do"), + url : wctx.url("/admin/getFileTree.do"), data : {}, headers: { Accept: "application/json; charset=utf-8" }, success : resp => { @@ -244,7 +244,7 @@ function fnImportFile(obj){ form.append("directories[]", tempPathArray); ajax.post({ - url : wctx.url("/user/superUser/importFile.do"), + url : wctx.url("/admin/importFile.do"), data : form, processData : false, contentType : false,