소스 정리

main
이범준 11 months ago
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;
}
}

@ -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<ManagedUser> {
@ -38,26 +24,20 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
@Resource(name="userService")
private UserService userService;
@Resource(name="user2Bean")
private cokr.xit.fims.base.service.bean.UserBean userBean;
@Resource(name="userBean2")
private cokr.xit.fims.base.service.bean.UserBean userBean2;
@Resource(name = "codeBean")
CodeBean codeBean;
private CodeBean codeBean;
@Resource(name="factionBean")
FactionBean factionBean;
private FactionBean factionBean;
@Resource(name="factionMapper")
FactionMapper factionMapper;
@Resource
SmgServiceBean smgServiceBean;
@Resource
ImportServiceBean importServiceBean;
private FactionMapper factionMapper;
@Resource(name = "stngBean")
StngBean stngBean;
private StngBean stngBean;
@Override
public ModelAndView main() {
@ -139,7 +119,7 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
ModelAndView mav = new ModelAndView("jsonView");
boolean result = false;
result = userBean.confirmPassword(password);
result = userBean2.confirmPassword(password);
mav.addObject("result", result);
return mav;
}
@ -175,158 +155,7 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
}
@RequestMapping(name="최고관리자 메인",value="/superUser/main.do")
public ModelAndView superUserMain(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/superUser-main");
}
return mav;
}
@RequestMapping(name="배치 수동 실행",value="/superUser/executeBatch.do")
public ModelAndView executeBatch(String batch) {
ModelAndView mav = new ModelAndView();
switch (batch) {
case "smgReceive" : {
smgServiceBean.receivePetitions();
break;
}
case "smgSend" : {
smgServiceBean.sendReplies();
break;
}
case "epostSend" : {
break;
}
case "epostReceive" : {
break;
}
default:
}
mav.setViewName("jsonView");
return mav;
}
@RequestMapping(name="업무통보 수동 실행",value="/superUser/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);
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) {

@ -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) {

@ -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,
Loading…
Cancel
Save