통역인현황 수정 작업완료.

master
강석 최 2023-04-04 13:13:24 +09:00
parent 7543382848
commit 7ec8d0a5ca
7 changed files with 116 additions and 111 deletions

View File

@ -126,14 +126,16 @@ public class TranslatorController {
} }
@GetMapping("/careerInsertTr") @GetMapping("/careerInsertTr")
public ModelAndView careerInsertTr(){ public ModelAndView careerInsertTr(TranslatorCrr translatorCrr){
return new ModelAndView("translator/careerTr"); ModelAndView mav = new ModelAndView("translator/careerTr");
mav.addObject("career", translatorCrr);
return mav;
} }
@PostMapping("/insertTranslatorCareer") @PostMapping("/saveTranslatorCareer")
@ResponseBody @ResponseBody
public int insertTranslatorCareer(@RequestBody List<TranslatorCrr> translatorCrr){ public int saveTranslatorCareer(@RequestBody List<TranslatorCrr> translatorCrr){
int trKey = translatorSevice.insertTranslatorCareer(translatorCrr); int trKey = translatorSevice.saveTranslatorCareer(translatorCrr);
return trKey; return trKey;
} }

View File

@ -41,13 +41,8 @@ public class TranslatorCrr extends BaseModel implements Serializable{
@Column(name = "remark") @Column(name = "remark")
private String remark; private String remark;
@Transient
@Override private String state;
public String toString() {
return "TranslatorCrr [careerSeq=" + careerSeq + ", translatorKey=" + translatorKey + ", hisGubun=" + hisGubun
+ ", contents=" + contents + ", tcDt=" + tcDt + ", remark=" + remark + "]";
}
@Embeddable @Embeddable
@Data @Data

View File

@ -9,7 +9,7 @@ import java.util.Optional;
public interface TranslatorCareerRepository extends JpaRepository<TranslatorCrr, TranslatorCrr.TranslatorCrrId> { public interface TranslatorCareerRepository extends JpaRepository<TranslatorCrr, TranslatorCrr.TranslatorCrrId> {
TranslatorCrr findTopByTranslatorKeyOrderByCareerSeqDesc(Integer translatorKey); Optional<TranslatorCrr> findTopByTranslatorKeyOrderByCareerSeqDesc(Integer translatorKey);
Optional<TranslatorCrr> findByCareerSeqAndTranslatorKey(Integer careerSeq, Integer translatorKey); Optional<TranslatorCrr> findByCareerSeqAndTranslatorKey(Integer careerSeq, Integer translatorKey);

View File

@ -57,19 +57,27 @@ public class TranslatorService {
return translatorCareerRepository.findByTranslatorKeyOrderByCareerSeqDesc(translatorKey); return translatorCareerRepository.findByTranslatorKeyOrderByCareerSeqDesc(translatorKey);
} }
public int insertTranslatorCareer(List<TranslatorCrr> translatorCrr) { @Transactional
int trKey = 0; public int saveTranslatorCareer(List<TranslatorCrr> crrList) {
for(TranslatorCrr tCrr : translatorCrr ) { int trKey = crrList.get(0).getTranslatorKey();
TranslatorCrr dbCareer = translatorCareerRepository.findTopByTranslatorKeyOrderByCareerSeqDesc(tCrr.getTranslatorKey()); TranslatorCrr dbCareer = translatorCareerRepository.findTopByTranslatorKeyOrderByCareerSeqDesc(trKey).orElse(null);
if (dbCareer == null) { int lastSeq = dbCareer==null?1:(dbCareer.getCareerSeq()+1);
tCrr.setCareerSeq(1); List<TranslatorCrr> saveList = new ArrayList<>();
translatorCareerRepository.save(tCrr); List<TranslatorCrr> deleteList = new ArrayList<>();
} else { for(TranslatorCrr tCrr : crrList ) {
tCrr.setCareerSeq(dbCareer.getCareerSeq()+ 1); switch (tCrr.getState()){
translatorCareerRepository.save(tCrr); case "new":
tCrr.setCareerSeq(lastSeq++);
case "updated":
saveList.add(tCrr);
break;
case "deleted":
deleteList.add(tCrr);
break;
} }
trKey = tCrr.getTranslatorKey();
} }
translatorCareerRepository.deleteAll(deleteList);
translatorCareerRepository.saveAll(saveList);
return trKey; return trKey;
} }

View File

@ -24,6 +24,10 @@ $(document).on('click', '.infoTr', function (){
getTranslatorEditModal($(this).find(".trKey").val(), $(this).find(".verNo").val()); getTranslatorEditModal($(this).find(".trKey").val(), $(this).find(".verNo").val());
}) })
$(document).on('change', '.careerInfo', function (){
$(this).parents('tr').find('.state').val('updated')
})
function getTranslatorEditModal(translatorKey, versionNo){ function getTranslatorEditModal(translatorKey, versionNo){
$.ajax({ $.ajax({
@ -34,6 +38,11 @@ function getTranslatorEditModal(translatorKey, versionNo){
success: function(html){ success: function(html){
$("#translatorEditModalContent").empty().append(html) $("#translatorEditModalContent").empty().append(html)
$("#translatorEditModal").modal('show'); $("#translatorEditModal").modal('show');
$(".tcDt").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
$("#viewAptDt").datepicker({ $("#viewAptDt").datepicker({
format: "yyyy-mm-dd", format: "yyyy-mm-dd",
language: "ko", language: "ko",
@ -103,39 +112,6 @@ $(document).on('click', '#approvalTab', function (){
document.getElementById('approvalTab').classList.add('active'); document.getElementById('approvalTab').classList.add('active');
}) })
$(document).on('click', '#accessTab', function (){
const trKey = (Number($('.tapTrKey').val()));
const verNo = (Number($('.tapVerNo').val()));
const url = '/translator/translatorEditModal';
revisionHistory(trKey,verNo,url);
document.getElementById('approvalTab').classList.remove('active');
document.getElementById('accessTab').classList.add('active');
})
function revisionHistory(trKey,verNo,url){
$.ajax({
url: url,
data: {
translatorKey: trKey,
versionNo : verNo
},
type: 'GET',
dataType:"html",
success: function(html){
$("#translatorEditContent").empty().append(html)
$("#translatorEditModal").modal('show');
$("#viewAptDt").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
},
error:function(e){
ajaxErrorAction(e);
}
});
}
$(document).on('change', '#trNny', function (){ $(document).on('change', '#trNny', function (){
if($(this).val() === "NNY001"){ if($(this).val() === "NNY001"){
$("#trVisa").attr("disabled", "disabled"); $("#trVisa").attr("disabled", "disabled");
@ -160,6 +136,7 @@ $(document).on('click', '.addCareerBtn', function (){
const hisGubun = $(this).attr('data-hisgubun') const hisGubun = $(this).attr('data-hisgubun')
$.ajax({ $.ajax({
url: '/translator/careerInsertTr', url: '/translator/careerInsertTr',
data: {hisGubun: hisGubun},
type: 'GET', type: 'GET',
dataType:"html", dataType:"html",
success: function(html){ success: function(html){
@ -181,30 +158,49 @@ $(document).on('click', '.addCareerBtn', function (){
}); });
}) })
$(document).on('click', '#crrInsertBtn', function (){
})
$(document).on('click', '#crrSaveBtn', function (){ $(document).on('click', '#crrSaveBtn', function (){
if(confirm("저장하시겠습니까?")){ if(confirm("저장하시겠습니까?")){
contentFade("in"); contentFade("in");
const translatorKey = $(this).attr('data-translatorkey');
const careerList = [];
$.each($(".kcgCareerTr"), function (idx, tr){
careerList.push({
translatorKey: translatorKey,
careerSeq: $(tr).find(".careerSeq").val(),
hisGubun: $(tr).find(".hisGubun").val(),
tcDt: $(tr).find(".tcDt").val(),
contents: $(tr).find(".contents").val(),
remark: $(tr).find(".remark").val(),
state: $(tr).find(".state").val(),
})
})
$.each($(".otherCareerTr"), function (idx, tr){
careerList.push({
translatorKey: translatorKey,
careerSeq: $(tr).find(".careerSeq").val(),
hisGubun: $(tr).find(".hisGubun").val(),
tcDt: $(tr).find(".tcDt").val(),
contents: $(tr).find(".contents").val(),
remark: $(tr).find(".remark").val(),
state: $(tr).find(".state").val(),
})
})
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
data : JSON.stringify(trCarrerList), data : JSON.stringify(careerList),
url : "/translator/insertTranslatorCareer", url : "/translator/saveTranslatorCareer",
contentType: 'application/json', contentType: 'application/json',
beforeSend: function (xhr){ beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
}, },
success : function(data) { success : function(data) {
contentFade("out"); contentFade("out");
alert("이력등록이 완료되었습니다."); alert("경력이 저장되었습니다.");
showCareer(data); location.reload();
trCarrerList.length = 0;
}, },
error : function(xhr, status) { error : function(xhr, status) {
contentFade("out"); contentFade("out");
alert("이력등록을 실패하였습니다"); alert("경력 저장을 실패하였습니다");
} }
}) })
} }
@ -212,23 +208,18 @@ $(document).on('click', '#crrSaveBtn', function (){
$(document).on('click', '.deleteCareerBtn', function (){ $(document).on('click', '.deleteCareerBtn', function (){
if(confirm("삭제하시겠습니까?")){ if(confirm("삭제하시겠습니까?")){
/*$.ajax({ const tr = $(this).parents('tr')
type : 'POST', const state = tr.find('.state');
url : "/translator/deleteCareer", switch (state.val()){
data : JSON.stringify({careerSeq:crrSeq, case "new":
translatorKey:trKey}), tr.remove();
contentType: 'application/json', break;
beforeSend: function (xhr){ case "saved":
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); case "update":
}, state.val("deleted");
success : function(data) { tr.hide();
alert("삭제 처리되었습니다."); break;
showCareer(data);
},
error : function(xhr, status) {
alert("삭제 처리에 실패하였습니다");
} }
})*/
} }
}) })
@ -245,12 +236,12 @@ $(document).on('click', '#trDeleteBtn', function (){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
}, },
success : function() { success : function() {
alert("해임되었습니다."); alert("삭제되었습니다.");
contentFade("out"); contentFade("out");
location.reload(); location.reload();
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("해임을 실패하였습니다."); alert("삭제를 실패하였습니다.");
contentFade("out"); contentFade("out");
} }
}) })

View File

@ -2,7 +2,10 @@
<html lang="ko" xmlns:th="http://www.thymeleaf.org"> <html lang="ko" xmlns:th="http://www.thymeleaf.org">
<table> <table>
<tbody id="addBody"> <tbody id="addBody">
<tr> <tr th:class="${career.hisGubun eq 'Y'?'kcgCareerTr':'otherCareerTr'}">
<input type="hidden" class="careerSeq">
<input type="hidden" class="hisGubun" th:value="${career.hisGubun}">
<input type="hidden" class="state" value="new">
<td></td> <td></td>
<td><input type="text" class="form-control form-control-sm tcDt" placeholder="날짜"></td> <td><input type="text" class="form-control form-control-sm tcDt" placeholder="날짜"></td>
<td><input type="text" class="form-control form-control-sm contents" placeholder="내용"></td> <td><input type="text" class="form-control form-control-sm contents" placeholder="내용"></td>

View File

@ -141,7 +141,7 @@
</div> </div>
</div> </div>
<div class="row justify-content-end"> <div class="row justify-content-end">
<button type="button" class="btn btn-secondary col-auto mx-1" id="trDeleteBtn" th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">해임</button> <button type="button" class="btn btn-secondary col-auto mx-1" id="trDeleteBtn" th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">삭제</button>
<button type="button" class="btn btn-warning col-auto mx-1" id="updateBtn" th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">수정</button> <button type="button" class="btn btn-warning col-auto mx-1" id="updateBtn" th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">수정</button>
<button type="button" class="btn btn-primary col-auto mx-1" id="saveBtn" th:if="${accessAuth ne 'ACC001' and trInfo.translatorKey eq null}">저장</button> <button type="button" class="btn btn-primary col-auto mx-1" id="saveBtn" th:if="${accessAuth ne 'ACC001' and trInfo.translatorKey eq null}">저장</button>
</div> </div>
@ -201,8 +201,8 @@
<table class="table table-sm table-hover table-bordered text-center"> <table class="table table-sm table-hover table-bordered text-center">
<colgroup> <colgroup>
<col style="width: 5%"> <col style="width: 5%">
<col style="width: 15%"> <col style="width: 10%">
<col style="width: 35%"> <col style="width: 40%">
<col style="width: 35%"> <col style="width: 35%">
<col style="width: 10%"> <col style="width: 10%">
</colgroup> </colgroup>
@ -216,11 +216,14 @@
</tr> </tr>
</thead> </thead>
<tbody class="overflow-scroll table-group-divider text-center" id="kcgCareerTbody"> <tbody class="overflow-scroll table-group-divider text-center" id="kcgCareerTbody">
<tr class="" th:each="crrInfo,i:${kcgCareerList}"> <tr class="kcgCareerTr" th:each="crrInfo,i:${kcgCareerList}">
<input type="hidden" class="careerSeq" th:value="${crrInfo.careerSeq}">
<input type="hidden" class="hisGubun" th:value="${crrInfo.hisGubun}">
<input type="hidden" class="state" value="saved">
<td th:text="${kcgCareerList.size()-i.index}"></td> <td th:text="${kcgCareerList.size()-i.index}"></td>
<td th:text="${crrInfo.tcDt}"></td> <td><input type="text" class="form-control form-control-sm careerInfo tcDt" th:value="${crrInfo.tcDt}"></td>
<td th:text="${crrInfo.contents}"></td> <td><input type="text" class="form-control form-control-sm careerInfo contents" th:value="${crrInfo.contents}"></td>
<td th:text="${crrInfo.remark}"></td> <td><input type="text" class="form-control form-control-sm careerInfo remark" th:value="${crrInfo.remark}"></td>
<td> <td>
<button type="button" class="btn btn-danger m-0 deleteCareerBtn" <button type="button" class="btn btn-danger m-0 deleteCareerBtn"
th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">삭제</button> th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">삭제</button>
@ -244,8 +247,8 @@
<table class="table table-sm table-hover table-bordered text-center"> <table class="table table-sm table-hover table-bordered text-center">
<colgroup> <colgroup>
<col style="width: 5%"> <col style="width: 5%">
<col style="width: 15%"> <col style="width: 10%">
<col style="width: 35%"> <col style="width: 40%">
<col style="width: 35%"> <col style="width: 35%">
<col style="width: 10%"> <col style="width: 10%">
</colgroup> </colgroup>
@ -259,11 +262,14 @@
</tr> </tr>
</thead> </thead>
<tbody class="overflow-scroll table-group-divider" id="otherCareerTbody"> <tbody class="overflow-scroll table-group-divider" id="otherCareerTbody">
<tr class="" th:each="crrInfo,i:${otherCareerList}"> <tr class="otherCareerTr" th:each="crrInfo,i:${otherCareerList}">
<input type="hidden" class="careerSeq" th:value="${crrInfo.careerSeq}">
<input type="hidden" class="hisGubun" th:value="${crrInfo.hisGubun}">
<input type="hidden" class="state" value="saved">
<td th:text="${otherCareerList.size()-i.index}"></td> <td th:text="${otherCareerList.size()-i.index}"></td>
<td th:text="${crrInfo.tcDt}"></td> <td><input type="text" class="form-control form-control-sm careerInfo tcDt" th:value="${crrInfo.tcDt}"></td>
<td th:text="${crrInfo.contents}"></td> <td><input type="text" class="form-control form-control-sm careerInfo contents" th:value="${crrInfo.contents}"></td>
<td th:text="${crrInfo.remark}"></td> <td><input type="text" class="form-control form-control-sm careerInfo remark" th:value="${crrInfo.remark}"></td>
<td> <td>
<button type="button" class="btn btn-danger m-0 deleteCareerBtn" <button type="button" class="btn btn-danger m-0 deleteCareerBtn"
th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">삭제</button> th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}">삭제</button>
@ -283,7 +289,7 @@
</table> </table>
</div> </div>
<div class="row justify-content-end"> <div class="row justify-content-end">
<button type="button" class="btn btn-primary col-auto" id="crrInsertBtn" th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}" th:data-translatorkey="${trInfo.translatorKey}">저장</button> <button type="button" class="btn btn-primary col-auto" id="crrSaveBtn" th:if="${accessAuth eq 'ACC003' or wrtUserSeq eq userSeq}" th:data-translatorkey="${trInfo.translatorKey}">저장</button>
</div> </div>
</div> </div>
</div> </div>