VehicleInoutStopController.java 2.02 KB
package com.bsth.controller.traffic;

import com.bsth.controller.BaseController;
import com.bsth.entity.traffic.VehicleInoutStop;
import com.bsth.service.impl.TrafficManageServiceImpl;
import com.bsth.service.traffic.VehicleInoutStopService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 *
 * @author BSTH
 *
 */
@RestController
@RequestMapping("vehicle_stop")
public class VehicleInoutStopController extends BaseController<VehicleInoutStop,Integer> {
    Logger logger = LoggerFactory.getLogger(TrafficManageServiceImpl.class);

    @Autowired
    VehicleInoutStopService vehicleInoutStopService;

    /**
     * 给定条件查车载上报停靠站
     * @param map
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "getVehicleInoutStopByParam")
    public Page<Map<String, Object>> getVehicleInoutStopByParam(@RequestParam Map<String, Object> map,
                        @RequestParam(defaultValue = "0") int page,
                        @RequestParam(defaultValue = "10") int size) {
        Page<Map<String, Object>> result = null;
        try {
            map.put("page",page);
            map.put("size",size);
            long total = vehicleInoutStopService.getVehicleInoutStopCountByParam(map);
            result = new PageImpl<>(vehicleInoutStopService.getVehicleInoutStopByParam(map),
                    new PageRequest(page, size, null),total);
        }catch (Exception e){
            logger.error("车载上报停靠站查询出错:",e);
            e.printStackTrace();
        }

        return result;
    }
}