package com.nmgs.controller;

import com.alibaba.fastjson.JSONArray;
import com.nmgs.config.ResultData;
import com.nmgs.service.UserVehicleService;
import com.nmgs.service.VehicleScoreService;
import com.nmgs.util.LogUtil;
import com.nmgs.util.PubTools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("vehicleScore")
@Api(tags="车辆里程信息")
public class VehicleScoreController {

    public VehicleScoreService vehicleScoreService;
    @Autowired
    public void setVehicleScoreService(VehicleScoreService vehicleScoreServiceT) {
        this.vehicleScoreService = vehicleScoreServiceT;
    }

    /**
     * 根据用户id 获取已经绑定的车牌
     * @param vehicleId  车牌号
     * @param entime 进入日期
     * @param extime 使出日期
     * @param type 类型，必填值
     * @return
     */
    @RequestMapping(value = "getVehicleScoreSList",
            method = {RequestMethod.POST}
    )
    @ApiOperation(value="车辆里程查询",httpMethod = "POST")
    public ResultData<List> getUserVehicleByUserId(@RequestParam("vehicleId")  String vehicleId, @RequestParam(value = "extime",required = false) String extime,
                                                   @RequestParam(value = "entime",required = false) String entime,@RequestParam(value = "type") String type){
        LogUtil.WriteLog_Info("查询车辆里程记录===vehicleId====>"+vehicleId+"=====extime===="+extime+"=====entime======"+entime+"====："+ PubTools.getCurrentDate(),"VehicleScoreController");
       if(PubTools.isNull(vehicleId)){
           return ResultData.success("查询成功",new ArrayList(),0);
       }
        List vehicleScoreList = this.vehicleScoreService.getVehicleScoreSList(vehicleId, entime,extime,type);
        if(vehicleScoreList != null){
            return ResultData.success("查询成功",vehicleScoreList,vehicleScoreList.size());
        }else{
            return ResultData.fail("接口查询出错");
        }
    }
}
