eclipse 使用maven 整合springboot + retrofit
阿新 • • 發佈:2019-01-07
說明:該類提供了三個方法,也是將來customerresultful服務遠端呼叫的三個方法。package com.zzg.resultful.controller; import java.util.ArrayList; import java.util.List; import org.springframework.web.bind.annotation.RequestBody; 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 com.zzg.resultful.domain.Hotel; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @RestController @RequestMapping("/hotel") @Api("HotelController相關api") public class HotelController { @ApiOperation("獲取酒店Hotel資訊:getHotelWithQueryParameter") @RequestMapping(value="/getHotelWithQueryParameter",method=RequestMethod.GET) public Hotel getHotelWithQueryParameter(@RequestParam("hotelname") String hotelname) { if(hotelname.equals("nana")){ return new Hotel(777, "假日酒店"); } return new Hotel(1314, "玫瑰酒店"); } @ApiOperation("獲取酒店Hotel資訊:getHotelList") @RequestMapping(value="/getHotelList",method=RequestMethod.POST) public List<Hotel> getHotelList() { List<Hotel> hotelList = new ArrayList<Hotel>(); hotelList.add(new Hotel(1314, "玫瑰酒店")); hotelList.add(new Hotel(2046, "2046酒店")); return hotelList; } @ApiOperation("獲取酒店Hotel資訊:getHotelListWithBody") @RequestMapping(value="/getHotelListWithBody",method=RequestMethod.POST) public List<Hotel> getHotelListWithBody(@RequestBody Hotel hotel) { List<Hotel> hotelList = new ArrayList<Hotel>(); if(hotel.getHotelname().equals("武林酒店")){ hotelList.add(new Hotel(13141, "玫瑰酒店1")); hotelList.add(new Hotel(20461, "2046酒店1")); return hotelList; } hotelList.add(new Hotel(1314, "玫瑰酒店")); hotelList.add(new Hotel(2046, "2046酒店")); return hotelList; } }