package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMallFloor;
import com.iformall.mapper.WxMallFloorMapper;
import com.iformall.service.WxMallFloorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class WxMallFloorServiceImpl implements WxMallFloorService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxMallFloorMapper wxMallFloorMapper;


    @Override
    public PageInfo<WxMallFloor> listAsPage(WxMallFloor record, Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMallFloorMapper.findList(record));
    }

    @Override
    public WxMallFloor getById(Long id) {
        return wxMallFloorMapper.selectById(id);
    }

    @Override
    public void saveOrUpdate(WxMallFloor record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            wxMallFloorMapper.insert(record);
        } else {
            wxMallFloorMapper.updateById(record);
        }
    }

    @Override
    public void deleteById(Long id) {
        wxMallFloorMapper.deleteById(id);
    }


    @Override
    public ResultData getfloorlist(String tenantId,Long buildingId) {
        WxMallFloor wxMallFloor = new WxMallFloor();
        wxMallFloor.setTenantId(tenantId);
        wxMallFloor.setBuildingId(buildingId);
        List<WxMallFloor> list = wxMallFloorMapper.findList(wxMallFloor);
        return new ResultData(list);
    }
    
    
    
    
    
}
