PREPAREMASTERController.java 2.2 KB
package com.tianbo.analysis.controller;


import com.github.pagehelper.PageInfo;
import com.tianbo.analysis.dao.PREPAREMASTERMapper;
import com.tianbo.analysis.model.PREPAREMASTER;
import com.tianbo.analysis.model.ResultJson;
import com.tianbo.analysis.service.PREPARMASTERService;
import com.tianbo.util.Date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@Slf4j
@RestController
@RequestMapping("/premaster/")
public class PREPAREMASTERController {

    @Autowired
    PREPARMASTERService preparmasterService;


    @RequestMapping("search")
    public ResultJson search(@RequestParam(value = "page",defaultValue = "1") int page,
                             @RequestParam(value = "limit",defaultValue = "10") int limit,
                             @RequestParam(value = "flightNo",required = false) String flightNo,
                             @RequestParam(value = "flightDate",required = false) String flightDate,
                             @RequestParam(value = "waybillnomaster",required = false) String waybillnomaster,
                             @RequestParam(value = "customsCode",required = false) String customsCode
                             ){
        PREPAREMASTER preparemaster = new PREPAREMASTER();
        preparemaster.setWaybillnomaster(waybillnomaster);
        preparemaster.setCustomscode(customsCode);
        if(StringUtils.isNotEmpty(flightNo)){
            preparemaster.setFlightno(flightNo.substring(2));
            preparemaster.setCarrier(flightNo.substring(0,2));
        }

        if(StringUtils.isNotEmpty(flightDate)){
            Date flight_Date = DateUtil.parseDate(flightDate,"yyyyMMdd");
            preparemaster.setFlightdate(flight_Date);
        }

        PageInfo<PREPAREMASTER>  pageInfo=  preparmasterService.search(preparemaster,page,limit);
        return new ResultJson("200","OK",pageInfo);
    }


}