刘俊驰 5 月之前
父节点
当前提交
b57ab6ecb1

+ 9 - 2
mec-application/src/main/java/com/ym/mec/student/controller/StudentManageController.java

@@ -260,9 +260,16 @@ public class StudentManageController extends BaseController {
 
         // 通过学生声部换乐器ID
         if (StringUtils.isNotBlank(student.getSubjectIdList())) {
-            List<Integer> instrumentIdsBySubjectId = instrumentService.getInstrumentIdsBySubjectId(Integer.parseInt(student.getSubjectIdList()));
+            String subjectId = student.getSubjectIdList();
+            if ("5".equals(student.getSubjectIdList())) {
+                subjectId = "6";
+            } else  if("122".equals(student.getSubjectIdList())){
+                subjectId = "122,121,113,23";
+            }
+            List<Integer> instrumentIdsBySubjectId = instrumentService.getInstrumentIdsBySubjectId(subjectId);
             if (CollectionUtils.isNotEmpty(instrumentIdsBySubjectId)) {
-                datas.put("instrumentId",instrumentIdsBySubjectId.get(0));
+                // 逗号隔开
+                datas.put("instrumentId", StringUtils.join(instrumentIdsBySubjectId, ","));
             }
         }
 		return succeed(datas);

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/InstrumentDao.java

@@ -22,4 +22,5 @@ public interface InstrumentDao extends BaseMapper<Instrument> {
 	 */
 	List<InstrumentWrapper.Instrument> selectPage(@Param("page") IPage<InstrumentWrapper.Instrument> page, @Param("param") InstrumentWrapper.InstrumentQuery param);
 
+    List<Instrument> getBySubjectId(@Param("subjectId") String subjectId);
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/InstrumentService.java

@@ -53,7 +53,7 @@ public interface InstrumentService extends IService<Instrument>  {
 
     List<InstrumentWrapper.Instrument> getList(InstrumentWrapper.InstrumentQuery query);
 
-    List<Integer> getInstrumentIdsBySubjectId(Integer subjectId);
+    List<Integer> getInstrumentIdsBySubjectId(String subjectId);
 
     void modify(InstrumentWrapper.Update update);
 }

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/InstrumentServiceImpl.java

@@ -14,6 +14,7 @@ import com.ym.mec.biz.dal.wrapper.InstrumentWrapper;
 import com.ym.mec.biz.service.InstrumentService;
 import com.ym.mec.biz.service.SubjectService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -36,6 +37,9 @@ public class InstrumentServiceImpl extends ServiceImpl<InstrumentDao, Instrument
     @Resource
     private SubjectService subjectService;
 
+    @Autowired
+    private InstrumentDao instrumentDao;
+
     /**
      * 查询详情
      *
@@ -189,10 +193,8 @@ public class InstrumentServiceImpl extends ServiceImpl<InstrumentDao, Instrument
     }
 
     @Override
-    public List<Integer> getInstrumentIdsBySubjectId(Integer subjectId) {
-        List<Instrument> list = this.lambdaQuery()
-            .eq(Instrument::getSubjectId, subjectId)
-            .list();
+    public List<Integer> getInstrumentIdsBySubjectId(String subjectId) {
+        List<Instrument> list = instrumentDao.getBySubjectId(subjectId);
         if (CollectionUtils.isEmpty(list)) {
             return new ArrayList<>();
         }

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/InstrumentMapper.xml

@@ -36,4 +36,10 @@
         </where>
 	</select>
 
+    <select id="getBySubjectId" resultType="com.ym.mec.biz.dal.entity.Instrument">
+        SELECT
+            <include refid="baseColumns" />
+        FROM instrument t
+        WHERE find_in_set(t.subject_id_, #{subjectId})
+    </select>
 </mapper>