Procházet zdrojové kódy

处理声部错误

yuanliang před 1 rokem
rodič
revize
ce5694a340

+ 24 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CbsSubjectServiceImpl.java

@@ -4,12 +4,17 @@ import com.dayaedu.cbs.openfeign.service.CbsSubjectService;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.service.SubjectService;
+import com.yonge.cooleshow.biz.dal.wrapper.SubjectWrapper;
+import com.yonge.toolset.base.page.PageInfo;
+import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class CbsSubjectServiceImpl implements CbsSubjectService {
@@ -28,6 +33,24 @@ public class CbsSubjectServiceImpl implements CbsSubjectService {
     }
 
     public List<CbsSubjectApiWrapper.Subject> list(CbsSubjectApiWrapper.SubjectQuery query) {
-        return subjectService.getDao().queryCbsList(query);
+        SubjectWrapper.SubjectQuery subjectQuery = new SubjectWrapper.SubjectQuery();
+        subjectQuery.setPage(1);
+        subjectQuery.setRows(999);
+        subjectQuery.setEnableFlag(query.getEnable());
+        List<Long> subjectIds = query.getSubjectIds();
+        if (CollectionUtils.isNotEmpty(subjectIds)) {
+            subjectQuery.setSubjectIds(subjectIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
+        }
+        PageInfo<SubjectWrapper.Subject> subjectPageInfo = subjectService.selectPage(subjectQuery);
+        Map<Long, String> cbsSubjectIdNameMap = subjectPageInfo.getRows().stream().collect(Collectors.toMap(SubjectWrapper.Subject::getCbsSubjectId, SubjectWrapper.Subject::getName));
+
+        List<CbsSubjectApiWrapper.Subject> subjects = subjectService.getDao().queryCbsList(query);
+        for (CbsSubjectApiWrapper.Subject subject : subjects) {
+            Long cbsSubjectId = subject.getCbsSubjectId();
+            if (cbsSubjectIdNameMap.containsKey(cbsSubjectId)) {
+                subject.setSubjectName(cbsSubjectIdNameMap.get(cbsSubjectId));
+            }
+        }
+        return subjects;
     }
 }