Java's new project learning online notes-day15

Keywords: Java Nginx

3.4.4 Service
Service method is defined in learning service, which requests course management service and media management service to obtain course learning address remotely.

[mw_shl_code=applescript,true]@Service  public class LearningService {     
   @Autowired    
  CourseSearchClient courseSearchClient;   
     //Getting lessons  
    public GetMediaResult getMedia(String courseId, String teachplanId) {      
      //Verify the learning authority of students. Charge or not      
    //Call search service query     
     TeachplanMediaPub teachplanMediaPub = courseSearchClient.getmedia(teachplanId);          if(teachplanMediaPub == null || StringUtils.isEmpty(teachplanMediaPub.getMediaUrl())){         
     //Error getting video playing address          
    ExceptionCast.cast(LearningCode.LEARNING_GETMEDIA_ERROR);   
       }      
      return new GetMediaResult(CommonCode.SUCCESS,teachplanMediaPub.getMediaUrl());  
    }  } 
[/mw_shl_code]

3.4.5 Controller
Call service to query the video playing address according to the course plan id:

[mw_shl_code=applescript,true]@RestController  @RequestMapping("/learning/course")  public class CourseLearningController implements CourseLearningControllerApi {  
      @Autowired    
  LearningService learningService;     
   @Override  
    @GetMapping("/getmedia/{courseId}/{teachplanId}")  
    public GetMediaResult getmedia(@PathVariable String courseId, @PathVariable String  teachplanId) {      
    //Get course learning address     
     return learningService.getMedia(courseId, teachplanId);  
    }    } [/mw_shl_code]

3.4.6 test
Use swagger UI or postman test learning service to query the course video address interface.

3.5 front end development
3.5.1 demand analysis
You need to complete the following functions on the front page of the learning center:
1. To enter the course learning page, you need to bring the parameters of course Id and course plan Id. the parameter of course Id must be brought, and the course plan Id can be blank.
2. Enter the page and display the course plan of the course on the right side according to the course Id.
3. After entering the page, judge that if there is a course plan Id in the request parameter, the video of this chapter will be played.
4. After entering the page, judge that if the course plan ID is 0, you need to take out the ID of the first course plan of this course and play the video of the first course plan.

3.5.2 api method

[mw_shl_code=applescript,true]let sysConfig = require('@/../config/sysConfig') let apiUrl = sysConfig.xcApiUrlPre; /*Get playback address*/ export const get_media = (courseId,chapter) => { 
  return http.requestGet(apiUrl+'/api/learning/course/getmedia/'+courseId+'/'+chapter); }
[/mw_shl_code]

3.3.3 configuring agents
Configure path forwarding of / api/learning / in ucenter.xuecheng.com virtual host in Nginx. Please forward this url to learning service.

[mw_shl_code=applescript,true]#Upstream learning ﹣ server ﹣ pool {server 127.0.0.1:40600 weight = 10;   
   }    #Learning service location ^~ /api/learning /{  
proxy_pass http://learning_server_pool/learning/;     
   }[/mw_shl_code]

Posted by markc1 on Fri, 01 Nov 2019 10:28:11 -0700