微服務呼叫demo,兩個服務,echarts介面
阿新 • • 發佈:2020-11-14
package cn.kgc.flight.service;
import cn.kgc.flight.dao.FlightDao;
import cn.kgc.flight.pojo.City;
import cn.kgc.flight.pojo.Flight;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
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.List;
@RestController
@Transactional(readOnly = true)
public class FlightService {
@Resource private FlightDao flightDao; @RequestMapping("/showCity") public List<City> showAllCity() { return flightDao.queryAllCity(); } @RequestMapping("/showFlight") public List<Flight> showFlight(@RequestParam(value = "departureCity") Integer departureCity, @RequestParam(value = "arrivalCity") Integer arrivalCity) { return flightDao.queryFlight(departureCity, arrivalCity); } @RequestMapping("/count") public Boolean queryCountByFlightNo(@RequestParam(value = "flightNo") String flightNo) { return flightDao.queryCountByFlightNo(flightNo) == 1; } @RequestMapping("/add") @Transactional public Boolean addFlight(@RequestBody Flight flight) { return flightDao.insertFlight(flight) == 1; }
}