package com.persagy.dmp.rwd.simple.service.impl;

import cn.hutool.core.util.StrUtil;
import com.persagy.dmp.basic.dto.RequestData;
import com.persagy.dmp.rwd.basic.utils.DigitalCommonUtils;
import com.persagy.dmp.rwd.simple.dao.SystemCustomMapper;
import com.persagy.dmp.rwd.simple.service.ISystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * @author lvxy
 * @date 2021/10/9
 */
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class SystemServiceImpl implements ISystemService {

    @Resource
    private SystemCustomMapper mapper;
    @Override
    public List<Map<String, Object>> queryNotSureSystem(RequestData requestData) {
        // 1.计算分页参数
        DigitalCommonUtils.computePageParam(requestData);
        // 2.不确定建筑 buildingId is null
        // 3.确定建筑不确定楼层 buildingId is not null
        if(StrUtil.isEmpty(requestData.getBuildingId())){
            return mapper.querySystemNotSureBuilding(requestData);
        }else{
            return mapper.querySystemNotSureFloor(requestData);
        }
    }
}
