更新 UserService.java
parent
2ac87ecbb0
commit
a32cdb4c81
|
|
@ -1,16 +1,28 @@
|
|||
package com.gao.finalhw.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gao.finalhw.mapper.UserMapper;
|
||||
import com.gao.finalhw.model.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private final Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
public User getUserByUsernameAndPassword(String username, String password) {
|
||||
return userMapper.findByUsernameAndPassword(username, password);
|
||||
logger.info("start getUserByUsernameAndPassword");
|
||||
|
||||
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("user_name", username) // 假设字段名为 'username'
|
||||
.eq("password", password); // 假设字段名为 'password'
|
||||
|
||||
User result = userMapper.selectOne(wrapper);
|
||||
logger.info("query result: {}",result.toString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue