package io.github.qifan777.knowledge.ai.agent.userAgent;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.toolkit.Db;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import io.github.qifan777.knowledge.context.UserContext;
import io.github.qifan777.knowledge.domain.po.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Description;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * <p>
 * 获取用户sql
 * </p>
 *
 * @author taohongrun
 * @since 2025/3/13
 */
@Component
@Description("查询获取成绩返回给用户")
@Slf4j
public  class UserNameFunction implements Function<UserNameFunction.Request, Integer> {

    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public Integer apply(Request request) {

        System.out.println(request.userName);
        return Db.lambdaQuery(User.class).select().eq(User::getNickname, request.userName).one().getScore();



    }

    public record Request( @JsonProperty(required = true)
                           @JsonPropertyDescription("this param is user's name")
                           String userName) {
    }
}
