修改登录API逻辑
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.guo.learningprogresstracker.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.guo.learningprogresstracker.domain.entity.UserEntity;
|
||||
import com.guo.learningprogresstracker.exception.AppException;
|
||||
import com.guo.learningprogresstracker.service.UserService;
|
||||
import com.guo.learningprogresstracker.mapper.UserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -12,9 +15,18 @@ import org.springframework.stereotype.Service;
|
||||
* @createDate 2024-06-09 15:28:48
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity>
|
||||
implements UserService{
|
||||
|
||||
@Override
|
||||
public String authenticate(String username, String password) throws AppException {
|
||||
|
||||
UserEntity userEntity = this.getOneOpt(Wrappers.<UserEntity>lambdaQuery()
|
||||
.eq(UserEntity::getUserName, username)
|
||||
.eq(UserEntity::getUserPassword, password)).orElseThrow(() -> new AppException("账号或密码错误!"));
|
||||
return userEntity.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user