当前位置:网站首页>[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");
}
}
}
边栏推荐
- What will be the game changes brought about by the meta universe?
- A tough battle for Tencent cloud
- 巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...
- Exploration and practice of "flow batch integration" in JD
- Combination of applet container and Internet of things
- Splitting. JS text title slow loading JS effect
- . Net ORM framework hisql practice - Chapter 1 - integrating hisql
- Apache parsing vulnerability (cve-2017-15715)_ Vulnerability recurrence
- TFTP下载kernel,nfs挂载文件系统
- TCP session hijacking based on hunt1.5
猜你喜欢

Apache parsing vulnerability (cve-2017-15715)_ Vulnerability recurrence

大文件处理(上传,下载)思考

IEEE TBD SCI影响因子提升至4.271,位列Q1区!

分享 5 大常用的特征选择方法,机器学习入门必看!!!
![[零基础学IoT Pwn] 环境搭建](/img/3b/a0689a1570fcc40bb9a5a4e9cdc63c.png)
[零基础学IoT Pwn] 环境搭建

Importing alicloud ECS locally to solve deployment problems

ABAP publish restful service

What will be the game changes brought about by the meta universe?

Parker variable displacement piston pump pv092r1k1t1nmmc
![leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]](/img/28/78e2961877776ca3dfcba5ee7e35d2.png)
leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]
随机推荐
Do fresh students get a job or choose a job after graduation?
每日面试1题-如何防止CDN防护被绕过
【机器学习】K-means聚类分析
[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection
DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital
[binary tree] preorder traversal to construct binary search tree
基于SSH的客户关系CRM管理系统
[sword finger offer] sword finger offer 53 - ii Missing numbers from 0 to n-1
Compile and generate busybox file system
网络:服务器网卡组技术原理与实践
Acwing game 57
5g business is officially commercial. What are the opportunities for radio and television?
vue3 响应式数据库—— reactive
Small Tools(3) 集成Knife4j3.0.3接口文档
5G商用三年,未来创新何去何从?
6 张图带你搞懂 TCP 为什么是三次握手?
Apache parsing vulnerability (cve-2017-15715)_ Vulnerability recurrence
Taishan Office Technology Lecture: how to align and draw words of different sizes on the same line
Hyper-V: enable SR-IOV in virtual network
[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入