mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-19 13:48:10 +00:00
update
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-11-22 16:08:38
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-24 12:59: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.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
* 联系:270580156@qq.com
|
||||
* Copyright (c) 2024 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.kbase.quick_reply;
|
||||
|
||||
public class QuickReplyConsts {
|
||||
private QuickReplyConsts() {}
|
||||
|
||||
// public static final String QUICK_REPLY_CATEGORY_DEMO_UID_1 = "quick_reply_category_demo_uid_1";
|
||||
// public static final String QUICK_REPLY_CATEGORY_DEMO_UID_2 = "quick_reply_category_demo_uid_2";
|
||||
// public static final String QUICK_REPLY_CATEGORY_DEMO_UID_3 = "quick_reply_category_demo_uid_3";
|
||||
// public static final String QUICK_REPLY_CATEGORY_DEMO_UID_4 = "quick_reply_category_demo_uid_4";
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-06-20 14:31:54
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-05 09:44:33
|
||||
* @LastEditTime: 2025-03-05 12:02: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.
|
||||
@@ -57,18 +57,13 @@ public class QuickReplyEventListener {
|
||||
public void onUploadCreateEvent(UploadCreateEvent event) {
|
||||
UploadEntity upload = event.getUpload();
|
||||
log.info("UploadEventListener create: {}", upload.toString());
|
||||
// etl分块处理
|
||||
if (upload.getType().equalsIgnoreCase(UploadTypeEnum.LLM.name())) {
|
||||
// ai 模块处理
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 导入Excel文件
|
||||
Resource resource = uploadRestService.loadAsResource(upload.getFileName());
|
||||
if (resource.exists()) {
|
||||
String filePath = resource.getFile().getAbsolutePath();
|
||||
log.info("UploadEventListener loadAsResource: {}", filePath);
|
||||
if (upload.getType().equalsIgnoreCase(UploadTypeEnum.QUICKREPLY.name())) {
|
||||
if (upload.getType().equalsIgnoreCase(UploadTypeEnum.QUICKREPLY.name())) {
|
||||
try {
|
||||
// 导入Excel文件
|
||||
Resource resource = uploadRestService.loadAsResource(upload.getFileName());
|
||||
if (resource.exists()) {
|
||||
String filePath = resource.getFile().getAbsolutePath();
|
||||
log.info("UploadEventListener loadAsResource: {}", filePath);
|
||||
// 导入快捷回复
|
||||
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
|
||||
// https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read
|
||||
@@ -78,10 +73,11 @@ public class QuickReplyEventListener {
|
||||
upload.getOrgUid())).sheet()
|
||||
.doRead();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("QuickReplyEventListener onUploadCreateEvent error: {}", e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("QuickReplyEventListener onUploadCreateEvent error: {}", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-03-22 22:59:07
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-24 12:47:08
|
||||
* @LastEditTime: 2025-03-05 11:58:04
|
||||
* @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.
|
||||
@@ -96,17 +96,16 @@ public class QuickReplyRestController extends BaseRestController<QuickReplyReque
|
||||
// https://github.com/alibaba/easyexcel
|
||||
// https://easyexcel.opensource.alibaba.com/docs/current/
|
||||
@ActionAnnotation(title = "quickReply", action = "export", description = "export quickReply")
|
||||
@GetMapping("/export")
|
||||
public Object export(QuickReplyRequest request, HttpServletResponse response) {
|
||||
// query data to export
|
||||
Page<QuickReplyResponse> quickReplyPage = quickReplyRestService.queryByOrg(request);
|
||||
Page<QuickReplyEntity> quickReplyPage = quickReplyRestService.queryByOrgExcel(request);
|
||||
//
|
||||
try {
|
||||
//
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
// download filename
|
||||
String fileName = "QuickReply-" + BdDateUtils.formatDatetimeUid() + ".xlsx";
|
||||
String fileName = "kbase-quick_reply-" + BdDateUtils.formatDatetimeUid() + ".xlsx";
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
|
||||
|
||||
// 转换数据
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-03-22 22:59:18
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-26 12:55:14
|
||||
* @LastEditTime: 2025-03-05 12:03:05
|
||||
* @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.
|
||||
@@ -39,6 +39,8 @@ import com.bytedesk.core.constant.BytedeskConsts;
|
||||
import com.bytedesk.core.constant.I18Consts;
|
||||
import com.bytedesk.core.enums.LevelEnum;
|
||||
import com.bytedesk.core.message.MessageTypeEnum;
|
||||
import com.bytedesk.core.rbac.auth.AuthService;
|
||||
import com.bytedesk.core.rbac.user.UserEntity;
|
||||
import com.bytedesk.core.uid.UidUtils;
|
||||
import com.bytedesk.core.utils.Utils;
|
||||
import com.bytedesk.kbase.kbase.KbaseEntity;
|
||||
@@ -61,23 +63,24 @@ public class QuickReplyRestService extends BaseRestService<QuickReplyEntity, Qui
|
||||
|
||||
private final KbaseRestService knowledgebaseService;
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
@Override
|
||||
public Page<QuickReplyResponse> queryByOrg(QuickReplyRequest request) {
|
||||
|
||||
Pageable pageable = PageRequest.of(request.getPageNumber(), request.getPageSize(), Sort.Direction.ASC,
|
||||
"updatedAt");
|
||||
|
||||
Pageable pageable = request.getPageable();
|
||||
Specification<QuickReplyEntity> spec = QuickReplySpecification.search(request);
|
||||
|
||||
Page<QuickReplyEntity> page = quickReplyRepository.findAll(spec, pageable);
|
||||
|
||||
return page.map(this::convertToResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<QuickReplyResponse> queryByUser(QuickReplyRequest 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");
|
||||
}
|
||||
request.setUserUid(user.getUid());
|
||||
return queryByOrg(request);
|
||||
}
|
||||
|
||||
@Cacheable(value = "quickreply", key = "#request.agentUid", unless = "#result == null")
|
||||
@@ -186,7 +189,13 @@ public class QuickReplyRestService extends BaseRestService<QuickReplyEntity, Qui
|
||||
return modelMapper.map(entity, QuickReplyResponse.class);
|
||||
}
|
||||
|
||||
public QuickReplyExcel convertToExcel(QuickReplyResponse quickReply) {
|
||||
public Page<QuickReplyEntity> queryByOrgExcel(QuickReplyRequest request) {
|
||||
Pageable pageable = request.getPageable();
|
||||
Specification<QuickReplyEntity> spec = QuickReplySpecification.search(request);
|
||||
return quickReplyRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public QuickReplyExcel convertToExcel(QuickReplyEntity quickReply) {
|
||||
return modelMapper.map(quickReply, QuickReplyExcel.class);
|
||||
}
|
||||
|
||||
@@ -384,7 +393,7 @@ public class QuickReplyRestService extends BaseRestService<QuickReplyEntity, Qui
|
||||
public QuickReplyEntity convertExcelToQuickReply(QuickReplyExcel excel, String kbUid, String orgUid) {
|
||||
// return modelMapper.map(excel, QuickReply.class);
|
||||
QuickReplyEntity quickReply = QuickReplyEntity.builder().build();
|
||||
quickReply.setUid(uidUtils.getCacheSerialUid());
|
||||
quickReply.setUid(uidUtils.getUid());
|
||||
quickReply.setTitle(excel.getTitle());
|
||||
quickReply.setContent(excel.getContent());
|
||||
// quickReply.setType(MessageTypeEnum.TEXT); // TODO: 根据实际类型设置
|
||||
|
||||
Reference in New Issue
Block a user