公共知识库开发
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled
This commit is contained in:
parent
6f3eb13fa3
commit
0fe1dba9fe
@ -1,10 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.service.knows;
|
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 org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
@ -32,7 +35,11 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
|||||||
private KnowledgePublicMapper knowledgePublicMapper;
|
private KnowledgePublicMapper knowledgePublicMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private CommentPublicMapper commentPublicMapper;
|
private CommentPublicMapper commentPublicMapper;
|
||||||
|
private boolean isEsFlag = true;
|
||||||
|
private String indexName = "knows_public_index";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RestHighLevelClient esClient;
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createKnowledgePublic(KnowledgePublicSaveReqVO createReqVO) {
|
public Long createKnowledgePublic(KnowledgePublicSaveReqVO createReqVO) {
|
||||||
@ -42,6 +49,14 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
|||||||
|
|
||||||
// 插入子表
|
// 插入子表
|
||||||
createCommentPublicList(knowledgePublic.getId(), createReqVO.getCommentPublics());
|
createCommentPublicList(knowledgePublic.getId(), createReqVO.getCommentPublics());
|
||||||
|
try {
|
||||||
|
if (isEsFlag){
|
||||||
|
EsearchUtils.saveIndex(knowledgePublic.getId(),createReqVO,indexName);
|
||||||
|
}
|
||||||
|
//saveIndex(createReqVO);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace(); // 处理异常,例如打印错误信息
|
||||||
|
}
|
||||||
// 返回
|
// 返回
|
||||||
return knowledgePublic.getId();
|
return knowledgePublic.getId();
|
||||||
}
|
}
|
||||||
@ -54,7 +69,9 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
|||||||
// 更新
|
// 更新
|
||||||
KnowledgePublicDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgePublicDO.class);
|
KnowledgePublicDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgePublicDO.class);
|
||||||
knowledgePublicMapper.updateById(updateObj);
|
knowledgePublicMapper.updateById(updateObj);
|
||||||
|
if (isEsFlag){
|
||||||
|
EsearchUtils.updateIndex(updateReqVO.getId(),updateReqVO,indexName);
|
||||||
|
}
|
||||||
// 更新子表
|
// 更新子表
|
||||||
updateCommentPublicList(updateReqVO.getId(), updateReqVO.getCommentPublics());
|
updateCommentPublicList(updateReqVO.getId(), updateReqVO.getCommentPublics());
|
||||||
}
|
}
|
||||||
@ -66,7 +83,9 @@ public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
|||||||
validateKnowledgePublicExists(id);
|
validateKnowledgePublicExists(id);
|
||||||
// 删除
|
// 删除
|
||||||
knowledgePublicMapper.deleteById(id);
|
knowledgePublicMapper.deleteById(id);
|
||||||
|
if (isEsFlag){
|
||||||
|
EsearchUtils.deleteKmsMainById(id,indexName);
|
||||||
|
}
|
||||||
// 删除子表
|
// 删除子表
|
||||||
deleteCommentPublicByKnowId(id);
|
deleteCommentPublicByKnowId(id);
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,25 @@ public class DeptController {
|
|||||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
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")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得部门信息")
|
@Operation(summary = "获得部门信息")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@ -80,5 +99,4 @@ public class DeptController {
|
|||||||
DeptDO dept = deptService.getDept(id);
|
DeptDO dept = deptService.getDept(id);
|
||||||
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user