mirror of
https://github.com/JeffLi1993/springboot-learning-example.git
synced 2026-03-15 06:49:26 +08:00
Springboot 实现 Restful 服务,基于 HTTP / JSON 传输
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package org.spring.springboot.service;
|
||||
|
||||
import org.spring.springboot.domain.City;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 城市业务逻辑接口类
|
||||
*
|
||||
* Created by bysocket on 07/02/2017.
|
||||
*/
|
||||
public interface CityService {
|
||||
|
||||
/**
|
||||
* 获取城市信息列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<City> findAllCity();
|
||||
|
||||
/**
|
||||
* 根据城市 ID,查询城市信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
City findCityById(Long id);
|
||||
|
||||
/**
|
||||
* 新增城市信息
|
||||
*
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
Long saveCity(City city);
|
||||
|
||||
/**
|
||||
* 更新城市信息
|
||||
*
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
Long updateCity(City city);
|
||||
|
||||
/**
|
||||
* 根据城市 ID,删除城市信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Long deleteCity(Long id);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.spring.springboot.service.impl;
|
||||
|
||||
import org.spring.springboot.dao.CityDao;
|
||||
import org.spring.springboot.domain.City;
|
||||
import org.spring.springboot.service.CityService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 城市业务逻辑实现类
|
||||
*
|
||||
* Created by bysocket on 07/02/2017.
|
||||
*/
|
||||
@Service
|
||||
public class CityServiceImpl implements CityService {
|
||||
|
||||
@Autowired
|
||||
private CityDao cityDao;
|
||||
|
||||
public List<City> findAllCity(){
|
||||
return cityDao.findAllCity();
|
||||
}
|
||||
|
||||
public City findCityById(Long id) {
|
||||
return cityDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long saveCity(City city) {
|
||||
return cityDao.saveCity(city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long updateCity(City city) {
|
||||
return cityDao.updateCity(city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deleteCity(Long id) {
|
||||
return cityDao.deleteCity(id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user