瀏覽代碼

老师详情接口

liweifan 3 年之前
父節點
當前提交
452cccc3ec

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

@@ -327,12 +327,13 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
         } else {
             data.setLiveing(YesOrNoEnum.NO);
         }
-
-        StudentStar studentStar = studentStarService.getByStudentIdAndTeacherId(studentId, teacherId);
-        if (null == studentStar) {
-            data.setIsStar(YesOrNoEnum.NO);
-        } else {
-            data.setIsStar(YesOrNoEnum.YES);
+        if(null != studentId){
+            StudentStar studentStar = studentStarService.getByStudentIdAndTeacherId(studentId, teacherId);
+            if (null == studentStar) {
+                data.setIsStar(YesOrNoEnum.NO);
+            } else {
+                data.setIsStar(YesOrNoEnum.YES);
+            }
         }
         return HttpResponseResult.succeed(data);
     }

+ 29 - 4
cooleshow-user/user-website/src/main/java/com/yonge/cooleshow/website/controller/open/OpenTeacherController.java

@@ -1,19 +1,29 @@
 package com.yonge.cooleshow.website.controller.open;
 
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.service.TeacherService;
-import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
+import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 @RestController
 @RequestMapping("/open/teacher")
 @Api(value = "开放老师接口", tags = "开放老师接口")
 public class OpenTeacherController extends BaseController {
     @Autowired
     private TeacherService teacherService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     /**
      * 查询单条
@@ -23,8 +33,23 @@ public class OpenTeacherController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "id", paramType = "path", dataType = "long", required = true),
     })
-    public HttpResponseResult<TeacherVo> detail(@PathVariable("id") Long userId) {
-        TeacherVo detail = teacherService.detail(userId);
-        return succeed(detail);
+    public HttpResponseResult<TeacherHomeVo> detail(@PathVariable("id") Long userId) {
+        if (null == userId) {
+            return failed("缺少老师ID");
+        }
+        SysUser user = sysUserFeignService.queryUserInfo();
+        HttpResponseResult<TeacherHomeVo> res;
+        if (user == null || null == user.getId()) {
+            res = teacherService.queryTeacherHome(null, userId);
+        } else {
+            res = teacherService.queryTeacherHome(user.getId(), userId);
+        }
+        //学生端过滤只看审核通过的
+        if (null != res.getData() && !CollectionUtils.isEmpty(res.getData().getStyleVideo())) {
+            List<TeacherStyleVideo> styleVideo = res.getData().getStyleVideo();
+            List<TeacherStyleVideo> collect = styleVideo.stream().filter(o -> AuthStatusEnum.PASS.equals(o.getAuthStatus())).collect(Collectors.toList());
+            res.getData().setStyleVideo(collect);
+        }
+        return res;
     }
 }