Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elleai
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
E
ellehuis-group
backend
elleai
Commits
5b55b410
Commit
5b55b410
authored
Oct 17, 2024
by
陈立彬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口规范
parent
678e2873
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
34 deletions
+64
-34
AppExamineService.java
.../breeze/elleai/application/service/AppExamineService.java
+27
-7
ChatCompletionMobileController.java
...eze/elleai/controller/ChatCompletionMobileController.java
+5
-1
ExamineController.java
...n/java/cn/breeze/elleai/controller/ExamineController.java
+2
-1
ExamineMobileController.java
.../cn/breeze/elleai/controller/ExamineMobileController.java
+4
-25
UserMobileController.java
...ava/cn/breeze/elleai/controller/UserMobileController.java
+26
-0
No files found.
src/main/java/cn/breeze/elleai/application/service/AppExamineService.java
View file @
5b55b410
...
...
@@ -10,6 +10,7 @@ import cn.breeze.elleai.domain.sparring.service.ExamineService;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.lang.Assert
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mybatisflex.core.paginate.Page
;
import
io.micrometer.common.util.StringUtils
;
...
...
@@ -22,10 +23,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.time.ZoneOffset
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -43,7 +41,7 @@ public class AppExamineService {
private
static
String
EXAM_REDIS_QUESTION_KEY
=
"EXAM_MASTER_QUESTION:%s:%s"
;
private
static
String
EXAM_REDIS_SESSION_KEY
=
"EXAM_MASTER_SESSION:%d:%s"
;
private
static
String
EXAM_REDIS_SESSION_KEY
=
"EXAM_MASTER_SESSION:%d:%
d:%
s"
;
private
static
String
EXAM_REDIS_CAS_KEY
=
"EXAM_MASTER_CURRENT_AI_SCORE:%d:%s"
;
...
...
@@ -923,10 +921,32 @@ public class AppExamineService {
}
public
ApiResponse
<
ExamineQaDifyDto
>
getQuestion
(
Integer
tenant
,
Integer
examineId
,
String
sessionId
,
String
userId
)
{
/**
* 开始考试,获取出题
* @param examineId
* @param userId
* @param examineMode
* @return
*/
public
ExamineQaDifyDto
getQuestion
(
Integer
examineId
,
String
userId
,
Integer
examineMode
)
{
// 获取缓存考试会话信息
String
examSessionKey
=
String
.
format
(
EXAM_REDIS_SESSION_KEY
,
examineId
,
examineMode
,
userId
);
String
sessionId
=
redisTemplate
.
opsForValue
().
get
(
examSessionKey
);
if
(
StrUtil
.
isEmptyIfStr
(
sessionId
))
{
// 生成sessionId
sessionId
=
UUID
.
randomUUID
().
toString
();
redisTemplate
.
opsForValue
().
set
(
examSessionKey
,
sessionId
,
1
,
TimeUnit
.
DAYS
);
}
// 获取缓存考题信息
String
questionKey
=
String
.
format
(
EXAM_REDIS_QUESTION_KEY
,
examineId
,
examineMode
,
userId
,
sessionId
);
ExamineQaDifyDto
result
=
new
ExamineQaDifyDto
();
ExamineQaRequestModel
req
=
null
;
examineService
.
examineQaList
(
req
);
// // 根据分类获取考题
// ExamineResponseModel model = examineService.examineDetail(examineId);
// if(Objects.nonNull(model)) {
...
...
@@ -949,7 +969,7 @@ public class AppExamineService {
// }
// }
return
ApiResponse
.
ok
(
result
)
;
return
result
;
}
}
src/main/java/cn/breeze/elleai/controller/ChatCompletionMobileController.java
View file @
5b55b410
...
...
@@ -58,5 +58,9 @@ public class ChatCompletionMobileController {
return
ApiResponse
.
ok
(
aiReply
);
}
@Operation
(
summary
=
"开启新会话"
)
@PostMapping
(
"/new"
)
public
ApiResponse
<
String
>
newChatCompletion
(
@RequestParam
(
"user_id"
)
String
userId
)
{
return
ApiResponse
.
ok
(
"ok"
);
}
}
src/main/java/cn/breeze/elleai/controller/ExamineController.java
View file @
5b55b410
...
...
@@ -11,6 +11,7 @@ import cn.breeze.elleai.application.dto.response.ExamineRecordDto;
import
cn.breeze.elleai.application.dto.response.ExamineRecordMobileDto
;
import
cn.breeze.elleai.application.service.AppExamineService
;
import
cn.breeze.elleai.config.QueryParam
;
import
cn.breeze.elleai.util.UserPrincipal
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
...
...
@@ -71,7 +72,7 @@ public class ExamineController {
@Operation
(
summary
=
"对练记录列表"
,
tags
=
"对练记录"
)
@GetMapping
(
"/record/list"
)
public
ApiResponse
<
PageResult
<
ExamineRecordDto
>>
recordList
(
@QueryParam
ExamineRecordRequestDto
request
)
{
public
ApiResponse
<
PageResult
<
ExamineRecordDto
>>
recordList
(
UserPrincipal
userPrincipal
,
@QueryParam
ExamineRecordRequestDto
request
)
{
PageResult
<
ExamineRecordDto
>
pageResult
=
examineService
.
examineRecordPaginQuery
(
request
);
return
ApiResponse
.
ok
(
pageResult
);
}
...
...
src/main/java/cn/breeze/elleai/controller/ExamineMobileController.java
View file @
5b55b410
...
...
@@ -13,6 +13,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.UUID
;
@RestController
@RequestMapping
(
value
=
"/front/examine"
)
@Tag
(
name
=
"AI对练移动端"
)
...
...
@@ -87,33 +89,10 @@ public class ExamineMobileController {
@Operation
(
summary
=
"开始考试,获取出题"
)
@GetMapping
(
value
=
"/get_question"
)
public
ApiResponse
<
ExamineQaDifyDto
>
getQuestion
(
@Schema
(
description
=
"对练ID"
)
@RequestParam
(
"examine_id"
)
Integer
examineId
,
@Schema
(
description
=
"
会话ID"
)
@RequestParam
(
"session_id"
)
String
sessionId
,
@Schema
(
description
=
"
对练模式(0练习 1对练)"
)
@RequestParam
(
"examine_mode"
)
Integer
examineMode
,
@Schema
(
description
=
"用户ID"
)
@RequestParam
(
"user_id"
)
String
userId
)
{
ExamineQaDifyDto
result
=
new
ExamineQaDifyDto
();
// // 根据分类获取考题
// ElehKnowledgeTagDo tagDo = tagMapper.selectByCode(tenant, code);
// if(Objects.nonNull(tagDo)) {
// Long maxQuestionId = qaRecordMapper.selectSessionMaxQuestionId(tenant, sessionId, userId);
// maxQuestionId = Objects.nonNull(maxQuestionId) ? maxQuestionId : 0;
// ElehKnowledgeDo knowledgeDo = knowledgeMapper.selectQuestion(tenant, tagDo.getId(), maxQuestionId);
// if(Objects.nonNull(knowledgeDo)) {
// result.setQuestion(knowledgeDo.getQuestion());
// result.setAnswer(knowledgeDo.getAnswer());
// result.setProject(tagDo.getName());
// result.setCode(tagDo.getCode());
// result.setQuestionId(knowledgeDo.getId());
// result.setNext(true);
//
// // 存储当前会话考试信息
// String redisKey = String.format(EXAM_REDIS_QUESTION_KEY, tenant, sessionId, userId);
// redisTemplate.opsForValue().set(redisKey, result.getQuestionId()+"", 10, TimeUnit.MINUTES);
//
// log.info("出题结果:result = {}, rediskey = {}", JSONObject.toJSONString(result), redisKey);
// }
// }
ExamineQaDifyDto
result
=
examineService
.
getQuestion
(
examineId
,
userId
,
examineMode
);
return
ApiResponse
.
ok
(
result
);
}
...
...
src/main/java/cn/breeze/elleai/controller/UserMobileController.java
0 → 100644
View file @
5b55b410
package
cn
.
breeze
.
elleai
.
controller
;
import
cn.breeze.elleai.application.dto.ApiResponse
;
import
cn.breeze.elleai.application.dto.response.ExamineSceneDto
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
value
=
"/front/user"
)
@Tag
(
name
=
"用户移动端"
)
@RequiredArgsConstructor
public
class
UserMobileController
{
@Operation
(
summary
=
"获取token"
)
@GetMapping
(
"/get_token"
)
public
ApiResponse
<
String
>
getToken
()
{
return
ApiResponse
.
ok
(
"ok"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment