스크립트로 조회 수 올리기
async function testViewCount(noticeId, count) {
console.log(`🚀 [테스트 시작] ${noticeId}번 공지사항 조회수 ${count}회 증가 요청...`);
for (let i = 0; i < count; i++) {
try {
await fetch('/erp/app/work/noti/view', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `notice_id=${noticeId}`
});
console.log(`✅ ${i + 1}번째 요청 완료`);
// 너무 빠르면 서버가 뻗을 수 있으니 0.1초 대기
await new Promise(resolve => setTimeout(resolve, 100));
} catch (error) {
console.error(`❌ ${i + 1}번째 요청 실패:`, error);
}
}
console.log(`🏁 [테스트 종료] 화면을 새로고침해서 1번 글의 조회수를 확인해 보세요!`);
}
// 1번 공지사항 조회수 100번 올리기 실행!
testViewCount(1, 100);