From ebf444a5bbfe19cd7873cef299243b4e671ce488 Mon Sep 17 00:00:00 2001 From: jack ning Date: Sat, 3 May 2025 11:20:22 +0800 Subject: [PATCH] update modules/core: mod 3 files --- .../core/action/ActionRepository.java | 5 ++++- .../core/action/ActionRestController.java | 4 ++-- .../core/action/ActionRestService.java | 22 +++++++++++++------ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/modules/core/src/main/java/com/bytedesk/core/action/ActionRepository.java b/modules/core/src/main/java/com/bytedesk/core/action/ActionRepository.java index 00c1d851bf..d26b4fd5d0 100644 --- a/modules/core/src/main/java/com/bytedesk/core/action/ActionRepository.java +++ b/modules/core/src/main/java/com/bytedesk/core/action/ActionRepository.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-04-25 15:40:53 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-05-30 16:10:00 + * @LastEditTime: 2025-05-03 10:57:55 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -13,9 +13,12 @@ */ package com.bytedesk.core.action; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; public interface ActionRepository extends JpaRepository, JpaSpecificationExecutor { + Optional findByUid(String uid); } \ No newline at end of file diff --git a/modules/core/src/main/java/com/bytedesk/core/action/ActionRestController.java b/modules/core/src/main/java/com/bytedesk/core/action/ActionRestController.java index a02a10ef87..1bc455c8c9 100644 --- a/modules/core/src/main/java/com/bytedesk/core/action/ActionRestController.java +++ b/modules/core/src/main/java/com/bytedesk/core/action/ActionRestController.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-04-25 15:40:19 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-05-03 10:47:49 + * @LastEditTime: 2025-05-03 10:50:55 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -77,7 +77,7 @@ public class ActionRestController extends BaseRestController { actionRestService.delete(request); - return ResponseEntity.ok(JsonResult.success("ok")); + return ResponseEntity.ok(JsonResult.success()); } // https://github.com/alibaba/easyexcel diff --git a/modules/core/src/main/java/com/bytedesk/core/action/ActionRestService.java b/modules/core/src/main/java/com/bytedesk/core/action/ActionRestService.java index a9febc6292..964e6457b3 100644 --- a/modules/core/src/main/java/com/bytedesk/core/action/ActionRestService.java +++ b/modules/core/src/main/java/com/bytedesk/core/action/ActionRestService.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-04-25 15:41:47 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-05-03 10:47:10 + * @LastEditTime: 2025-05-03 10:56:40 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -16,6 +16,7 @@ package com.bytedesk.core.action; import java.util.Optional; import org.modelmapper.ModelMapper; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; @@ -61,10 +62,10 @@ public class ActionRestService extends BaseRestServiceWithExcel findByUid(String uid) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'findByUid'"); + return actionRepository.findByUid(uid); } public ActionResponse create(ActionRequest actionRequest) { @@ -81,7 +82,7 @@ public class ActionRestService extends BaseRestServiceWithExcel actionOptional = findByUid(request.getUid()); + if (actionOptional.isPresent()) { + ActionEntity action = actionOptional.get(); + modelMapper.map(request, action); + // + ActionEntity savedAction = save(action); + return convertToResponse(savedAction); + } + return null; } @Override @@ -111,7 +119,7 @@ public class ActionRestService extends BaseRestServiceWithExcel