package com.ruoyi.ss.wifi.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.wifi.domain.Wifi;
import com.ruoyi.ss.wifi.domain.WifiQuery;
import com.ruoyi.ss.wifi.domain.WifiVO;
import com.ruoyi.ss.wifi.mapper.WifiMapper;
import com.ruoyi.ss.wifi.service.IWifiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.ruoyi.common.utils.SecurityUtils.getUserId;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * wifiService业务层处理
 *
 * @author qzz
 * @date 2025-01-06
 */
@Service
public class WifiServiceImpl implements IWifiService
{
    @Autowired
    private WifiMapper wifiMapper;

    /**
     * 查询wifi
     *
     * @param wifiId wifi主键
     * @return wifi
     */
    @Override
    public WifiVO selectWifiByWifiId(Long wifiId)
    {
        return wifiMapper.selectWifiByWifiId(wifiId);
    }

    /**
     * 查询wifi列表
     *
     * @param wifi wifi
     * @return wifi
     */
    @Override
    public List<WifiVO> selectWifiList(WifiQuery wifi)
    {
        return wifiMapper.selectWifiList(wifi);
    }

    /**
     * 新增wifi
     *
     * @param wifi wifi
     * @return 结果
     */
    @Override
    public int insertWifi(Wifi wifi)
    {
        if(ObjectUtil.isNull(wifi.getMerchantId())){
            wifi.setMerchantId(getUserId());
        }
        wifi.setCreateBy(getUsername());
        wifi.setCreateTime(DateUtils.getNowDate());
        return wifiMapper.insertWifi(wifi);
    }

    /**
     * 修改wifi
     *
     * @param wifi wifi
     * @return 结果
     */
    @Override
    public int updateWifi(Wifi wifi)
    {
        return wifiMapper.updateWifi(wifi);
    }

    /**
     * 批量删除wifi
     *
     * @param wifiIds 需要删除的wifi主键
     * @return 结果
     */
    @Override
    public int deleteWifiByWifiIds(Long[] wifiIds)
    {
        return wifiMapper.deleteWifiByWifiIds(wifiIds);
    }

    /**
     * 删除wifi信息
     *
     * @param wifiId wifi主键
     * @return 结果
     */
    @Override
    public int deleteWifiByWifiId(Long wifiId)
    {
        return wifiMapper.deleteWifiByWifiId(wifiId);
    }
}
