Browse Source

管乐迷曲目来源内容平台

zouxuan 1 year ago
parent
commit
0cda4e61aa

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectDao.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper;
 import com.ym.mec.biz.dal.dto.ConditionDto;
 import com.ym.mec.biz.dal.dto.StudentAttendanceViewDto;
 import com.ym.mec.biz.dal.dto.StudentSubjectDto;
@@ -183,4 +184,6 @@ public interface SubjectDao extends BaseDAO<Integer, Subject> {
     int findCount(Map<String, Object> params);
 
     List<SubjectWrapper.Subject> findPage(Map<String, Object> params);
+
+    List<CbsSubjectApiWrapper.Subject> queryCbsSubjects(@Param("query") CbsSubjectApiWrapper.SubjectQuery query);
 }

+ 57 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CbsSubjectServiceImpl.java

@@ -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;
+    }
+}

+ 17 - 0
mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -412,4 +412,21 @@
         </if>
         <include refid="global.limit"/>
     </select>
+    <select id="queryCbsSubjects"
+            resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper$Subject">
+        SELECT id_ subjectId,cbs_subject_id_ cbsSubjectId,name_ subjectName,code_ code FROM `subject`
+        WHERE del_flag_ = 0
+        <if test="query.cbsSubjectIds != null and query.cbsSubjectIds.size > 0">
+            AND cbs_subject_id_ IN
+            <foreach collection="query.cbsSubjectIds" item="cbsSubjectId" open="(" close=")" separator=",">
+                #{cbsSubjectId}
+            </foreach>
+        </if>
+        <if test="query.subjectIds != null and query.subjectIds.size > 0">
+            AND id_ IN
+            <foreach collection="query.subjectIds" item="subjectId" open="(" close=")" separator=",">
+                #{subjectId}
+            </foreach>
+        </if>
+    </select>
 </mapper>