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.ReviewEvaluate;
import cn.com.countrygarden.bi.main.service.review.ReviewEvaluateService;

/**
 * 评价表-业务逻辑层实现
 *
 * @author 汤婷
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2018-07-06
 */
@RestController("ReviewEvaluateController")
@RequestMapping("/api/reviewEvaluate")
public class ReviewEvaluateController extends BaseController{
    @Autowired
    private ReviewEvaluateService reviewEvaluateService;


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

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

    @PostMapping(value = "/add")
    public Result add(ReviewEvaluate reviewEvaluate,
                      HttpServletRequest request){

        return  reviewEvaluateService.add(reviewEvaluate,getAccessToken(request));
    }

    @PutMapping(value = "/edit")
    public Result edit(ReviewEvaluate reviewEvaluate, HttpServletRequest request){
        return  reviewEvaluateService.edit(reviewEvaluate,getAccessToken(request));
    }

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


}