52 lines
1.8 KiB
Java
52 lines
1.8 KiB
Java
package com.zioinfo.mro.calibration;
|
|
|
|
import com.zioinfo.mro.common.ApiResponse;
|
|
import com.zioinfo.mro.common.AuthSupport;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.security.core.Authentication;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 계측기 교정 API. 조회 Viewer+, 생성/수정/삭제 Manager+(기준정보 가드).
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/mro/calibrations")
|
|
@RequiredArgsConstructor
|
|
public class CalibrationController {
|
|
|
|
private final CalibrationService service;
|
|
|
|
@GetMapping
|
|
public ApiResponse<List<MroCalibration>> list(@RequestParam(required = false) String equipmentCode,
|
|
@RequestParam(required = false) String status,
|
|
@RequestParam(required = false) String keyword) {
|
|
return ApiResponse.ok(service.list(equipmentCode, status, keyword));
|
|
}
|
|
|
|
@GetMapping("/{id}")
|
|
public ApiResponse<MroCalibration> get(@PathVariable Long id) {
|
|
return ApiResponse.ok(service.get(id));
|
|
}
|
|
|
|
@PostMapping
|
|
public ApiResponse<MroCalibration> create(@RequestBody MroCalibration c, Authentication auth) {
|
|
AuthSupport.requireManager(auth);
|
|
return ApiResponse.ok(service.create(c, AuthSupport.actor(auth)));
|
|
}
|
|
|
|
@PutMapping("/{id}")
|
|
public ApiResponse<MroCalibration> update(@PathVariable Long id, @RequestBody MroCalibration c, Authentication auth) {
|
|
AuthSupport.requireManager(auth);
|
|
return ApiResponse.ok(service.update(id, c, AuthSupport.actor(auth)));
|
|
}
|
|
|
|
@DeleteMapping("/{id}")
|
|
public ApiResponse<Void> delete(@PathVariable Long id, Authentication auth) {
|
|
AuthSupport.requireManager(auth);
|
|
service.delete(id);
|
|
return ApiResponse.ok(null);
|
|
}
|
|
}
|