package com.crm.pay.service.impl;

import com.crm.pay.dao.repository.UserInfoRepository;
import com.crm.pay.service.UserInfoService;
import com.crm.rely.backend.model.pojo.table.UserInfoTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.rmi.ServerException;

/**
 * Created by max on 2020/8/9.
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {


    @Autowired
    private UserInfoRepository userInfoRepository;

    @Override
    public UserInfoTable getById(Long id) throws ServerException {

        UserInfoTable userInfoTable = userInfoRepository.getFirstById(id);
        if (userInfoTable == null) {
            throw new ServerException("user_not_found");
        }

        return userInfoTable;
    }

    @Override
    public UserInfoTable getByAgentId(Long agentId)  {
        return userInfoRepository.getFirstById(agentId);
    }
}
