zoujiajian 2 роки тому
батько
коміт
0b32d652fd

+ 9 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsGptCarController.java

@@ -64,6 +64,13 @@ public class CmsGptCarController {
 			String gptSession = chatGptAccountService.getGptSession(dbChatSession.getEmail(), dbChatSession.getPassword());
 			chatgptSession.setOfficialSession(gptSession);
 		}
+		Integer selectCount = chatgptSessionMapper.selectCount(Wrappers.lambdaQuery(ChatgptSession.class)
+				.and(e -> e.eq(ChatgptSession::getEmail, chatgptSession.getEmail())
+						.or().eq(ChatgptSession::getCarId, chatgptSession.getCarId()))
+				.ne(ChatgptSession::getId, chatgptSession.getId()));
+		if (selectCount > 0) {
+			throw BusinessRuntimeException.getInstance("请检验车队ID或账号是否已存在");
+		}
 		chatgptSessionMapper.updateById(chatgptSession);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -99,9 +106,9 @@ public class CmsGptCarController {
 	@PostMapping("/post/mirror/car/session")
 	public Result<String> postMirrorCarSession(@RequestBody ChatgptSession chatgptSession) {
 		Integer selectCount = chatgptSessionMapper.selectCount(Wrappers.lambdaQuery(ChatgptSession.class)
-				.eq(ChatgptSession::getCarId, chatgptSession.getCarId()));
+				.eq(ChatgptSession::getCarId, chatgptSession.getCarId()).or().eq(ChatgptSession::getEmail, chatgptSession.getEmail()));
 		if (selectCount > 0) {
-			throw BusinessRuntimeException.getInstance("输入的车队id已存在");
+			throw BusinessRuntimeException.getInstance("请检验车队ID或账号是否已存在");
 		}
 		String gptSession = chatGptAccountService.getGptSession(chatgptSession.getEmail(), chatgptSession.getPassword());
 		chatgptSession.setIsCar(true);