package com.jiayue.insu.incloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.insu.incloud.entity.User;
import com.jiayue.insu.incloud.mapper.UserMapper;
import com.jiayue.insu.incloud.service.UserService;
import org.springframework.stereotype.Service;
/**
 * 用户登录业务实现
 *
 * @author yh
 * @version 1.0
 * @since 2022/5/22 11:29
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {



    @Override
    public User findByNameAndPwd(String name, String pwd) {
        LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(User::getUsername,name);
        lambdaQueryWrapper.eq(User::getPassword,pwd);
        User user = this.getOne(lambdaQueryWrapper);
        return user;
    }

    @Override
    public User findByName(String name) {
        LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(User::getUsername,name);
        User user = this.getOne(lambdaQueryWrapper);
        return user;
    }
}
