Bläddra i källkod

管乐迷曲目来源内容平台

zouxuan 1 år sedan
förälder
incheckning
4cd1dcbf54

+ 6 - 2
mec-application/src/main/java/com/ym/mec/web/controller/SubjectController.java

@@ -1,6 +1,7 @@
 package com.ym.mec.web.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.musicInstrument.CbsMusicalInstrumentWrapper;
 import com.microsvc.toolkit.common.webportal.exception.BizException;
@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -26,8 +28,10 @@ import java.util.stream.Collectors;
 @RestController
 public class SubjectController extends BaseController {
 
-    @Autowired
+    @Resource
     private SubjectService subjectService;
+    @Resource
+    private MusicFeignClientService musicFeignClientService;
 
     @ApiOperation(value = "修改、新增科目")
     @PostMapping("/upset")
@@ -151,7 +155,7 @@ public class SubjectController extends BaseController {
             // 查询本地已经添加过的曲目数据
             SubjectWrapper.SubjectQuery query1 = new SubjectWrapper.SubjectQuery();
             query1.setHasInstrument(true);
-            List<SubjectWrapper.Subject> list = subjectService.list(query1);
+            List<SubjectWrapper.Subject> list = subjectService.queryList(query1);
             // 转map
             Map<Long, SubjectWrapper.Subject> subjectMap = list.stream().collect(Collectors.groupingBy(e -> e.getCbsSubjectId(), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
 

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

@@ -176,4 +176,6 @@ public interface SubjectDao extends BaseDAO<Integer, Subject> {
     List<Subject> findByNames();
 
     List<Subject> queryCbsList(@Param("cbsSubjectIds") List<Long> cbsSubjectIds);
+
+    List<Subject> notInSubjectIds(@Param("subjectId") Long subjectId);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SubjectService.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
 import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
 import com.ym.mec.biz.dal.page.SubjectQueryInfo;
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
@@ -116,4 +117,5 @@ public interface SubjectService extends BaseService<Integer, Subject> {
 
     Map<Integer, StudentSubjectDto> getSubjectByStudentId(Set studentIds);
 
+    List<SubjectWrapper.Subject> queryList(SubjectWrapper.SubjectQuery query);
 }

+ 29 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectServiceImpl.java

@@ -11,6 +11,8 @@ import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SubjectGoodsMapper;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.SubjectQueryInfo;
+import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
+import com.ym.mec.biz.dal.wrapper.SubjectWrapper;
 import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.page.PageInfo;
@@ -252,4 +254,31 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
         }
         return map;
     }
+
+    @Override
+    public List<SubjectWrapper.Subject> queryList(SubjectWrapper.SubjectQuery query) {
+        query.setPage(1);
+        query.setRows(9999);
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, query);
+
+        PageInfo<SubjectWrapper.Subject> subjectIPage = this.selectPage(query);
+        List<SubjectWrapper.Subject> records = subjectIPage.getRows();
+        if (org.apache.commons.collections.CollectionUtils.isEmpty(records)) {
+            return records;
+        }
+        String instrumentIds = query.getInstrumentIds();
+        List<Long> instrumentIdList = new ArrayList<>();
+        if (StringUtils.isNotEmpty(instrumentIds)) {
+            List<Long> collect = Arrays.stream(instrumentIds.split(",")).map(Long::valueOf).distinct().collect(Collectors.toList());
+            instrumentIdList.addAll(collect);
+        }
+        if (!instrumentIdList.isEmpty()) {
+            records.forEach(record -> {
+                List<InstrumentWrapper.Instrument> instruments = record.getInstruments();
+                instruments.removeIf(next -> !instrumentIdList.contains(next.getId()));
+            });
+        }
+        return records;
+    }
 }

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

@@ -318,4 +318,7 @@
             </foreach>
         </if>
     </select>
+    <select id="notInSubjectIds" resultMap="Subject">
+        SELECT * FROM subject WHERE del_flag_ = 0 and id_ != #{subjectId}
+    </select>
 </mapper>