完成RoomService类编写,通过单元测试

This commit is contained in:
freeebird
2018-11-12 16:43:47 +08:00
parent 01475b6215
commit 435e38198d
6 changed files with 171 additions and 29 deletions

View File

@@ -6,13 +6,11 @@ import java.util.List;
public interface RoomService {
int addRoom(Room room);
int deleteRoom(int roomId);
int deleteRoom(String roomNumber);
int updateRoom(Room room);
Room findById(int roomId);
Room findByNumber(String roomNumber);
List<Room> findByStatus(String status);
List<Room> findByType(String typeName);
List<Room> findAll();
int insert(Room room);
int delete(int roomId);
int update(Room room);
Room selectById(int roomId);
List<Room> selectByStatus(int roomStatus);
List<Room> selectByType(int typeId);
List<Room> selectAll();
}

View File

@@ -0,0 +1,50 @@
package cn.mafangui.hotel.service.impl;
import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.mapper.RoomMapper;
import cn.mafangui.hotel.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class RoomServiceImpl implements RoomService {
@Autowired
private RoomMapper roomMapper;
@Override
public int insert(Room room) {
return roomMapper.insertSelective(room);
}
@Override
public int delete(int roomId) {
return roomMapper.deleteByPrimaryKey(roomId);
}
@Override
public int update(Room room) {
return roomMapper.updateByPrimaryKeySelective(room);
}
@Override
public Room selectById(int roomId) {
return roomMapper.selectByPrimaryKey(roomId);
}
@Override
public List<Room> selectByStatus(int roomStatus) {
return roomMapper.selectByStatus(roomStatus);
}
@Override
public List<Room> selectByType(int typeId) {
return roomMapper.selectByType(typeId);
}
@Override
public List<Room> selectAll() {
return roomMapper.selectAll();
}
}