package com.icomsys.main_vm.biz.common.system.controller;

import com.google.gson.Gson;
import com.icomsys.main_vm.biz.advice.excep.CustomBadRequestException;
import com.icomsys.main_vm.biz.advice.excep.CustomNotFoundException;
import com.icomsys.main_vm.biz.common.common.service.ExcelService;
import com.icomsys.main_vm.biz.common.system.service.SystemCommoncodeService;
import com.icomsys.main_vm.biz.common.system.vo.*;
import com.querydsl.core.QueryResults;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Controller
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/admin/common/system")
public class SystemCommoncodeController {

    private final SystemCommoncodeService systemOprmngcodeService;


    @GetMapping("/oprmngcode/manage.do")
    public String OprmngcodeView() {
        return "/adm/common/system/commoncode";
    }

    @PostMapping("/oprmngcode/list")
    @ResponseBody
    public DslDataTableRes<SystemCommoncodeRes> SystemCommoncodeList(@RequestBody SystemCommoncodeReq dto) {
        QueryResults<SystemCommoncodeRes> result = systemOprmngcodeService.SystemCommoncodeList(dto);
        return new DslDataTableRes<SystemCommoncodeRes>(result);
    }

    @PostMapping("/oprmngcode/insert")
    @ResponseBody
    public void SystemCommoncodeInsert(@RequestBody SystemCommoncodeInsertReq dto) throws CustomBadRequestException, CustomNotFoundException {
        systemOprmngcodeService.SystemCommoncodeInsert(dto);
    }

    @PostMapping("/oprmngcode/update")
    @ResponseBody
    public void SystemCommoncodeUpdate(@RequestBody SystemCommoncodeUpdateReq dto) throws CustomNotFoundException {
        systemOprmngcodeService.SystemCommoncodeUpdate(dto);
    }

    @PostMapping("/oprmngcode/delete")
    @ResponseBody
    public void SystemCommoncodeDelete(@RequestBody SystemCommonCodeDeleteReq dto) throws CustomNotFoundException {
        systemOprmngcodeService.SystemCommoncodeDelete(dto);
    }

}
