CarDeviceController.java 1.67 KB
package com.bsth.controller.schedule.basicinfo;

import com.bsth.common.ResponseCode;
import com.bsth.controller.schedule.BController;
import com.bsth.entity.CarDevice;
import com.bsth.service.schedule.CarDeviceService;
import com.bsth.service.schedule.exception.ScheduleException;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xu on 16/12/15.
 */
@RestController(value = "carDeviceController_sc")
@RequestMapping("cde_sc")
public class CarDeviceController extends BController<CarDevice, Long> {
    @Autowired
    private CarDeviceService carDeviceService;

    @RequestMapping(value = "/validate_qyrq", method = RequestMethod.GET)
    public Map<String, Object> validate_qyrq(@RequestParam Map<String, Object> param) {
        Map<String, Object> rtn = new HashMap<>();

        try {
            // 启用日期验证
            CarDevice carDevice = new CarDevice(
                    param.get("id_eq"),
                    param.get("xl_eq"),
                    param.get("cl_eq"),
                    param.get("qyrq_eq")
            );
            carDeviceService.validate_qyrq(carDevice);
            rtn.put("status", ResponseCode.SUCCESS);
        } catch (ScheduleException exp) {
            rtn.put("status", ResponseCode.ERROR);
            rtn.put("msg", exp.getMessage());
        }

        return rtn;
    }

}