package com.its.web.controller.popup;

import com.its.web.dto.admin.TbWwwPopupDto;
import com.its.web.dto.message.ResultDto;
import com.its.web.service.popup.PopupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/popup")
@Api(tags = "05.팝업")
public class popupController {
    private final PopupService service;

    @ApiOperation(value = "01.팝업 글쓰기")
    @PostMapping(value= {"/writePopup", }, produces = {"application/json; charset=utf-8"})
    @ResponseBody
    public ResultDto writePopup(@ModelAttribute TbWwwPopupDto.PopupUpdateReq req) {
        return this.service.writePopup(req);
    }
//
//    @ApiOperation(value = "02.팝업 이미지 다운")
//    @PostMapping(value = "/attach", produces = {"application/json; charset=utf-8"})
//    @ResponseBody
//    public AttachFileDto downloadAttach(@Param("imgId") String imgId, @Param("imgName") String imgName) {
//        return this.service.downloadAttach(imgId, imgName);
//    }

    @ApiOperation(value= "02.팝업 글수정")
    @PostMapping(value = "/modifyPopup", produces = {"application/json; charset=utf-8"})
    @ResponseBody
    public ResultDto modifyPopup(@ModelAttribute TbWwwPopupDto.PopupUpdateReq req) {
        return this.service.modifyPopup(req);
    }

    @ApiOperation(value= "03.팝업 글삭제")
    @PostMapping(value = "/deletePopup", produces = {"application/json; charset=utf-8"})
    @ResponseBody
    public ResultDto deletePopup(@ApiParam(value = "popupId", example = "1", required = true)
                                 @RequestParam(defaultValue = "") String popupId) {
        return this.service.deletePopup(popupId);
    }
}
