package com.bweb.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.model.ResponseData;
import com.hai.service.HighOilCardContactRecordService;
import com.hai.service.HighOilCardRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/oilCardContactRecord")
@Api(value = "油卡变更记录")
public class HighOilCardContactRecordController {

    private static Logger log = LoggerFactory.getLogger(HighOilCardContactRecordController.class);

    @Resource
    private HighOilCardContactRecordService oilCardContactRecordService;

    @RequestMapping(value = "/getOilCardContactRecordList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询油卡记录列表")
    public ResponseData getOilCardContactRecordList(
                                            @RequestParam(name = "cardNo", required = true) String cardNo,
                                            @RequestParam(name = "createTimeS", required = false) Long createTimeS,
                                            @RequestParam(name = "createTimeE", required = false) Long createTimeE,
                                            @RequestParam(name = "pageNum", required = true) Integer pageNum,
                                            @RequestParam(name = "pageSize", required = true) Integer pageSize) {
        try {

            Map<String, Object> param = new HashMap<>();
            param.put("cardNo", cardNo);
            param.put("createTimeS", createTimeS);
            param.put("createTimeE", createTimeE);

            PageHelper.startPage(pageNum, pageSize);
            return ResponseMsgUtil.success(new PageInfo<>(oilCardContactRecordService.getRecordList(param)));

        } catch (Exception e) {
            log.error("HighOilCardRecordController --> getOilCardContactRecordList() error!", e);
            return ResponseMsgUtil.exception(e);
        }
    }
}
