@ -38,7 +38,7 @@ public class AirServiceImpl implements AirService {
@Override
@Override
public PageInfo findAirByDistrictIdAndPage ( Integer page , Integer size , Integer districtId ) {
public PageInfo findAirByDistrictIdAndPage ( Integer page , Integer size , Integer districtId ) {
//1、分页
//1、分页
PageHelper . startPage ( page , size ) ;
PageHelper . startPage ( page , size ) ;
//2、查询
//2、查询
List < Air > airList = airMapper . findBydDistrictId ( districtId ) ;
List < Air > airList = airMapper . findBydDistrictId ( districtId ) ;
//3、封装PageInfo
//3、封装PageInfo
@ -52,7 +52,7 @@ public class AirServiceImpl implements AirService {
public void add ( AirAddForm airAddForm ) {
public void add ( AirAddForm airAddForm ) {
//1、封装数据
//1、封装数据
Air air = new Air ( ) ;
Air air = new Air ( ) ;
BeanUtils . copyProperties ( airAddForm , air ) ;
BeanUtils . copyProperties ( airAddForm , air ) ;
//2、添加数据
//2、添加数据
int count = airMapper . insert ( air ) ;
int count = airMapper . insert ( air ) ;
@ -65,6 +65,7 @@ public class AirServiceImpl implements AirService {
}
}
@Override
@Override
@Transactional
public void updateById ( Air air ) {
public void updateById ( Air air ) {
//1、修改数据
//1、修改数据
int count = airMapper . updateById ( air ) ;
int count = airMapper . updateById ( air ) ;
@ -74,4 +75,16 @@ public class AirServiceImpl implements AirService {
throw new RuntimeException ( "【修改空气质量】 修改失败!!" ) ;
throw new RuntimeException ( "【修改空气质量】 修改失败!!" ) ;
}
}
}
}
@Override
@Transactional
public void deleteById ( Integer id ) {
// 删除
int count = airMapper . deleteById ( id ) ;
// 判断
if ( count ! = 1 ) {
System . out . println ( "【删除空气质量】 删除失败!!" ) ;
throw new RuntimeException ( "【删除空气质量】 删除失败!!" ) ;
}
}
}
}