시군구 정보 수정 기능 추가(주소, 직인, 심볼, 로고)

main
이범준 10 months ago
parent 8e01e685c7
commit 6e55c4e678

@ -0,0 +1,65 @@
package cokr.xit.fims.mngt;
import cokr.xit.foundation.AbstractEntity;
import lombok.Getter;
import lombok.Setter;
/**
*
* @author leebj
*/
@Getter
@Setter
public class Sgg extends AbstractEntity {
/**
*
*/
private String sggCd;
/**
*
*/
private String instZip;
/**
*
*/
private String instAddr;
/**
*
*/
private String instDaddr;
/**
*
*/
private String symbolFilePath;
/**
*
*/
private String symbolFileNm;
/**
*
*/
private String logoFilePath;
/**
*
*/
private String logoFileNm;
/**
*
*/
private String offcsFilePath;
/**
*
*/
private String offcsFileNm;
}

@ -0,0 +1,71 @@
package cokr.xit.fims.mngt.dao;
import java.util.List;
import java.util.Map;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.mngt.Sgg;
import cokr.xit.foundation.component.AbstractMapper;
import cokr.xit.foundation.data.DataObject;
/** DAO
*
* <p> :
*
* <pre>
* ============ ============
* 2023-02-02 leebj
* ================================
* </pre>
*/
@Mapper("sggMapper")
public interface SggMapper extends AbstractMapper {
/** .
* @param params
* <ul><li>"sgg" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
int updateSgg(Map<String, Object> params);
/** .
* @param sgg
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
default boolean update(Sgg sgg) {
return sgg != null && updateSgg(params().set("sgg", sgg)) == 1;
}
/** .
* @param req
* @return
*/
List<DataObject> selectSggs(CmmnQuery req);
/** .
* @param req
* @return
*/
default DataObject selectSggInfo(CmmnQuery req) {
// 사용 여부 확인
if (req.getUseYN() == null) {
req.setUseYN("Y");
}
// 기본 정렬
if (req.getOrderBy() == null) {
req.setOrderBy("S.SGG_CD DESC");
}
List<DataObject> sggs = selectSggs(req);
return !sggs.isEmpty() ? sggs.get(0) : null;
}
}

@ -0,0 +1,34 @@
package cokr.xit.fims.mngt.service;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.mngt.Sgg;
import cokr.xit.foundation.data.DataObject;
/** .
*
* <p> :
*
* <pre>
* ============ ============
* 2024-02-02 leebj
* ================================
* </pre>
*/
public interface SggService {
/** .
* @param sgg
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
boolean update(Sgg sgg);
/** .
* @param req
* @return
*/
DataObject getSggInfo(CmmnQuery req);
}

@ -0,0 +1,49 @@
package cokr.xit.fims.mngt.service.bean;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.mngt.Sgg;
import cokr.xit.fims.mngt.dao.SggMapper;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.data.DataObject;
/** Bean
*
* <p> :
*
* <pre>
* ============ ============
* 2024-02-02 leebj
* ================================
* </pre>
*/
@Component("sggBean")
public class SggBean extends AbstractComponent {
/** 시군구 DAO */
@Resource(name = "sggMapper")
private SggMapper sggMapper;
/** .
* @param sgg
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean update(Sgg sgg) {
return sggMapper.update(sgg);
}
/** .
* @param req
* @return
*/
public DataObject getSggInfo(CmmnQuery req) {
return sggMapper.selectSggInfo(req);
}
}

@ -0,0 +1,29 @@
package cokr.xit.fims.mngt.service.bean;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.mngt.Sgg;
import cokr.xit.fims.mngt.service.SggService;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
@Service("sggService")
public class SggServiceBean extends AbstractServiceBean implements SggService {
@Resource(name = "sggBean")
private SggBean sggBean;
@Override
public boolean update(Sgg sgg) {
return sggBean.update(sgg);
}
@Override
public DataObject getSggInfo(CmmnQuery req) {
return sggBean.getSggInfo(req);
}
}

