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

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.investment.InvestProjectProfit;
import cn.com.countrygarden.bi.main.dao.investment.InvestProjectProfitMapper;
import cn.com.countrygarden.bi.main.service.investment.InvestProjectProfitService;

/**
 * 个人项目收益-业务逻辑层实现
 *
 * @author 汤婷
 * @email www.justintoforest@gamail.com
 * @url
 * @date 2018-08-20
 */
@RestController("InvestProjectProfitController")
@RequestMapping("/api/invest/project/profit")
public class InvestProjectProfitController extends BaseController {
	@Autowired
	private InvestProjectProfitService investProjectProfitService;

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

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

	@PostMapping(value = "/add")
	public Result add(InvestProjectProfit investProjectProfit, HttpServletRequest request) {

		return investProjectProfitService.add(investProjectProfit, getAccessToken(request));
	}

	@PutMapping(value = "/edit")
	public Result edit(InvestProjectProfit investProjectProfit, HttpServletRequest request) {
		return investProjectProfitService.edit(investProjectProfit, getAccessToken(request));
	}

}