|
|
@@ -7,7 +7,7 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.model.entity.ClaudeSession;
|
|
|
-import com.cyksj.model.views.ChatgptCarSessionView;
|
|
|
+import com.cyksj.model.views.ClaudeCarSessionView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.claude.ClaudeSessionService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
@@ -42,9 +42,9 @@ public class CmsClaudeController {
|
|
|
* 获取镜像车队账号列表
|
|
|
*/
|
|
|
@GetMapping("/get")
|
|
|
- public Result<SearchResult<ChatgptCarSessionView>> getMirrorCarSession() {
|
|
|
- SearchResult<ChatgptCarSessionView> search = beanSearcher.search(ChatgptCarSessionView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .orderBy(ChatgptCarSessionView::getId).desc()
|
|
|
+ public Result<SearchResult<ClaudeCarSessionView>> getMirrorCarSession() {
|
|
|
+ SearchResult<ClaudeCarSessionView> search = beanSearcher.search(ClaudeCarSessionView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .orderBy(ClaudeCarSessionView::getId).desc()
|
|
|
.build());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
@@ -56,16 +56,24 @@ public class CmsClaudeController {
|
|
|
public Result<String> updateMirrorCarSession(@RequestBody ClaudeSession claudeSession) {
|
|
|
Long id = claudeSession.getId();
|
|
|
ClaudeSession dbChatSession = claudeSessionService.getById(id);
|
|
|
+ Integer sessionId = null;
|
|
|
+ Boolean isUpdateSession = false;
|
|
|
if (!ObjectUtil.equal(dbChatSession.getEmail(), claudeSession.getEmail()) || !ObjectUtil.equal(dbChatSession.getPassword(), claudeSession.getPassword())) {
|
|
|
- claudeSessionService.getSession(dbChatSession.getEmail(), dbChatSession.getPassword(), claudeSession.getOfficialSession(), claudeSession.getIsPlus());
|
|
|
+ sessionId = claudeSessionService.getSession(dbChatSession.getEmail(), dbChatSession.getPassword(), claudeSession.getOfficialSession(), claudeSession.getIsPlus());
|
|
|
+ isUpdateSession = true;
|
|
|
}
|
|
|
Integer selectCount = claudeSessionService.getBaseMapper().selectCount(Wrappers.lambdaQuery(ClaudeSession.class)
|
|
|
.and(e -> e.eq(ClaudeSession::getEmail, claudeSession.getEmail())
|
|
|
- .or().eq(ClaudeSession::getCarID, claudeSession.getCarID()))
|
|
|
+ .or().eq(ClaudeSession::getCarId, claudeSession.getCarId()))
|
|
|
.ne(ClaudeSession::getId, claudeSession.getId()));
|
|
|
if (selectCount > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("请检验车队ID或账号是否已存在");
|
|
|
}
|
|
|
+ if (isUpdateSession) {
|
|
|
+ if (sessionId != null) {
|
|
|
+ claudeSession.setStatus(1);
|
|
|
+ } else claudeSession.setStatus(0);
|
|
|
+ }
|
|
|
claudeSessionService.updateById(claudeSession);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
@@ -77,7 +85,7 @@ public class CmsClaudeController {
|
|
|
public Result<String> deleteMirrorCarSession(@PathVariable Long id) {
|
|
|
Optional.ofNullable(claudeSessionService.getById(id))
|
|
|
.ifPresent(e -> {
|
|
|
- String carId = e.getCarID();
|
|
|
+ String carId = e.getCarId();
|
|
|
if (StrUtil.isNotBlank(carId)) {
|
|
|
claudeSessionService.removeById(e.getId());
|
|
|
String highCarChatKey = RedisService.key.CLAUDE_CAR_CHAT.getName() + carId;
|
|
|
@@ -93,12 +101,15 @@ public class CmsClaudeController {
|
|
|
@PostMapping("/post/mirror/car/session")
|
|
|
public Result<String> postMirrorCarSession(@RequestBody ClaudeSession claudeSession) {
|
|
|
Integer selectCount = claudeSessionService.getBaseMapper().selectCount(Wrappers.lambdaQuery(ClaudeSession.class)
|
|
|
- .eq(ClaudeSession::getCarID, claudeSession.getCarID()).or().eq(ClaudeSession::getEmail, claudeSession.getEmail()));
|
|
|
+ .eq(ClaudeSession::getCarId, claudeSession.getCarId()).or().eq(ClaudeSession::getEmail, claudeSession.getEmail()));
|
|
|
if (selectCount > 0) {
|
|
|
throw BusinessRuntimeException.getInstance("请检验车队ID或账号是否已存在");
|
|
|
}
|
|
|
- claudeSessionService.getSession(claudeSession.getEmail(), claudeSession.getPassword(), claudeSession.getOfficialSession(),claudeSession.getIsPlus());
|
|
|
-
|
|
|
+ Integer sessionId = claudeSessionService.getSession(claudeSession.getEmail(), claudeSession.getPassword(), claudeSession.getOfficialSession(), claudeSession.getIsPlus());
|
|
|
+ if (sessionId != null) {
|
|
|
+ claudeSession.setStatus(1);
|
|
|
+ } else claudeSession.setStatus(0);
|
|
|
+ claudeSessionService.save(claudeSession);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|