스팸단어 체크 드레그 기능 추가

This commit is contained in:
hylee 2024-09-03 17:39:22 +09:00
parent b5c1cba2c3
commit 40df003057
5 changed files with 83 additions and 19 deletions

View File

@ -9,6 +9,7 @@ import com.itn.admin.itn.mjon.spam.mapper.domain.SpamVO;
import com.itn.admin.itn.mjon.spam.service.SpamService;
import jakarta.servlet.ServletOutputStream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
@ -122,15 +123,15 @@ public class SpamServiceImpl implements SpamService {
// 키워드를 버튼용 배열로 변환
for (SpamVO spam : spamList) {
if (spam.getKeywords() != null) {
if (StringUtils.isNotEmpty(spam.getKeywords())) {
spam.setKeywordList(Arrays.asList(spam.getKeywords().split(", ")));
}
if (spam.getChcKeywords() != null) {
if (StringUtils.isNotEmpty(spam.getChcKeywords())) {
spam.setChcKeywordList(Arrays.asList(spam.getChcKeywords().split(", ")));
}
}
List<CodeDetailVO> rsnCode02List = new ArrayList<>();
// List<CodeDetailVO> rsnCode02List = new ArrayList<>();
// 키워드를 버튼용 배열로 변환
for (SpamVO spam : spamList) {
if (spam.getSpamRsnCode01() != null) {

View File

@ -5,6 +5,7 @@ import com.itn.admin.itn.code.mapper.domain.CodeDetailVO;
import com.itn.admin.itn.mjon.spam.service.SpamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@ -12,6 +13,10 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
@Slf4j
@RestController
public class RestSpamController {
@ -32,6 +37,13 @@ public class RestSpamController {
// 키워드 -> 핵심키워드 :: keywords -> chc_keywords
@PutMapping("/mjon/spam/chcKeyword/{spamId}/{word}")
public ResponseEntity<RestResponse> updateChcKeyword(@PathVariable String spamId, @PathVariable String word) {
/* try {
String decodedWord = URLDecoder.decode(word, StandardCharsets.UTF_8.toString());
return ResponseEntity.ok().body(spamService.updateChcKeyword(spamId, decodedWord));
} catch (UnsupportedEncodingException e) {
// 디코딩에 실패할 경우, 적절한 오류 응답을 보냅니다.
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new RestResponse("Invalid encoding"));
}*/
return ResponseEntity.ok().body(spamService.updateChcKeyword(spamId, word));
}

View File

@ -524,12 +524,16 @@
$main_header.addClass(color)
})
var active_navbar_color = null
$('.main-header')[0].classList.forEach(function (className) {
if (navbar_all_colors.indexOf(className) > -1 && active_navbar_color === null) {
active_navbar_color = className.replace('navbar-', 'bg-')
}
})
var active_navbar_color = null;
var mainHeader = document.querySelector('.main-header');
if (mainHeader) {
mainHeader.classList.forEach(function (className) {
if (navbar_all_colors.indexOf(className) > -1 && active_navbar_color === null) {
active_navbar_color = className.replace('navbar-', 'bg-');
}
});
}
$navbar_variants_colors.find('option.' + active_navbar_color).prop('selected', true)
$navbar_variants_colors.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_navbar_color)
@ -557,12 +561,17 @@
$body.addClass(accent_color_class)
}, true))
var active_accent_color = null
$('body')[0].classList.forEach(function (className) {
if (accent_colors.indexOf(className) > -1 && active_accent_color === null) {
active_accent_color = className.replace('navbar-', 'bg-')
}
})
var active_accent_color = null;
var bodyElement = document.querySelector('body');
if (bodyElement) {
bodyElement.classList.forEach(function (className) {
if (accent_colors.indexOf(className) > -1 && active_accent_color === null) {
active_accent_color = className.replace('navbar-', 'bg-');
}
});
}
// $accent_variants.find('option.' + active_accent_color).prop('selected', true)
// $accent_variants.removeClass().addClass('custom-select mb-3 text-light border-0 ').addClass(active_accent_color)

View File

@ -53,7 +53,7 @@
<!-- ChartJS -->
<script th:src="@{/plugins/chart.js/Chart.min.js}"></script>
<!-- Sparkline -->
<script th:src="@{/plugins/sparklines/sparkline.js}"></script>
<!-- <script th:src="@{/plugins/sparklines/sparkline.js}"></script>-->
<!-- JQVMap -->
<script th:src="@{/plugins/jqvmap/jquery.vmap.min.js}"></script>
<script th:src="@{/plugins/jqvmap/maps/jquery.vmap.usa.js}"></script>
@ -71,9 +71,9 @@
<!-- AdminLTE App -->
<script th:src="@{/dist/js/adminlte.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/dist/js/demo.js}"></script>
<!-- <script th:src="@{/dist/js/demo.js}"></script>-->
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script th:src="@{/dist/js/pages/dashboard.js}"></script>
<!-- <script th:src="@{/dist/js/pages/dashboard.js}"></script>-->
<!-- <script th:src="@{/js/fontawesome/all.min.js}"></script>-->
<script th:src="@{/plugins/toastr/toastr.min.js}"></script>

View File

@ -122,7 +122,7 @@
<tbody>
<tr th:each="spam, iterStat : ${spamList}">
<td th:text="${(pagingVO.pageNum - 1) * pagingVO.pageSize + iterStat.index + 1}"></td>
<td th:text="${spam.smsTxt}">스팸문자 내용</td>
<td th:class="spamTxt" th:text="${spam.smsTxt}">스팸문자 내용</td>
<td>
<!--
- adminLTE3 css 참고
@ -246,8 +246,50 @@
// console.log($(this).val());
// });
$('.spamTxt').on('mouseup', function() {
var selectedText = window.getSelection().toString().trim();
// 선택된 텍스트가 있는 경우에만 실행
if (selectedText) {
console.log(selectedText); // 선택된 텍스트를 콘솔에 출력
// 핵심 단어 칼럼에 새로운 단어 버튼 추가
var spamId = $(this).closest('tr').find('button').first().data('spamid');
addKeywordToCore(selectedText, spamId, this);
}
});
});
function addKeywordToCore(word, spamId, element) {
// 핵심 단어 td를 찾음
var coreKeywordTd = $(element).closest('tr').find('td:nth-child(4)');
// 새로운 버튼 생성
var newButton = $('<button>', {
class: 'btn btn-success rounded-pill mx-1 my-1',
text: word,
'data-spamid': spamId,
'data-word': word,
'data-original-td':2,
'data-current-td':3,
click: function() {
handleClick(this);
}
});
// 새로운 스팬 생성
var newSpan = $('<span></span>').append(newButton);
// 버튼을 핵심 단어 td에 추가
coreKeywordTd.append(newSpan);
// AJAX 호출로 서버에 업데이트
fn_chcKeywordUpdate(spamId, word);
}
function handleClickDrag(button){
console.log('button : ', button);
}
function handleClick(button) {
var spamId = button.getAttribute('data-spamid');