update modules/kbase: mod 5 files

This commit is contained in:
jack ning
2025-03-01 10:48:40 +08:00
parent 80be6a2681
commit ad39d040cb
5 changed files with 28 additions and 20 deletions

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-03-22 22:59:48
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-03-01 09:54:36
* @LastEditTime: 2025-03-01 10:46:26
* @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.
@@ -90,4 +90,6 @@ public class ArticleRequest extends BaseRequest {
private String categoryUid;
private String kbUid;
private String userUid;
}

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-03-22 22:59:07
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2024-11-18 17:09:41
* @LastEditTime: 2025-03-01 10:45:13
* @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.
@@ -15,13 +15,11 @@ package com.bytedesk.kbase.article;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bytedesk.core.base.BaseRestController;
import com.bytedesk.core.rbac.role.RolePermissions;
import com.bytedesk.core.utils.JsonResult;
import lombok.AllArgsConstructor;
@@ -33,7 +31,7 @@ public class ArticleRestController extends BaseRestController<ArticleRequest> {
private final ArticleRestService articleService;
@PreAuthorize(RolePermissions.ROLE_ADMIN)
// @PreAuthorize(RolePermissions.ROLE_ADMIN)
@Override
public ResponseEntity<?> queryByOrg(ArticleRequest request) {
@@ -44,8 +42,10 @@ public class ArticleRestController extends BaseRestController<ArticleRequest> {
@Override
public ResponseEntity<?> queryByUser(ArticleRequest request) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'query'");
Page<ArticleResponse> page = articleService.queryByUser(request);
return ResponseEntity.ok(JsonResult.success(page));
}
@Override

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-03-22 22:59:18
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-25 21:15:23
* @LastEditTime: 2025-03-01 10:45:27
* @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.
@@ -18,9 +18,7 @@ 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.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Service;
@@ -50,21 +48,23 @@ public class ArticleRestService extends BaseRestService<ArticleEntity, ArticleRe
@Override
public Page<ArticleResponse> queryByOrg(ArticleRequest request) {
Pageable pageable = PageRequest.of(request.getPageNumber(), request.getPageSize(), Sort.Direction.DESC,
"updatedAt");
Pageable pageable = request.getPageable();
Specification<ArticleEntity> spec = ArticleSpecification.search(request);
Page<ArticleEntity> page = articleRepository.findAll(spec, pageable);
return page.map(this::convertToResponse);
}
@Override
public Page<ArticleResponse> queryByUser(ArticleRequest request) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'queryByUser'");
UserEntity user = authService.getUser();
if (user == null) {
throw new RuntimeException("user not found");
}
String userUid = user.getUid();
//
request.setUserUid(userUid);
//
return queryByOrg(request);
}
@Cacheable(value = "article", key="#uid", unless = "#result == null")

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-06-08 12:30:14
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2024-10-29 16:47:23
* @LastEditTime: 2025-03-01 10:46:35
* @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.
@@ -50,6 +50,9 @@ public class ArticleSpecification extends BaseSpecification {
if (StringUtils.hasText(request.getKbUid())) {
predicates.add(criteriaBuilder.equal(root.get("kbUid"), request.getKbUid()));
}
if (StringUtils.hasText(request.getUserUid())) {
predicates.add(criteriaBuilder.equal(root.get("userUid"), request.getUserUid()));
}
//
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
};

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-06-08 12:30:14
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2024-07-31 18:34:23
* @LastEditTime: 2025-03-01 10:46:58
* @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.
@@ -38,6 +38,9 @@ public class KbaseSpecification extends BaseSpecification {
if (StringUtils.hasText(request.getType())) {
predicates.add(criteriaBuilder.equal(root.get("type"), request.getType()));
}
if (StringUtils.hasText(request.getUserUid())) {
predicates.add(criteriaBuilder.equal(root.get("userUid"), request.getUserUid()));
}
//
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
};