FAISP/src/main/resources/mybatisMapper/InvestigationBoardMapper.xml

111 lines
3.6 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">
<mapper namespace="com.dbnt.faisp.main.ivsgtMgt.boardInvestigation.mapper.InvestigationBoardMapper">
<sql id="selectInvestigationBoardListWhere">
<where>
<if test='downOrganCdList != null'>
and a.wrt_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</if>
<if test='ivsgtType != null and ivsgtType != ""'>
AND a.ivsgt_type = #{ivsgtType}
</if>
<if test='wrtUserNm != null and wrtUserNm != ""'>
AND a.wrt_user_nm LIKE '%'||#{wrtUserNm}||'%'
</if>
<if test='wrtOrgan != null and wrtOrgan != ""'>
AND a.wrt_organ = #{wrtOrgan}
</if>
<if test='wrtPart != null and wrtPart != ""'>
AND a.wrt_part = #{wrtPart}
</if>
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
AND a.wrt_user_seq = #{wrtUserSeq}
</if>
<if test='title != null and title != ""'>
AND a.title LIKE '%'||#{title}||'%'
</if>
<if test='arrestCd != null and arrestCd != ""'>
AND a.arrest_cd = #{arrestCd}
</if>
<if test='arrestCd2 != null and arrestCd2 != ""'>
AND a.arrest_cd2 = #{arrestCd2}
</if>
<if test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
And a.wrt_dt >= #{startDate}::DATE
</if>
<if test='endDate != null and endDate != ""'>
AND a.wrt_dt &lt;= #{endDate}::DATE+1
</if>
</if>
</where>
</sql>
<select id="selectInvestigationBoardList" resultType="InvestigationBoard" parameterType="InvestigationBoard">
SELECT
a.ivsgt_key,
a.ivsgt_type,
a.arrest_cd,
a.arrest_cd2,
a.title,
a.content,
a.status,
a.wrt_organ,
a.wrt_part,
a.wrt_user_grd,
a.wrt_user_seq,
a.wrt_user_nm,
a.wrt_dt,
b.fileCnt
FROM investigation_board a
LEFT OUTER JOIN (
SELECT
ivsgt_key,
count(file_seq) AS fileCnt
FROM investigation_file
GROUP BY ivsgt_key
) b ON a.ivsgt_key = b.ivsgt_key
<include refid="selectInvestigationBoardListWhere"></include>
ORDER BY ivsgt_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
</select>
<select id="selectInvestigationBoardListCnt" resultType="int" parameterType="InvestigationBoard">
SELECT count(*)
FROM investigation_board a
LEFT OUTER JOIN (
SELECT
ivsgt_key,
count(file_seq) AS fileCnt
FROM investigation_file
GROUP BY ivsgt_key
) b
ON a.ivsgt_key = b.ivsgt_key
<include refid="selectInvestigationBoardListWhere"></include>
</select>
<select id="selectHashTags" resultType="string" parameterType="int">
SELECT array_to_string(array_agg(b.tag_nm), ' ') AS hashTags
FROM hash_tag_link_ivsgt a
INNER JOIN hash_tag b ON a.tag_key = b.tag_key
WHERE a.ivsgt_key = #{ivsgtKey}
</select>
<select id="selectRelatedReportsList" resultType="InvestigationRelatedReports" parameterType="int">
SELECT
a.related_reports_key,
a.child_ivsgt_key,
a.parent_ivsgt_key,
i.content_title
FROM investigation_related_reports a
INNER JOIN investigation_board i
ON i.ivsgt_key = a.child_ivsgt_key
WHERE a.parent_ivsgt_key = #{ivsgtKey}
</select>
</mapper>