|
@@ -1,13 +1,5 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.client.UserServiceClient;
|
|
@@ -15,6 +7,7 @@ import com.diagbot.dto.GetAllLexiconDTO;
|
|
|
import com.diagbot.dto.GetLexiconListDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.Lexicon;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.LexiconServiceImpl;
|
|
@@ -25,6 +18,13 @@ import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.AddLexiconVO;
|
|
|
import com.diagbot.vo.GetAllLexiconVO;
|
|
|
import com.diagbot.vo.GetLexiconListVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 术语类型业务层
|
|
@@ -33,73 +33,76 @@ import com.diagbot.vo.GetLexiconListVO;
|
|
|
*/
|
|
|
@Component
|
|
|
public class LexiconFacade extends LexiconServiceImpl {
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserServiceClient userServiceClient;
|
|
|
-
|
|
|
- /**
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取所有术语类型
|
|
|
+ *
|
|
|
* @param getAllLexiconVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<GetAllLexiconDTO> getAllLexicon(GetAllLexiconVO getAllLexiconVO){
|
|
|
- QueryWrapper<Lexicon> lexiconQe = new QueryWrapper<>();
|
|
|
- lexiconQe.eq("is_deleted", "N");
|
|
|
- if(StringUtil.isNotBlank(getAllLexiconVO.getName())){
|
|
|
- lexiconQe.like("name", getAllLexiconVO.getName());
|
|
|
- }
|
|
|
-
|
|
|
- return BeanUtil.listCopyTo(list(lexiconQe), GetAllLexiconDTO.class);
|
|
|
+ public List<GetAllLexiconDTO> getAllLexicon(GetAllLexiconVO getAllLexiconVO) {
|
|
|
+ QueryWrapper<Lexicon> lexiconQe = new QueryWrapper<>();
|
|
|
+ lexiconQe.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ if (StringUtil.isNotBlank(getAllLexiconVO.getName())) {
|
|
|
+ lexiconQe.like("name", getAllLexiconVO.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ return BeanUtil.listCopyTo(list(lexiconQe), GetAllLexiconDTO.class);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取术语类型列表
|
|
|
+ *
|
|
|
* @param getLexiconListVO
|
|
|
* @return
|
|
|
*/
|
|
|
public IPage<GetLexiconListDTO> getLexiconList(GetLexiconListVO getLexiconListVO) {
|
|
|
- IPage<GetLexiconListDTO> ipage = this.baseMapper.getLexiconList(getLexiconListVO);
|
|
|
- if(ipage.getRecords().size()>0){
|
|
|
- List<String> ids = ipage.getRecords().stream().map(i->i.getModifier()).distinct().collect(Collectors.toList());
|
|
|
- RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
|
|
|
- if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
|
+ IPage<GetLexiconListDTO> ipage = this.baseMapper.getLexiconList(getLexiconListVO);
|
|
|
+ if (ipage.getRecords().size() > 0) {
|
|
|
+ List<String> ids = ipage.getRecords().stream().map(i -> i.getModifier()).distinct().collect(Collectors.toList());
|
|
|
+ RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
|
|
|
+ if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"获取用户信息失败");
|
|
|
}
|
|
|
- ipage.getRecords().forEach(i->{
|
|
|
- i.setModifier(respDTO.data.get(i.getModifier()));
|
|
|
- });
|
|
|
- }
|
|
|
+ ipage.getRecords().forEach(i -> {
|
|
|
+ i.setModifier(respDTO.data.get(i.getModifier()));
|
|
|
+ });
|
|
|
+ }
|
|
|
return ipage;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 术语类型添加
|
|
|
+ *
|
|
|
* @param addLexiconVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean addLexicon(AddLexiconVO addLexiconVO){
|
|
|
- String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
- Date now = DateUtil.now();
|
|
|
-
|
|
|
- QueryWrapper<Lexicon> lexiconQe = new QueryWrapper<>();
|
|
|
- lexiconQe.eq("name", addLexiconVO.getName());
|
|
|
- Lexicon lexicon = getOne(lexiconQe);
|
|
|
- if(lexicon==null){
|
|
|
- lexicon = new Lexicon();
|
|
|
- lexicon.setName(addLexiconVO.getName());
|
|
|
- lexicon.setCreator(currentUser);
|
|
|
- lexicon.setGmtCreate(now);
|
|
|
- }else if(lexicon.getIsDeleted().equals("Y")){
|
|
|
- lexicon.setIsDeleted("N");
|
|
|
- }else{
|
|
|
- throw new CommonException(CommonErrorCode.IS_EXISTS);
|
|
|
- }
|
|
|
-
|
|
|
- lexicon.setGmtModified(now);
|
|
|
- lexicon.setModifier(currentUser);
|
|
|
+ public Boolean addLexicon(AddLexiconVO addLexiconVO) {
|
|
|
+ String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+
|
|
|
+ QueryWrapper<Lexicon> lexiconQe = new QueryWrapper<>();
|
|
|
+ lexiconQe.eq("name", addLexiconVO.getName());
|
|
|
+ Lexicon lexicon = getOne(lexiconQe);
|
|
|
+ if (lexicon == null) {
|
|
|
+ lexicon = new Lexicon();
|
|
|
+ lexicon.setName(addLexiconVO.getName());
|
|
|
+ lexicon.setCreator(currentUser);
|
|
|
+ lexicon.setGmtCreate(now);
|
|
|
+ } else if (lexicon.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ lexicon.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS);
|
|
|
+ }
|
|
|
+
|
|
|
+ lexicon.setGmtModified(now);
|
|
|
+ lexicon.setModifier(currentUser);
|
|
|
|
|
|
- return saveOrUpdate(lexicon);
|
|
|
+ return saveOrUpdate(lexicon);
|
|
|
}
|
|
|
|
|
|
|