@@ -635,7 +635,12 @@ exports.getOrgActivities = async (req, res) => {
635635 const limit = 4 ;
636636 const offset = ( page - 1 ) * limit ;
637637
638- try { // ๋ ์ง, ์ง์ญ, ํ๊ทธ, ์์ ์ ํ๋ ์ถ๊ฐ
638+ try {
639+ // ํด๋น ๋จ์ฒด๊ฐ ์์ฑํ ์ ์ฒด ๊ฒ์๊ธ ๊ฐ์ ์กฐํ
640+ const countSql = 'SELECT COUNT(*) as total FROM boards WHERE user_id = ?' ;
641+ const [ countRows ] = await pool . query ( countSql , [ id ] ) ;
642+ const total_count = countRows [ 0 ] . total ;
643+
639644 const sql = `
640645 SELECT
641646 b.id, b.title, b.start_date, b.end_date, b.region, b.district, b.topics, b.created_at,
@@ -658,7 +663,13 @@ exports.getOrgActivities = async (req, res) => {
658663 return success ( res , '์์ง ๋ฑ๋กํ ์ฐ๋ ํ๋์ด ์์ด์.' , { posts : [ ] } ) ;
659664 }
660665
661- return success ( res , 'ํ๋ ์กฐํ ์ฑ๊ณต' , { posts } ) ;
666+ // ๊ฒฐ๊ณผ ๋ฐํ
667+ return success ( res , 'ํ๋ ์กฐํ ์ฑ๊ณต' , {
668+ posts,
669+ total_count : total_count ,
670+ total_pages : Math . ceil ( total_count / limit ) ,
671+ current_page : page
672+ } ) ;
662673 } catch ( error ) {
663674 console . error ( 'Get Org Activities Error:' , error ) ;
664675 return fail ( res , '์๋ฒ ์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค.' , 500 ) ;
@@ -863,6 +874,11 @@ exports.getIndividualActivities = async (req, res) => {
863874 const limit = 4 ;
864875 const offset = ( page - 1 ) * limit ;
865876 try {
877+ // ์ ์ฒด ๊ฒ์๊ธ ๊ฐ์ ์กฐํ ์ถ๊ฐ
878+ const countSql = 'SELECT COUNT(*) as total FROM boards WHERE user_id = ?' ;
879+ const [ countRows ] = await pool . query ( countSql , [ id ] ) ;
880+ const total_count = countRows [ 0 ] . total ;
881+
866882 // LIMIT์ OFFSET์ ์ ์ฉํ ๊ฒ์๊ธ ์กฐํ ์ฟผ๋ฆฌ
867883 const postSql = `
868884 SELECT
@@ -887,7 +903,9 @@ exports.getIndividualActivities = async (req, res) => {
887903
888904 return success ( res , 'ํ๋ ์กฐํ ์ฑ๊ณต' , {
889905 written_posts : posts ,
890- cheer_count : cheers [ 0 ] . count
906+ total_count : total_count ,
907+ total_pages : Math . ceil ( total_count / limit ) ,
908+ current_page : page
891909 } ) ;
892910 } catch ( error ) {
893911 console . error ( 'Get Individual Activities Error:' , error ) ;
0 commit comments