package com.happy.service.impl;

import com.happy.Model.Booking;
import com.happy.Model.HouseNumber;
import com.happy.Until.DateUtil;
import com.happy.dao.HouseNumberDao;
import com.happy.dto.HouseNumberDto;
import com.happy.service.HouseNumberService;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("HouseNumberService")
public class HouseNumberImplService implements HouseNumberService {
    @Resource
    public HouseNumberDao houseNumberDao;

    @Override
    public int saveBatch(List<HouseNumber> list) {
        return houseNumberDao.saveBatch(list);
    }

    @Override
    public int updateBatch(List<HouseNumber> list) {
        return houseNumberDao.updateBatch(list);
    }

    @Override
    public int updateHouseStatus(String ids) {
        return houseNumberDao.updateHouseStatus(ids);
    }

    @Override
    public List<HouseNumber> queryHouseStatus(Booking book) {
        return houseNumberDao.queryHouseStatus(book);
    }

    @Override
    public List<HouseNumber> queryCheckRoom(Booking book) {
        List<HouseNumber> result = houseNumberDao.queryCheckRoom(book);
        return result;
    }


    @Override
    public List<HouseNumber> queryByHouseId(String houseId) {
        return houseNumberDao.queryByHouseId(houseId);
    }

    @SneakyThrows
    @Override
    public void modifyHouseStatus(HouseNumberDto houseNumberDto) {
        Date dataTime = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
        houseNumberDto.setModifyDate(dataTime);
        houseNumberDao.modifyHouseStatus(houseNumberDto);
    }
}
