mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-11-04 14:34:47 +08:00 
			
		
		
		
	update RoomType
This commit is contained in:
		@@ -0,0 +1,26 @@
 | 
			
		||||
package cn.mafangui.hotel.controller;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.RoomType;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomTypeService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(value = "/roomType")
 | 
			
		||||
public class RoomTypeController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomTypeService roomTypeService;
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/add")
 | 
			
		||||
    public int addNewType(int roomType,String typeName,double bookingPrice,double bookingDiscount){
 | 
			
		||||
        RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount);
 | 
			
		||||
        return roomTypeService.addRoomType(rt);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int delType(int roomType,String typeName){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -10,9 +10,9 @@ public class RoomType {
 | 
			
		||||
 | 
			
		||||
    private String typeName;
 | 
			
		||||
 | 
			
		||||
    private BigDecimal bookingPrice;
 | 
			
		||||
    private Double bookingPrice;
 | 
			
		||||
 | 
			
		||||
    private Float bookingDiscount;
 | 
			
		||||
    private Double bookingDiscount;
 | 
			
		||||
 | 
			
		||||
    private Date createTime;
 | 
			
		||||
 | 
			
		||||
@@ -42,19 +42,19 @@ public class RoomType {
 | 
			
		||||
        this.typeName = typeName == null ? null : typeName.trim();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getBookingPrice() {
 | 
			
		||||
    public Double getBookingPrice() {
 | 
			
		||||
        return bookingPrice;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBookingPrice(BigDecimal bookingPrice) {
 | 
			
		||||
    public void setBookingPrice(Double bookingPrice) {
 | 
			
		||||
        this.bookingPrice = bookingPrice;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Float getBookingDiscount() {
 | 
			
		||||
    public Double getBookingDiscount() {
 | 
			
		||||
        return bookingDiscount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBookingDiscount(Float bookingDiscount) {
 | 
			
		||||
    public void setBookingDiscount(Double bookingDiscount) {
 | 
			
		||||
        this.bookingDiscount = bookingDiscount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -73,4 +73,25 @@ public class RoomType {
 | 
			
		||||
    public void setUpdateTime(Date updateTime) {
 | 
			
		||||
        this.updateTime = updateTime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public RoomType(Integer roomType, String typeName, Double bookingPrice, Double bookingDiscount) {
 | 
			
		||||
        this.roomType = roomType;
 | 
			
		||||
        this.typeName = typeName;
 | 
			
		||||
        this.bookingPrice = bookingPrice;
 | 
			
		||||
        this.bookingDiscount = bookingDiscount;
 | 
			
		||||
    }
 | 
			
		||||
    public RoomType(){}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "RoomType{" +
 | 
			
		||||
                "typeId=" + typeId +
 | 
			
		||||
                ", roomType=" + roomType +
 | 
			
		||||
                ", typeName='" + typeName + '\'' +
 | 
			
		||||
                ", bookingPrice=" + bookingPrice +
 | 
			
		||||
                ", bookingDiscount=" + bookingDiscount +
 | 
			
		||||
                ", createTime=" + createTime +
 | 
			
		||||
                ", updateTime=" + updateTime +
 | 
			
		||||
                '}';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,17 +1,21 @@
 | 
			
		||||
package cn.mafangui.hotel.mapper;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.RoomType;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
public interface RoomTypeMapper {
 | 
			
		||||
    int deleteByPrimaryKey(Integer typeId);
 | 
			
		||||
 | 
			
		||||
    int insert(RoomType record);
 | 
			
		||||
    RoomType selectByPrimaryKey(Integer typeId);
 | 
			
		||||
    int updateByPrimaryKeySelective(RoomType record);
 | 
			
		||||
    int updateByPrimaryKey(RoomType record);
 | 
			
		||||
 | 
			
		||||
    int insertSelective(RoomType record);
 | 
			
		||||
 | 
			
		||||
    RoomType selectByPrimaryKey(Integer typeId);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKeySelective(RoomType record);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKey(RoomType record);
 | 
			
		||||
    int updateByRoomTypeSelective(RoomType record);
 | 
			
		||||
    int deleteByRoomType(RoomType roomType);
 | 
			
		||||
    RoomType selectByRoomType(RoomType roomType);
 | 
			
		||||
    List<RoomType> findAll();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/main/java/cn/mafangui/hotel/service/RoomTypeService.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/main/java/cn/mafangui/hotel/service/RoomTypeService.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
package cn.mafangui.hotel.service;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.RoomType;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public interface RoomTypeService {
 | 
			
		||||
 | 
			
		||||
    int addRoomType(RoomType roomType);
 | 
			
		||||
 | 
			
		||||
    int delRoomType(RoomType roomType);
 | 
			
		||||
 | 
			
		||||
    int updateRoomType(RoomType roomType);
 | 
			
		||||
 | 
			
		||||
    RoomType selectByName(RoomType roomType);
 | 
			
		||||
 | 
			
		||||
    List<RoomType> findAllType();
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,40 @@
 | 
			
		||||
package cn.mafangui.hotel.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.mafangui.hotel.entity.RoomType;
 | 
			
		||||
import cn.mafangui.hotel.mapper.RoomTypeMapper;
 | 
			
		||||
import cn.mafangui.hotel.service.RoomTypeService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
public class RoomTypeServiceImpl implements RoomTypeService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RoomTypeMapper roomTypeMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int addRoomType(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.insertSelective(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int delRoomType(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.deleteByRoomType(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateRoomType(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.updateByRoomTypeSelective(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public RoomType selectByName(RoomType roomType) {
 | 
			
		||||
        return roomTypeMapper.selectByRoomType(roomType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<RoomType> findAllType() {
 | 
			
		||||
        return roomTypeMapper.findAll();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user