术宇吧 关注:3贴子:16
  • 0回复贴,共1

carServiceImpl

只看楼主收藏回复

package com.feicui.service.impl;
import java.math.BigDecimal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.feicui.bean.Car;
import com.feicui.dao.CarMapper;
import com.feicui.service.CarService;
import com.feicui.util.PageModel;
@Service("carServiceImpl")
public class CarServiceImpl implements CarService {
@Autowired
private CarMapper carMapper;
@Transactional
@Override
public void add(Car car) throws Exception {
carMapper.add(car);
}
@Transactional
@Override
public void del(Integer[] ids) throws Exception {
carMapper.del(ids);
}
@Transactional
@Override
public void update2(Car car) throws Exception {
carMapper.update(car);
}
@Transactional
@Override
public void updateByPrice(BigDecimal price) throws Exception {
carMapper.updateByPrice(price);
}
@Transactional(readOnly = true)
@Override
public Car queryCarById(Integer id) throws Exception {
return carMapper.queryCarById(id);
}
@Transactional(readOnly = true)
@Override
public List<Car> queryCars(Car car) throws Exception {
return carMapper.queryCars(car);
}
/**
* 分页带条件查询
* 1.查询符合条件的记录总数
* 2.获得当前页的数据
* */
@Override
public PageModel<Car> queryCarsForPage(PageModel<Car> page) throws Exception {
// 查询符合条件的记录总数
int num = carMapper.queryCarsNum(page.getSearchObj());
// 把查询的总数设置给pagemodel
page.setTotalRecords(num);
// 获得当前页的数据
List<Car> list = carMapper.queryCarsForPage(page);
page.setList(list);
return page;
}
@Override
public void delete(Car car) throws Exception {
carMapper.deleteByPrimaryKey(car.getId());
}
@Override
public void insert(Car car) throws Exception {
carMapper.insertSelective(car);
}
@Override
public void update(Car car) throws Exception {
int a = carMapper.updateByPrimaryKeySelective(car);
System.out.println(a);
}
@Override
public List<Car> select(Car car) throws Exception {
return carMapper.selectAll();
}
@Override
public Car selectOne(Car car) throws Exception {
return carMapper.selectOne(car);
}
}


IP属地:北京1楼2017-12-21 12:27回复