sql mapper 추가

master
mjkhan21 7 months ago
parent e56faa3cb3
commit 60a87e8d35

@ -0,0 +1,78 @@
<?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.base.security.access.dao.ActionGroupMapper">
<resultMap id="groupRow" type="cokr.xit.base.security.access.ActionGroup">
<result property="id" column="GRP_ID"/>
<result property="name" column="GRP_NM"/>
<result property="description" column="DSCRP"/>
<result property="createdAt" column="REG_DT"/>
</resultMap>
<sql id="selectGroups"><include refid="utility.paging-prefix" />
SELECT A.*
FROM TB_ACTION_GRP A
<where>
<if test="groupIDs != null">AND GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</if>
<if test="by != null and term != null">AND ${by} LIKE CONCAT('%', #{term}, '%')</if>
</where>
<include refid="utility.paging-suffix" /></sql>
<select id="getGroupList" parameterType="map" resultType="dataobject">/* 기능그룹 목록 조회(actionGroupMapper.getGroupList) */
<include refid="selectGroups" /></select>
<select id="getGroups" parameterType="map" resultMap="groupRow">/* 기능그룹 가져오기(actionGroupMapper.getGroups) */
<include refid="selectGroups" /></select>
<insert id="insertGroup" parameterType="cokr.xit.base.security.access.ActionGroup">/* 기능그룹 등록(actionGroupMapper.insertGroup) */
INSERT INTO TB_ACTION_GRP (
GRP_ID
, GRP_NM
, DSCRP
, REG_DT
) VALUES (
#{id}
, #{name}
, #{description}
,<include refid="utility.now" />
)</insert>
<update id="updateGroup" parameterType="cokr.xit.base.security.access.ActionGroup">/* 기능그룹 수정(actionGroupMapper.updateGroup) */
UPDATE TB_ACTION_GRP SET
GRP_NM = #{name}
, DSCRP = #{description}
WHERE GRP_ID = #{id}</update>
<delete id="removeGroups" parameterType="map">/* 기능그룹 삭제(actionGroupMapper.removeGroups) */
DELETE FROM TB_ACTION_GRP
WHERE GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</delete>
<select id="getActionList" parameterType="map" resultType="dataobject">/* 그룹별 기능 가져오기(actionGroupMapper.getActionList) */
SELECT *
FROM TB_GRP_ACTION
<if test="groupIDs != null">WHERE GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</if>
ORDER BY GRP_ID, ACTION
</select>
<insert id="addActions" parameterType="map">/* 그룹별 기능 추가(actionGroupMapper.addActions) */
INSERT INTO TB_GRP_ACTION (GRP_ID, ACTION, REG_DT, RGTR)
SELECT GRP_ID, ACTION,<include refid="utility.now" />, #{currentUser.id}
FROM (<foreach collection="actions" item="action" separator="UNION">
SELECT #{groupID} GRP_ID, #{action} ACTION FROM DUAL</foreach>
) 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
)</insert>
<delete id="removeActions" parameterType="map">/* 그룹별 기능 삭제(actionGroupMapper.removeActions) */
DELETE FROM TB_GRP_ACTION
<where>
<if test="groupIDs != null">AND GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</if>
<if test="actions != null">AND ACTION IN (<foreach collection="actions" item="action" separator=",">#{action}</foreach>)</if>
</where>
</delete>
</mapper>

@ -0,0 +1,154 @@
<?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.base.security.access.dao.AuthorityMapper">
<resultMap id="authRow" type="cokr.xit.base.security.Authority">
<result property="type" column="AUTH_TYPE"/>
<result property="id" column="AUTH_ID"/>
<result property="name" column="AUTH_NM"/>
<result property="infoScope" column="INF_SCP"/>
<result property="userInfoScope" column="USER_INF_SCP"/>
<result property="description" column="DSCRP"/>
<result property="createdAt" column="REG_DT"/>
</resultMap>
<sql id="selectAuthorities"><include refid="utility.paging-prefix" />
SELECT * FROM (
SELECT 0 AUTH_TYPE, 'ROLE_ADMIN' AUTH_ID, '시스템 관리자' AUTH_NM, '시스템 관리자' DSCRP, 'all' INF_SCP, 'all' USER_INF_SCP,<include refid="utility.now"/>REG_DT UNION
SELECT 1 AUTH_TYPE, 'ROLE_ANONYMOUS' AUTH_ID, '익명 사용자' AUTH_NM, '모든 사용자' DSCRP, 'none' INF_SCP, 'none' USER_INF_SCP,<include refid="utility.now"/>REG_DT UNION
SELECT 1 AUTH_TYPE, 'ROLE_USER' AUTH_ID, '시스템 사용자' AUTH_NM, '로그인한 사용자' DSCRP, 'self' INF_SCP, 'self' USER_INF_SCP,<include refid="utility.now"/>REG_DT UNION
SELECT 2 AUTH_TYPE, AUTH_ID, AUTH_NM, DSCRP, INF_SCP, USER_INF_SCP, REG_DT
FROM TB_AUTHORITY
) A
<where>
<if test="authIDs != null">AND AUTH_ID IN (<foreach collection="authIDs" item="authID" separator=",">#{authID}</foreach>)</if>
<if test="by != null and term != null">AND ${by} LIKE CONCAT('%', #{term}, '%')</if>
</where>
<include refid="utility.orderBy"/>
<include refid="utility.paging-suffix" /></sql>
<select id="getAuthorityList" parameterType="map" resultType="dataobject">/* 권한 목록 조회(authorityMapper.getAuthorityList) */
<include refid="selectAuthorities" /></select>
<select id="getAuthorities" parameterType="map" resultMap="authRow">/* 권한 가져오기(authorityMapper.getAuthorities) */
<include refid="selectAuthorities" /></select>
<insert id="insertAuthority" parameterType="cokr.xit.base.security.Authority">/* 권한 등록(authorityMapper.insertAuthority) */
INSERT INTO TB_AUTHORITY (
AUTH_ID
, AUTH_NM
, DSCRP
, INF_SCP
, USER_INF_SCP
, REG_DT
) VALUES (
#{id}
, #{name}
, #{description}
, #{infoScope}
, #{userInfoScope}
,<include refid="utility.now" />
)</insert>
<update id="updateAuthority" parameterType="cokr.xit.base.security.Authority">/* 권한 수정(authorityMapper.updateAuthority) */
UPDATE TB_AUTHORITY SET
AUTH_NM = #{name}
, DSCRP = #{description}
, INF_SCP = #{infoScope}
, USER_INF_SCP = #{userInfoScope}
WHERE AUTH_ID = #{id}</update>
<delete id="removeAuthorities" parameterType="map">/* 권한 삭제(authorityMapper.removeAuthorities) */
DELETE FROM TB_AUTHORITY
WHERE AUTH_ID IN (<foreach collection="authIDs" item="authID" separator=",">#{authID}</foreach>)</delete>
<select id="getActionGroupList" parameterType="map" resultType="dataobject">/* 권한-기능그룹 가져오기(authorityMapper.getActionGroups) */
<include refid="utility.paging-prefix" />
SELECT A.*
, (SELECT AG.GRP_NM FROM TB_ACTION_GRP AG WHERE AG.GRP_ID = A.GRP_ID) AS GRP_NM
FROM TB_AUTH_ACTION A
<if test="authIDs != null">WHERE AUTH_ID IN (<foreach collection="authIDs" item="authID" separator=",">#{authID}</foreach>)</if>
ORDER BY AUTH_ID, GRP_ID
<include refid="utility.paging-suffix" /></select>
<insert id="addActionGroups" parameterType="map">/* 권한-기능그룹 추가(authorityMapper.addActionGroups) */
INSERT INTO TB_AUTH_ACTION (AUTH_ID, GRP_ID, REG_DT)
SELECT AUTH_ID, GRP_ID,<include refid="utility.now" />
FROM (<foreach collection="groupIDs" item="groupID" separator=" UNION">
SELECT #{authID} AUTH_ID, #{groupID} GRP_ID FROM DUAL</foreach>
) 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
)</insert>
<delete id="removeActionGroups" parameterType="map">/* 권한-기능그룹 삭제(authorityMapper.removeActionGroups) */
DELETE FROM TB_AUTH_ACTION
<where>
<if test="authIDs != null">AND AUTH_ID IN (<foreach collection="authIDs" item="authID" separator=",">#{authID}</foreach>)</if>
<if test="groupIDs != null">AND GRP_ID IN (<foreach collection="groupIDs" item="groupID" separator=",">#{groupID}</foreach>)</if>
</where>
</delete>
<select id="getActionList" resultType="dataobject">/* 권한-기능 가져오기(authorityMapper.getActionList) */
SELECT A.AUTH_ID
, A.GRP_ID
, C.ACTION
FROM TB_AUTH_ACTION A
, TB_ACTION_GRP B
, TB_GRP_ACTION C
WHERE A.GRP_ID = B.GRP_ID
AND B.GRP_ID = C.GRP_ID
ORDER BY A.AUTH_ID, A.GRP_ID, C.ACTION</select>
<sql id="selectAuthUser">
<include refid="utility.paging-prefix" />
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
<where>
<if test="authIDs != null">AND AUTH_ID IN (<foreach collection="authIDs" item="authID" separator=",">#{authID}</foreach>)</if>
<if test="userIDs != null">AND A.USER_ID IN (<foreach collection="userIDs" item="userID" separator=",">#{userID}</foreach>)</if>
AND A.USER_ID = B.USER_ID
</where>
<include refid="utility.orderBy"/>
<include refid="utility.paging-suffix" /></sql>
<select id="getUserList" parameterType="map" resultType="dataobject">/* 권한-사용자 가져오기(authorityMapper.getUserList) */
<include refid="selectAuthUser" /></select>
<select id="getUserAuths" parameterType="map" resultType="dataobject">/* 사용자-권한 가져오기(authorityMapper.getUserAuths) */
<include refid="selectAuthUser" /></select>
<insert id="addUsers" parameterType="map">/* 권한-사용자 추가(authorityMapper.addUsers) */
INSERT INTO TB_AUTH_USER (AUTH_ID, USER_ID, REG_DT)
SELECT AUTH_ID, USER_ID,<include refid="utility.now" />
FROM (<foreach collection="userIDs" item="userID" separator="UNION">
SELECT #{authID} AUTH_ID, #{userID} USER_ID FROM DUAL</foreach>
) 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
)</insert>
<delete id="removeUsers" parameterType="map">/* 권한-사용자 삭제(authorityMapper.removeUsers) */
DELETE FROM TB_AUTH_USER
<where>
<if test="authIDs != null">AND AUTH_ID IN (<foreach collection="authIDs" item="authID" separator=",">#{authID}</foreach>)</if>
<if test="userIDs != null">AND USER_ID IN (<foreach collection="userIDs" item="userID" separator=",">#{userID}</foreach>)</if>
</where>
</delete>
</mapper>

@ -0,0 +1,70 @@
<?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.base.security.authentication.dao.PolicyMapper">
<resultMap id="policyRow" type="cokr.xit.base.security.authentication.AuthenticationPolicy">
<result property="userID" column="USER_ID"/>
<result property="ipAddress" column="IP_ADRS"/>
<result property="duplicateYN" column="DPLCT_YN"/>
<result property="limitYN" column="LIMIT_YN"/>
<result property="createdBy" column="RGTR"/>
<result property="createdAt" column="REG_DT"/>
<result property="modifiedBy" column="MDFR"/>
<result property="lastModified" column="MDFCN_DT"/>
</resultMap>
<select id="getPolicyList" parameterType="map" resultType="dataobject">/* 로그인 정책 목록 조회(policyMapper.getPolicyList) */
<include refid="utility.paging-prefix"/>
SELECT A.USER_ID
, USER_NM
, IP_ADRS
, DPLCT_YN
, LIMIT_YN
, MDFR
, MDFCN_DT
FROM TB_USER A LEFT OUTER JOIN TB_LOGIN_POLICY B ON A.USER_ID = B.USER_ID
<if test="term != null">WHERE A.${by} LIKE CONCAT('%', #{term}, '%')</if>
<include refid="utility.orderBy" />
<include refid="utility.paging-suffix"/></select>
<select id="getPolicies" parameterType="map" resultMap="policyRow">/* 로그인 정책 가져오기(policyMapper.getPolicies) */
SELECT *
FROM TB_LOGIN_POLICY
<if test="userIDs != null">WHERE USER_ID IN (<foreach collection="userIDs" item="userID" separator=",">#{userID}</foreach>)</if>
ORDER BY USER_ID</select>
<insert id="insertPolicy" parameterType="map">/* 로그인 정책 등록(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}
,<include refid="utility.now" />
, #{currentUser.id}
,<include refid="utility.now" />
, #{currentUser.id}
)</insert>
<update id="updatePolicy" parameterType="map">/* 로그인 정책 수정(policyMapper.updatePolicy) */
UPDATE TB_LOGIN_POLICY SET
IP_ADRS = #{policy.ipAddress}
, DPLCT_YN = #{policy.duplicateYN}
, LIMIT_YN = #{policy.limitYN}
, MDFR = #{currentUser.id}
, MDFCN_DT =<include refid="utility.now" />
WHERE USER_ID = #{policy.userID}</update>
<delete id="removePolicy" parameterType="map">/* 로그인 정책 삭제(policyMapper.removePolicy) */
DELETE FROM TB_LOGIN_POLICY
WHERE USER_ID IN (<foreach collection="userIDs" item="userID" separator=",">#{userID}</foreach>)</delete>
</mapper>

@ -0,0 +1,135 @@
<?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="program">
<resultMap id="programRow" type="cokr.xit.base.menu.Program">
<result property="filename" column="PGRM_FILE_NM"/>
<result property="location" column="PGRM_FILE_PATH"/>
<result property="name" column="PGRM_NM"/>
<result property="description" column="DSCRP"/>
<result property="url" column="URL"/>
</resultMap>
<resultMap id="reqRow" type="cokr.xit.base.menu.ChangeRequest">
<result property="filename" column="PGRM_FILE_NM"/>
<result property="id" column="REQ_ID"/>
<result property="subject" column="SUBJECT"/>
<result property="requestorID" column="REQ_USER"/>
<result property="requestDate" column="REQ_DT"/>
<result property="requestDetail" column="REQ_CNTNT"/>
<result property="processorID" column="PRSC_USER"/>
<result property="processDate" column="PRCS_DT"/>
<result property="processDetail" column="PRCS_CNTNT"/>
<result property="status" column="PRCS_STATUS"/>
</resultMap>
<sql id="selectPrograms">
<include refid="utility.paging-prefix"/>
SELECT A.*
FROM TB_PROGRAM A
<where>
<if test="by != null and term != null">${by} LIKE CONCAT('%', #{term}, '%')</if>
<if test='filenames != null'>PGRM_FILE_NM IN (<foreach collection="filenames" item="filename" separator=",">#{filename}</foreach>)</if>
</where>
ORDER BY<if test='by != null'>${by}</if><if test='by == null'>PGRM_FILE_NM</if>
<include refid="utility.paging-suffix"/></sql>
<select id="getProgramList" parameterType="map" resultType="dataobject">/* 프로그램 목록 조회(program.getProgramList) */
<include refid="selectPrograms"/></select>
<select id="getPrograms" parameterType="map" resultMap="programRow">/* 프로그램 가져오기(program.getPrograms) */
<include refid="selectPrograms"/></select>
<insert id="insertProgram" parameterType="cokr.xit.base.menu.Program">/* 프로그램 등록(program.insertProgram) */
INSERT INTO TB_PROGRAM (
PGRM_FILE_NM
, PGRM_FILE_PATH
, PGRM_NM
, DSCRP
, URL
) VALUES (
#{filename}
, #{location}
, #{name}
, #{description}
, #{url}
)</insert>
<update id="updateProgram" parameterType="cokr.xit.base.menu.Program">/* 프로그램 수정(program.updateProgram) */
UPDATE TB_PROGRAM SET
PGRM_FILE_PATH = #{location}
, PGRM_NM = #{name}
, DSCRP = #{description}
, URL = #{url}
WHERE PGRM_FILE_NM = #{filename}</update>
<delete id="removePrograms" parameterType="map">/* 프로그램 삭제(program.removePrograms) */
DELETE FROM TB_PROGRAM
WHERE PGRM_FILE_NM IN (<foreach collection="filenames" item="filename" separator=",">#{filename}</foreach>)</delete>
<delete id="clearPrograms" parameterType="map">/* 프로그램 비우기(program.clearPrograms) */
DELETE FROM TB_PROGRAM
WHERE PGRM_FILE_NM NOT IN (SELECT PGRM_FILE_NM FROM TB_MENU)</delete>
<sql id="selectRequests">
SELECT A.*
FROM TB_PGRM_CHNG_REQ A
<where>
<if test='fromReqDate != null'>REQ_DT >= #{fromReqDate}</if>
<if test='toReqDate != null'>REQ_DT &lt;= #{toReqDate}</if>
<if test="by != null and term != null">${by} LIKE CONCAT('%', #{term}, '%')</if>
<if test='filenames != null'>PGRM_FILE_NAME IN (<foreach collection="filenames" item="filename" separator=",">#{filename}</foreach>)</if>
<if test='reqIDs != null'>REQ_ID IN (<foreach collection="reqIDs" item="reqID" separator=",">#{reqID}</foreach>)</if>
</where>
ORDER BY PGRM_FILE_NM,<if test='by != null'>${by}</if><if test='by == null'>REQ_ID DESC</if></sql>
<select id="getRequestList" parameterType="map" resultType="dataobject">/* 변경요청 목록 조회(program.getRequestList) */
<include refid="selectRequests" /></select>
<select id="getRequests" parameterType="map" resultType="dataobject">/* 프로그램별 변경요청 목록 조회(program.getRequests) */
<include refid="selectRequests" /></select>
<insert id="insertRequest" parameterType="cokr.xit.base.menu.ChangeRequest">/* 프로그램 변경요청 등록(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}
)</insert>
<update id="updateRequest" parameterType="cokr.xit.base.menu.ChangeRequest">/* 프로그램 변경요청 수정(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}</update>
<update id="setRequestStatus" parameterType="map">/* 프로그램 변경요청 상태 변경(program.setRequestStatus) */
UPDATE TB_PGRM_CHNG_REQ SET
PRCS_STATUS = #{status}
WHERE PGRM_FILE_NM = #{filename}
AND REQ_ID = #{id}</update>
</mapper>
Loading…
Cancel
Save