Commit 0f1badb5 authored by 李超鹏's avatar 李超鹏

历史记录

parent 33502dd9
Pipeline #7456 canceled with stages
......@@ -10,6 +10,9 @@ import cc.shenjiying.ai.repository.entity.Question;
import cc.shenjiying.ai.repository.entity.Questioner;
import cc.shenjiying.ai.repository.mapper.FeedbackMapper;
import cc.shenjiying.ai.repository.mapper.QuestionMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.quarkus.logging.Log;
import io.quarkus.runtime.util.StringUtil;
import io.smallrye.common.vertx.ContextLocals;
......@@ -21,6 +24,7 @@ import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
......@@ -90,5 +94,10 @@ public class KnowledgeService {
return entity.getId();
}
public List<Question> history(Long pageNum, Long pageSize) {
return questionMapper.selectList(new Page<>(pageNum, pageSize), new LambdaQueryWrapper<Question>().eq(Question::getUserId, QuestionerHolder.getId())
.orderByDesc(Question::getCreateTime));
}
}
......@@ -4,6 +4,7 @@ import cc.shenjiying.ai.config.QuestionerHolder;
import cc.shenjiying.ai.dto.ChatAIResponse;
import cc.shenjiying.ai.dto.FeedbackSaveDTO;
import cc.shenjiying.ai.manager.KnowledgeService;
import cc.shenjiying.ai.repository.entity.Question;
import io.quarkiverse.bucket4j.runtime.RateLimited;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
......@@ -14,8 +15,11 @@ import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.resteasy.reactive.RestPath;
import org.jboss.resteasy.reactive.RestQuery;
import org.jboss.resteasy.reactive.RestStreamElementType;
import java.util.List;
@Path("/chat")
@Tag(name = "问答")
public class KnowLedgeResource {
......@@ -23,13 +27,13 @@ public class KnowLedgeResource {
KnowledgeService knowledgeService;
@HeaderParam(QuestionerHolder.TOKEN_KEY)
@Parameter(name = QuestionerHolder.TOKEN_KEY,description = "登录返回的token")
@Parameter(name = QuestionerHolder.TOKEN_KEY, description = "登录返回的token")
String myHeaderId;
@GET
@Path("/stream")
@Operation(summary = "流式请求")
@Parameter(name = QuestionerHolder.TOKEN_KEY,description = "登录返回的token")
@Parameter(name = QuestionerHolder.TOKEN_KEY, description = "登录返回的token")
@Produces(MediaType.SERVER_SENT_EVENTS)
@RestStreamElementType(MediaType.APPLICATION_JSON)
@RateLimited(bucket = "chat")
......@@ -61,4 +65,15 @@ public class KnowLedgeResource {
return Uni.createFrom().item(() -> knowledgeService.newFeedback(feedback));
}
@GET
@Path("/history")
@Operation(summary = "历史记录")
@Produces(MediaType.APPLICATION_JSON)
public List<Question> history(@RestQuery("pageNum") Long pageNum, @RestQuery("pageSize") Long pageSize) {
return knowledgeService.history(pageNum, pageSize);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment