From 02ede42ebf95871600e89d4357ec1dd2a408dec3 Mon Sep 17 00:00:00 2001 From: leebj Date: Tue, 11 Jun 2024 10:49:04 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=9C=EA=B5=B0=EA=B5=AC,=EB=B6=80=EC=84=9C?= =?UTF-8?q?=20bean=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cokr/xit/applib/SQLUtil.java | 39 ++ .../java/cokr/xit/applib/ogdp/OgdpQuery.java | 70 +++ .../cokr/xit/applib/ogdp/OgdpSigungu.java | 36 ++ .../cokr/xit/applib/ogdp/dao/OgdpMapper.java | 466 ++++++++++++++++++ .../ogdp/service/bean/AbstractOgdpBean.java | 133 +++++ .../ogdp/service/bean/DefaultOgdpBean.java | 63 +++ 6 files changed, 807 insertions(+) create mode 100644 src/main/java/cokr/xit/applib/SQLUtil.java create mode 100644 src/main/java/cokr/xit/applib/ogdp/OgdpQuery.java create mode 100644 src/main/java/cokr/xit/applib/ogdp/OgdpSigungu.java create mode 100644 src/main/java/cokr/xit/applib/ogdp/dao/OgdpMapper.java create mode 100644 src/main/java/cokr/xit/applib/ogdp/service/bean/AbstractOgdpBean.java create mode 100644 src/main/java/cokr/xit/applib/ogdp/service/bean/DefaultOgdpBean.java diff --git a/src/main/java/cokr/xit/applib/SQLUtil.java b/src/main/java/cokr/xit/applib/SQLUtil.java new file mode 100644 index 0000000..352849c --- /dev/null +++ b/src/main/java/cokr/xit/applib/SQLUtil.java @@ -0,0 +1,39 @@ +package cokr.xit.applib; + +public class SQLUtil { + + public static final String SCRIPT_START = ""; + + public static final String now = """ + DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s') + TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISS') + """; + + public static final String sortBy = """ + ORDER BY ${orderBy} + """; + + public static final String orderBy = """ + """ + +sortBy+""" + """; + + public static final String pagingPrefix = """ + + SELECT QROWS.* + FROM ( + SELECT ROW_NUMBER() OVER(""" + +sortBy+""" + ) ROW_NUM + , COUNT(*) OVER() TOT_CNT + , QBODY.* + FROM ( + """; + + public static final String pagingSuffix = """ + ) QBODY + ) QROWS + WHERE ROW_NUM BETWEEN ((#{pageNum} - 1) * #{fetchSize}) + 1 AND (#{pageNum} * #{fetchSize}) + """; +} diff --git a/src/main/java/cokr/xit/applib/ogdp/OgdpQuery.java b/src/main/java/cokr/xit/applib/ogdp/OgdpQuery.java new file mode 100644 index 0000000..eaff449 --- /dev/null +++ b/src/main/java/cokr/xit/applib/ogdp/OgdpQuery.java @@ -0,0 +1,70 @@ +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 setSggCd(String sggCd) { + this.sggCd = sggCd; + return self(); + } + + public String getDeptCd() { + return ifEmpty(deptCd, () -> null); + } + + public T setDeptCd(String deptCd) { + this.deptCd = deptCd; + return self(); + } + + public String getInstCd() { + return ifEmpty(instCd, () -> null); + } + + public T setInstCd(String instCd) { + this.instCd = instCd; + return self(); + } + + public String getUseYn() { + return ifEmpty(useYn, () -> null); + } + + public T setUseYn(String useYn) { + this.useYn = useYn; + return self(); + } + + public String getDelYn() { + return ifEmpty(delYn, () -> null); + } + + public T setDelYn(String delYn) { + this.delYn = delYn; + return self(); + } + + public String getSelectAdd() { + return ifEmpty(selectAdd, () -> null); + } + + public T setSelectAdd(String selectAdd) { + this.selectAdd = selectAdd; + return self(); + } +} diff --git a/src/main/java/cokr/xit/applib/ogdp/OgdpSigungu.java b/src/main/java/cokr/xit/applib/ogdp/OgdpSigungu.java new file mode 100644 index 0000000..397b03c --- /dev/null +++ b/src/main/java/cokr/xit/applib/ogdp/OgdpSigungu.java @@ -0,0 +1,36 @@ +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; + + +} diff --git a/src/main/java/cokr/xit/applib/ogdp/dao/OgdpMapper.java b/src/main/java/cokr/xit/applib/ogdp/dao/OgdpMapper.java new file mode 100644 index 0000000..4697a34 --- /dev/null +++ b/src/main/java/cokr/xit/applib/ogdp/dao/OgdpMapper.java @@ -0,0 +1,466 @@ +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 { + + /**모든 기관,부서 목록을 반환한다.
+ * @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 selectAllOgdpList(); + + /**사용가능한 기관,부서 목록을 반환한다.
+ * @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) + + + WHERE A.INST_CD = #{institute} + + + + WHERE A.SGG_CD = #{currentUser.user.orgID} + + + 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 selectAbleOgdpList(Map params); + + + + /**사용자의 시군구코드,시군구명,기관코드,기관명,부서코드,부서명을 반환한다.
+ * @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); + + + /**모든 기관 목록을 반환한다.
+ * @param + * @return 기관 목록 + */ + @Select(SQLUtil.SCRIPT_START+""" + /* 모든 기관 조회(ogdpMapper.selectAllInstList) */ + SELECT INST_CD + , INST_NM + FROM TB_SGG + WHERE USE_YN = 'Y' + """+SQLUtil.SCRIPT_END) + List selectAllInstList(); + + /**모든 시군구 목록을 반환한다.
+ * @param + * @return 시군구 목록 + */ + @Select(SQLUtil.SCRIPT_START+""" + /* 모든 시군구 조회(ogdpMapper.selectAllSggList) */ + SELECT SGG_CD + , SGG_NM + FROM TB_SGG + WHERE USE_YN = 'Y' + """+SQLUtil.SCRIPT_END) + List selectAllSggList(); + + /**부서코드에 매칭되는 시군구코드를 반환한다.
+ * @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 저장 여부 + *
  • 저장됐으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + default boolean updateSgg(OgdpSigungu sgg) { + return sgg != null && updateSgg(params().set("sgg", sgg)) == 1; + } + + /**시군구 정보를 수정한다. + * @param params 파라미터 + *
  • "sgg" - 시군구 정보
  • + *
  • "currentUser" - 현재 접속한 사용자
  • + *
+ * @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} + + , SYMBOL_FILE_PATH = #{sgg.symbolFilepath} + , SYMBOL_FILE_NM = #{sgg.symbolFilename} + + + , LOGO_FILE_PATH = #{sgg.logoFilepath} + , LOGO_FILE_NM = #{sgg.logoFilename} + + + , OFFCS_FILE_PATH = #{sgg.officialSealFilepath} + , OFFCS_FILE_NM = #{sgg.officialSealFilename} + + WHERE SGG_CD = #{sgg.sggID} + """+SQLUtil.SCRIPT_END) + int updateSgg(Map 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.selectSgg) */ "; + + 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 = """ + + + AND S.SGG_CD = #{sggCd} + + + AND S.USE_YN = #{useYn} + + + """; + + 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 파라미터 + *
  • "deptCds" - 부서 코드 목록
  • + *
  • "currentUser" - 현재 접속한 사용자
  • + *
+ * @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 ( #{deptCd} ) + """+SQLUtil.SCRIPT_END) + int setStatus(Map params); + + + @InsertProvider(type=OgdpMapper.class, method="insertDeptProvider") + int insertDept(Map params); + + /**부서 정보를 등록한다. + * @param params 파라미터 + *
  • "dept" - 부서 정보
  • + *
  • "currentUser" - 현재 접속한 사용자
  • + *
+ * @return 저장된 정보수 + */ + public static String insertDeptProvider(Map 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 params); + + + public static String updateDeptProvider(Map 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 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 + + + AND D.SGG_CD = #{sggCd} + + + AND D.DEPT_CD = #{deptCd} + + + AND D.INST_CD = #{instCd} + + + AND D.USE_YN = #{useYn} + + + """; + return select + req.getSelectAdd() + fromWhere; + } +} diff --git a/src/main/java/cokr/xit/applib/ogdp/service/bean/AbstractOgdpBean.java b/src/main/java/cokr/xit/applib/ogdp/service/bean/AbstractOgdpBean.java new file mode 100644 index 0000000..a15c3a7 --- /dev/null +++ b/src/main/java/cokr/xit/applib/ogdp/service/bean/AbstractOgdpBean.java @@ -0,0 +1,133 @@ +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 selectAbleOgdpList(DataObject params) { + return ogdpMapper.selectAbleOgdpList(params); + } + + public List selectAllInstList() { + return ogdpMapper.selectAllInstList(); + } + + public List 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 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 저장 여부 + *
  • 저장됐으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + public boolean updateSgg(OgdpSigungu sgg) { + return ogdpMapper.updateSgg(sgg); + } + + /**지정한 조건에 따라 시군구 객체를 반환한다. + * @param req 시군구 조회 조건 + * @return 시군구 객체 + */ + public DataObject getSggInfo(OgdpQuery req) { + return ogdpMapper.selectSggInfo(req); + } + + /**부서 정보를 삭제한다. + * @param deptCds 부서 코드 목록 + * @return 저장 여부 + *
  • 저장됐으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + public boolean remove(String... deptCds) { + return ogdpMapper.setStatus("N", deptCds) > 0 ? true : false; + } + + + /**지정한 조건에 따라 부서 목록을 조회하여 반환한다. + * @param req 부서 정보 조회 조건 + * @return 부서 목록 + */ + public abstract List getDeptList(OgdpQuery req); + + /**지정한 조건에 따라 부서 객체를 반환한다. + * @param req 부서 조회 조건 + * @return 부서 객체 + */ + public abstract DataObject getDeptInfo(OgdpQuery req); + + /**부서 정보를 등록한다. + * @param dept 부서 + * @return 저장 여부 + *
  • 저장됐으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + public abstract boolean createDept(Department dept); + + /**부서 정보를 수정한다. + * @param dept 부서 + * @return 저장 여부 + *
  • 저장됐으면 true
  • + *
  • 그렇지 않으면 false
  • + *
+ */ + public abstract boolean updateDept(Department dept); +} diff --git a/src/main/java/cokr/xit/applib/ogdp/service/bean/DefaultOgdpBean.java b/src/main/java/cokr/xit/applib/ogdp/service/bean/DefaultOgdpBean.java new file mode 100644 index 0000000..bb2df00 --- /dev/null +++ b/src/main/java/cokr/xit/applib/ogdp/service/bean/DefaultOgdpBean.java @@ -0,0 +1,63 @@ +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 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; + } + + +}