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.ReviewQuestionnaireProblemClassification;
import cn.com.countrygarden.bi.main.dao.review.ReviewQuestionnaireProblemClassificationMapper;
import cn.com.countrygarden.bi.main.service.review.ReviewQuestionnaireProblemClassificationService;

/**
 * 问题分类-业务逻辑层实现
 *
 * @author 汤婷
 * @email www.justintoforest@gamail.com
 * @url
 * @date 2018-06-25
 */
@RestController("ReviewQuestionnaireProblemClassificationController")
@RequestMapping("/api/reviewQuestionnaireProblemClassification")
public class ReviewQuestionnaireProblemClassificationController extends BaseController {
	@Autowired
	private ReviewQuestionnaireProblemClassificationService reviewQuestionnaireProblemClassificationService;

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

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

	@PostMapping(value = "/add")
	public Result add(ReviewQuestionnaireProblemClassification reviewQuestionnaireProblemClassification,
			HttpServletRequest request) {
		return reviewQuestionnaireProblemClassificationService.add(reviewQuestionnaireProblemClassification,
				getAccessToken(request));
	}

	@PutMapping(value = "/edit")
	public Result edit(ReviewQuestionnaireProblemClassification reviewQuestionnaireProblemClassification,
			HttpServletRequest request) {
		return reviewQuestionnaireProblemClassificationService.edit(reviewQuestionnaireProblemClassification,
				getAccessToken(request));
	}

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

}