package com.fs.qw.service.impl;

import com.fs.common.utils.DateUtils;
import com.fs.qw.domain.QwAccount;
import com.fs.qw.domain.QwAccountAudit;
import com.fs.qw.domain.QwUser;
import com.fs.qw.mapper.QwAccountMapper;
import com.fs.qw.mapper.QwUserMapper;
import com.fs.qw.service.IQwAccountService;
import com.fs.qw.service.IQwUserService;
import com.fs.qw.vo.QwAccountListVO;
import com.fs.qw.vo.QwUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 企微功能账号管理Service业务层处理
 *
 * @author fs
 * @date 2023-08-23
 */
@Service
public class QwUserServiceImpl implements IQwUserService {
    @Autowired
    private QwUserMapper qwUserMapper;
    @Autowired
    private QwAccountMapper qwAccountMapper;

    /**
     * 查询企微账号信息
     *
     * @param userId 企微账号信息ID
     * @return 企微账号信息
     */
    @Override
    public QwUser selectQwUserById(Long userId) {
        return qwUserMapper.selectQwUserById(userId);
    }

    /**
     * 查询企微账号信息列表
     *
     * @param qwUser 企微账号信息
     * @return 企微账号信息
     */
    @Override
    public List<QwUser> selectQwUserList(QwUser qwUser) {
        return qwUserMapper.selectQwUserList(qwUser);
    }

    /**
     * 新增企微账号信息
     *
     * @param qwUser 企微账号信息
     * @return 结果
     */
    @Override
    public int insertQwUser(QwUser qwUser) {
        qwUser.setCreateTime(new Date());
        qwAccountMapper.setUserIdByDeviceId(qwUser.getDeviceId(),qwUser.getUserId());
        return qwUserMapper.insertQwUser(qwUser);
    }

    /**
     * 修改企微账号信息
     *
     * @param qwUser 企微账号信息
     * @return 结果
     */
    @Override
    public int updateQwUser(QwUser qwUser) {
        return qwUserMapper.updateQwUser(qwUser);
    }

    /**
     * 批量删除企微账号信息
     *
     * @param userIds 需要删除的企微账号信息ID
     * @return 结果
     */
    @Override
    public int deleteQwUserByIds(Long[] userIds) {
        return qwUserMapper.deleteQwUserByIds(userIds);
    }

    /**
     * 删除企微账号信息信息
     *
     * @param userId 企微账号信息ID
     * @return 结果
     */
    @Override
    public int deleteQwUserById(Long userId) {
        return qwUserMapper.deleteQwUserById(userId);
    }

    @Override
    public int selectBangDingDeviceId(String deviceId) {
        return qwUserMapper.selectBangDingDeviceId(deviceId);
    }

    @Override
    public QwUserVO selectQwUserByDeviceId(String deviceId) {
        return qwUserMapper.selectQwUserByDeviceId(deviceId);
    }


}
