zouxuan 8 ماه پیش
والد
کامیت
c51d0d4ef1

+ 15 - 9
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
@@ -77,12 +76,14 @@ import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
 import com.yonge.toolset.utils.date.DateUtil;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import com.yonge.toolset.utils.string.ValueUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -1004,22 +1005,27 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public HttpResponseResult<TeacherVo> saveTeacherStyle(TeacherDto teacherDto) {
+    public HttpResponseResult saveTeacherStyle(TeacherDto teacherDto) {
         //校验敏感词
         if (wordFilter.include(teacherDto.getIntroduction(), 3)) {
             throw new BizException("文本包含敏感信息");
         }
-        //修改老师信息
         //获取已经配置的vip、陪练课声部
         List<TeacherSubjectPrice> subjectPrices = teacherSubjectPriceService.lambdaQuery()
                 .eq(TeacherSubjectPrice::getTeacherId, teacherDto.getUserId())
                 .list();
-        String subjectId = teacherDto.getSubjectId();
-        //校验老师提交的声部是否包含已经配置的声部
-        List<Long> oldSubjectIds = subjectPrices.stream().map(TeacherSubjectPrice::getSubjectId).collect(Collectors.toList());
-        List<Long> newSubjectIds = Arrays.stream(subjectId.split(",")).map(Long::parseLong).collect(Collectors.toList());
-        if (!oldSubjectIds.containsAll(newSubjectIds)) {
-            throw new BizException("提交的声部不包含已经配置的声部");
+        if(CollectionUtils.isNotEmpty(subjectPrices)){
+            Map<Long,String> map = new HashMap<>();
+            List<Long> newSubjectIds = Arrays.stream(teacherDto.getSubjectId().split(",")).map(Long::parseLong).collect(Collectors.toList());
+            for (TeacherSubjectPrice subjectPrice : subjectPrices) {
+                if (!newSubjectIds.contains(subjectPrice.getSubjectId())) {
+                    map.put(subjectPrice.getSubjectId(),subjectPrice.getSubjectName());
+                }
+            }
+            if(!map.isEmpty()){
+                String subjectNames = String.join(",", map.values());
+                return HttpResponseResult.failed(HttpStatus.NO_CONTENT,map,subjectNames + "存在售卖中的课程,暂不支持修改");
+            }
         }
 
         int i = baseMapper.updateById(teacherDto);