当前位置:网站首页>[PROJECT] Xiaomao school (IX)
[PROJECT] Xiaomao school (IX)
2022-06-30 18:04:00 【Lemon cap】
Xiaomao school
20. The course is finally released
@RestController
@RequestMapping("/eduservice/course")
@CrossOrigin
public class EduCourseController {
@Autowired
private EduCourseService courseService;
// The course is finally released
// Modify course status
@PostMapping("publishCourse/{id}")
public R publishCourse(@PathVariable String id) {
EduCourse eduCourse = new EduCourse();
eduCourse.setId(id);
eduCourse.setStatus("Normal"); // Set course publishing status
courseService.updateById(eduCourse);
return R.ok();
}
}
// src\api\edu\course.js
import request from '@/utils/request'
export default {
// The course is finally released
publishCourse(id) {
return request({
url: '/eduservice/course/publishCourse/' + id,
method: 'post',
})
}
}
// src\views\edu\course\publish.vue
<script> import course from '@/api/edu/course' export default {
methods: {
publish() {
course.publishCourse(this.courseId) .then(response => {
// Tips this.$message({
type: 'success', message: ' The course was published successfully !' }); // Jump to the course list page this.$router.push({
path: '/course/list' }) }) } } } </script>
21. Course list
@RestController
@RequestMapping("/eduservice/course")
@CrossOrigin
public class EduCourseController {
@Autowired
private EduCourseService courseService;
// Course list Basic implementation
// TODO Perfect conditional query with paging
@GetMapping
public R getCourseList() {
List<EduCourse> list = courseService.list(null);
return R.ok().data("list",list);
}
}
// src\api\edu\course.js
import request from '@/utils/request'
export default {
// TODO Course list
getListCourse() {
return request({
url: '/eduservice/course',
method: 'get'
})
}
}
// src\views\edu\course\list.vue
<template>
<div class="app-container">
Course list
<!-- Query form -->
<el-form :inline="true" class="demo-form-inline">
<el-form-item>
<el-input v-model="courseQuery.title" placeholder=" Course name "/>
</el-form-item>
<el-form-item>
<el-select v-model="courseQuery.status" clearable placeholder=" Course status ">
<el-option :value="Normal" label=" The published "/>
<el-option :value="Draft" label=" Unpublished "/>
</el-select>
</el-form-item>
<el-button type="primary" icon="el-icon-search" @click="getList()"> Inquire about </el-button>
<el-button type="default" @click="resetData()"> Empty </el-button>
</el-form>
<!-- form -->
<el-table :data="list" border fit highlight-current-row>
<el-table-column label=" Serial number " width="70" align="center">
<template slot-scope="scope">
{
{ (page - 1) * limit + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column prop="title" label=" Course name " width="80" />
<el-table-column label=" Course status " width="80">
<template slot-scope="scope">
{
{ scope.row.status==='Normal'?' The published ':' Unpublished ' }}
</template>
</el-table-column>
<el-table-column prop="lessonNum" label=" Class hours " />
<el-table-column prop="gmtCreate" label=" Add the time " width="160"/>
<el-table-column prop="viewCount" label=" Number of views " width="60" />
<el-table-column label=" operation " width="200" align="center">
<template slot-scope="scope">
<router-link :to="'/teacher/edit/'+scope.row.id">
<el-button type="primary" size="mini" icon="el-icon-edit"> Edit course basic information </el-button>
</router-link>
<router-link :to="'/teacher/edit/'+scope.row.id">
<el-button type="primary" size="mini" icon="el-icon-edit"> Edit course outline information </el-button>
</router-link>
<el-button type="danger" size="mini" icon="el-icon-delete" @click="removeDataById(scope.row.id)"> Delete course information </el-button>
</template>
</el-table-column>
</el-table>
<!-- Pagination -->
<el-pagination :current-page="page" :page-size="limit" :total="total" style="padding: 30px 0; text-align: center;" layout="total, prev, pager, next, jumper" @current-change="getList" />
</div>
</template>
<script> // Introduce call course.js file import course from '@/api/edu/course' export default {
// Where to write core code data() {
// Define variables and initial values return {
list: null, // The collection returned by the interface after query page: 1, // The current page limit: 10, // Records per page total: 0, // Total number of records courseQuery: {
} // Conditional encapsulation object } }, created() {
// Execute before rendering the page , The general call methods Method of definition this.getList() }, methods: {
// Create specific methods , call teacher.js Method of definition // How to list lecturers getList() {
course.getListCourse() .then(response => {
// The request is successful // response The data returned by the interface // console.log(response); this.list= response.data.list }) }, resetData() {
// How to clear // The form entry data is cleared this.courseQuery = {
} // Query all instructor data this.getList() }, } } </script>
22. Delete course ( Back end )
@RestController
@RequestMapping("/eduservice/course")
@CrossOrigin
public class EduCourseController {
@Autowired
private EduCourseService courseService;
// Delete course
@DeleteMapping("{courseId}")
public R deleteCourse(@PathVariable String courseId) {
courseService.removeCourse(courseId);
return R.ok();
}
}
@Service
public class EduCourseServiceImpl extends ServiceImpl<EduCourseMapper, EduCourse> implements EduCourseService {
// Course description
@Autowired
private EduCourseDescriptionService courseDescriptionService;
// Inject sections and chapters service
@Autowired
private EduVideoService eduVideoService;
@Autowired
private EduChapterService eduChapterService;
// Delete course
@Override
public void removeCourse(String courseId) {
// 1. According to the course id Delete section
eduVideoService.removeVideoByCourseId(courseId);
// 2. According to the course id Delete chapter
eduChapterService.removeChapterByCourseId(courseId);
// 3. According to the course id Delete description
courseDescriptionService.removeById(courseId);
// 4. According to the course id Delete the course itself
int result = baseMapper.deleteById(courseId);
if(result == 0) {
// Failure to return
throw new LemonException(20001, " Delete failed ");
}
}
}
public interface EduVideoService extends IService<EduVideo> {
void removeVideoByCourseId(String courseId);
}
@Service
public class EduVideoServiceImpl extends ServiceImpl<EduVideoMapper, EduVideo> implements EduVideoService {
// According to the course id Delete section
// TODO Delete section , Delete the corresponding video file
@Override
public void removeVideoByCourseId(String courseId) {
QueryWrapper<EduVideo> wrapper = new QueryWrapper<>();
wrapper.eq("course_id", courseId);
baseMapper.delete(wrapper);
}
}
public interface EduChapterService extends IService<EduChapter> {
// According to the course id Delete chapter
void removeChapterByCourseId(String courseId);
}
@Service
public class EduChapterServiceImpl extends ServiceImpl<EduChapterMapper, EduChapter> implements EduChapterService {
@Autowired
private EduVideoService videoService; // Injection section service
// According to the course id Delete chapter
@Override
public void removeChapterByCourseId(String courseId) {
QueryWrapper<EduChapter> wrapper = new QueryWrapper<>();
wrapper.eq("course_id", courseId);
baseMapper.delete(wrapper);
}
}
23. Alibaba cloud video on demand
- video on demand (ApsaraVideo for VoD) It's a collection of audio and video collection 、 edit 、 Upload 、 Automatic transcoding 、 Media resource management 、 A one-stop audio and video on demand solution with distribution acceleration .
- Application scenarios
- Audio and video websites : Whether it's a start-up video service enterprise , Or already have a huge amount of video resources , Customized on-demand services help customers quickly build an extreme viewing experience 、 Secure and reliable VOD applications .
- Short video : Audio and video shooting 、 Special effects editor 、 Local transcoding 、 High speed upload 、 Automatic cloud transcoding 、 Media resource management 、 Distribution acceleration 、 Play in one complete short video solution . Has helped 1000+APP Fast implementation of mobile phone short video function .
- Live to on demand : Record the live stream synchronously as a video on demand , For looking back . And support media management 、 Media processing ( Transcoding and content auditing / Smart head map, etc AI Handle )、 Content production ( Cloud clip )、CDN Distribution acceleration and a series of operations .
- Online education : Easy to use for online education customers 、 Secure and reliable VOD service . Through the console /API And other ways to upload teaching videos , The powerful transcoding capability ensures that videos can be released quickly , The acceleration node covering the whole network ensures the fluency of students' watching . Anti theft chain 、 Video encryption and other copyright protection programs protect teaching content from theft .
- Video production : Provide online visual editing platform and rich OpenAPI, Help customers deal with 、 Making video content . Except for the shear splicing of the foundation 、 Mixing 、 Cover label 、 Special effects 、 Besides a series of functions such as synthesis , Relying on cloud editing and on-demand integrated services, standardization can also be achieved 、 Intelligent editing production , The threshold of video production is greatly reduced , Shorten production time , Improve content productivity .
- Content review : For short video platform 、 Media industry audit, etc , Help customers from voice 、 written words 、 Vision and other multi-dimensional accurate recognition of video 、 cover 、 The prohibited content of the title or comment is carried out AI Intelligent audit and manual audit .
- Function is introduced
24. Alicloud video on demand SDK( Get video address )
Create a video on demand micro service
- Create a microservice module Artifact:service-vod
- pom
- service-vod Introduce dependency in
<dependencies> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> </dependency> <dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-vod</artifactId> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-sdk-vod-upload</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> </dependency> </dependencies>
test
public class InitObject { public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { String regionId = "cn-shanghai"; // On demand service access area DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); DefaultAcsClient client = new DefaultAcsClient(profile); return client; } }
public class TestVod { public static void main(String[] args) throws Exception{ // 1. According to the video id Get video playback address // Create initialization object DefaultAcsClient client = InitObject.initVodClient(" Secret key ", " password "); // Create get video address request and response GetPlayInfoRequest request = new GetPlayInfoRequest(); GetPlayInfoResponse response = new GetPlayInfoResponse(); // towards request Set the video in the object id request.setVideoId("7272bc8cc64344c2a3209c15881712fe"); // Call the method in the initialization object , Pass on request, get data response = client.getAcsResponse(request); List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList(); // Broadcast address for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) { System.out.print("PlayInfo.PlayURL = " + playInfo.getPlayURL() + "\n"); } //Base Information System.out.print("VideoBase.Title = " + response.getVideoBase().getTitle() + "\n"); } }
25. Alicloud video on demand SDK( Get video credentials )
public class TestVod {
public static void main(String[] args) throws Exception{
// 2. According to the video id Get video playback credentials
// Create initialization object
// Create initialization object
DefaultAcsClient client = InitObject.initVodClient(" Secret key ", " password ");
// Create and obtain video credentials request and response
GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();
// towards request Set the video in the object id
request.setVideoId("7272bc8cc64344c2a3209c15881712fe");
// Call the method in the initialization object , Pass on request, get data
response = client.getAcsResponse(request);
System.out.println("platauth: " + response.getPlayAuth());
}
}
26. Alicloud video on demand ( Upload video )
public class TestVod {
public static void main(String[] args){
String accessKeyId = " Secret key ";
String accessKeySecret = " password ";
String title = "3 - How Does Project Submission Work - upload by sdk"; // The name of the file after uploading
String fileName = "D:/abc/3 - How Does Project Submission Work.mp4"; // The path and name of the local file
// How to upload video
UploadVideoRequest request = new UploadVideoRequest(accessKeyId, accessKeySecret, title, fileName);
/* You can specify the size of each slice when uploading slices , The default is 2M byte */
request.setPartSize(2 * 1024 * 1024L);
/* You can specify the number of concurrent threads during fragment upload , The default is 1,( notes : This configuration will occupy the server CPU resources , It needs to be specified according to the situation of the server )*/
request.setTaskNum(1);
UploadVideoImpl uploader = new UploadVideoImpl();
UploadVideoResponse response = uploader.uploadVideo(request);
System.out.print("RequestId=" + response.getRequestId() + "\n"); // Request for video on demand service ID
if (response.isSuccess()) {
System.out.print("VideoId=" + response.getVideoId() + "\n");
} else {
/* If the callback is set URL Invalid , Does not affect the video upload , Can return VideoId At the same time, the error code will be returned . In other cases, the upload fails ,VideoId It's empty , At this time, you need to analyze the specific error reason according to the returned error code */
System.out.print("VideoId=" + response.getVideoId() + "\n");
System.out.print("ErrorCode=" + response.getCode() + "\n");
System.out.print("ErrorMessage=" + response.getMessage() + "\n");
}
}
}
边栏推荐
- Lenovo's "dual platform" operation and maintenance solution helps to comprehensively improve the intelligent management ability of the intelligent medical industry
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- 墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
- Redis (II) -- persistence
- 广电5G正式启航,黄金频段将如何应用引关注
- Six photos vous montrent pourquoi TCP serre la main trois fois?
- Redis (V) - advanced data types
- 大文件处理(上传,下载)思考
- Course design for the end of the semester: product sales management system based on SSM
- 应届生毕业之后先就业还是先择业?
猜你喜欢
Design and principle of tubes responsive data system
流批一体在京东的探索与实践
New skill: accelerate node through code cache JS startup
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
Tubes响应性数据系统的设计与原理
Thinking on large file processing (upload, download)
Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.
Redis (III) - transaction
Write the simplest small program in C language Hello World
Radio and television 5g officially set sail, attracting attention on how to apply the golden band
随机推荐
联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
Redis (II) -- persistence
.NET ORM框架HiSql实战-第一章-集成HiSql
Is there an optimal solution to the energy consumption anxiety in the data center?
Building a basic buildreoot file system
New skill: accelerate node through code cache JS startup
AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集
生成对抗网络,从DCGAN到StyleGAN、pixel2pixel,人脸生成和图像翻译。
腾讯云安装mysql数据库
Synchronized summary
Lenovo's "dual platform" operation and maintenance solution helps to comprehensively improve the intelligent management ability of the intelligent medical industry
Post MSF infiltration summary
如何写一个技术方案
Redis (VII) - sentry
Daily question brushing record (IX)
Course design for the end of the semester: product sales management system based on SSM
Word中添加代码块(转载)
Combination of applet container and Internet of things
巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...
TFTP下载kernel,nfs挂载文件系统