package cn.com.countrygarden.bi.main.controller.review;
import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import cn.com.countrygarden.bi.main.model.review.Investigationmanagement;
import cn.com.countrygarden.bi.main.dao.review.InvestigationmanagementMapper;
import cn.com.countrygarden.bi.main.service.review.InvestigationmanagementService;

/**
 * 问卷管理表-业务逻辑层实现
 *
 * @author 汤婷
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2018-08-11
 */
@RestController("InvestigationmanagementController")
@RequestMapping("/api/investigationmanagement")
public class InvestigationmanagementController extends BaseController{
    @Autowired
    private InvestigationmanagementService investigationmanagementService;


    @GetMapping(value = "/list", produces = "application/json;charset=utf-8")
    public Result list(Investigationmanagement investigationmanagement,
                       @RequestParam(value = "size", required = false, defaultValue = "10") int size,
                       @RequestParam(value = "page", required = false, defaultValue = "1") int page,
                       HttpServletRequest request){
        return  investigationmanagementService.queryPageList(investigationmanagement,page,size);
    }

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

    @PostMapping(value = "/add")
    public Result add(Investigationmanagement investigationmanagement,
                      HttpServletRequest request){
        return  investigationmanagementService.add(investigationmanagement,getAccessToken(request));
    }

    @PutMapping(value = "/edit")
    public Result edit(Investigationmanagement investigationmanagement, HttpServletRequest request){
        return  investigationmanagementService.edit(investigationmanagement,getAccessToken(request));
    }

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


}