package com.sky.ioc.controller.notice;

import com.sky.ioc.entity.domain.notice.Feedback;
import com.sky.ioc.entity.params.notice.FeedBackParam;
import com.sky.ioc.entity.params.notice.NoticeParam;
import com.sky.ioc.service.notice.FeedBackService;
import com.sky.ioc.tool.ReturnMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.resource.HttpResource;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(tags ="用户反馈")
@Slf4j
@RestController
@RequestMapping("/feedback")
public class FeedBackController {

    @Autowired
    FeedBackService feedBackService;

    @ApiOperation("分页列表")
    @PostMapping("/getFeedBackList")
    public ReturnMsg getFeedBackList(@RequestBody FeedBackParam feedBackParam){
        return feedBackService.listPage(feedBackParam);
    }

    @ApiOperation("用户反馈设为已读")
    @PostMapping("/readFeedBack")
    public ReturnMsg readFeedBack(@RequestBody List<Integer> ids){
        return feedBackService.readFeedBack(ids);
    }

    @ApiOperation("删除用户反馈")
    @PostMapping("/delFeedBack")
    public ReturnMsg delNotice(@RequestBody List<Integer> ids){
        return feedBackService.delFeedBack(ids);
    }

    @ApiOperation("查看用户反馈")
    @GetMapping("/getFeedBack")
    public ReturnMsg getFeedBack(@RequestParam Integer id){
        return feedBackService.getFeedBack(id);
    }

    @ApiOperation("新增用户反馈")
    @PostMapping("/addFeedBack")
    public ReturnMsg addFeedBack(@RequestBody Feedback feedback, HttpServletRequest request){
        String token = request.getHeader("token");
        return feedBackService.addFeedBack(feedback,token);
    }
}
