Xuecheng Online - day 15 - handout - media management system integration II

2. Learning page to obtain video playing address
2.1 demand analysis
The user enters the online learning page and clicks the course plan to play the corresponding teaching video of the course plan.  
The business process is as follows:
Business Process Description:
1. Users enter the online learning page, and the page requests the search service to obtain course information (including course plan information) and display it on the page.  
2. Online learning requests learning service to get video playing address.  
3. The learning service verifies whether the current user has permission to learn, and prompts the user if there is no permission to learn.  
4. The learning service passes the verification and requests the search service to obtain the course media information.  
5. Search service requests ElasticSearch for course media information.  
Why do you want to ask ElasticSearch for course media information?  
For performance reasons, course information is publicly queried from a search service.  
When will course media information be stored in elastic search?  
Course media information is stored in elastic search when the course is released, because the course information will not be modified after the course is released.  
2.2 release and storage of media information
2.2.1 demand analysis
The course media information is stored in the ElasticSearch index library when the course is released, because the course information will not be modified after the course is released, and the specific business process is as follows.

The business process is as follows:
1. Release the course and write data to the course media information table.  
1) Delete data in teachplan mediapub according to course id
2) Query teachplan media data according to course id
3) Insert the queried teachplan media data into teachplan media Pub
2. Logstash regularly scans the course media information table and writes the course media information into the index database.  
2.2.2 data model
Create the media release form of course plan in XC course database:

CREATE TABLE `teachplan_media_pub` (
`teachplan_id` varchar(32) NOT NULL COMMENT 'Curriculum plan id',
`media_id` varchar(32) NOT NULL COMMENT 'Media funding document id',
`media_fileoriginalname` varchar(128) NOT NULL COMMENT 'Original name of media documents',
`media_url` varchar(256) NOT NULL COMMENT 'Access address of media documents',
`courseid` varchar(32) NOT NULL COMMENT 'curriculum Id',
'logstash Use',
PRIMARY KEY (`teachplan_id`)

The data model classes are as follows:

@GenericGenerator(name = "jpa‐assigned", strategy = "assigned")
public class TeachplanMediaPub implements Serializable {
private static final long serialVersionUID = ‐916357110051689485L;
@GeneratedValue(generator = "jpa‐assigned")
private String teachplanId;
private String mediaId;
private String mediaFileOriginalName;
private String mediaUrl;
private String courseId;
private Date timestamp;//time stamp

2.2.3 Dao 
To create Dao of teachplan mediapub table and store the information to teachplan mediapub, delete the course's media information first, and then add the course's media information, so the method of deleting the course plan's media according to the course id is defined here:

public interface TeachplanMediaPubRepository extends JpaRepository<TeachplanMediaPub, String> {
//Delete course plan media information according to course id
long deleteByCourseId(String courseId);
//Query media information of course plan from teachplan media
public interface TeachplanMediaRepository extends JpaRepository<TeachplanMedia, String> {
List<TeachplanMedia> findByCourseId(String courseId);

2.2.4 Service 
Write a method to save the media information of the course plan, and call this method when the course is published.  
1. How to save the media information of the course plan
This method is to delete the media information of the course, and then add the media information of the course.

//Save course plan media information
private void saveTeachplanMediaPub(String courseId){
//Query course media information
List<TeachplanMedia> teachplanMediaList = teachplanMediaRepository.findByCourseId(courseId);
//Store the media information of the course plan in the table to be indexed
List<TeachplanMediaPub> teachplanMediaPubList = new ArrayList<>();
for(TeachplanMedia teachplanMedia:teachplanMediaList){
TeachplanMediaPub teachplanMediaPub =new TeachplanMediaPub();

2. Call this method when the course is published
Modify the service method of course Publishing:

//Save the media information of the course plan to the table to be indexed
//Page url
String pageUrl = cmsPostPageResult.getPageUrl();
return new CoursePublishResult(CommonCode.SUCCESS,pageUrl);

3.2.5 testing
Test whether the course media information is successfully stored in teachplan? Media? Pub after the course is published. The test process is as follows:
1. Assign a course
2. Add course media to the course plan
3. Executive course release
4. Observe whether the media information of the course plan is stored in teachplan media pub
Note: since this test is only used to test the function of publishing course plan media information, the function of cms page publishing can be temporarily blocked to improve the test efficiency

818 original articles published, 150 praised, 130000 visitors+
His message board follow

Tags: ElasticSearch Database

Posted on Thu, 06 Feb 2020 02:57:03 -0500 by Renegade85