115 lines
4.7 KiB
Java
115 lines
4.7 KiB
Java
|
|
package com.pms.controller;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
import jakarta.servlet.http.HttpServletRequest;
|
||
|
|
import jakarta.servlet.http.HttpServletResponse;
|
||
|
|
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import com.pms.service.TableManagementService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 테이블 관리 API 컨트롤러
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/table-management")
|
||
|
|
public class TableManagementController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private TableManagementService tableManagementService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 테이블 목록 조회
|
||
|
|
*/
|
||
|
|
@GetMapping("/tables")
|
||
|
|
public ResponseEntity<Map<String, Object>> getTableList(HttpServletRequest request) {
|
||
|
|
try {
|
||
|
|
List<Map<String, Object>> tableList = tableManagementService.getTableList();
|
||
|
|
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", true);
|
||
|
|
response.put("data", tableList);
|
||
|
|
response.put("message", "테이블 목록을 성공적으로 조회했습니다.");
|
||
|
|
|
||
|
|
return ResponseEntity.ok(response);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", false);
|
||
|
|
response.put("message", "테이블 목록 조회 중 오류가 발생했습니다: " + e.getMessage());
|
||
|
|
|
||
|
|
return ResponseEntity.badRequest().body(response);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 테이블 컬럼 정보 조회
|
||
|
|
*/
|
||
|
|
@GetMapping("/tables/{tableName}/columns")
|
||
|
|
public ResponseEntity<Map<String, Object>> getColumnList(
|
||
|
|
HttpServletRequest request,
|
||
|
|
@PathVariable String tableName) {
|
||
|
|
try {
|
||
|
|
List<Map<String, Object>> columns = tableManagementService.getColumnList(tableName);
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", true);
|
||
|
|
response.put("data", columns);
|
||
|
|
response.put("message", "컬럼 목록을 성공적으로 조회했습니다.");
|
||
|
|
return ResponseEntity.ok(response);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", false);
|
||
|
|
response.put("message", "컬럼 목록 조회 중 오류가 발생했습니다: " + e.getMessage());
|
||
|
|
return ResponseEntity.badRequest().body(response);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/tables/{tableName}/columns/{columnName}/settings")
|
||
|
|
public ResponseEntity<Map<String, Object>> updateColumnSettings(
|
||
|
|
HttpServletRequest request,
|
||
|
|
@PathVariable String tableName,
|
||
|
|
@PathVariable String columnName,
|
||
|
|
@RequestBody Map<String, Object> settings) {
|
||
|
|
try {
|
||
|
|
tableManagementService.updateColumnSettings(tableName, columnName, settings);
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", true);
|
||
|
|
response.put("message", "컬럼 설정을 성공적으로 저장했습니다.");
|
||
|
|
return ResponseEntity.ok(response);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", false);
|
||
|
|
response.put("message", "컬럼 설정 저장 중 오류가 발생했습니다: " + e.getMessage());
|
||
|
|
return ResponseEntity.badRequest().body(response);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/tables/{tableName}/columns/settings")
|
||
|
|
public ResponseEntity<Map<String, Object>> updateAllColumnSettings(
|
||
|
|
HttpServletRequest request,
|
||
|
|
@PathVariable String tableName,
|
||
|
|
@RequestBody List<Map<String, Object>> columnSettings) {
|
||
|
|
try {
|
||
|
|
tableManagementService.updateAllColumnSettings(tableName, columnSettings);
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", true);
|
||
|
|
response.put("message", "모든 컬럼 설정을 성공적으로 저장했습니다.");
|
||
|
|
return ResponseEntity.ok(response);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Map<String, Object> response = new HashMap<>();
|
||
|
|
response.put("success", false);
|
||
|
|
response.put("message", "컬럼 설정 저장 중 오류가 발생했습니다: " + e.getMessage());
|
||
|
|
return ResponseEntity.badRequest().body(response);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|