当前位置:网站首页>[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");
}
}
}
边栏推荐
- 5g business is officially commercial. What are the opportunities for radio and television?
- 墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
- Small tools (3) integration knife4j3.0.3 interface document
- 新技能:通过代码缓存加速 Node.js 的启动
- Vue3 reactive database
- Tubes响应性数据系统的设计与原理
- Exch:exchange server 2013 is about to end support
- Canvas cloud shape animation
- [零基础学IoT Pwn] 环境搭建
- Post penetration file system + uploading and downloading files
猜你喜欢

splitting. JS password display hidden JS effect

Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.

Redis (V) - advanced data types

Interview shock 60: what will cause MySQL index invalidation?

Parker Parker sensor p8s-grflx
![[zero basic IOT pwn] environment construction](/img/3b/a0689a1570fcc40bb9a5a4e9cdc63c.png)
[zero basic IOT pwn] environment construction

中基协:推荐使用电子合同

新技能:通过代码缓存加速 Node.js 的启动

自旋锁探秘

NFT: 开启加密艺术时代的无限可能
随机推荐
Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.
Taishan Office Technology Lecture: how to align and draw words of different sizes on the same line
Small Tools(3) 集成Knife4j3.0.3接口文档
编译生成busybox文件系统
构建基本buildroot文件系统
应届生毕业之后先就业还是先择业?
每日面试1题-蓝队基础面试题-应急响应(1)应急响应基本思路流程+Windows入侵排查思路
What should I pay attention to when playing futures? Where is safe to open an account? It's my first contact
Interview shock 60: what will cause MySQL index invalidation?
Development details of NFT casting trading platform
如何写一个技术方案
IEEE TBD SCI impact factor increased to 4.271, ranking Q1!
Flutter custom component
Zero foundation can also be an apple blockbuster! This free tool can help you render, make special effects and show silky slides
TCP session hijacking based on hunt1.5
新技能:通过代码缓存加速 Node.js 的启动
Six photos vous montrent pourquoi TCP serre la main trois fois?
Splitting. JS text title slow loading JS effect
Ardunio esp32 obtains real-time temperature and humidity in mqtt protocol (DH11)
Network: principle and practice of server network card group technology