知识库展示列表拆分成两列
This commit is contained in:
parent
273dc9df8b
commit
41822d9898
|
@ -37,9 +37,14 @@ public class KnowledgeBaseController {
|
||||||
return knowledgeBaseService.uploadDoc(uuid, embedding, doc);
|
return knowledgeBaseService.uploadDoc(uuid, embedding, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/search")
|
@GetMapping("/searchMine")
|
||||||
public Page<KnowledgeBase> list(String keyword, Boolean includeOthersPublic, @NotNull @Min(1) Integer currentPage, @NotNull @Min(10) Integer pageSize) {
|
public Page<KnowledgeBase> searchMine(@RequestParam(defaultValue = "") String keyword, @RequestParam(defaultValue = "false") Boolean includeOthersPublic, @NotNull @Min(1) Integer currentPage, @NotNull @Min(10) Integer pageSize) {
|
||||||
return knowledgeBaseService.search(keyword, includeOthersPublic, currentPage, pageSize);
|
return knowledgeBaseService.searchMine(keyword, includeOthersPublic, currentPage, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/searchPublic")
|
||||||
|
public Page<KnowledgeBase> searchPublic(@RequestParam(defaultValue = "") String keyword, @NotNull @Min(1) Integer currentPage, @NotNull @Min(10) Integer pageSize) {
|
||||||
|
return knowledgeBaseService.searchPublic(keyword, currentPage, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/info/{uuid}")
|
@GetMapping("/info/{uuid}")
|
||||||
|
@ -59,4 +64,14 @@ public class KnowledgeBaseController {
|
||||||
public boolean embedding(@PathVariable String uuid, @RequestParam(defaultValue = "false") Boolean forceAll) {
|
public boolean embedding(@PathVariable String uuid, @RequestParam(defaultValue = "false") Boolean forceAll) {
|
||||||
return knowledgeBaseService.embedding(uuid, forceAll);
|
return knowledgeBaseService.embedding(uuid, forceAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点赞
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/star/{uuid}")
|
||||||
|
public boolean star(@PathVariable String kbUuid) {
|
||||||
|
return knowledgeBaseService.star(kbUuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,10 @@ public class KnowledgeBase extends BaseEntity {
|
||||||
@TableField("is_public")
|
@TableField("is_public")
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
|
|
||||||
|
@Schema(title = "点赞数")
|
||||||
|
@TableField("star_count")
|
||||||
|
private Long starCount;
|
||||||
|
|
||||||
@Schema(title = "所属人id")
|
@Schema(title = "所属人id")
|
||||||
@TableField("owner_id")
|
@TableField("owner_id")
|
||||||
private Long ownerId;
|
private Long ownerId;
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class KnowledgeBaseService extends ServiceImpl<KnowledgeBaseMapper, Knowl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<KnowledgeBase> search(String keyword, Boolean includeOthersPublic, Integer currentPage, Integer pageSize) {
|
public Page<KnowledgeBase> searchMine(String keyword, Boolean includeOthersPublic, Integer currentPage, Integer pageSize) {
|
||||||
User user = ThreadContext.getCurrentUser();
|
User user = ThreadContext.getCurrentUser();
|
||||||
if (user.getIsAdmin()) {
|
if (user.getIsAdmin()) {
|
||||||
return baseMapper.searchByAdmin(new Page<>(currentPage, pageSize), keyword);
|
return baseMapper.searchByAdmin(new Page<>(currentPage, pageSize), keyword);
|
||||||
|
@ -200,6 +200,17 @@ public class KnowledgeBaseService extends ServiceImpl<KnowledgeBaseMapper, Knowl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Page<KnowledgeBase> searchPublic(String keyword, Integer currentPage, Integer pageSize) {
|
||||||
|
LambdaQueryWrapper<KnowledgeBase> wrapper = new LambdaQueryWrapper();
|
||||||
|
wrapper.eq(KnowledgeBase::getIsPublic, true);
|
||||||
|
wrapper.eq(KnowledgeBase::getIsDeleted, false);
|
||||||
|
if(StringUtils.isNotBlank(keyword)){
|
||||||
|
wrapper.like(KnowledgeBase::getTitle, keyword);
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(KnowledgeBase::getStarCount, KnowledgeBase::getUpdateTime);
|
||||||
|
return baseMapper.selectPage(new Page<>(currentPage, pageSize), wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean softDelete(String uuid) {
|
public boolean softDelete(String uuid) {
|
||||||
checkPrivilege(null, uuid);
|
checkPrivilege(null, uuid);
|
||||||
return ChainWrappers.lambdaUpdateChain(baseMapper)
|
return ChainWrappers.lambdaUpdateChain(baseMapper)
|
||||||
|
@ -227,6 +238,14 @@ public class KnowledgeBaseService extends ServiceImpl<KnowledgeBaseMapper, Knowl
|
||||||
return sseEmitter;
|
return sseEmitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean star(String kbUuid) {
|
||||||
|
KnowledgeBase knowledgeBase = getOrThrow(kbUuid);
|
||||||
|
return ChainWrappers.lambdaUpdateChain(baseMapper)
|
||||||
|
.eq(KnowledgeBase::getId, knowledgeBase.getId())
|
||||||
|
.set(KnowledgeBase::getStarCount, knowledgeBase.getStarCount() + 1)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 知识库问答限额判断
|
* 知识库问答限额判断
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<if test="keyword != null and keyword != ''">
|
<if test="keyword != null and keyword != ''">
|
||||||
and title like "%"#{keyword}"%"
|
and title like "%"#{keyword}"%"
|
||||||
</if>
|
</if>
|
||||||
order by update_time desc
|
order by star_count,update_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -419,6 +419,7 @@ create table adi_knowledge_base
|
||||||
title varchar(250) default ''::character varying not null,
|
title varchar(250) default ''::character varying not null,
|
||||||
remark text default ''::character varying not null,
|
remark text default ''::character varying not null,
|
||||||
is_public boolean default false not null,
|
is_public boolean default false not null,
|
||||||
|
star_count int default 0 not null,
|
||||||
owner_id bigint default 0 not null,
|
owner_id bigint default 0 not null,
|
||||||
owner_name varchar(45) default ''::character varying not null,
|
owner_name varchar(45) default ''::character varying not null,
|
||||||
create_time timestamp default CURRENT_TIMESTAMP not null,
|
create_time timestamp default CURRENT_TIMESTAMP not null,
|
||||||
|
@ -434,6 +435,8 @@ comment on column adi_knowledge_base.remark is '知识库描述';
|
||||||
|
|
||||||
comment on column adi_knowledge_base.is_public is '是否公开';
|
comment on column adi_knowledge_base.is_public is '是否公开';
|
||||||
|
|
||||||
|
comment on column adi_knowledge_base.star_count is '点赞数';
|
||||||
|
|
||||||
comment on column adi_knowledge_base.owner_id is '所属人id';
|
comment on column adi_knowledge_base.owner_id is '所属人id';
|
||||||
|
|
||||||
comment on column adi_knowledge_base.owner_name is '所属人名称';
|
comment on column adi_knowledge_base.owner_name is '所属人名称';
|
||||||
|
|
Loading…
Reference in New Issue