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

81 lines
2.7 KiB
XML
Raw Normal View History

<?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.fpiMgt.sri.mapper.SriMapper">
<sql id="selectSriWhere">
<where>
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
and a.wrt_user_seq = #{wrtUserSeq}
</if>
<if test='receiveUserSeq != null and receiveUserSeq != ""'>
and a.fa_sri_key in (select fa_sri_key
from fa_sri_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 &lt;= #{endDate}::date+1
</if>
<if test='status != null and status != ""'>
and a.status = #{status}
</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="selectSriList" resultType="Sri" parameterType="Sri">
select a.fa_sri_key,
a.title,
a.fa_sri_type,
a.status,
a.fa_sri_edate,
a.wrt_organ,
a.wrt_part,
a.wrt_user_nm,
a.wrt_title,
a.wrt_user_seq,
a.wrt_dt,
b.fileCnt,
c.readCnt,
c.userCnt
from fa_sri_board a
left outer join (select fa_sri_key,
count(file_seq) as fileCnt
from fa_sri_file
group by fa_sri_key) b
on a.fa_sri_key = b.fa_sri_key
left outer join (select fa_sri_key,
count(read_yn='T') as readCnt,
count(*) as userCnt
from fa_sri_read_user
group by fa_sri_key) c
on a.fa_sri_key = c.fa_sri_key
<include refid="selectSriWhere"></include>
order by fa_sri_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectSriCnt" resultType="int" parameterType="Sri">
select count(*)
from fa_sri_board a
<include refid="selectSriWhere"></include>
</select>
</mapper>