package com.qmth.exam.reserve.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.exam.reserve.dao.UserDao;
import com.qmth.exam.reserve.entity.UserEntity;
import com.qmth.exam.reserve.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);

    @Override
    public UserEntity findUserByLoginName(Long orgId, String loginName) {
        LambdaQueryWrapper<UserEntity> wrapper = new LambdaQueryWrapper<>();
        if (orgId != null) {
            wrapper.eq(UserEntity::getOrgId, orgId);
        }
        wrapper.eq(UserEntity::getLoginName, loginName);
        wrapper.eq(UserEntity::getEnable, true);
        return baseMapper.selectOne(wrapper);
    }

}
