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

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

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, String> {

    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public String apply(Request request) {
        System.out.println(UserContext.getThreadUserId());
        List<String> userNameList = Db.lambdaQuery(User.class).list().stream().map(User::getNickname).collect(Collectors.toList());
        System.out.println(".................xxxxxxxxxxxxxx:{}xxxxxxx"+userNameList);
        return userNameList.toString();
    }

    public record Request() {
    }
}
