package com.fs.company.service.impl;

import com.fs.common.annotation.DataScope;
import com.fs.common.utils.DateUtils;
import com.fs.company.domain.CompanyUser;
import com.fs.company.domain.CompanyWxAccount;
import com.fs.company.mapper.CompanyWxAccountMapper;
import com.fs.company.service.ICompanyWxAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 企微账号Service业务层处理
 * 
 * @author fs
 * @date 2024-12-09
 */
@Service
public class CompanyWxServiceImpl implements ICompanyWxAccountService
{
    @Autowired
    private CompanyWxAccountMapper companyWxAccountMapper;

    /**
     * 查询企微账号
     * 
     * @param id 企微账号ID
     * @return 企微账号
     */
    @Override
    public CompanyWxAccount selectCompanyWxAccountById(Long id)
    {
        return companyWxAccountMapper.selectCompanyWxAccountById(id);
    }

    /**
     * 查询企微账号列表
     * 
     * @param companyWxAccount 企微账号
     * @return 企微账号
     */
    @Override
    public List<CompanyWxAccount> selectCompanyWxAccountList(CompanyWxAccount companyWxAccount)
    {
        return companyWxAccountMapper.selectCompanyWxAccountList(companyWxAccount);
    }
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<CompanyWxAccount> selectCompanyWxAccountListCompany(CompanyWxAccount companyWxAccount)
    {
        return companyWxAccountMapper.selectCompanyWxAccountListCompany(companyWxAccount);
    }

    /**
     * 新增企微账号
     * 
     * @param companyWxAccount 企微账号
     * @return 结果
     */
    @Override
    public int insertCompanyWxAccount(CompanyWxAccount companyWxAccount)
    {
        companyWxAccount.setCreateTime(DateUtils.getNowDate());
        return companyWxAccountMapper.insertCompanyWxAccount(companyWxAccount);
    }

    /**
     * 修改企微账号
     * 
     * @param companyWxAccount 企微账号
     * @return 结果
     */
    @Override
    public int updateCompanyWxAccount(CompanyWxAccount companyWxAccount)
    {
        return companyWxAccountMapper.updateCompanyWxAccount(companyWxAccount);
    }

    /**
     * 批量删除企微账号
     * 
     * @param ids 需要删除的企微账号ID
     * @return 结果
     */
    @Override
    public int deleteCompanyWxAccountByIds(Long[] ids)
    {
        return companyWxAccountMapper.deleteCompanyWxAccountByIds(ids);
    }

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

    @Override
    public List<CompanyUser> companyListAll() {
        return companyWxAccountMapper.companyListAll();
    }

    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<CompanyUser> companyListAllCompany(CompanyUser companyUser) {
        return companyWxAccountMapper.companyListAllCompany(companyUser);
    }

    @Override
    public CompanyWxAccount selectByCompanyUserAndWxNo(Long userId, String wxNo) {
        return companyWxAccountMapper.selectByCompanyUserAndWxNo(userId, wxNo);
    }
}
