mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-11-04 14:34:47 +08:00 
			
		
		
		
	完成房间信息接口编写,通过单元测试
This commit is contained in:
		@@ -4,6 +4,7 @@ import cn.mafangui.hotel.entity.Room;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -15,11 +16,42 @@ public class RoomController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomService roomService;
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/all")
 | 
			
		||||
    public List<Room> getAllRoom(){
 | 
			
		||||
        List<Room> result = roomService.selectAll();
 | 
			
		||||
        for (Room r:result) {
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    @RequestMapping(value = "/add")
 | 
			
		||||
    public int addRoom(String roomNumber,int typeId,String roomType,double roomPrice,double roomDiscount,int roomStatus,String remark){
 | 
			
		||||
        Room room = new Room(roomNumber,typeId,roomType,roomPrice,roomDiscount,roomStatus,remark);
 | 
			
		||||
        return roomService.insert(room);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/delete")
 | 
			
		||||
    public int deleteRoom(int roomId){
 | 
			
		||||
        return roomService.delete(roomId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/update")
 | 
			
		||||
    public int updateRoom(int roomId,String roomNumber,int typeId,
 | 
			
		||||
                          String roomType,double roomPrice,double roomDiscount,int roomStatus,String remark){
 | 
			
		||||
        Room room = new Room(roomNumber,typeId,roomType,roomPrice,roomDiscount,roomStatus,remark);
 | 
			
		||||
        room.setRoomId(roomId);
 | 
			
		||||
        return roomService.update(room);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/withId")
 | 
			
		||||
    public Room getById(int roomId){
 | 
			
		||||
        return roomService.selectById(roomId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/withType")
 | 
			
		||||
    public List<Room> getByType(int typeId){
 | 
			
		||||
        return roomService.selectByType(typeId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/withStatus")
 | 
			
		||||
    public List<Room> getByStatus(int roomStatus){
 | 
			
		||||
        return roomService.selectByStatus(roomStatus);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/all")
 | 
			
		||||
    public List<Room> getAll(){
 | 
			
		||||
        return roomService.selectAll();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -22,6 +22,12 @@ public class RoomTypeController {
 | 
			
		||||
        return roomTypeService.findAllType();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/withId")
 | 
			
		||||
    public RoomType getById(int typeId){
 | 
			
		||||
        return roomTypeService.selectById(typeId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/add")
 | 
			
		||||
    public int addRoomType(String roomType,Double price,Double discount,int area,
 | 
			
		||||
                           int bedNum,String bedSize,int window,String remark){
 | 
			
		||||
 
 | 
			
		||||
@@ -103,6 +103,19 @@ public class Room {
 | 
			
		||||
        this.updateTime = updateTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Room() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Room(String roomNumber, Integer typeId, String roomType, Double roomPrice, Double roomDiscount, Integer roomStatus, String remark) {
 | 
			
		||||
        this.roomNumber = roomNumber;
 | 
			
		||||
        this.typeId = typeId;
 | 
			
		||||
        this.roomType = roomType;
 | 
			
		||||
        this.roomPrice = roomPrice;
 | 
			
		||||
        this.roomDiscount = roomDiscount;
 | 
			
		||||
        this.roomStatus = roomStatus;
 | 
			
		||||
        this.remark = remark;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Room{" +
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user