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