package com.brilliance.isc.common.user.service.impl;

import com.brilliance.isc.bo.Auzlvl;
import com.brilliance.isc.common.user.service.UserService;
import com.brilliance.isc.mda.dao.AuzlvlMapper;
import com.brilliance.isc.mda.dao.UserMapper;
import com.brilliance.isc.vo.manager.UserVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Resource
    private AuzlvlMapper auzlvlMapper;


    @Override
    public UserVo getUserByPersonId(Integer personId) {
        return userMapper.getUserByPersonId(personId);
    }

    @Override
    public UserVo getUserByUsrInr(String usrInr) {
        return userMapper.getUserByUsrInr(usrInr);
    }

    @Override
    public UserVo getUserByLogName(String logName) {
        return userMapper.getUserByLogName(logName);
    }

    @Override
    public Auzlvl getAuzlvlbyUsrInr(String usrInr, String accBch, String busTyp, String trnCode) {
        UserVo user = userMapper.getUserByUsrInr(usrInr);
        String authlevel = user.getAuthlevel();
        Auzlvl auzlvl = new Auzlvl();
        auzlvl.setBranch(accBch);
        auzlvl.setAuthlevel(authlevel);
        auzlvl.setType(busTyp);
        auzlvl.setCode(trnCode);
        List<Auzlvl> auzlvls = auzlvlMapper.listByUniqueKey(auzlvl);
        if (auzlvls != null && auzlvls.size() >0) {
            return auzlvls.get(0);
        }
        return null;
    }

    @Override
    public List<UserVo> getAllUser() {
        return userMapper.getAllUser();
    }

}
