시군구,부서 관리 수정

main
이범준 5 months ago
parent 3888847093
commit 047bb6d49f

@ -1,39 +0,0 @@
package cokr.xit.applib;
public class SQLUtil {
public static final String SCRIPT_START = "<script>";
public static final String SCRIPT_END = "</script>";
public static final String now = """
<if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s')</if>
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISS')</if>
""";
public static final String sortBy = """
<if test="orderBy != null and orderBy != ''">ORDER BY ${orderBy}</if>
""";
public static final String orderBy = """
<if test="fetchSize == null or fetchSize &lt; 1">"""
+sortBy+"""
</if>""";
public static final String pagingPrefix = """
<if test="fetchSize != null and fetchSize &gt; 0">
SELECT QROWS.*
FROM (
SELECT ROW_NUMBER() OVER("""
+sortBy+"""
) ROW_NUM
, COUNT(*) OVER() TOT_CNT
, QBODY.*
FROM (
</if>""";
public static final String pagingSuffix = """
<if test="fetchSize != null and fetchSize &gt; 0"> ) QBODY
) QROWS
WHERE ROW_NUM BETWEEN ((#{pageNum} - 1) * #{fetchSize}) + 1 AND (#{pageNum} * #{fetchSize})
</if>""";
}

@ -1,70 +0,0 @@
package cokr.xit.applib.ogdp;
import cokr.xit.foundation.component.QueryRequest;
public class OgdpQuery extends QueryRequest {
private static final long serialVersionUID = 1L;
private String sggCd; // 시군구 코드
private String deptCd; // 부서 코드
private String instCd; // 기관 코드
private String useYn; // 사용 여부
private String delYn; // 삭제 여부
private String selectAdd;
public String getSggCd() {
return ifEmpty(sggCd, () -> null);
}
public <T extends OgdpQuery> T setSggCd(String sggCd) {
this.sggCd = sggCd;
return self();
}
public String getDeptCd() {
return ifEmpty(deptCd, () -> null);
}
public <T extends OgdpQuery> T setDeptCd(String deptCd) {
this.deptCd = deptCd;
return self();
}
public String getInstCd() {
return ifEmpty(instCd, () -> null);
}
public <T extends OgdpQuery> T setInstCd(String instCd) {
this.instCd = instCd;
return self();
}
public String getUseYn() {
return ifEmpty(useYn, () -> null);
}
public <T extends OgdpQuery> T setUseYn(String useYn) {
this.useYn = useYn;
return self();
}
public String getDelYn() {
return ifEmpty(delYn, () -> null);
}
public <T extends OgdpQuery> T setDelYn(String delYn) {
this.delYn = delYn;
return self();
}
public String getSelectAdd() {
return ifEmpty(selectAdd, () -> null);
}
public <T extends OgdpQuery> T setSelectAdd(String selectAdd) {
this.selectAdd = selectAdd;
return self();
}
}

@ -1,36 +0,0 @@
package cokr.xit.applib.ogdp;
import cokr.xit.base.user.Sigungu;
import lombok.Getter;
import lombok.Setter;
/**
*
* @author leebj
*/
@Getter
@Setter
public class OgdpSigungu extends Sigungu {
/**
*
*/
private String symbolFilepath;
/**
*
*/
private String symbolFilename;
/**
*
*/
private String logoFilepath;
/**
*
*/
private String logoFilename;
}

