SaleManServiceImpl.java 1.11 KB
package tkio.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tkio.model.BussinessMan;
import tkio.model.SalesManLeader;
import tkio.repository.SalesManLeaderRepository;
import tkio.service.SalesManService;

/**
 * Created by mxq on 2018/1/2.
 */
@Service
public class SaleManServiceImpl implements SalesManService {
    @Autowired
    SalesManLeaderRepository salesManLeaderRepository;
    @Override
    public void create(String loginEmail, String email, String name) {
        SalesManLeader salesManLeader = new SalesManLeader();
        salesManLeader.setEmail(email);
        salesManLeader.setName(name);

        SalesManLeader manLeader = salesManLeaderRepository.findOneByEmail(loginEmail);
        if(null != manLeader){
            salesManLeader.setLeader(manLeader.getLeader());
            salesManLeaderRepository.save(salesManLeader);
        }else{
            SalesManLeader save = salesManLeaderRepository.save(salesManLeader);
            save.setLeader(save.getId());
            salesManLeaderRepository.save(save);
        }

    }
}