Package com.bytedesk.kbase.llm_faq
Class FaqRestService
java.lang.Object
com.bytedesk.core.base.BaseRestService<T,TRequest,TResponse>
com.bytedesk.core.base.BaseRestServiceWithExport<FaqEntity,FaqRequest,FaqResponse,FaqExcel>
com.bytedesk.kbase.llm_faq.FaqRestService
@Service
public class FaqRestService
extends BaseRestServiceWithExport<FaqEntity,FaqRequest,FaqResponse,FaqExcel>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BytedeskEventPublisherprivate final CategoryRestServiceprivate final FaqJsonLoaderprivate final FaqRepositoryprivate final KbaseRestServiceprivate final MessageRestServiceprivate final org.modelmapper.ModelMapperprivate final ThreadRestServiceprivate final UidUtilsFields inherited from class com.bytedesk.core.base.BaseRestService
authService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclickFaq(FaqRequest request) convertToExcel(FaqEntity faq) 转换为Excel对象 子类必须实现此方法convertToResponse(FaqEntity entity) create(FaqRequest request) protected org.springframework.data.jpa.domain.Specification<FaqEntity>createSpecification(FaqRequest request) 创建Specification对象,子类必须实现 用于queryByOrg的通用实现voiddelateAll(FaqRequest request) voiddelete(FaqRequest entity) voiddeleteByUid(String uid) protected FaqEntity子类实现具体的保存逻辑enable(FaqRequest request) protected org.springframework.data.domain.Page<FaqEntity>executePageQuery(org.springframework.data.jpa.domain.Specification<FaqEntity> spec, org.springframework.data.domain.Pageable pageable) 执行分页查询,子类必须实现 用于queryByOrg的通用实现existsByQuestionAndAnswerAndKbUidAndOrgUid(String question, String answer, String kbUid, String orgUid) existsByUid(String uid) findByKbUid(String kbUid) findByQuestionContains(String question) 获取一个随机FAQ,用于测试static MessageEntitygetFaqAnswerMessage(FaqResponse faqResponse, ThreadEntity threadEntity) static MessageEntitygetFaqQuestionMessage(FaqResponse faqResponse, ThreadEntity threadEntity) handleOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException e, FaqEntity entity) voidimportFaqs(String orgUid, String kbUid) 导入FAQ数据 从JSON文件加载数据并存储到数据库queryByUid(FaqRequest request) 通用的queryByUid实现voidvoidsaveFaqPairs(String qaPairs, String kbUid, String orgUid) update(FaqRequest request) Methods inherited from class com.bytedesk.core.base.BaseRestServiceWithExport
queryByOrgEntityMethods inherited from class com.bytedesk.core.base.BaseRestService
deleteByOrgUid, findByOrgUid, getUidFromRequest, queryByOrg, queryByUser, recover, save, setUserUidToRequest
-
Field Details
-
faqRepository
-
modelMapper
private final org.modelmapper.ModelMapper modelMapper -
uidUtils
-
categoryRestService
-
faqJsonLoader
-
kbaseRestService
-
threadRestService
-
messageRestService
-
bytedeskEventPublisher
-
-
Constructor Details
-
FaqRestService
public FaqRestService()
-
-
Method Details
-
createSpecification
protected org.springframework.data.jpa.domain.Specification<FaqEntity> createSpecification(FaqRequest request) Description copied from class:BaseRestService创建Specification对象,子类必须实现 用于queryByOrg的通用实现- Specified by:
createSpecificationin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
executePageQuery
protected org.springframework.data.domain.Page<FaqEntity> executePageQuery(org.springframework.data.jpa.domain.Specification<FaqEntity> spec, org.springframework.data.domain.Pageable pageable) Description copied from class:BaseRestService执行分页查询,子类必须实现 用于queryByOrg的通用实现- Specified by:
executePageQueryin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
queryByUid
Description copied from class:BaseRestService通用的queryByUid实现- Overrides:
queryByUidin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
clickFaq
-
findByUid
@Cacheable(value="faq", key="#uid", unless="#result == null") public Optional<FaqEntity> findByUid(String uid) - Specified by:
findByUidin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
findByKbUid
-
findByQuestionContains
-
existsByQuestionAndAnswerAndKbUidAndOrgUid
-
existsByUid
-
create
- Specified by:
createin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
update
- Specified by:
updatein classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
enable
-
doSave
Description copied from class:BaseRestService子类实现具体的保存逻辑- Specified by:
doSavein classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
handleOptimisticLockingFailureException
public FaqEntity handleOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException e, FaqEntity entity) - Specified by:
handleOptimisticLockingFailureExceptionin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
save
-
deleteByUid
- Specified by:
deleteByUidin classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
delete
- Specified by:
deletein classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
delateAll
-
convertToResponse
- Specified by:
convertToResponsein classBaseRestService<FaqEntity,FaqRequest, FaqResponse>
-
convertToExcel
Description copied from class:BaseRestServiceWithExport转换为Excel对象 子类必须实现此方法- Specified by:
convertToExcelin classBaseRestServiceWithExport<FaqEntity,FaqRequest, FaqResponse, FaqExcel>
-
convertExcelToFaq
-
saveFaqPairs
-
importFaqs
导入FAQ数据 从JSON文件加载数据并存储到数据库- Parameters:
orgUid- 组织IDkbUid- 知识库ID
-
getFaqQuestionMessage
public static MessageEntity getFaqQuestionMessage(FaqResponse faqResponse, ThreadEntity threadEntity) -
getFaqAnswerMessage
-
findRandomFaq
获取一个随机FAQ,用于测试- Returns:
- 随机FAQ的Optional包装
-