package com.wms_main.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wms_main.dao.ITSysUserService;
import com.wms_main.mapper.SysUserMapper;
import com.wms_main.model.po.TSysUser;
import org.springframework.stereotype.Service;

import static com.wms_main.repository.utils.StringUtils.encryptPassword;

/**
 * User服务实现
 */
@Service
public class TSysUserServiceImpl extends ServiceImpl<SysUserMapper, TSysUser> implements ITSysUserService {
    @Override
    public TSysUser getUserWithAuth(String loginAccount, String loginPassword) {
        LambdaQueryWrapper<TSysUser> queryWrapper = new LambdaQueryWrapper<>();
        // 设置查询条件
        queryWrapper.eq(TSysUser::getLoginAccount, loginAccount)
                .eq(TSysUser::getLoginPassword, encryptPassword(loginPassword));

        return getOne(queryWrapper);
    }

    @Override
    public TSysUser getUserWithOutAuth(String loginAccount) {
        LambdaQueryWrapper<TSysUser> queryWrapper = new LambdaQueryWrapper<>();
        // 设置查询条件
        queryWrapper.eq(TSysUser::getLoginAccount, loginAccount);

        return getOne(queryWrapper);
    }
}