@ -1,14 +1,21 @@
package cokr.xit.fims.mngt.web;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.mngt.Sgg;
import cokr.xit.fims.mngt.VltnQuery;
import cokr.xit.fims.mngt.service.SggService;
import cokr.xit.fims.mngt.service.TaskService;
import cokr.xit.fims.mngt.service.VltnService;
import cokr.xit.fims.mngt.service.bean.FactionBean;
@ -26,11 +33,17 @@ public class Mngt03Controller extends ApplicationController {
public class METHOD_URL {
public static final String
sggMngtMain = "/010/main.do",
getTasks = "/getTasks.do",
getVltns = "/getVltns.do"
getSggInfo = "/010/getSggInfo.do",
getTasks = "/010/getTasks.do",
getVltns = "/010/getVltns.do",
updateSgg = "/010/updateSgg.do"
;
}
/** 시군구 정보 서비스 */
@Resource(name = "sggService")
private SggService sggService;
/** 업무 정보 서비스 */
@Resource(name = "taskService")
private TaskService taskService;
@ -72,14 +85,95 @@ public class Mngt03Controller extends ApplicationController {
return mav;
}
/** .<br />
* @param req
* @return jsonView
*/
public ModelAndView getSggInfo(CmmnQuery req) {
ModelAndView mav = new ModelAndView("jsonView");
DataObject sggInfo = sggService.getSggInfo(req);
mav.addObject("sggInfo", sggInfo);
return mav;
}
/** .<br />
* @param req
* @return jsonView
*/
public ModelAndView getTasks(CmmnQuery req) {
List<DataObject> result = taskService.getTasks(req);
return setCollectionInfo(new ModelAndView("jsonView"), result, "task");
}
/** .<br />
* @return
*/
public ModelAndView getVltns(VltnQuery req) {
List<DataObject> result = vltnService.getVltns(req);
return setCollectionInfo(new ModelAndView("jsonView"), result, "vltn");
}
/** .
* @param sgg , symbol , logo , offcs
* @return jsonView
* <pre><code> {
* "saved": true, false
* }</code></pre>
*/
public ModelAndView updateSgg(Sgg sgg, MultipartFile symbol, MultipartFile logo, MultipartFile offcs) {
ModelAndView mav = new ModelAndView("jsonView");
String sggCd = sgg.getSggCd();
if(symbol != null && !symbol.isEmpty() && symbol.getSize() != 0) {
Map<String,String> newSymbol = this.uploadForSgg(symbol, sggCd, "symbol");
sgg.setSymbolFilePath(newSymbol.get("filePath"));
sgg.setSymbolFileNm(newSymbol.get("fileName"));
}
if(logo != null && !logo.isEmpty() && logo.getSize() != 0) {
Map<String,String> newLogo = this.uploadForSgg(logo, sggCd, "logo");
sgg.setLogoFilePath(newLogo.get("filePath"));
sgg.setLogoFileNm(newLogo.get("fileName"));
}
if(offcs != null && !offcs.isEmpty() && offcs.getSize() != 0) {
Map<String,String> newOffcs = this.uploadForSgg(offcs, sggCd, "offcs");
sgg.setOffcsFilePath(newOffcs.get("filePath"));
sgg.setOffcsFileNm(newOffcs.get("fileName"));
}
boolean saved = sggService.update(sgg);
mav.addObject("saved", saved);
return mav;
}
private Map<String, String> uploadForSgg(MultipartFile mf, String sggCd, String fileSe){
Map<String,String> newFileInfoMap = new HashMap<>();
String workDirPath = "files/"+fileSe;
String ext = FilenameUtils.getExtension(mf.getOriginalFilename());
String fileName = sggCd+"."+ext;
File workDir = new File(workDirPath);
workDir.mkdirs();
String newFileFullPath = workDirPath + "/" + fileName;
try {
File newFile = new File(newFileFullPath);
if(newFile.exists()) {
newFile.delete();
}
mf.transferTo(newFile);
} catch (Exception e) {
throw new RuntimeException("[F]배경 이미지 업로드 중 오류가 발생하였습니다.");
}
newFileInfoMap.put("filePath", newFileFullPath);
newFileInfoMap.put("fileName", mf.getOriginalFilename());
return newFileInfoMap;
}
}

