接口:
/**
* @author yt
* @create 2022/11/1 10:37
*/
public interface UserDao extends IService<UserDO> {
UserDO getUserByUserId(String userId);
}
实现类
@Repository
public class UserDaoImpl extends ServiceImpl<UserMapper,UserDO> implements UserDao {
@Resource
private UserMapper userMapper;
@Override
public UserDO getUserByUserId(String userId) {
QueryWrapper<UserDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId);
UserDO userDO = userMapper.selectOne(queryWrapper.orderByDesc("id").last("limit 1"));
return userDO;
}
}