公共知识库开发
This commit is contained in:
parent
6f3eb13fa3
commit
0fe1dba9fe
@ -1,10 +1,13 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.knows;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.elasticsearch.EsearchUtils;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||
@ -32,7 +35,11 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
||||
private KnowledgePublicMapper knowledgePublicMapper;
|
||||
@Resource
|
||||
private CommentPublicMapper commentPublicMapper;
|
||||
private boolean isEsFlag = true;
|
||||
private String indexName = "knows_public_index";
|
||||
|
||||
@Resource
|
||||
private RestHighLevelClient esClient;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createKnowledgePublic(KnowledgePublicSaveReqVO createReqVO) {
|
||||
@ -42,6 +49,14 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
||||
|
||||
// 插入子表
|
||||
createCommentPublicList(knowledgePublic.getId(), createReqVO.getCommentPublics());
|
||||
try {
|
||||
if (isEsFlag){
|
||||
EsearchUtils.saveIndex(knowledgePublic.getId(),createReqVO,indexName);
|
||||
}
|
||||
//saveIndex(createReqVO);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(); // 处理异常,例如打印错误信息
|
||||
}
|
||||
// 返回
|
||||
return knowledgePublic.getId();
|
||||
}
|
||||
@ -54,7 +69,9 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
||||
// 更新
|
||||
KnowledgePublicDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgePublicDO.class);
|
||||
knowledgePublicMapper.updateById(updateObj);
|
||||
|
||||
if (isEsFlag){
|
||||
EsearchUtils.updateIndex(updateReqVO.getId(),updateReqVO,indexName);
|
||||
}
|
||||
// 更新子表
|
||||
updateCommentPublicList(updateReqVO.getId(), updateReqVO.getCommentPublics());
|
||||
}
|
||||
@ -66,7 +83,9 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
||||
validateKnowledgePublicExists(id);
|
||||
// 删除
|
||||
knowledgePublicMapper.deleteById(id);
|
||||
|
||||
if (isEsFlag){
|
||||
EsearchUtils.deleteKmsMainById(id,indexName);
|
||||
}
|
||||
// 删除子表
|
||||
deleteCommentPublicByKnowId(id);
|
||||
}
|
||||
|
@ -72,6 +72,25 @@ public class DeptController {
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getdeptinfo")
|
||||
@Operation(summary = "获得部门详细信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "君风科技/深圳总公司/研发部门")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<DeptRespVO> getDeptInfo(@RequestParam("id") Long id) {
|
||||
DeptDO dept = deptService.getDept(id);
|
||||
DeptDO tmpdept = dept;
|
||||
String deptname = tmpdept.getName();
|
||||
while(tmpdept.getId() != 100){
|
||||
DeptDO parentDept = deptService.getDept(tmpdept.getParentId());
|
||||
deptname = parentDept.getName() + "/" + deptname;
|
||||
//System.out.println("deptname="+deptname);
|
||||
tmpdept.setParentId(parentDept.getParentId());
|
||||
tmpdept.setId(parentDept.getId());
|
||||
}
|
||||
dept.setName(deptname);
|
||||
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得部门信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@ -80,5 +99,4 @@ public class DeptController {
|
||||
DeptDO dept = deptService.getDept(id);
|
||||
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user