@ -2,6 +2,129 @@
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace= "com.backoffice.m.bf_board" >
<select id= "select_list_bf_board" resultClass= "dataMap" parameterClass= "dataMap" >
SELECT
x.*
FROM (
<isNotEqual property= "bd_tp" compareValue= "BF_CT_TP_5" >
SELECT
x.bd_no
,x.bd_tp
,x.title
,x.content
,x.hashtag
,x.member_id
,z.title as bd_tp_nm
,IFNULL(star,0) as star
,IFNULL(h_nt ,0) as h_nt
,(select count(*)
from tbl_bf_board_like tbl
where tbl.bd_no = x.bd_no ) as l_nt
,(select count(*)
from tbl_bf_board_comment tbc
where tbc.bd_no = x.bd_no ) as c_nt
,DATE_FORMAT(x.reg_dt,'%H:%i') reg_tm
,tbv.v_content
,x.thumbnail
,m.profile_path
,m.name
,m.nickname
,tmf.mt_file_seq
,tmf.mt_file_local_url
,ROW_NUMBER() OVER (ORDER BY x.reg_dt desc, x.h_nt desc, x.bd_no desc) AS row_num
FROM tbl_bf_board x
LEFT JOIN tbl_code_item z
on x.bd_tp = z.val_1 and cg_cd ='BF_COMMUNITY_TP'
LEFT JOIN (select bd_no, group_concat(concat (v_content, '♭⊙♭', nvl(v_nt, 0)) separator '♭§♭') v_content
from tbl_bf_board_vote group by bd_no) tbv ON tbv.bd_no = x.bd_no
LEFT JOIN tbl_member m ON m.member_id = x.member_id
LEFT JOIN tbl_bf_board_attach tba ON tba.bd_no = x.bd_no
and tba.file_seq = (
SELECT file_seq
FROM tbl_bf_board_attach fa
WHERE fa.bd_no = x.bd_no
LIMIT 1
)
LEFT JOIN tbl_mt_file tmf ON tmf.mt_file_seq = tba.file_seq
where x.use_yn ='Y'
<isNotEmpty property= "who" prepend= "" >
AND member_id = #member_id#
</isNotEmpty>
<isNotEmpty property= "bd_tp" prepend= "" >
AND x.bd_tp = #bd_tp#
</isNotEmpty>
</isNotEqual>
<isEqual property= "bd_tp" compareValue= "BF_CT_TP_5" >
SELECT
x.bd_no
,x.bd_tp
,x.title
,x.content
,x.hashtag
,x.member_id
,z.title as bd_tp_nm
,IFNULL(star,0) as star
,IFNULL(h_nt ,0) as h_nt
,(select count(*)
from tbl_bf_board_like tbl
where tbl.bd_no = x.bd_no ) as l_nt
,(select count(*)
from tbl_bf_board_comment tbc
where tbc.bd_no = x.bd_no ) as c_nt
,DATE_FORMAT(x.reg_dt,'%H:%i') reg_tm
,tbv.v_content
,x.thumbnail
,m.profile_path
,m.name
,m.nickname
,tmf.mt_file_seq
,tmf.mt_file_local_url
,ROW_NUMBER() OVER (ORDER BY x.reg_dt DESC) AS row_num
FROM tbl_bf_board x
LEFT JOIN tbl_code_item z
on x.bd_tp = z.val_1 and cg_cd ='BF_COMMUNITY_TP'
LEFT JOIN (select bd_no, group_concat(concat (v_content, '♭⊙♭', nvl(v_nt, 0)) separator '♭§♭') v_content
from tbl_bf_board_vote group by bd_no) tbv ON tbv.bd_no = x.bd_no
LEFT JOIN tbl_member m ON m.member_id = x.member_id
LEFT JOIN tbl_bf_board_attach tba ON tba.bd_no = x.bd_no
and tba.file_seq = (
SELECT file_seq
FROM tbl_bf_board_attach fa
WHERE fa.bd_no = x.bd_no
LIMIT 1
)
LEFT JOIN tbl_mt_file tmf ON tmf.mt_file_seq = tba.file_seq
WHERE 1 = 1
and x.use_yn ='Y'
and x.bd_tp ='BF_CT_TP_5'
<isNotEmpty property= "who" prepend= "" >
AND member_id = #member_id#
</isNotEmpty>
LIMIT 8
</isEqual>
)x
WHERE 1 = 1
<isNotEmpty property= "keyword" prepend= "" >
AND (x.title like concat('%', #keyword# ,'%') or x.name like concat('%', #keyword# ,'%'))
</isNotEmpty>
<isNotEmpty property= "kind" prepend= "" >
<isEqual property= "kind" compareValue= "tab1" >
AND x.member_id = #member_id#
</isEqual>
<isEqual property= "kind" compareValue= "tab2" >
AND x.bd_no in(
select bd_no from tbl_bf_board_like
where member_id = #member_id#
)
</isEqual>
</isNotEmpty>
</select>
<select id= "select_top_bf_board" resultClass= "dataMap" parameterClass= "dataMap" >
SELECT
x.*
FROM (
@ -46,7 +169,7 @@
)
LEFT JOIN tbl_mt_file tmf ON tmf.mt_file_seq = tba.file_seq
WHERE DATE_FORMAT(x.reg_dt,'%Y%M%d') = DATE_FORMAT(now( ),'%Y%M%d')
WHERE DATE_FORMAT(x.reg_dt,'%Y%M%d') = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 day ),'%Y%M%d')
and x.use_yn ='Y'
<isNotEmpty property= "who" prepend= "" >
AND member_id = #member_id#
@ -54,6 +177,7 @@
<isNotEmpty property= "bd_tp" prepend= "" >
AND x.bd_tp = #bd_tp#
</isNotEmpty>
LIMIT 1
</isNotEqual>
<isEqual property= "bd_tp" compareValue= "BF_CT_TP_5" >
SELECT
@ -102,7 +226,7 @@
<isNotEmpty property= "who" prepend= "" >
AND member_id = #member_id#
</isNotEmpty>
LIMIT 8
LIMIT 1
</isEqual>
)x
@ -396,7 +520,7 @@
left join tbl_member t
on a.member_id = t.member_id
WHERE a.bd_no = #bd_no# ) x
order by r_ct_no desc , seq
order by r_ct_no , seq
</select>
</sqlMap>