Online studies - Day 15 - Lecture - Media Asset Management System Integration two

Learning page for video playback address 
2.1  Requirements Analysis 
users enter online learning page, click on the video teaching lesson plans will play the corresponding lesson plans. 
Business processes are as follows:
 
Business Process Description: 
1 , users enter online learning page, search page requests to obtain course information (including lesson plans information) and page impressions. 
2 , learning online learning service request to obtain the video playback address. 
3 , learning services check whether the current user has permission to study, to learn if there is no permission to prompt the user. 
4 , learning services by check, request media information search service to obtain course information. 
5 , the search service request ElasticSearch get media information curriculum information. 
Why should request ElasticSearch query media information curriculum information? 
For performance reasons, publicly available information inquiry from the course search service. 
When the information stored in the media information curriculum ElasticSearch in? 
Course information is stored in the media capital at the time of course released elasticsearch , because the basic curriculum publish course information will not be modified. 
2.2  Course publish information storage media assets 
2.2.1  Analysis of Demand 
Media Asset course information is stored in the time course of releaseElasticSearch index database, because the basic curriculum publish course information will no longer modify specific business processes as follows.

Business processes are as follows: 
1 , curriculum releases, write data to the media information program information table. 
1 ) The program id delete teachplanMediaPub data 
2 ) a course id query teachplanMedia data 
3 ) the query to teachplanMedia insert data into teachplanMediaPub in 
2 , Logstash regular scanning program information table of media information, and index information into the media information curriculum library. 
2.2.2  Data Model 
in xc_course create lesson plans owned media publish tables in the database:

CREATE TABLE `teachplan_media_pub` (
`teachplan_id` varchar(32) NOT NULL COMMENT '课程计划id',
`media_id` varchar(32) NOT NULL COMMENT '媒资文件id',
`media_fileoriginalname` varchar(128) NOT NULL COMMENT '媒资文件的原始名称',
`media_url` varchar(256) NOT NULL COMMENT '媒资文件访问地址',
`courseid` varchar(32) NOT NULL COMMENT '课程Id',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT
'logstash使用',
PRIMARY KEY (`teachplan_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Data model classes are as follows:

@Data
@ToString
@Entity
@Table(name="teachplan_media_pub")
@GenericGenerator(name = "jpa‐assigned", strategy = "assigned")
public class TeachplanMediaPub implements Serializable {
private static final long serialVersionUID = ‐916357110051689485L;
@Id
@GeneratedValue(generator = "jpa‐assigned")
@Column(name="teachplan_id")
private String teachplanId;
@Column(name="media_id")
private String mediaId;
@Column(name="media_fileoriginalname")
private String mediaFileOriginalName;
@Column(name="media_url")
private String mediaUrl;
@Column(name="courseid")
private String courseId;
@Column(name="timestamp")
private Date timestamp;//时间戳
}

2.2.3 Dao 
create TeachplanMediaPub table Dao , to TeachplanMediaPub using the media capital of the course information delete stored information, and then add the class media asset information processes, so here is defined according curriculum id delete the lesson plan media assets method:

public interface TeachplanMediaPubRepository extends JpaRepository<TeachplanMediaPub, String> {
//根据课程id删除课程计划媒资信息
long deleteByCourseId(String courseId);
}
//从TeachplanMedia查询课程计划媒资信息
public interface TeachplanMediaRepository extends JpaRepository<TeachplanMedia, String> {
List<TeachplanMedia> findByCourseId(String courseId);
}

2.2.4 Service 
to write lesson plans media resource information stored method, and this method is called when the course release. 
1 , the media capital preservation lesson plan information method 
This method uses the information to delete the media capital of the course, and then add the information to the media information programs.

//保存课程计划媒资信息
private void saveTeachplanMediaPub(String courseId){
//查询课程媒资信息
List<TeachplanMedia> teachplanMediaList = teachplanMediaRepository.findByCourseId(courseId);
//将课程计划媒资信息存储待索引表
teachplanMediaPubRepository.deleteByCourseId(courseId);
List<TeachplanMediaPub> teachplanMediaPubList = new ArrayList<>();
for(TeachplanMedia teachplanMedia:teachplanMediaList){
TeachplanMediaPub teachplanMediaPub =new TeachplanMediaPub();
BeanUtils.copyProperties(teachplanMedia,teachplanMediaPub);
teachplanMediaPubList.add(teachplanMediaPub);
}
teachplanMediaPubRepository.saveAll(teachplanMediaPubList);
}

2 , this method is called when publishing program 
revision of curricula release service method:

....
//保存课程计划媒资信息到待索引表
saveTeachplanMediaPub(courseId);
//页面url
String pageUrl = cmsPostPageResult.getPageUrl();
return new CoursePublishResult(CommonCode.SUCCESS,pageUrl);
.....

3.2.5  test 
is successful after the test course curriculum will release information storage media information to teachplan_media_pub , the test process is as follows: 
1 , specify a course 
2 , add media assets to the course curriculum plan 
3 , the implementation of programs release 
4 , lesson plans observed Media Assets whether information stored in teachplan_media_pub in 
Note: Because this test is only for functional testing of media information published lesson plan information, can temporarily cms pages released temporarily shielding function, improve test efficiency 
rate.

发布了835 篇原创文章 · 获赞 152 · 访问量 14万+

Guess you like

Origin blog.csdn.net/qq_40208605/article/details/104195690