浏览代码

Merge remote-tracking branch 'origin/dev/icss' into dev/icss

wangyu 6 年之前
父节点
当前提交
9b5a028124

+ 1 - 1
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -150,9 +150,9 @@ public class PushFacade {
 
     /**
      * 获取返回结果标签
-     *
      * @param map
      * @param pushVO
+     * @param type
      * @return
      */
     public List<QuestionDTO> getTagListByMap(Map<String, Object> map, PushVO pushVO, Integer type) {

+ 33 - 0
icssman-service/src/main/java/com/diagbot/dto/AddTagRetrievalDTO.java

@@ -0,0 +1,33 @@
+/**
+ * 
+ */
+package com.diagbot.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description
+ * @author rgb
+ * @time 2018年12月5日下午5:00:34
+ */
+@ApiModel(value="标签添加同义词接口出参")
+@Getter
+@Setter
+public class AddTagRetrievalDTO {
+	
+	/**
+	 * 同义词id
+	 */
+	@ApiModelProperty(value="同义词id")
+	private Long retrievalId;
+	
+	/**
+	 * 同义词映射id
+	 */
+	@ApiModelProperty(value="同义词映射id")
+	private Long retrievalMappingId;
+	
+}

+ 29 - 0
icssman-service/src/main/java/com/diagbot/facade/IntroduceInfoFacade.java

@@ -4,10 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.entity.IntroduceDetail;
 import com.diagbot.entity.IntroduceInfo;
+import com.diagbot.entity.IntroduceMap;
 import com.diagbot.service.impl.IntroduceDetailServiceImpl;
 import com.diagbot.service.impl.IntroduceInfoServiceImpl;
+import com.diagbot.service.impl.IntroduceMapServiceImpl;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.IntroduceDetailVO;
+import com.diagbot.vo.IntroduceMapVO;
 import com.diagbot.vo.IntroducePageVO;
 import com.diagbot.vo.IntroduceVO;
 import com.google.common.collect.Lists;
@@ -32,6 +36,8 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
     IntroduceDetailFacade introduceDetailFacade;
     @Autowired
     IntroduceDetailServiceImpl introduceDetailServiceImpl;
+    @Autowired
+    IntroduceMapServiceImpl introduceMapServiceImpl;
 
     /**
      * 保存提示信息(新增or修改)
@@ -78,6 +84,21 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
         }
         //插入新的明细记录
         introduceDetailServiceImpl.saveBatch(introduceDetailList);
+
+        //更新映射关系
+        //删除已有映射关系
+        QueryWrapper<IntroduceMap> introduceMapQueryWrapper = new QueryWrapper<>();
+        introduceMapQueryWrapper.eq("introduce_id", introduceInfo.getId());
+        introduceMapFacade.remove(introduceMapQueryWrapper);
+        //插入新的映射关系
+        List<IntroduceMap> introduceMapList = Lists.newLinkedList();
+        for (IntroduceMapVO introduceMapVO : introduceVO.getMapVOList()) {
+            IntroduceMap introduceMap = new IntroduceMap();
+            BeanUtil.copyProperties(introduceMapVO, introduceMap);
+            introduceMap.setIntroduceId(introduceInfo.getId());
+            introduceMapList.add(introduceMap);
+        }
+        introduceMapServiceImpl.saveBatch(introduceMapList);
         return true;
     }
 
@@ -88,6 +109,10 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
      * @return
      */
     public Boolean deleteRecord(Long id) {
+        //删除已有映射关系
+        QueryWrapper<IntroduceMap> introduceMapQueryWrapper = new QueryWrapper<>();
+        introduceMapQueryWrapper.eq("introduce_id", id);
+        introduceMapFacade.remove(introduceMapQueryWrapper);
         //删除明细
         QueryWrapper<IntroduceDetail> introduceDetailQueryWrapper = new QueryWrapper<>();
         introduceDetailQueryWrapper.eq("introduce_id", id);
@@ -104,6 +129,10 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
      * @return
      */
     public Boolean deleteRecords(Long[] ids) {
+        //删除已有映射关系
+        QueryWrapper<IntroduceMap> introduceMapQueryWrapper = new QueryWrapper<>();
+        introduceMapQueryWrapper.in("introduce_id", ids);
+        introduceMapFacade.remove(introduceMapQueryWrapper);
         //删除明细
         QueryWrapper<IntroduceDetail> introduceDetailQueryWrapper = new QueryWrapper<>();
         introduceDetailQueryWrapper.in("introduce_id", ids);

+ 37 - 0
icssman-service/src/main/java/com/diagbot/facade/RetrievalFacede.java

@@ -8,8 +8,13 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.dto.AddTagRetrievalDTO;
 import com.diagbot.dto.GetRetrievalsByTagDTO;
+import com.diagbot.entity.Retrieval;
+import com.diagbot.entity.RetrievalMapping;
 import com.diagbot.service.impl.RetrievalServiceImpl;
+import com.diagbot.vo.AddTagRetrievalVO;
 import com.diagbot.vo.DelRetrievalsByMapsVO;
 import com.diagbot.vo.GetRetrievalsByTagVO;
 
@@ -44,4 +49,36 @@ public class RetrievalFacede extends RetrievalServiceImpl {
 		return true;
 	}
 	
+	/**
+	 * 标签添加同义词
+	 * @param addTagRetrievalVO
+	 * @return
+	 */
+	public AddTagRetrievalDTO addTagRetrieval(AddTagRetrievalVO addTagRetrievalVO) {
+		AddTagRetrievalDTO addTagRetrievalDTO = new AddTagRetrievalDTO();
+		QueryWrapper<Retrieval> queryWrapper = new QueryWrapper<Retrieval>();
+		queryWrapper.eq("name", addTagRetrievalVO.getRetrievalName());
+		queryWrapper.eq("is_deleted", "N");
+		Retrieval retrieval = this.getOne(queryWrapper);
+		if(retrieval==null){
+			retrieval = new Retrieval();
+			retrieval.setName(addTagRetrievalVO.getRetrievalName());
+			this.save(retrieval);
+		}else{
+			QueryWrapper<RetrievalMapping> queryWrapper2 = new QueryWrapper<RetrievalMapping>();
+			queryWrapper2.eq("retrieval_id", retrieval.getId());
+			queryWrapper2.eq("question_id", addTagRetrievalVO.getQuestionId());
+			retrievalMappingFacede.remove(queryWrapper2);
+		}
+		
+		RetrievalMapping retrievalMapping = new RetrievalMapping();
+		retrievalMapping.setQuestionId(addTagRetrievalVO.getQuestionId());
+		retrievalMapping.setRetrievalId(retrieval.getId());
+		retrievalMappingFacede.save(retrievalMapping);
+		
+		addTagRetrievalDTO.setRetrievalId(retrieval.getId());
+		addTagRetrievalDTO.setRetrievalMappingId(retrievalMapping.getId());
+		return addTagRetrievalDTO;
+	}
+	
 }

+ 36 - 0
icssman-service/src/main/java/com/diagbot/vo/AddTagRetrievalVO.java

@@ -0,0 +1,36 @@
+package com.diagbot.vo;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description
+ * @author rgb
+ * @time 2018年12月5日下午5:00:52
+ */
+@ApiModel(value="标签添加同义词接口传参")
+@Getter
+@Setter
+public class AddTagRetrievalVO {
+	
+	/**
+     * 标签id
+     */
+	@ApiModelProperty(value="标签id",required=true)
+	@NotNull(message="标签id必传")
+    private Long questionId;
+	
+	
+	/**
+	 * 同义词名称
+	 */
+	@ApiModelProperty(value="同义词名称",required=true)
+	@NotBlank(message="同义词名称必传")
+	private String retrievalName;
+	
+}

+ 1 - 1
icssman-service/src/main/java/com/diagbot/vo/IntroduceMapVO.java

@@ -15,7 +15,7 @@ import javax.validation.constraints.NotNull;
 public class IntroduceMapVO {
     @NotNull(message = "请输入标签id")
     private Long questionId;
-    @NotNull(message = "请输入提示信息id")
+    //@NotNull(message = "请输入提示信息id")
     private Long introduceId;
     @NotNull(message = "请输入标签类型")
     private Integer type;

+ 1 - 1
icssman-service/src/main/java/com/diagbot/vo/IntroduceVO.java

@@ -1,6 +1,5 @@
 package com.diagbot.vo;
 
-import com.diagbot.entity.IntroduceDetail;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -20,4 +19,5 @@ public class IntroduceVO {
     private String name;
     private String remark;
     private List<IntroduceDetailVO> detailVOList;
+    private List<IntroduceMapVO> mapVOList;
 }

+ 9 - 1
icssman-service/src/main/java/com/diagbot/web/RetrievalController.java

@@ -12,9 +12,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.AddTagRetrievalDTO;
 import com.diagbot.dto.GetRetrievalsByTagDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.RetrievalFacede;
+import com.diagbot.vo.AddTagRetrievalVO;
 import com.diagbot.vo.DelRetrievalsByMapsVO;
 import com.diagbot.vo.GetRetrievalsByTagVO;
 
@@ -54,7 +56,13 @@ public class RetrievalController {
 		return RespDTO.onSuc(retrievalFacede.delRetrievalsByMaps(delRetrievalsByMapsVO));
 	}
 	
-	
+    @ApiOperation(value = "标签添加同义词[by:rengb]")
+	@PostMapping("/addTagRetrieval")
+	@SysLogger("addTagRetrieval")
+	@Transactional
+	public RespDTO<AddTagRetrievalDTO> addTagRetrieval(@Valid @RequestBody AddTagRetrievalVO addTagRetrievalVO) {
+		return RespDTO.onSuc(retrievalFacede.addTagRetrieval(addTagRetrievalVO));
+	}