package com.test.mapper;

import com.test.bean.RoomType;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface RoomTypeMapper {

    @Select("select count(*) from room_type")
    public long getRoomTypeCount();

//    start为起始索引
    @Select("select * from room_type limit #{start}, #{pageSize}")
    public ArrayList<RoomType> getRoomTypeByPage(int start, int pageSize);

    @Select("select * from room_type")
    public ArrayList<RoomType> getRoomType();

    @Insert("insert into room_type(room_type, remark,price, cover,bed_num, remain,windows, create_time, update_time) VALUE (#{roomType}, #{remark}, #{price}, #{cover}, #{bedNum}, #{remain}, #{windows}, #{createTime}, #{updateTime})")
    public boolean addRoomType(RoomType roomType);

    @Select("select * from room_type where type_id = #{id}")
    RoomType getRoomTypeById(Long id);

    @Update("update room_type set room_type = #{roomType}, remark = #{remark}, price = #{price}, cover = #{cover}, bed_num = #{bedNum}, remain = #{remain}, windows = #{windows}, update_time = #{updateTime} where type_id = #{typeId}")
    boolean updateRoomType(RoomType roomType);

    @Delete("delete from room_type where type_id = #{id}")
    boolean deleteRoomType(Long id);
}
