package com.crm.manager.service.impl;

import com.crm.manager.dao.mapper.AccountInfoMapper;
import com.crm.manager.service.AccountInfoService;
import com.crm.rely.backend.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountInfoServiceImpl implements AccountInfoService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private AccountInfoMapper accountInfoMapper;

    @Override
    public Boolean loginExistsByPlatform(Long login, String platform) throws ServiceException {
        try {
            Integer result = accountInfoMapper.existsByLoginAndPlatform(login, platform);
            return result != null;
        } catch (Exception e) {
            logger.error(e.getMessage());
            throw new ServiceException(e.getMessage());
        }
    }
}