@ -638,7 +638,7 @@ public class Sprt01Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("jsonView");
boolean saved = false;
if(backgroundFile != null && !backgroundFile.isEmpty()) {
if(backgroundFile != null && !backgroundFile.isEmpty() && backgroundFile.getSize() != 0) {
String institute = currentUser().getInstitute();
String account = currentUser().getAccount();
ManagedUser currentUser = userMapper.getUser(account, institute);

@ -9,6 +9,7 @@ import org.springframework.web.servlet.ModelAndView;
import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.crdn.Crdn;
import cokr.xit.fims.mngt.Sgg;
import cokr.xit.fims.mngt.VltnQuery;
import cokr.xit.fims.sprt.OtptForm;
import cokr.xit.fims.sprt.OtptStngQuery;
@ -599,6 +600,12 @@ public class CmnController {
return super.sggMngtMain(sggCd);
}
@Override
@RequestMapping(name="시군구 조회", value=METHOD_URL.getSggInfo)
public ModelAndView getSggInfo(CmmnQuery req) {
return super.getSggInfo(req);
}
@Override
@RequestMapping(name="업무 조회", value=METHOD_URL.getTasks)
public ModelAndView getTasks(CmmnQuery req) {
@ -610,6 +617,12 @@ public class CmnController {
public ModelAndView getVltns(VltnQuery req) {
return super.getVltns(req);
}
@Override
@RequestMapping(name="시군구 정보 수정", value=METHOD_URL.updateSgg)
public ModelAndView updateSgg(Sgg sgg, MultipartFile symbol, MultipartFile logo, MultipartFile offcs) {
return super.updateSgg(sgg, symbol, logo, offcs);
}
}
@Controller

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cokr.xit.fims.mngt.dao.SggMapper">
<sql id="select">
SELECT S.SGG_CD <!-- 시군구 코드 -->
, S.SGG_NM <!-- 시군구 명 -->
, S.INST_SE_CD <!-- 기관 구분 코드 -->
, S.INST_CD <!-- 기관 코드 -->
, S.INST_NM <!-- 기관 명 -->
, (CASE
WHEN S.INST_DADDR IS NULL OR S.INST_DADDR = ''
THEN S.INST_ADDR
ELSE CONCAT(S.INST_ADDR,' ',S.INST_DADDR)
END) AS INST_FULL_ADDR <!-- 기관 전체 주소 -->
, S.INST_ADDR <!-- 기관 기본 주소 -->
, S.INST_DADDR <!-- 기관 상세 주소 -->
, S.INST_ZIP <!-- 기관 우편번호 -->
, S.SYMBOL_FILE_PATH <!-- 상징 파일 경로 -->
, S.SYMBOL_FILE_NM <!-- 상징 파일 명 -->
, S.LOGO_FILE_PATH <!-- 로고 파일 경로 -->
, S.LOGO_FILE_NM <!-- 로고 파일 명 -->
, S.OFFCS_FILE_PATH <!-- 직인 파일 경로 -->
, S.OFFCS_FILE_NM <!-- 직인 파일 명 -->
FROM TB_SGG S
</sql>
<select id="selectSggs" parameterType="map" resultType="dataobject">
/* 시군구 객체 가져오기(sggMapper.selectSggs) */
<include refid="select" />
<where>
<if test="deptCd != null">
AND S.SGG_CD = #{sggCd} <!-- 시군구 코드 -->
</if>
<if test="useYN != null">
AND S.USE_YN = #{useYN} <!-- 사용 여부 -->
</if>
</where>
<include refid="utility.orderBy" />
</select>
<update id="updateSgg" parameterType="map">
/* 시군구 설정정보 수정 (sggMapper.updateSgg) */
UPDATE TB_SGG
SET MDFCN_DT = <include refid="utility.now" />
, MDFR = #{sgg.modifiedBy}
, INST_ZIP = #{sgg.instZip} <!-- 기관 우편번호 -->
, INST_ADDR = #{sgg.instAddr} <!-- 기관 기본 주소 -->
, INST_DADDR = #{sgg.instDaddr} <!-- 기관 상세 주소 -->
<if test="sgg.symbolFilePath != null">
, SYMBOL_FILE_PATH = #{sgg.symbolFilePath} <!-- 상징 파일 경로 -->
, SYMBOL_FILE_NM = #{sgg.symbolFileNm} <!-- 상징 파일 명 -->
</if>
<if test="sgg.logoFilePath != null">
, LOGO_FILE_PATH = #{sgg.logoFilePath} <!-- 로고 파일 경로 -->
, LOGO_FILE_NM = #{sgg.logoFileNm} <!-- 로고 파일 명 -->
</if>
<if test="sgg.offcsFilePath != null">
, OFFCS_FILE_PATH = #{sgg.offcsFilePath} <!-- 직인 파일 경로 -->
, OFFCS_FILE_NM = #{sgg.offcsFileNm} <!-- 직인 파일 명 -->
</if>
WHERE SGG_CD = #{sgg.sggCd}
</update>
</mapper>

@ -4,15 +4,15 @@
<div class="content-wrapper">
<div class="container-xxl flex-grow-1 px-0">
<div class="card wrapper-list">
<form id="mainForm--${pageName}">
<form id="mainForm--${pageName}" method="post" enctype="multipart/form-data">
<div class="card my-2">
<div class="mx-3 my-2 d-block">
<span class="h3">
시군구 정보
</span>
<span>
<button type="button" onclick="" class="btn btn-primary w-px-100" style="float:right"
disabled>저장</button>
<button type="button" id="btnSaveSgg--${pageName}" class="btn btn-primary w-px-100"
style="float:right">저장</button>
</span>
</div>
@ -36,31 +36,28 @@
<input name="instDaddr" type="text" class="form-control w-px-300" />
</div>
<div class="col-md-4" style="display: flex;align-items: center;">
<label class="w-px-140 col-form-label text-sm-end pe-2" for="">
<label class="w-px-140 col-form-label text-sm-end pe-2">
직인
</label>
<img id="offcs--${pageName}" alt="파일이 없습니다." src="/resources/image/no-image.png"
<img id="offcsImage--${pageName}" alt="" src="" data-orgn-path="" data-orgn-name=""
style="object-fit:contain;max-width:100px;max-heigt:100px;" />
<input name="" type="hidden" />
<input name="" type="hidden" />
<input id="offcs--${pageName}" name="offcs" type="file" hidden />
</div>
<div class="col-md-4" style="display: flex;align-items: center;">
<label class="w-px-140 col-form-label text-sm-end pe-2" for="">
<label class="w-px-140 col-form-label text-sm-end pe-2">
심볼
</label>
<img id="symbol--${pageName}" alt="파일이 없습니다." src="/resources/image/no-image.png"
<img id="symbolImage--${pageName}" alt="" src="" data-orgn-path="" data-orgn-name=""
style="object-fit:contain;max-width:100px;max-heigt:100px;" />
<input name="" type="hidden" />
<input name="" type="hidden" />
<input id="symbol--${pageName}" name="symbol" type="file" hidden />
</div>
<div class="col-md-4" style="display: flex;align-items: center;">
<label class="w-px-140 col-form-label text-sm-end pe-2" for="">
<label class="w-px-140 col-form-label text-sm-end pe-2">
로고
</label>
<img id="logo--${pageName}" alt="파일이 없습니다." src="/resources/image/no-image.png"
<img id="logoImage--${pageName}" alt="" src="" data-orgn-path="" data-orgn-name=""
style="object-fit:contain;max-width:100px;max-heigt:100px;" />
<input name="" type="hidden" />
<input name="" type="hidden" />
<input id="logo--${pageName}" name="logo" type="file" hidden />
</div>
</div>
</div>
@ -204,6 +201,13 @@ $(document).ready(function(){
var $P = pageObject["${pageName}"];
$P.sggInfo = {};
$P.taskList = [];
$P.curSggCd = "";
if("${sggCd}" == ""){
$P.curSggCd = MY_INFO.info.sggCd;
} else {
$P.curSggCd = "${sggCd}";
}
$P.taskDatasets = {};
var taskCodes = Object.keys(ALL_TASK);
@ -216,10 +220,12 @@ $(document).ready(function(){
$P.getSggInfo = async function(){
return new Promise((resolve, reject) => {
ajax.get({
url: wctx.url("user/stngInfo.do"),
data: { type : "sgg" },
url: wctx.url("mngt/mngt03/010/getSggInfo.do"),
data: {
sggCd : $P.curSggCd
},
success : function(resp, textStatus, jqXHR) {
$P.sggInfo = resp.stngInfo;
$P.sggInfo = resp.sggInfo;
$("#mainForm--${pageName}").find("[name='sggCd']").val($P.sggInfo.SGG_CD);
$("#mainForm--${pageName}").find("[name='sggNm']").val($P.sggInfo.SGG_NM);
@ -230,18 +236,20 @@ $(document).ready(function(){
$("#mainForm--${pageName}").find("[name='instAddr']").val($P.sggInfo.INST_ADDR);
$("#mainForm--${pageName}").find("[name='instDaddr']").val($P.sggInfo.INST_DADDR);
if(!isEmpty($P.sggInfo.OFFCS_FILE_PATH)){
$("#offcs--${pageName}").attr("alt", $P.sggInfo.OFFCS_FILE_NM);
$("#offcs--${pageName}").attr("src", $P.sggInfo.OFFCS_FILE_PATH);
}
if(!isEmpty($P.sggInfo.SYMBOL_FILE_PATH)){
$("#symbol--${pageName}").attr("alt", $P.sggInfo.SYMBOL_FILE_NM);
$("#symbol--${pageName}").attr("src", $P.sggInfo.SYMBOL_FILE_PATH);
}
if(!isEmpty($P.sggInfo.LOGO_FILE_PATH)){
$("#logo--${pageName}").attr("alt", $P.sggInfo.LOGO_FILE_NM);
$("#logo--${pageName}").attr("src", $P.sggInfo.LOGO_FILE_PATH);
}
$("#offcsImage--${pageName}")
.attr("data-orgn-name", $P.sggInfo.OFFCS_FILE_NM)
.attr("data-orgn-path", $P.sggInfo.OFFCS_FILE_PATH);
$("#offcs--${pageName}").trigger("change");
$("#symbolImage--${pageName}")
.attr("data-orgn-name", $P.sggInfo.SYMBOL_FILE_NM)
.attr("data-orgn-path", $P.sggInfo.SYMBOL_FILE_PATH);
$("#symbol--${pageName}").trigger("change");
$("#logoImage--${pageName}")
.attr("data-orgn-name", $P.sggInfo.LOGO_FILE_NM)
.attr("data-orgn-path", $P.sggInfo.LOGO_FILE_PATH);
$("#logo--${pageName}").trigger("change");
resolve({resp, textStatus, jqXHR});
},
@ -255,8 +263,11 @@ $(document).ready(function(){
$P.getSggTaskInfo = async function(){
return new Promise((resolve, reject) => {
ajax.get({
url: wctx.url("mngt/mngt03/getTasks.do"),
data: { useYN : "Y", sggCd : MY_INFO.info.sggCd },
url: wctx.url("mngt/mngt03/010/getTasks.do"),
data: {
useYN : "Y",
sggCd : $P.curSggCd
},
success : function(resp, textStatus, jqXHR) {
$P.taskList = resp.taskList;
@ -314,12 +325,15 @@ $(document).ready(function(){
});
});
};
$P.getVltnInfo = async function(){
return new Promise((resolve, reject) => {
ajax.get({
url: wctx.url("mngt/mngt03/getVltns.do"),
data: { useYN : "Y", sggCd : MY_INFO.info.sggCd },
url: wctx.url("mngt/mngt03/010/getVltns.do"),
data: {
useYN : "Y",
sggCd : $P.curSggCd
},
success : function(resp, textStatus, jqXHR) {
var datasetNames = Object.keys($P.taskDatasets);
@ -342,7 +356,35 @@ $(document).ready(function(){
}
});
});
}
};
fnMakeSingleImageViewer($("#offcsImage--${pageName}")[0] , $("#offcs--${pageName}")[0], "orgn-path", "orgn-name");
fnMakeSingleImageViewer($("#symbolImage--${pageName}")[0] , $("#symbol--${pageName}")[0], "orgn-path", "orgn-name");
fnMakeSingleImageViewer($("#logoImage--${pageName}")[0] , $("#logo--${pageName}")[0], "orgn-path", "orgn-name");
$("#btnSaveSgg--${pageName}").on("click", function(){
var formData = new FormData($("#mainForm--${pageName}")[0]);
ajax.post({
url: wctx.url("mngt/mngt03/010/updateSgg.do"),
data: formData,
contentType : false, processData : false,
success: (resp) => {
dialog.alert({
content : "저장됐습니다.",
init : function(){
setDialogZindex();
focusClose();
},
onClose : () => {
$P.getSggInfo();
}
});
}
});
});
$P.getSggInfo()
.then(() => {
@ -350,11 +392,10 @@ $(document).ready(function(){
})
.then(() => {
return $P.getVltnInfo();
})
.then(() => {
console.log('end...');
});
});
</script>

@ -246,4 +246,37 @@ function fnMakeScrollableTable(tableScrollEl, thisScrollendEvent){
}
};
}
/**************************************************************************
* 단일 업로드 이미지 뷰어
**************************************************************************/
function fnMakeSingleImageViewer(imgEl, fileInputEl, dataAttributeForFilePath, dataAttributeForFileName){
$(imgEl).on("click", function(){
$(fileInputEl).click();
});
$(fileInputEl).on("change", function(){
if(this.files != null && this.files.length > 0){
$(imgEl).attr("alt", this.files[0].name);
$(imgEl).attr("src", (window.URL || window.webkitURL).createObjectURL(this.files[0]));
} else {
var orgnName = $(imgEl).attr("data-"+dataAttributeForFileName);
var orgnPath = $(imgEl).attr("data-"+dataAttributeForFilePath);
if(orgnPath != undefined && orgnPath != null && orgnPath != ""){
$(imgEl).attr("alt", orgnName);
$(imgEl).attr("src", orgnPath);
} else {
$(imgEl).attr("alt", "파일이 없습니다.");
$(imgEl).attr("src", "/resources/image/no-image.png");
}
}
});
}
Loading…
Cancel
Save