@ -1,466 +0,0 @@
package cokr.xit.applib.ogdp.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.applib.SQLUtil;
import cokr.xit.applib.ogdp.OgdpQuery;
import cokr.xit.applib.ogdp.OgdpSigungu;
import cokr.xit.foundation.component.AbstractMapper;
import cokr.xit.foundation.data.DataObject;
@Mapper("ogdpMapper")
public interface OgdpMapper extends AbstractMapper {
/** , .<br />
* @param
* @return ,
*/
@Select(SQLUtil.SCRIPT_START+"""
/* 전체 기관,부서 목록 조회(ogdpMapper.selectAllOgdpList) */
SELECT CONCAT(A.INST_CD,'/',B.DEPT_CD) AS OGDP_CD
, CONCAT(A.INST_NM,' / ',B.DEPT_NM) AS OGDP_NM
, A.INST_CD
, A.INST_NM
, B.DEPT_CD
, B.DEPT_NM
, A.SGG_CD
, A.SGG_NM
FROM TB_SGG A
LEFT OUTER JOIN TB_DEPT B ON (A.INST_CD = B.INST_CD)
UNION
SELECT ('default/default') AS OGDP_CD
, CONCAT(' ',' / ',' ') AS OGDP_NM
, 'default' AS INST_CD
, ' ' AS INST_NM
, 'default' AS DEPT_CD
, ' ' AS DEPT_NM
, 'default' AS SGG_CD
, ' ' AS SGG_NM
FROM DUAL
"""+SQLUtil.SCRIPT_END)
List<DataObject> selectAllOgdpList();
/** , .<br />
* @param stringMap
* @param
* @return ,
*/
@Select(SQLUtil.SCRIPT_START+"""
/* 사용가능한 기관,부서 목록 조회(ogdpMapper.selectAbleOgdpList) */
SELECT CONCAT(A.INST_CD,'/',B.DEPT_CD) AS OGDP_CD
, CONCAT(A.INST_NM,' / ',B.DEPT_NM) AS OGDP_NM
, A.INST_CD
, A.INST_NM
, B.DEPT_CD
, B.DEPT_NM
, A.SGG_CD
, A.SGG_NM
FROM TB_SGG A
LEFT OUTER JOIN TB_DEPT B ON (A.INST_CD = B.INST_CD)
<choose>
<when test='anonymous == "Y" '>
WHERE A.INST_CD = #{institute}
</when>
<otherwise>
<if test="currentUser.institute != 'default'">
WHERE A.SGG_CD = #{currentUser.user.orgID}
</if>
<if test="currentUser.institute == 'default'">
UNION
SELECT 'default/default' AS OGDP_CD
, CONCAT(' ',' / ',' ') AS OGDP_NM
, 'default' AS INST_CD
, ' ' AS INST_NM
, 'default' AS DEPT_CD
, ' ' AS DEPT_NM
, 'default' AS SGG_CD
, ' ' AS SGG_NM
FROM DUAL
</if>
</otherwise>
</choose>
"""+SQLUtil.SCRIPT_END)
List<DataObject> selectAbleOgdpList(Map<String, Object> params);
/** ,,,,, .<br />
* @param ID
* @return ,,,,,
*/
@Select(SQLUtil.SCRIPT_START+"""
/* 사용자의 시군구,기관,부서 조회(ogdpMapper.selectOgdpInfoOfUser) */
SELECT S.SGG_CD
, S.SGG_NM
, U.NSTT_CD AS INST_CD
, S.INST_NM
, U.DEPT_CD
, D.DEPT_NM
FROM TB_USER U
LEFT OUTER JOIN TB_SGG S ON (U.ORG_ID = S.SGG_CD)
LEFT OUTER JOIN TB_DEPT D ON (U.DEPT_CD = D.DEPT_CD)
WHERE U.USER_ID = #{userId}
"""+SQLUtil.SCRIPT_END)
DataObject selectOgdpInfoOfUser(String userId);
/** .<br />
* @param
* @return
*/
@Select(SQLUtil.SCRIPT_START+"""
/* 모든 기관 조회(ogdpMapper.selectAllInstList) */
SELECT INST_CD
, INST_NM
FROM TB_SGG
WHERE USE_YN = 'Y'
"""+SQLUtil.SCRIPT_END)
List<DataObject> selectAllInstList();
/** .<br />
* @param
* @return
*/
@Select(SQLUtil.SCRIPT_START+"""
/* 모든 시군구 조회(ogdpMapper.selectAllSggList) */
SELECT SGG_CD
, SGG_NM
FROM TB_SGG
WHERE USE_YN = 'Y'
"""+SQLUtil.SCRIPT_END)
List<DataObject> selectAllSggList();
/** .<br />
* @param deptCd
* @return
*/
@Select(SQLUtil.SCRIPT_START+"""
/* 부서에 따른 시군구코드 조회(ogdpMapper.selectSggCdByDeptCd) */
SELECT SGG_CD
FROM TB_DEPT
WHERE DEPT_CD = #{deptCd}
"""+SQLUtil.SCRIPT_END)
String selectSggCdByDeptCd(String deptCd);
/** .
* @param sgg
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
default boolean updateSgg(OgdpSigungu sgg) {
return sgg != null && updateSgg(params().set("sgg", sgg)) == 1;
}
/** .
* @param params
* <ul><li>"sgg" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
@Update(SQLUtil.SCRIPT_START+"""
/* 시군구 설정정보 수정 (ogdpMapper.updateSgg) */
UPDATE TB_SGG
SET MDFCN_DT =
"""
+SQLUtil.now
+"""
, MDFR = #{sgg.modifiedBy}
, INST_ZIP = #{sgg.instituteZipCode} <!-- -->
, INST_ADDR = #{sgg.instAddress} <!-- -->
, INST_DADDR = #{sgg.instDetailAddress} <!-- -->
<if test="sgg.symbolFilepath != null">
, SYMBOL_FILE_PATH = #{sgg.symbolFilepath} <!-- -->
, SYMBOL_FILE_NM = #{sgg.symbolFilename} <!-- -->
</if>
<if test="sgg.logoFilepath != null">
, LOGO_FILE_PATH = #{sgg.logoFilepath} <!-- -->
, LOGO_FILE_NM = #{sgg.logoFilename} <!-- -->
</if>
<if test="sgg.officialSealFilepath != null">
, OFFCS_FILE_PATH = #{sgg.officialSealFilepath} <!-- -->
, OFFCS_FILE_NM = #{sgg.officialSealFilename} <!-- -->
</if>
WHERE SGG_CD = #{sgg.sggID}
"""+SQLUtil.SCRIPT_END)
int updateSgg(Map<String, Object> params);
/** .
* @param req
* @return
*/
default DataObject selectSggInfo(OgdpQuery req) {
// 사용 여부 확인
if (req.getUseYn() == null) {
req.setUseYn("Y");
}
return selectSgg(req);
}
/** .
* @param req
* @return
*/
@SelectProvider(type=OgdpMapper.class, method="selectSggProvider")
DataObject selectSgg(OgdpQuery req);
public static String selectSggProvider() {
String comment = " /* 시군구 객체 가져오기(ogdpMapper.selectSggs) */ ";
String selectFrom = """
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
""";
String where = """
<where>
<if test="sggCd != null">
AND S.SGG_CD = #{sggCd} <!-- -->
</if>
<if test="useYn != null">
AND S.USE_YN = #{useYn} <!-- -->
</if>
</where>
""";
return SQLUtil.SCRIPT_START
+ comment
+ selectFrom + where
+ SQLUtil.SCRIPT_END;
}
/** .
* @param deptCds
* @return
*/
default int setStatus(String useYn, String... deptCds) {
DataObject params = params();
params.set("useYn", useYn);
params.set("deptCds", deptCds);
int effected = setStatus(params);
return effected;
}
/** .
* @param params
* <ul><li>"deptCds" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
@Update(SQLUtil.SCRIPT_START+"""
/* 부서 사용 여부 변경(ogdpMapper.setStatus) */
UPDATE TB_DEPT
SET USE_YN = #{useYn} <!-- -->
, MDFCN_DT =
"""
+SQLUtil.now
+"""
<!-- -->
, MDFR = #{currentUser.id} <!-- -->
WHERE DEPT_CD IN ( <foreach collection="deptCds" item="deptCd" separator=","> #{deptCd} </foreach> )<!-- -->
"""+SQLUtil.SCRIPT_END)
int setStatus(Map<String, ?> params);
@InsertProvider(type=OgdpMapper.class, method="insertDeptProvider")
int insertDept(Map<String, Object> params);
/** .
* @param params
* <ul><li>"dept" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
public static String insertDeptProvider(Map<String, Object> params) {
String comment = "/* 부서 등록(ogdpMapper.insertDept) */ ";
String insertInto = """
INSERT
INTO TB_DEPT (
DEPT_CD <!-- -->
, SGG_CD <!-- -->
, INST_CD <!-- -->
, DEPT_NM <!-- -->
, DEPT_TELNO <!-- -->
, DEPT_FXNO <!-- -->
, USE_YN <!-- -->
, REG_DT <!-- -->
, RGTR <!-- -->
, MDFCN_DT <!-- -->
, MDFR <!-- -->
""";
String values = """
) VALUES (
#{dept.deptID} <!-- -->
, #{dept.sggID} <!-- -->
, #{dept.instCode} <!-- -->
, #{dept.name} <!-- -->
, #{dept.telno} <!-- -->
, #{dept.faxno} <!-- -->
, 'Y' <!-- -->
,
"""
+SQLUtil.now
+"""
, #{dept.createdBy} <!-- -->
,
"""
+SQLUtil.now
+"""
, #{dept.modifiedBy} <!-- -->
""";
String close = ")";
String insertIntoAdd = params.get("insertIntoAdd") == null ? "" : (String)params.get("insertIntoAdd");
String valuesAdd = params.get("valuesAdd") == null ? "" : (String)params.get("valuesAdd");
return SQLUtil.SCRIPT_START
+ comment
+ insertInto + insertIntoAdd + values + valuesAdd + close
+ SQLUtil.SCRIPT_END;
}
@UpdateProvider(type=OgdpMapper.class, method="updateDeptProvider")
int updateDept(Map<String, Object> params);
public static String updateDeptProvider(Map<String, Object> params) {
String comment = "/* 부서 수정(ogdpMapper.updateDept) */ ";
String updateSet = """
UPDATE TB_DEPT
SET SGG_CD = #{dept.sggID} <!-- -->
, INST_CD = #{dept.instCode} <!-- -->
, DEPT_NM = #{dept.name} <!-- -->
, DEPT_TELNO = #{dept.telno} <!-- -->
, DEPT_FXNO = #{dept.faxno} <!-- -->
, MDFCN_DT =
"""
+SQLUtil.now
+"""
<!-- -->
, MDFR = #{dept.modifiedBy} <!-- -->
""";
String where = """
WHERE DEPT_CD = #{dept.deptID}
AND USE_YN = 'Y'
""";
String updateSetAdd = params.get("updateSetAdd") == null ? "" : (String)params.get("updateSetAdd");
return SQLUtil.SCRIPT_START
+ comment
+ updateSet + updateSetAdd + where
+ SQLUtil.SCRIPT_END;
}
@SelectProvider(type=OgdpMapper.class, method="selectDeptInfoProvider")
DataObject selectDeptInfo(OgdpQuery req);
public static String selectDeptInfoProvider(OgdpQuery req) {
String comment = "/* 부서 객체 가져오기(ogdpMapper.selectDeptInfo) */ ";
String selectFromWhere = selectDept(req);
return SQLUtil.SCRIPT_START
+ comment
+ selectFromWhere
+ SQLUtil.SCRIPT_END;
}
@SelectProvider(type=OgdpMapper.class, method="selectDeptListProvider")
List<DataObject> selectDeptList(OgdpQuery query);
public static String selectDeptListProvider(OgdpQuery req) {
String comment = "/* 부서 객체 목록 가져오기(ogdpMapper.selectDeptList) */ ";
String selectFromWhere = selectDept(req);
return SQLUtil.SCRIPT_START
+ comment
+ SQLUtil.pagingPrefix
+ selectFromWhere
+ SQLUtil.orderBy
+ SQLUtil.pagingSuffix
+ SQLUtil.SCRIPT_END;
}
public static String selectDept(OgdpQuery req) {
String select = """
SELECT D.DEPT_CD <!-- -->
, D.SGG_CD <!-- -->
, (SELECT SGG_NM FROM TB_SGG WHERE SGG_CD = D.SGG_CD) AS SGG_NM <!-- -->
, D.INST_CD <!-- -->
, (SELECT INST_NM FROM TB_SGG WHERE INST_CD = D.INST_CD) AS INST_NM <!-- -->
, D.DEPT_NM <!-- -->
, D.DEPT_TELNO <!-- -->
, D.DEPT_FXNO <!-- -->
, D.USE_YN <!-- -->
, (CASE D.USE_YN WHEN 'Y' THEN '' WHEN 'N' THEN '' ELSE '' END) AS USE_YN_NM <!-- -->
, D.REG_DT <!-- -->
, D.RGTR <!-- -->
, D.MDFCN_DT <!-- -->
, D.MDFR <!-- -->
""";
String fromWhere = """
FROM TB_DEPT D
<where>
<if test="sggCd != null">
AND D.SGG_CD = #{sggCd} <!-- -->
</if>
<if test="deptCd != null">
AND D.DEPT_CD = #{deptCd} <!-- -->
</if>
<if test="instCd != null">
AND D.INST_CD = #{instCd} <!-- -->
</if>
<if test="useYn != null">
AND D.USE_YN = #{useYn} <!-- -->
</if>
</where>
""";
return select + req.getSelectAdd() + fromWhere;
}
}

@ -1,133 +0,0 @@
package cokr.xit.applib.ogdp.service.bean;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import cokr.xit.applib.ogdp.OgdpQuery;
import cokr.xit.applib.ogdp.OgdpSigungu;
import cokr.xit.applib.ogdp.dao.OgdpMapper;
import cokr.xit.base.user.Department;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.component.AbstractBean;
import cokr.xit.foundation.data.DataObject;
public abstract class AbstractOgdpBean extends AbstractBean {
@Resource(name="ogdpMapper")
private OgdpMapper ogdpMapper;
public Object selectAllOgdpList() {
return ogdpMapper.selectAllOgdpList();
}
public List<DataObject> selectAbleOgdpList(DataObject params) {
return ogdpMapper.selectAbleOgdpList(params);
}
public List<DataObject> selectAllInstList() {
return ogdpMapper.selectAllInstList();
}
public List<DataObject> selectAllSggList(){
return ogdpMapper.selectAllSggList();
}
public DataObject selectOgdpInfoOfUser(String userId){
return ogdpMapper.selectOgdpInfoOfUser(userId);
}
public String selectSggCdByDeptCd(String deptCd) {
return ogdpMapper.selectSggCdByDeptCd(deptCd);
}
/**userInfo ,, .
* @param userInfo
* @return
*/
public void initUserInfo(UserInfo userInfo) {
DataObject ogdpInfo = ogdpMapper.selectOgdpInfoOfUser(userInfo.getId());
Map<String, Object> infoMap = userInfo.getInfo();
if(ogdpInfo == null) {
infoMap.put("sggCd", "");
infoMap.put("sggNm", "");
infoMap.put("instCd", "");
infoMap.put("instNm", "");
infoMap.put("deptCd", "");
infoMap.put("deptNm", "");
} else {
infoMap.put("sggCd", ogdpInfo.string("SGG_CD"));
infoMap.put("sggNm", ogdpInfo.string("SGG_NM"));
infoMap.put("instCd", ogdpInfo.string("INST_CD"));
infoMap.put("instNm", ogdpInfo.string("INST_NM"));
infoMap.put("deptCd", ogdpInfo.string("DEPT_CD"));
infoMap.put("deptNm", ogdpInfo.string("DEPT_NM"));
}
userInfo.setInfo(infoMap);
}
/** .
* @param sgg
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean updateSgg(OgdpSigungu sgg) {
return ogdpMapper.updateSgg(sgg);
}
/** .
* @param req
* @return
*/
public DataObject getSggInfo(OgdpQuery req) {
return ogdpMapper.selectSggInfo(req);
}
/** .
* @param deptCds
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean remove(String... deptCds) {
return ogdpMapper.setStatus("N", deptCds) > 0 ? true : false;
}
/** .
* @param req
* @return
*/
public abstract List<DataObject> getDeptList(OgdpQuery req);
/** .
* @param req
* @return
*/
public abstract DataObject getDeptInfo(OgdpQuery req);
/** .
* @param dept
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public abstract boolean createDept(Department dept);
/** .
* @param dept
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public abstract boolean updateDept(Department dept);
}

@ -1,63 +0,0 @@
package cokr.xit.applib.ogdp.service.bean;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cokr.xit.applib.ogdp.OgdpQuery;
import cokr.xit.applib.ogdp.dao.OgdpMapper;
import cokr.xit.base.user.Department;
import cokr.xit.foundation.data.DataObject;
@Component("defaultOgdpBean")
public class DefaultOgdpBean extends AbstractOgdpBean {
@Resource(name = "ogdpMapper")
private OgdpMapper ogdpMapper;
@Override
public List<DataObject> getDeptList(OgdpQuery query) {
// 기본 정렬
if (query.getOrderBy() == null) {
if(query.getFetchSize() > 0) {
query.setOrderBy("QBODY.DEPT_CD DESC");
} else {
query.setOrderBy("D.DEPT_CD DESC");
}
}
return ogdpMapper.selectDeptList(query);
}
@Override
public DataObject getDeptInfo(OgdpQuery query) {
return ogdpMapper.selectDeptInfo(query);
}
@Override
public boolean createDept(Department dept) {
boolean result = dept != null && ogdpMapper.insertDept(
new DataObject()
.set("currentUser", currentUser())
.set("dept", dept)) == 1;
return result;
}
@Override
public boolean updateDept(Department dept) {
boolean result = dept != null && ogdpMapper.updateDept(
new DataObject()
.set("currentUser", currentUser())
.set("dept", dept)) == 1;
return result;
}
}
Loading…
Cancel
Save