This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
var url = '<c:url value="/onl/admin/authserver/scopeMan.json" />';
|
||||
var url_view = '<c:url value="/onl/admin/authserver/scopeMan.view" />';
|
||||
var api_url_view = '<c:url value="/onl/apim/apigroup/apiGroupMan.view" />';
|
||||
var mapping_url = '<c:url value="/onl/admin/authserver/apiScopeMan.json" />';
|
||||
|
||||
var isDetail = false;
|
||||
function isValid(){
|
||||
@@ -65,9 +64,9 @@ function mappingInfo(key){
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url: mapping_url,
|
||||
url: url,
|
||||
dataType: "json",
|
||||
data: {cmd: 'LIST', searchScopeId : key},
|
||||
data: {cmd: 'API_LIST', searchScopeId : key},
|
||||
success: function(json){
|
||||
var mappingData = json.rows;
|
||||
|
||||
@@ -131,45 +130,6 @@ function init(key, callback){
|
||||
}
|
||||
}
|
||||
|
||||
function saveApiGridData(scopeId, returnUrl) {
|
||||
var postData = [];
|
||||
var rows = $("#selectedApiGrid").jqGrid('getRowData');
|
||||
|
||||
$.each(rows, function(index, item) {
|
||||
item.scopeId = scopeId;
|
||||
});
|
||||
|
||||
postData.push({
|
||||
name: "apiList",
|
||||
value: JSON.stringify(rows)
|
||||
});
|
||||
|
||||
postData.push({ name: "cmd" , value:"INSERT_APILIST" });
|
||||
postData.push({ name: "scopeId" , value:scopeId });
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url:mapping_url,
|
||||
data: postData,
|
||||
beforeSend: function() {
|
||||
$("[id^='btn_']").prop("disabled", true);
|
||||
$("#btn_modify").text("처리중 . . . . .");
|
||||
},
|
||||
success:function(args){
|
||||
alert("저장 되었습니다.");
|
||||
|
||||
goNav(returnUrl);//LIST로 이동
|
||||
},
|
||||
error:function(e){
|
||||
alert(e.responseText);
|
||||
},
|
||||
complete: function() {
|
||||
$("[id^='btn_']").prop("disabled", false);
|
||||
$("#btn_modify").text("수정");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var returnUrl = getReturnUrlForReturn();
|
||||
var key ="${param.scopeId}";
|
||||
@@ -182,28 +142,39 @@ $(document).ready(function() {
|
||||
if (!isValid()){
|
||||
return;
|
||||
}
|
||||
var scopeId = $('input[name=scopeId]').val();
|
||||
var postData = $('#ajaxForm').serializeArray();
|
||||
|
||||
var rows = $("#selectedApiGrid").jqGrid('getRowData');
|
||||
$.each(rows, function(index, item) {
|
||||
item.scopeId = scopeId;
|
||||
});
|
||||
postData.push({ name: "apiList" , value: JSON.stringify(rows) });
|
||||
|
||||
if (isDetail){
|
||||
postData.push({ name: "cmd" , value:"UPDATE"});
|
||||
}else{
|
||||
postData.push({ name: "cmd" , value:"INSERT"});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url:url,
|
||||
data:postData,
|
||||
beforeSend: function() {
|
||||
$("[id^='btn_']").prop("disabled", true);
|
||||
$("#btn_modify").text("처리중 . . . . .");
|
||||
},
|
||||
success:function(args){
|
||||
alert("SCOPE 정보가 저장 되었습니다. 이어서 API 리스트를 저장합니다.");
|
||||
|
||||
if(!isDetail) { // INSERT 일 경우 ScopeId를 업데이트
|
||||
key = $('input[name=scopeId]').val();
|
||||
}
|
||||
saveApiGridData(key, returnUrl); // API LIST 저장.
|
||||
|
||||
|
||||
alert("저장 되었습니다.");
|
||||
goNav(returnUrl);//LIST로 이동
|
||||
},
|
||||
error:function(e){
|
||||
alert(e.responseText);
|
||||
},
|
||||
complete: function() {
|
||||
$("[id^='btn_']").prop("disabled", false);
|
||||
$("#btn_modify").text("수정");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.eactive.eai.rms.onl.manage.authserver.scope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -8,21 +10,29 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.eactive.eai.agent.authserver.ReloadApiScopeCommand;
|
||||
import com.eactive.eai.agent.command.CommonCommand;
|
||||
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
|
||||
import com.eactive.eai.rms.common.vo.GridResponse;
|
||||
import com.eactive.eai.rms.data.entity.onl.authserver.ScopeSearch;
|
||||
import com.eactive.eai.rms.data.entity.onl.eaimsg.ApiScopeSearch;
|
||||
import com.eactive.eai.rms.onl.common.exception.BizException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Controller
|
||||
public class ScopeController extends OnlBaseAnnotationController {
|
||||
|
||||
private ScopeManService scopeManService;
|
||||
|
||||
private ApiScopeManService apiScopeManService;
|
||||
|
||||
@Autowired
|
||||
public ScopeController(ScopeManService scopeManService) {
|
||||
public ScopeController(ScopeManService scopeManService, ApiScopeManService apiScopeManService) {
|
||||
this.scopeManService = scopeManService;
|
||||
this.apiScopeManService = apiScopeManService;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/onl/admin/authserver/scopeMan.view")
|
||||
@@ -41,6 +51,12 @@ public class ScopeController extends OnlBaseAnnotationController {
|
||||
return ResponseEntity.ok(new GridResponse<>(page));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authserver/scopeMan.json", params = "cmd=API_LIST")
|
||||
public ResponseEntity<GridResponse<ApiScopeUI>> selectApiList(Pageable pageable, ApiScopeSearch apiScopeSearch) {
|
||||
Page<ApiScopeUI> page = apiScopeManService.selectApiScopeRelationsList(pageable, apiScopeSearch);
|
||||
return ResponseEntity.ok(new GridResponse<>(page));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authserver/scopeMan.json", params = "cmd=DETAIL")
|
||||
public ResponseEntity<ScopeUI> selectDetail(String scopeId) {
|
||||
ScopeUI scopeUI = scopeManService.selectDetail(scopeId);
|
||||
@@ -48,14 +64,16 @@ public class ScopeController extends OnlBaseAnnotationController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authserver/scopeMan.json", params = "cmd=INSERT")
|
||||
public ResponseEntity<Void> insert(ScopeUI scopeUI) {
|
||||
public ResponseEntity<Void> insert(ScopeUI scopeUI, @RequestParam(value = "apiList", required = false) String apiListJson) {
|
||||
scopeManService.insert(scopeUI);
|
||||
saveApiScopeRelations(scopeUI.getScopeId(), apiListJson);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/onl/admin/authserver/scopeMan.json", params = "cmd=UPDATE")
|
||||
public ResponseEntity<Void> update(ScopeUI scopeUI) {
|
||||
public ResponseEntity<Void> update(ScopeUI scopeUI, @RequestParam(value = "apiList", required = false) String apiListJson) {
|
||||
scopeManService.update(scopeUI);
|
||||
saveApiScopeRelations(scopeUI.getScopeId(), apiListJson);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@@ -73,4 +91,25 @@ public class ScopeController extends OnlBaseAnnotationController {
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
private void saveApiScopeRelations(String scopeId, String apiListJson) {
|
||||
if (apiListJson == null || apiListJson.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ApiScopeUI> apiScopeList;
|
||||
try {
|
||||
apiScopeList = new ObjectMapper().readValue(apiListJson, new TypeReference<List<ApiScopeUI>>() {});
|
||||
} catch (Exception e) {
|
||||
throw new BizException("데이터 변환 중 오류가 발생했습니다.");
|
||||
}
|
||||
|
||||
scopeManService.updateApiScopeRelations(apiScopeList, scopeId);
|
||||
|
||||
CommonCommand.builder()
|
||||
.name(CommonCommand.RELOAD_API_SCOPE_COMMAND)
|
||||
.args(new String[] {ReloadApiScopeCommand.COMMAND_TYPE_SCOPE, "", scopeId})
|
||||
.build()
|
||||
.broadcast(agentUtilService);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.eactive.eai.rms.onl.manage.authserver.scope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -24,14 +26,17 @@ public class ScopeManService extends OnlBaseService {
|
||||
|
||||
private ScopeUIMapper scopeUIMapper;
|
||||
|
||||
private ApiScopeUIMapper apiScopeUIMapper;
|
||||
|
||||
private LocaleMessage localeMessage;
|
||||
|
||||
@Autowired
|
||||
public ScopeManService(ScopeInfoService scopeInfoService, ScopeEntityService scopeEntityService,
|
||||
ScopeUIMapper scopeUIMapper, LocaleMessage localeMessage ) {
|
||||
ScopeUIMapper scopeUIMapper, ApiScopeUIMapper apiScopeUIMapper, LocaleMessage localeMessage ) {
|
||||
this.scopeInfoService = scopeInfoService;
|
||||
this.scopeEntityService = scopeEntityService;
|
||||
this.scopeUIMapper = scopeUIMapper;
|
||||
this.apiScopeUIMapper = apiScopeUIMapper;
|
||||
this.localeMessage = localeMessage;
|
||||
}
|
||||
|
||||
@@ -66,4 +71,22 @@ public class ScopeManService extends OnlBaseService {
|
||||
scopeEntityService.deleteByIdScopeId(scopeId);
|
||||
}
|
||||
|
||||
public void updateApiScopeRelations(List<ApiScopeUI> apiScopeList, String scopeId) {
|
||||
if (scopeId == null || scopeId.isEmpty()) {
|
||||
throw new BizException("ScopeId 가 존재하지 않습니다.");
|
||||
}
|
||||
|
||||
// ScopeId 기준 전체 삭제 후 LIST 기준으로 재저장.
|
||||
scopeEntityService.deleteByIdScopeId(scopeId);
|
||||
|
||||
if (apiScopeList == null || apiScopeList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ApiScopeUI ui : apiScopeList) {
|
||||
ui.setScopeId(scopeId);
|
||||
scopeEntityService.save(apiScopeUIMapper.toEntity(ui));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user