|
|
@@ -1,13 +1,20 @@
|
|
|
package com.fdkankan.ucenter.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.ucenter.entity.Case;
|
|
|
+import com.fdkankan.ucenter.entity.FeedbackOption;
|
|
|
import com.fdkankan.ucenter.mapper.ICaseMapper;
|
|
|
import com.fdkankan.ucenter.service.ICaseService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.ucenter.service.IFeedbackOptionService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -21,6 +28,8 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class CaseServiceImpl extends ServiceImpl<ICaseMapper, Case> implements ICaseService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IFeedbackOptionService feedbackOptionService;
|
|
|
@Override
|
|
|
public List<Case> allList(Case caseEntity) {
|
|
|
LambdaQueryWrapper<Case> wrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -37,6 +46,31 @@ public class CaseServiceImpl extends ServiceImpl<ICaseMapper, Case> implements I
|
|
|
wrapper.eq(Case::getIsPublic,1);
|
|
|
wrapper.orderByAsc(Case::getSort);
|
|
|
wrapper.orderByAsc(Case::getId);
|
|
|
- return this.list(wrapper);
|
|
|
+ List<Case> list = this.list(wrapper);
|
|
|
+ HashSet<Integer> feedIds = new HashSet<>();
|
|
|
+ for (Case aCase : list) {
|
|
|
+ if(StringUtils.isNotBlank(aCase.getFeedbackOptionIds())){
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(aCase.getFeedbackOptionIds());
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ feedIds.add((Integer) object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashMap<Integer, FeedbackOption> mapByIds = feedbackOptionService.getMapByIds(feedIds);
|
|
|
+ for (Case aCase : list) {
|
|
|
+ if(StringUtils.isNotBlank(aCase.getFeedbackOptionIds())){
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(aCase.getFeedbackOptionIds());
|
|
|
+ List<FeedbackOption> options = new ArrayList<>();
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ FeedbackOption feedbackOption = mapByIds.get((Integer) object);
|
|
|
+ if(feedbackOption!=null){
|
|
|
+ options.add(feedbackOption);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ aCase.setFeedbackOptionList(options);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|