package cn.com.countrygarden.bi.main.controller.advise;

import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dto.advise.param.AdviseFeedbackParam;
import cn.com.countrygarden.bi.main.model.advise.AfAdviseNotice;
import cn.com.countrygarden.bi.main.service.advise.IAfAdviseNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 公告建言-控制层实现
 *
 * @author 木木子
 * @email 944528607@qq.com
 * @url 
 * @date 2019-04-15
 */
@RestController("AfAdviseNoticeController")
@RequestMapping("/api/afAdviseNotice")
public class AfAdviseNoticeController extends BaseController{
    @Autowired
    private IAfAdviseNoticeService afAdviseNoticeService;



    @GetMapping(value = "/list", produces = "application/json;charset=utf-8")
    public Result list(AdviseFeedbackParam adviseFeedbackParam,
                       @RequestParam(value = "size", required = false, defaultValue = "10") int size,
                       @RequestParam(value = "page", required = false, defaultValue = "1") int page,
                       HttpServletRequest request){


        adviseFeedbackParam.setUserCode(getAccessToken().getUserCode());
        return  afAdviseNoticeService.queryPageList(adviseFeedbackParam,page,size);
    }

    @GetMapping(value = "/one", produces = "application/json;charset=utf-8")
    public Result queryById(@RequestParam(value = "id", required = true)Integer id,
                            HttpServletRequest request){
        return  afAdviseNoticeService.queryById(id);
    }

    @PostMapping(value = "/addOrEdit")
    public Result add(AfAdviseNotice afAdviseNotice,
                      HttpServletRequest request){
        return  afAdviseNoticeService.addOrEdit(afAdviseNotice,getAccessToken(request));
    }

  

    @DeleteMapping(value="/del")
    public Result del(@RequestParam(value = "id", required = true)Integer id){
        return  afAdviseNoticeService.del(id);
    }


}