guardia-esn/backend/src/main/resources/mapper/uiws/ScheduleMapper.xml
DESKTOP-TKLFCPR\ython f60cf93254 feat(uiws): UIWS 업무모듈(worklog·schedule·message·stats)+2FA 이식
- tb_uiws_* 9테이블 + esn_user 2FA 컬럼(91_uiws_port.sql)
- com.zioinfo.esn.uiws.* 백엔드 40 java + JwtFilter purpose=2fa 차단
- 프론트 업무화면+2FA+다크/라이트 테마
- 자동배포 인프라 구축(repos/guardia-esn)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 22:17:46 +09:00

169 lines
7.1 KiB
XML

<?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">
<!-- UIWS 이식: 일정/일지/첨부 (tb_uiws_schedule / tb_uiws_diary / tb_uiws_attach). -->
<mapper namespace="com.zioinfo.esn.uiws.schedule.mapper.ScheduleMapper">
<!-- ===================== schedule ===================== -->
<insert id="insertSchedule" useGeneratedKeys="true" keyProperty="scheduleId" keyColumn="schedule_id"
parameterType="com.zioinfo.esn.uiws.schedule.model.UiwsSchedule">
INSERT INTO tb_uiws_schedule
(sche_type, title, sche_gubun_cd, importance_cd, start_dt, end_dt, content,
owner_id, dept_id, charger_id, created_by, created_at)
VALUES
(#{scheType}, #{title}, #{scheGubunCd}, #{importanceCd}, #{startDt}, #{endDt}, #{content},
#{ownerId}, #{deptId}, #{chargerId}, #{createdBy}, #{createdAt})
</insert>
<update id="updateSchedule" parameterType="com.zioinfo.esn.uiws.schedule.model.UiwsSchedule">
UPDATE tb_uiws_schedule SET
sche_type = #{scheType}, title = #{title}, sche_gubun_cd = #{scheGubunCd},
importance_cd = #{importanceCd}, start_dt = #{startDt}, end_dt = #{endDt},
content = #{content}, dept_id = #{deptId}, charger_id = #{chargerId},
updated_by = #{updatedBy}, updated_at = #{updatedAt}
WHERE schedule_id = #{scheduleId}
</update>
<select id="findScheduleById" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsSchedule">
SELECT * FROM tb_uiws_schedule WHERE schedule_id = #{scheduleId}
</select>
<select id="existsScheduleById" resultType="boolean">
SELECT EXISTS(SELECT 1 FROM tb_uiws_schedule WHERE schedule_id = #{scheduleId})
</select>
<delete id="deleteScheduleById">
DELETE FROM tb_uiws_schedule WHERE schedule_id = #{scheduleId}
</delete>
<!-- 기간 겹침: start_dt &lt; to(배타 상한) AND end_dt &gt;= from -->
<select id="findInRange" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsSchedule">
SELECT * FROM tb_uiws_schedule
WHERE sche_type = #{scheType}
AND start_dt &lt; #{to}
AND end_dt &gt;= #{from}
<if test="ownerId != null">AND owner_id = #{ownerId}</if>
<if test="deptId != null">AND dept_id = #{deptId}</if>
ORDER BY start_dt ASC, schedule_id ASC
</select>
<sql id="allWhere">
WHERE start_dt &lt; #{to}
AND end_dt &gt;= #{from}
<if test="scheType != null">AND sche_type = #{scheType}</if>
<if test="!scopeAll">
AND owner_id IN
<foreach collection="ownerIds" item="oid" open="(" separator="," close=")">#{oid}</foreach>
</if>
</sql>
<select id="searchAll" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsSchedule">
SELECT * FROM tb_uiws_schedule
<include refid="allWhere"/>
ORDER BY start_dt DESC, schedule_id DESC
LIMIT #{limit} OFFSET #{offset}
</select>
<select id="countAll" resultType="long">
SELECT COUNT(*) FROM tb_uiws_schedule
<include refid="allWhere"/>
</select>
<select id="searchPopup" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsSchedule">
SELECT * FROM tb_uiws_schedule
WHERE 1=1
<if test="keyword != null">
AND (title LIKE '%' || #{keyword} || '%' OR content LIKE '%' || #{keyword} || '%')
</if>
<if test="!scopeAll">
AND owner_id IN
<foreach collection="ownerIds" item="oid" open="(" separator="," close=")">#{oid}</foreach>
</if>
ORDER BY start_dt DESC, schedule_id DESC
LIMIT 50
</select>
<!-- ===================== diary ===================== -->
<insert id="insertDiary" useGeneratedKeys="true" keyProperty="diaryId" keyColumn="diary_id"
parameterType="com.zioinfo.esn.uiws.schedule.model.UiwsDiary">
INSERT INTO tb_uiws_diary
(title, content, schedule_id, writer_id, diary_date, created_by, created_at)
VALUES
(#{title}, #{content}, #{scheduleId}, #{writerId}, #{diaryDate}, #{createdBy}, #{createdAt})
</insert>
<update id="updateDiary" parameterType="com.zioinfo.esn.uiws.schedule.model.UiwsDiary">
UPDATE tb_uiws_diary SET
title = #{title}, content = #{content}, schedule_id = #{scheduleId}, diary_date = #{diaryDate},
updated_by = #{updatedBy}, updated_at = #{updatedAt}
WHERE diary_id = #{diaryId}
</update>
<select id="findDiaryById" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsDiary">
SELECT * FROM tb_uiws_diary WHERE diary_id = #{diaryId}
</select>
<select id="existsDiaryById" resultType="boolean">
SELECT EXISTS(SELECT 1 FROM tb_uiws_diary WHERE diary_id = #{diaryId})
</select>
<delete id="deleteDiaryById">
DELETE FROM tb_uiws_diary WHERE diary_id = #{diaryId}
</delete>
<select id="searchDiary" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsDiary">
SELECT * FROM tb_uiws_diary
WHERE (diary_date IS NULL OR diary_date BETWEEN #{from} AND #{to})
ORDER BY COALESCE(diary_date, created_at::date) DESC, diary_id DESC
LIMIT #{limit} OFFSET #{offset}
</select>
<select id="countDiary" resultType="long">
SELECT COUNT(*) FROM tb_uiws_diary
WHERE (diary_date IS NULL OR diary_date BETWEEN #{from} AND #{to})
</select>
<!-- ===================== attach ===================== -->
<insert id="insertAttach" useGeneratedKeys="true" keyProperty="attachId" keyColumn="attach_id"
parameterType="com.zioinfo.esn.uiws.schedule.model.UiwsAttach">
INSERT INTO tb_uiws_attach
(ref_type, ref_id, file_nm, file_path, file_size, created_by, created_at)
VALUES
(#{refType}, #{refId}, #{fileNm}, #{filePath}, #{fileSize}, #{createdBy}, #{createdAt})
</insert>
<select id="findAttachById" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsAttach">
SELECT * FROM tb_uiws_attach WHERE attach_id = #{attachId}
</select>
<update id="updateAttachRef">
UPDATE tb_uiws_attach
SET ref_type = #{refType}, ref_id = #{refId}, updated_by = #{actor}, updated_at = now()
WHERE attach_id = #{attachId}
</update>
<select id="findAttachByRef" resultType="com.zioinfo.esn.uiws.schedule.model.UiwsAttach">
SELECT * FROM tb_uiws_attach
WHERE ref_type = #{refType} AND ref_id = #{refId}
ORDER BY attach_id ASC
</select>
<delete id="deleteAttachById">
DELETE FROM tb_uiws_attach WHERE attach_id = #{attachId}
</delete>
<delete id="deleteAttachByRef">
DELETE FROM tb_uiws_attach WHERE ref_type = #{refType} AND ref_id = #{refId}
</delete>
<!-- ===================== 사용자명 라벨 ===================== -->
<select id="findUserNames" resultType="map">
SELECT username AS "username", username AS "fullName"
FROM esn_user
WHERE username IN
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
</select>
</mapper>