94 lines
3.3 KiB
XML
94 lines
3.3 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.faRpt.mapper.FaRptMapper">
|
|
<sql id="selectFaRptWhere">
|
|
<where>
|
|
a.status <> 'DST008'
|
|
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
|
|
and a.wrt_user_seq = #{wrtUserSeq}
|
|
</if>
|
|
<if test='receiveUserSeq != null and receiveUserSeq != ""'>
|
|
and a.fa_rpt_key in (select fa_rpt_key
|
|
from fa_rpt_read_user
|
|
where user_seq = #{receiveUserSeq})
|
|
</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='title != null and title != ""'>
|
|
and a.title like '%'||#{title}||'%'
|
|
</if>
|
|
<if test='startDate != null and startDate != ""'>
|
|
and a.wrt_dt >= #{startDate}::date
|
|
</if>
|
|
<if test='endDate != null and endDate != ""'>
|
|
and a.wrt_dt <= #{endDate}::date+1
|
|
</if>
|
|
<if test='status != null and status != ""'>
|
|
and a.status = #{status}
|
|
</if>
|
|
<if test='hashTags != null and hashTags != ""'>
|
|
and a.fa_rpt_key in (
|
|
select aa.fa_rpt_key
|
|
from hash_tag_link_fa_rpt aa
|
|
inner join hash_tag ab on aa.tag_key = ab.tag_key
|
|
where ab.tag_nm like '%'||#{hashTags}||'%'
|
|
)
|
|
</if>
|
|
<if test="downOrganCdList != null">
|
|
and a.wrt_organ in
|
|
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
|
|
#{organCd}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
<select id="selectFaRptList" resultType="FaRptBoard" parameterType="FaRptBoard">
|
|
select a.fa_rpt_key,
|
|
a.title,
|
|
a.fa_rpt_type,
|
|
a.status,
|
|
a.wrt_organ,
|
|
a.wrt_part,
|
|
a.wrt_user_nm,
|
|
a.wrt_user_grd,
|
|
a.wrt_user_seq,
|
|
a.wrt_dt,
|
|
b.fileCnt,
|
|
c.readCnt,
|
|
c.userCnt
|
|
from fa_rpt_board a
|
|
left outer join (select fa_rpt_key,
|
|
count(file_seq) as fileCnt
|
|
from fa_rpt_file
|
|
group by fa_rpt_key) b
|
|
on a.fa_rpt_key = b.fa_rpt_key
|
|
left outer join (select fa_rpt_key,
|
|
sum(case when read_yn='T' then 1 else 0 end) as readCnt,
|
|
count(*) as userCnt
|
|
from fa_rpt_read_user
|
|
group by fa_rpt_key) c
|
|
on a.fa_rpt_key = c.fa_rpt_key
|
|
<include refid="selectFaRptWhere"></include>
|
|
order by fa_rpt_key desc
|
|
limit #{rowCnt} offset #{firstIndex}
|
|
</select>
|
|
<select id="selectFaRptCnt" resultType="int" parameterType="FaRptBoard">
|
|
select count(*)
|
|
from fa_rpt_board a
|
|
<include refid="selectFaRptWhere"></include>
|
|
</select>
|
|
|
|
<select id="selectHashTags" resultType="string" parameterType="int">
|
|
select array_to_string(array_agg(b.tag_nm), ' ') as hashTags
|
|
from hash_tag_link_fa_rpt a
|
|
inner join hash_tag b on a.tag_key = b.tag_key
|
|
where a.fa_rpt_key = #{faRptKey}
|
|
</select>
|
|
</mapper> |