From 60a87e8d3587312459386510e8bfc01b19e57517 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 18 Apr 2024 14:16:55 +0900 Subject: [PATCH] =?UTF-8?q?sql=20mapper=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sql/mapper/actiongroup-mapper.xml | 78 +++++++++ .../resources/sql/mapper/authority-mapper.xml | 154 ++++++++++++++++++ .../resources/sql/mapper/policy-mapper.xml | 70 ++++++++ src/main/resources/sql/mapper/program.xml | 135 +++++++++++++++ 4 files changed, 437 insertions(+) create mode 100644 src/main/resources/sql/mapper/actiongroup-mapper.xml create mode 100644 src/main/resources/sql/mapper/authority-mapper.xml create mode 100644 src/main/resources/sql/mapper/policy-mapper.xml create mode 100644 src/main/resources/sql/mapper/program.xml diff --git a/src/main/resources/sql/mapper/actiongroup-mapper.xml b/src/main/resources/sql/mapper/actiongroup-mapper.xml new file mode 100644 index 0000000..f42bb2e --- /dev/null +++ b/src/main/resources/sql/mapper/actiongroup-mapper.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + +SELECT A.* + FROM TB_ACTION_GRP A + +AND GRP_ID IN (#{groupID}) +AND ${by} LIKE CONCAT('%', #{term}, '%') + + + + + + + +/* 기능그룹 등록(actionGroupMapper.insertGroup) */ +INSERT INTO TB_ACTION_GRP ( + GRP_ID + , GRP_NM + , DSCRP + , REG_DT +) VALUES ( + #{id} + , #{name} + , #{description} + , +) + +/* 기능그룹 수정(actionGroupMapper.updateGroup) */ +UPDATE TB_ACTION_GRP SET + GRP_NM = #{name} + , DSCRP = #{description} + WHERE GRP_ID = #{id} + +/* 기능그룹 삭제(actionGroupMapper.removeGroups) */ +DELETE FROM TB_ACTION_GRP + WHERE GRP_ID IN (#{groupID}) + + + +/* 그룹별 기능 추가(actionGroupMapper.addActions) */ +INSERT INTO TB_GRP_ACTION (GRP_ID, ACTION, REG_DT, RGTR) +SELECT GRP_ID, ACTION,, #{currentUser.id} + FROM ( + SELECT #{groupID} GRP_ID, #{action} ACTION FROM DUAL + ) A + WHERE NOT EXISTS ( + SELECT GRP_ID, ACTION + FROM TB_GRP_ACTION B + WHERE B.GRP_ID = A.GRP_ID + AND B.ACTION = A.ACTION + ) + +/* 그룹별 기능 삭제(actionGroupMapper.removeActions) */ +DELETE FROM TB_GRP_ACTION + +AND GRP_ID IN (#{groupID}) +AND ACTION IN (#{action}) + + + + \ No newline at end of file diff --git a/src/main/resources/sql/mapper/authority-mapper.xml b/src/main/resources/sql/mapper/authority-mapper.xml new file mode 100644 index 0000000..94f295c --- /dev/null +++ b/src/main/resources/sql/mapper/authority-mapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + +SELECT * FROM ( + SELECT 0 AUTH_TYPE, 'ROLE_ADMIN' AUTH_ID, '시스템 관리자' AUTH_NM, '시스템 관리자' DSCRP, 'all' INF_SCP, 'all' USER_INF_SCP,REG_DT UNION + SELECT 1 AUTH_TYPE, 'ROLE_ANONYMOUS' AUTH_ID, '익명 사용자' AUTH_NM, '모든 사용자' DSCRP, 'none' INF_SCP, 'none' USER_INF_SCP,REG_DT UNION + SELECT 1 AUTH_TYPE, 'ROLE_USER' AUTH_ID, '시스템 사용자' AUTH_NM, '로그인한 사용자' DSCRP, 'self' INF_SCP, 'self' USER_INF_SCP,REG_DT UNION + SELECT 2 AUTH_TYPE, AUTH_ID, AUTH_NM, DSCRP, INF_SCP, USER_INF_SCP, REG_DT + FROM TB_AUTHORITY +) A + +AND AUTH_ID IN (#{authID}) +AND ${by} LIKE CONCAT('%', #{term}, '%') + + + + + + + + +/* 권한 등록(authorityMapper.insertAuthority) */ +INSERT INTO TB_AUTHORITY ( + AUTH_ID + , AUTH_NM + , DSCRP + , INF_SCP + , USER_INF_SCP + , REG_DT +) VALUES ( + #{id} + , #{name} + , #{description} + , #{infoScope} + , #{userInfoScope} + , +) + +/* 권한 수정(authorityMapper.updateAuthority) */ +UPDATE TB_AUTHORITY SET + AUTH_NM = #{name} + , DSCRP = #{description} + , INF_SCP = #{infoScope} + , USER_INF_SCP = #{userInfoScope} + WHERE AUTH_ID = #{id} + +/* 권한 삭제(authorityMapper.removeAuthorities) */ +DELETE FROM TB_AUTHORITY + WHERE AUTH_ID IN (#{authID}) + + + +/* 권한-기능그룹 추가(authorityMapper.addActionGroups) */ +INSERT INTO TB_AUTH_ACTION (AUTH_ID, GRP_ID, REG_DT) +SELECT AUTH_ID, GRP_ID, + FROM ( + SELECT #{authID} AUTH_ID, #{groupID} GRP_ID FROM DUAL + ) A + WHERE NOT EXISTS ( + SELECT AUTH_ID, GRP_ID + FROM TB_AUTH_ACTION B + WHERE B.AUTH_ID = A.AUTH_ID + AND B.GRP_ID = A.GRP_ID + ) + +/* 권한-기능그룹 삭제(authorityMapper.removeActionGroups) */ +DELETE FROM TB_AUTH_ACTION + +AND AUTH_ID IN (#{authID}) +AND GRP_ID IN (#{groupID}) + + + + + + + +SELECT A.* + , B.USER_ACNT + , B.USER_NM + , B.ORG_ID + , (SELECT SGG_NM FROM TB_SGG WHERE SGG_CD = B.ORG_ID) AS SGG_NM + , B.NSTT_CD + , (SELECT INST_NM FROM TB_SGG WHERE SGG_CD = B.ORG_ID) AS NSTT_NM + , B.DEPT_CD + , (SELECT DEPT_NM FROM TB_DEPT WHERE DEPT_CD = B.DEPT_CD) AS DEPT_NM + FROM TB_AUTH_USER A + , TB_USER B + +AND AUTH_ID IN (#{authID}) +AND A.USER_ID IN (#{userID}) + AND A.USER_ID = B.USER_ID + + + + + + + + +/* 권한-사용자 추가(authorityMapper.addUsers) */ +INSERT INTO TB_AUTH_USER (AUTH_ID, USER_ID, REG_DT) +SELECT AUTH_ID, USER_ID, + FROM ( + SELECT #{authID} AUTH_ID, #{userID} USER_ID FROM DUAL + ) A + WHERE NOT EXISTS ( + SELECT AUTH_ID, USER_ID + FROM TB_AUTH_USER B + WHERE B.AUTH_ID = A.AUTH_ID + AND B.USER_ID = A.USER_ID + ) + +/* 권한-사용자 삭제(authorityMapper.removeUsers) */ +DELETE FROM TB_AUTH_USER + +AND AUTH_ID IN (#{authID}) +AND USER_ID IN (#{userID}) + + + + \ No newline at end of file diff --git a/src/main/resources/sql/mapper/policy-mapper.xml b/src/main/resources/sql/mapper/policy-mapper.xml new file mode 100644 index 0000000..ad69238 --- /dev/null +++ b/src/main/resources/sql/mapper/policy-mapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + +/* 로그인 정책 등록(policyMapper.insertPolicy) */ +INSERT INTO TB_LOGIN_POLICY ( + USER_ID + , IP_ADRS + , DPLCT_YN + , LIMIT_YN + , REG_DT + , RGTR + , MDFCN_DT + , MDFR +) VALUES ( + #{policy.userID} + , #{policy.ipAddress} + , #{policy.duplicateYN} + , #{policy.limitYN} + , + , #{currentUser.id} + , + , #{currentUser.id} +) + +/* 로그인 정책 수정(policyMapper.updatePolicy) */ +UPDATE TB_LOGIN_POLICY SET + IP_ADRS = #{policy.ipAddress} + , DPLCT_YN = #{policy.duplicateYN} + , LIMIT_YN = #{policy.limitYN} + , MDFR = #{currentUser.id} + , MDFCN_DT = +WHERE USER_ID = #{policy.userID} + +/* 로그인 정책 삭제(policyMapper.removePolicy) */ +DELETE FROM TB_LOGIN_POLICY + WHERE USER_ID IN (#{userID}) + + \ No newline at end of file diff --git a/src/main/resources/sql/mapper/program.xml b/src/main/resources/sql/mapper/program.xml new file mode 100644 index 0000000..dbcfd76 --- /dev/null +++ b/src/main/resources/sql/mapper/program.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +SELECT A.* + FROM TB_PROGRAM A + +${by} LIKE CONCAT('%', #{term}, '%') +PGRM_FILE_NM IN (#{filename}) + + ORDER BY${by}PGRM_FILE_NM + + + + + + +/* 프로그램 등록(program.insertProgram) */ +INSERT INTO TB_PROGRAM ( + PGRM_FILE_NM + , PGRM_FILE_PATH + , PGRM_NM + , DSCRP + , URL +) VALUES ( + #{filename} + , #{location} + , #{name} + , #{description} + , #{url} +) + +/* 프로그램 수정(program.updateProgram) */ +UPDATE TB_PROGRAM SET + PGRM_FILE_PATH = #{location} + , PGRM_NM = #{name} + , DSCRP = #{description} + , URL = #{url} +WHERE PGRM_FILE_NM = #{filename} + +/* 프로그램 삭제(program.removePrograms) */ +DELETE FROM TB_PROGRAM + WHERE PGRM_FILE_NM IN (#{filename}) + +/* 프로그램 비우기(program.clearPrograms) */ +DELETE FROM TB_PROGRAM + WHERE PGRM_FILE_NM NOT IN (SELECT PGRM_FILE_NM FROM TB_MENU) + + +SELECT A.* + FROM TB_PGRM_CHNG_REQ A + +REQ_DT >= #{fromReqDate} +REQ_DT <= #{toReqDate} +${by} LIKE CONCAT('%', #{term}, '%') +PGRM_FILE_NAME IN (#{filename}) +REQ_ID IN (#{reqID}) + + ORDER BY PGRM_FILE_NM,${by}REQ_ID DESC + + + + + +/* 프로그램 변경요청 등록(program.insertRequest) */ +INSERT INTO TB_PGRM_CHNG_REQ ( + PGRM_FILE_NM + , REQ_ID + , SUBJECT + , REQ_USER + , REQ_DT + , REQ_CNTNT + , PRSC_USER + , PRCS_DT + , PRCS_CNTNT + , PRCS_STATUS +) VALUES ( + #{filename} + , #{id} + , #{subject} + , #{requestorID} + , #{requestDate} + , #{requestDetail} + , #{processorID} + , #{processDate} + , #{processDetail} + , #{status} +) + +/* 프로그램 변경요청 수정(program.updateRequest) */ +UPDATE TB_PGRM_CHNG_REQ SET + SUBJECT = #{subject} + , REQ_USER = #{requestorID} + , REQ_DT = #{requestDate} + , REQ_CNTNT = #{requestDetail} + , PRSC_USER = #{processorID} + , PRCS_DT = #{processDate} + , PRCS_CNTNT = #{processDetail} +WHERE PGRM_FILE_NM = #{filename} +AND REQ_ID = #{id} + +/* 프로그램 변경요청 상태 변경(program.setRequestStatus) */ +UPDATE TB_PGRM_CHNG_REQ SET + PRCS_STATUS = #{status} + WHERE PGRM_FILE_NM = #{filename} + AND REQ_ID = #{id} + + \ No newline at end of file