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.ReviewJudge;
import cn.com.countrygarden.bi.main.dao.review.ReviewJudgeMapper;
import cn.com.countrygarden.bi.main.service.review.ReviewJudgeService;

/**
 * 评选人-业务逻辑层实现
 *
 * @author 汤婷
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2018-06-25
 */
@RestController("ReviewJudgeController")
@RequestMapping("/api/reviewJudge")
public class ReviewJudgeController extends BaseController{
    @Autowired
    private ReviewJudgeService reviewJudgeService;


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

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

    @PostMapping(value = "/add")
    public Result add(ReviewJudge reviewJudge,
                      HttpServletRequest request){
        return  reviewJudgeService.add(reviewJudge,getAccessToken(request));
    }

    @PutMapping(value = "/edit")
    public Result edit(ReviewJudge reviewJudge, HttpServletRequest request){
        return  reviewJudgeService.edit(reviewJudge,getAccessToken(request));
    }

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


}