package cn.com.ty.lift.business.emergency.controller;

import cn.com.ty.lift.business.emergency.dto.CostRequest;
import cn.com.ty.lift.business.emergency.dto.CostResponse;
import cn.com.ty.lift.business.emergency.service.ErRecordCostService;
import cn.com.ty.lift.common.model.CountPage;
import cn.com.ty.lift.common.verify.Val;
import cn.com.ty.lift.common.verify.Validation;
import cn.com.xwy.boot.web.dto.RestResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 急修费用 前端控制器
 * </p>
 *
 * @author wcz
 * @since 2020-02-06
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/emergency/record-cost")
public class ErRecordCostController {

    private ErRecordCostService erRecordCostService;

    @PostMapping("page")
    public RestResponse page(@Val @RequestBody CostRequest request){
        IPage<CostResponse> pages = erRecordCostService.pageByCondition(request);
        long count = erRecordCostService.countByCondition(request);
        return RestResponse.success(CountPage.getCountPage(count, pages));
    }
    
    @PostMapping("one")
    @Validation(fields = {"id"})
    public RestResponse one(@Val @RequestBody CostRequest request){

        return RestResponse.success();
    }


}
