82 lines
3.7 KiB
Java
82 lines
3.7 KiB
Java
package com.erp.controller;
|
|
|
|
import com.erp.dto.ApiResponse;
|
|
import com.erp.service.CascadingConditionService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.*;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/cascading-condition")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class CascadingConditionController {
|
|
private final CascadingConditionService cascadingConditionService;
|
|
|
|
@GetMapping("/list")
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> getCascadingConditionListAlias(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@RequestParam Map<String, Object> params) {
|
|
params.put("company_code", companyCode);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.getCascadingConditionList(params)));
|
|
}
|
|
|
|
@GetMapping
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> getCascadingConditionList(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@RequestParam Map<String, Object> params) {
|
|
params.put("company_code", companyCode);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.getCascadingConditionList(params)));
|
|
}
|
|
|
|
@GetMapping("/filtered-options/{relationCode}")
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> getFilteredOptions(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@PathVariable String relationCode,
|
|
@RequestParam Map<String, Object> params) {
|
|
params.put("company_code", companyCode);
|
|
params.put("relation_code", relationCode);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.getFilteredOptions(params)));
|
|
}
|
|
|
|
@GetMapping("/{conditionId}")
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> getCascadingConditionInfo(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@PathVariable Long conditionId) {
|
|
Map<String, Object> params = new HashMap<>();
|
|
params.put("company_code", companyCode);
|
|
params.put("condition_id", conditionId);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.getCascadingConditionInfo(params)));
|
|
}
|
|
|
|
@PostMapping
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> insertCascadingCondition(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@RequestBody Map<String, Object> body) {
|
|
body.put("company_code", companyCode);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.insertCascadingCondition(body)));
|
|
}
|
|
|
|
@PutMapping("/{conditionId}")
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> updateCascadingCondition(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@PathVariable Long conditionId,
|
|
@RequestBody Map<String, Object> body) {
|
|
body.put("company_code", companyCode);
|
|
body.put("condition_id", conditionId);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.updateCascadingCondition(body)));
|
|
}
|
|
|
|
@DeleteMapping("/{conditionId}")
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> deleteCascadingCondition(
|
|
@RequestAttribute("company_code") String companyCode,
|
|
@PathVariable Long conditionId) {
|
|
Map<String, Object> params = new HashMap<>();
|
|
params.put("company_code", companyCode);
|
|
params.put("condition_id", conditionId);
|
|
return ResponseEntity.ok(ApiResponse.success(cascadingConditionService.deleteCascadingCondition(params)));
|
|
}
|
|
}
|