|
@@ -0,0 +1,57 @@
|
|
|
+package com.ym.mec.biz.service.impl;
|
|
|
+
|
|
|
+import com.dayaedu.cbs.openfeign.service.CbsSubjectService;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.ym.mec.biz.dal.entity.Subject;
|
|
|
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
|
|
|
+import com.ym.mec.biz.service.SubjectService;
|
|
|
+import com.ym.mec.common.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 {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CbsSubjectServiceImpl.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SubjectService subjectService;
|
|
|
+
|
|
|
+ public Boolean checkSubjectEnable(CbsSubjectApiWrapper.CheckSubjectDto checkSubjectDto) {
|
|
|
+ List<Subject> subjects = subjectService.getDao().queryCbsList(Lists.newArrayList(checkSubjectDto.getSubjectId().longValue()));
|
|
|
+ if (CollectionUtils.isNotEmpty(subjects)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<CbsSubjectApiWrapper.Subject> list(CbsSubjectApiWrapper.SubjectQuery 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().queryCbsSubjects(query);
|
|
|
+ for (CbsSubjectApiWrapper.Subject subject : subjects) {
|
|
|
+ Long cbsSubjectId = subject.getCbsSubjectId();
|
|
|
+ if (cbsSubjectIdNameMap.containsKey(cbsSubjectId)) {
|
|
|
+ subject.setSubjectName(cbsSubjectIdNameMap.get(cbsSubjectId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return subjects;
|
|
|
+ }
|
|
|
+}
|