package com.takensoft.cms.accesCtrl.web; import com.takensoft.cms.accesCtrl.service.AccesCtrlService; import com.takensoft.cms.accesCtrl.vo.AccesCtrlVO; import com.takensoft.common.message.MessageCode; import com.takensoft.common.util.ResponseData; import com.takensoft.common.util.ResponseUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import jakarta.servlet.http.HttpServletRequest; import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author takensoft * @since 2024.04.01 * @modification * since | author | description * 2024.04.01 | takensoft | 최초 등록 * * 접근 제어 관련 컨트롤러 */ @RestController @RequiredArgsConstructor @Slf4j @RequestMapping(value = "/admin/accesCtrl") public class AccesCtrlController { private final ResponseUtil resUtil; private final AccesCtrlService accesCtrlService; /** * @author takensoft * @since 2024.04.09 * @param accesCtrlVO * @return * @throws Exception * * 접근제어 등록 */ @PostMapping("/saveProc.json") public ResponseEntity saveProc(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { Map result = accesCtrlService.accesCtrlSave(accesCtrlVO); int saveResult = (int) result.get("result"); // 응답 처리 if(saveResult > 0) { return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); } else { return resUtil.errorRes(MessageCode.COMMON_INSERT_FAIL); } } /** * @author takensoft * @since 2024.04.15 * @param params * @return * @throws Exception * * 접근제어 목록 조회 */ @PostMapping("/findAll.json") public ResponseEntity findAll(@RequestBody Map params) throws Exception { // 접근제어 목록 관련 정보 조회 Map result = accesCtrlService.findAll(params); // 응답 처리 return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); } /** * @author takensoft * @since 2024.04.15 * @param accesCtrlVO * @return * @throws Exception * * 접근제어 상세 조회 */ @PostMapping("/findByAcces.json") public ResponseEntity findByAcces(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { // 상세 조회 Map result = accesCtrlService.findByAccesCtrl(accesCtrlVO.getAcsCntrlId()); // 응답 처리 return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); } /** * @author takensoft * @since 2024.04.15 * @param accesCtrlVO * @return * @throws Exception * * 접근제어 수정 */ @PostMapping("/updateProc.json") public ResponseEntity updateProc(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { // 접근제어 수정 처리 int result = accesCtrlService.accesCtrlUpdate(accesCtrlVO); // 응답 처리 if(result > 0) { return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); } else { return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL); } } /** * @author takensoft * @since 2024.04.15 * @param accesCtrlVO * @return * @throws Exception * * 접근제어 삭제 */ @PostMapping("/deleteProc.json") public ResponseEntity deleteProc(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { // 접근제어 삭제 처리 int result = accesCtrlService.accesCtrlUpdate(accesCtrlVO); // 응답 처리 if(result > 0) { return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); } else { return resUtil.errorRes(MessageCode.COMMON_DELETE_FAIL); } } }