mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-11-04 14:34:47 +08:00 
			
		
		
		
	完成RoomService类编写,通过单元测试
This commit is contained in:
		@@ -102,4 +102,20 @@ public class Room {
 | 
			
		||||
    public void setUpdateTime(Date updateTime) {
 | 
			
		||||
        this.updateTime = updateTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Room{" +
 | 
			
		||||
                "roomId=" + roomId +
 | 
			
		||||
                ", roomNumber='" + roomNumber + '\'' +
 | 
			
		||||
                ", typeId=" + typeId +
 | 
			
		||||
                ", roomType='" + roomType + '\'' +
 | 
			
		||||
                ", roomPrice=" + roomPrice +
 | 
			
		||||
                ", roomDiscount=" + roomDiscount +
 | 
			
		||||
                ", roomStatus=" + roomStatus +
 | 
			
		||||
                ", remark='" + remark + '\'' +
 | 
			
		||||
                ", createTime=" + createTime +
 | 
			
		||||
                ", updateTime=" + updateTime +
 | 
			
		||||
                '}';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
package cn.mafangui.hotel.mapper;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.Room;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@Component
 | 
			
		||||
public interface RoomMapper {
 | 
			
		||||
    int deleteByPrimaryKey(Integer roomId);
 | 
			
		||||
 | 
			
		||||
@@ -14,4 +17,10 @@ public interface RoomMapper {
 | 
			
		||||
    int updateByPrimaryKeySelective(Room record);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKey(Room record);
 | 
			
		||||
 | 
			
		||||
    List<Room> selectByType(Integer typeId);
 | 
			
		||||
 | 
			
		||||
    List<Room> selectByStatus(Integer roomStatus);
 | 
			
		||||
 | 
			
		||||
    List<Room> selectAll();
 | 
			
		||||
}
 | 
			
		||||
@@ -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();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user