package com.lightinit.hsdatashow.impl.admin;

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

/**
 * Created by WangYao on 2018/5/28.
 */
@Service
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;
    }
}
