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


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

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

/**
 * <p>
 *   公共资源收入模块接口
 * </p>
 *
 * @author
 * @date 2021-06-29
 * @version V1.0
 */
@RestController("CkResourcesRevenueController")
@RequestMapping("/api/ckResourcesRevenue")
public class CkResourcesRevenueController extends BaseController {
    @Autowired
    private CkResourcesRevenueService ckResourcesRevenueService;


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

    @GetMapping(value = "/getRegionDate", produces = "application/json;charset=utf-8")
    public Result getRegionDate(HttpServletRequest request) {

        return Response.response(ckResourcesRevenueService.getRegionDate(getAccessToken(request)));
    }

    @GetMapping(value = "/getPojDate", produces = "application/json;charset=utf-8")
    public Result getPojDate(HttpServletRequest request,
                             @RequestParam(value = "organCode",required = true) String organCode) {

        return Response.response(ckResourcesRevenueService.getPojDate(getAccessToken(request),organCode));
    }

    @PostMapping(value = "/add")
    public Result add(CkResourcesRevenue ckResourcesRevenue,
                      HttpServletRequest request){
        return  ckResourcesRevenueService.add(ckResourcesRevenue,getAccessToken(request));
    }

    @PostMapping(value = "/edit")
    public Result edit(CkResourcesRevenue ckResourcesRevenue, HttpServletRequest request){
        return  ckResourcesRevenueService.edit(ckResourcesRevenue,getAccessToken(request));
    }

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

    @GetMapping(value = "/auditorUser", produces = "application/json;charset=utf-8")
    public Result auditorUser(@RequestParam(value = "organCode",required = true) String organCode,
                              @RequestParam(value = "commCode",required = true) String commCode,
                              HttpServletRequest request){
        return  ckResourcesRevenueService.auditorUser(organCode,commCode,getAccessToken(request),request);
    }
    //审核提示

    @GetMapping(value = "/auditReminder", produces = "application/json;charset=utf-8")
    public Result auditReminder(HttpServletRequest request) throws ParseException {
        return  ckResourcesRevenueService.auditReminder(getAccessToken(request),request);
    }

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

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