package cn.com.countrygarden.bi.main.controller.ck.res;


import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.model.ck.res.CkResourceIncome;
import cn.com.countrygarden.bi.main.service.ck.CkResourceIncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * <p>
 *   公共资源收益模块接口
 * </p>
 *
 * @author
 * @date 2021-06-29
 * @version V1.0
 */
@RestController("CkResourceIncomeController")
@RequestMapping("/api/ckResourceIncome")
public class CkResourceIncomeController extends BaseController {
    @Autowired
    private CkResourceIncomeService ckResourceIncomeService;


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

    @PostMapping(value = "/add")
    public Result add(CkResourceIncome ckResourceIncome,
                      HttpServletRequest request){
        return  ckResourceIncomeService.add(ckResourceIncome,getAccessToken(request));
    }

    @PostMapping(value = "/edit")
    public Result edit(CkResourceIncome ckResourceIncome, HttpServletRequest request){
        return  ckResourceIncomeService.edit(ckResourceIncome,getAccessToken(request));
    }

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

    //审核
    @PostMapping(value = "/toExamine")
    public Result toExamine(CkResourceIncome ckResourceIncome,
                            HttpServletRequest request){
        return  ckResourceIncomeService.toExamine(ckResourceIncome);
    }

    @PostMapping(value = "/getrevenue")
    public Result getrevenue(
            HttpServletRequest request) throws IOException {
        return ckResourceIncomeService.getrevenue( getAccessToken(request),request);
    }

    @GetMapping(value = "/addone", produces = "application/json;charset=utf-8")
    public Result addone(CkResourceIncome ro,
                         HttpServletRequest request) throws IOException {
        return ckResourceIncomeService.addone(ro,getAccessToken(request),request);
    }

    @GetMapping(value = "/openingClosing", produces = "application/json;charset=utf-8")
    public Result openingClosing(CkResourceIncome ro,
                         HttpServletRequest request) throws IOException {
        return ckResourceIncomeService.openingClosing(ro,getAccessToken(request),request);
    }


    //审核人查看当年最前数据
    @GetMapping(value = "/openingClosingShenHeOne", produces = "application/json;charset=utf-8")
    public Result openingClosingShenHeOne(CkResourceIncome ro,
                                 HttpServletRequest request) throws IOException {
        return ckResourceIncomeService.openingClosingShenHeOne(ro,getAccessToken(request),request);
    }
}