package com.lightinit.hsdataportal.impl.share;

import com.lightinit.hsdataportal.entity.Admin;
import com.lightinit.hsdataportal.mapper.AdminMapper;
import com.lightinit.hsdataportal.model.LoginUser;
import com.lightinit.hsdataportal.service.share.IAccountService;
import com.lightinit.hsdataportal.spring.DynamicDataContextHolder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author WangYao
 * @date 2018/6/22 11:13
 * @description 账户业务实现
 */
@Service("shareAccountServiceImpl")
public class AccountServiceImpl implements IAccountService {

    @Autowired
    private AdminMapper adminMapper;

    public LoginUser getLoginUserByUsername(String username) {
        DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
        LoginUser loginUser = new LoginUser();
        Admin admin = adminMapper.selectByUserName(username);
        BeanUtils.copyProperties(admin, loginUser);
        return loginUser;
    }

}
