package com.zehong.system.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.domain.TYehuaqiDevice;
import com.zehong.system.domain.vo.TDetectorUserVO;
import com.zehong.system.domain.vo.TYehuaqiUserVO;
import com.zehong.system.mapper.TYehuaqiDeviceMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TYehuaqiUserMapper;
import com.zehong.system.domain.TYehuaqiUser;
import com.zehong.system.service.ITYehuaqiUserService;

/**
 * 燃气用户Service业务层处理
 * 
 * @author zehong
 * @date 2022-09-14
 */
@Service
public class TYehuaqiUserServiceImpl implements ITYehuaqiUserService 
{
    @Autowired
    private TYehuaqiUserMapper tYehuaqiUserMapper;
    @Autowired
    private TYehuaqiDeviceMapper tYehuaqiDeviceMapper;

    /**
     * 查询燃气用户
     * 
     * @param userId 燃气用户ID
     * @return 燃气用户
     */
    @Override
    public TYehuaqiUser selectTYehuaqiUserById(Long userId)
    {
        return tYehuaqiUserMapper.selectTYehuaqiUserById(userId);
    }

    /**
     * 查询燃气用户列表
     * 
     * @param tYehuaqiUser 燃气用户
     * @return 燃气用户
     */
    @Override
    public List<TYehuaqiUser> selectTYehuaqiUserList(TYehuaqiUser tYehuaqiUser)
    {
        return tYehuaqiUserMapper.selectTYehuaqiUserList(tYehuaqiUser);
    }
    @Override
    public List<TYehuaqiUser> selectAllUserList(TYehuaqiUser tYehuaqiUser)
    {
        List<TYehuaqiUser> list =  tYehuaqiUserMapper.selectTYehuaqiUserListTwo(tYehuaqiUser);
//        for (TYehuaqiUser user : list){
//            TYehuaqiDevice d = new TYehuaqiDevice();
//            d.setUserId(user.getUserId());
//            List<TYehuaqiDevice> devices = tYehuaqiDeviceMapper.selectTYehuaqiDeviceList(d);
//            user.setDeviceNum(devices.size());
//        }
        return list;
    }

    /**
     * 新增燃气用户
     * 
     * @param tYehuaqiUser 燃气用户
     * @return 结果
     */
    @Override
    public int insertTYehuaqiUser(TYehuaqiUser tYehuaqiUser)
    {
        tYehuaqiUser.setCreateTime(DateUtils.getNowDate());
        return tYehuaqiUserMapper.insertTYehuaqiUser(tYehuaqiUser);
    }

    /**
     * 修改燃气用户
     * 
     * @param tYehuaqiUser 燃气用户
     * @return 结果
     */
    @Override
    public int updateTYehuaqiUser(TYehuaqiUser tYehuaqiUser)
    {
        tYehuaqiUser.setUpdateTime(DateUtils.getNowDate());
        return tYehuaqiUserMapper.updateTYehuaqiUser(tYehuaqiUser);
    }

    /**
     * 批量删除燃气用户
     * 
     * @param userIds 需要删除的燃气用户ID
     * @return 结果
     */
    @Override
    public int deleteTYehuaqiUserByIds(Long[] userIds)
    {
        return tYehuaqiUserMapper.deleteTYehuaqiUserByIds(userIds);
    }

    /**
     * 删除燃气用户信息
     * 
     * @param userId 燃气用户ID
     * @return 结果
     */
    @Override
    public int deleteTYehuaqiUserById(Long userId)
    {
        return tYehuaqiUserMapper.deleteTYehuaqiUserById(userId);
    }
}
