发表于: 2019-12-06 21:32:25
1 1338
一、今天完成的事
后台-视频管理
package com.jnshu.video.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jnshu.model.Teacher;
import com.jnshu.model.Video;
import com.jnshu.video.service.WebVideoSerivce;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @author Admin
* @PackageName com.jnshu.academyctrlwebclient.controller
* @ClassName ctrl
* @Description
* @create 2019-11-29 14:05
*/
@RestController
@RequestMapping("/video/a")
public class WebVideoController {
private static final Logger log= LogManager.getLogger(WebVideoController.class);
@Autowired
WebVideoSerivce webVideoSerivce;
/**
* 获取列表
* @param start
* @return
* @throws Exception
*/
@GetMapping(value = "/u/videoList")
private PageInfo<Video> getVideoList(@RequestParam(value = "start", defaultValue = "1") int start, Video video)throws Exception{
PageHelper.startPage(start,10);
List<Video> videoList = webVideoSerivce.selectVideoList(video);
return new PageInfo<>(videoList);
}
/**
* 修改状态
* @param id
* @param status
* @return
*/
@PutMapping(value = "/u/video")
private boolean setStatus(@RequestParam(value = "id") long id, @RequestParam(value = "status")int status){
return webVideoSerivce.setStatus(id,status);
}
/**
* 编辑
* @param video
* @return
*/
@PutMapping(value = "/u/video/setVideo")
private Video setVideo(@RequestParam(value = "video")Video video){
return webVideoSerivce.setVideo(video);
}
/**
* 新增
* @param video
* @return
*/
@PostMapping(value = "/u/video/addVideo")
private boolean addVideo(@RequestBody Video video,Long tid){
System.out.println("+++++++++++++++++++++++++"+tid);
boolean status = webVideoSerivce.addVideo(video);
if(status){
Long vid = video.getId();
status = webVideoSerivce.addTeacherVideo(vid,tid);
}
return status ;
}
/**
* 视频详情
* @param id
* @return
*/
@GetMapping(value = "/u/video")
private Video getVideo(Long id){
return webVideoSerivce.queryVideoById(id);
}
/**
* 老师列表
* @param start
* @param teacher
* @return
*/
@GetMapping(value = "/u/teacher/teacherList")
private PageInfo<Teacher> teacherList(@RequestParam(value = "start", defaultValue = "1") int start, Teacher teacher){
PageHelper.startPage(start,10);
List<Teacher> teacherList = webVideoSerivce.teacherList(teacher);
return new PageInfo<>(teacherList);
}
/**
* 增加老师
* @param teacher
* @return
*/
@PostMapping(value = "/u/teacher/addTeacher")
private boolean addTeacher(@RequestBody Teacher teacher){
return webVideoSerivce.addTeacher(teacher);
}
/**
* 图片上传
* @param multipartFile
* @return
*/
@PostMapping(value = "/u/uploadImages")
private String uploadImages(MultipartFile multipartFile){
System.out.println(multipartFile+"+++++++++++++++++++++++++++++++");
String URL = webVideoSerivce.uploadImage(multipartFile);
return URL;
}
}
二、遇到的问题
三、收获
id重新排序
ALTER TABLE `video` DROP `id`;
ALTER TABLE `video` ADD `id` MEDIUMINT( 10) NOT NULL FIRST;
ALTER TABLE `video` MODIFY COLUMN `id` MEDIUMINT( 10) NOT NULL AUTO_INCREMENT,ADD PRIMARY KEY(id);
spingboot注解方式insert后获取id
@Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
insert动态
<script>
insert into`video`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="grade != null">`grade`,</if>
<if test="subject != null">`subject`,</if>
<if test="title != null">`title`,</if>
<if test="classification != null">`classification`,</if>
<if test="introduction != null">`introduction`,</if>
<if test="video_url != null">`video_url`,</if>
<if test="content != null">`content`,</if>
<if tess="status != null">`status`,</if>
<if test="image != null">video_image,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="grade != null">#{grade},</if>
<if test="subject != null">#{subject},</if>
<if test="title != null">#{title},</if>
<if test="classification != null">#{classification},</if>
<if test="introduction != null">#{introduction},</if>
<if test="video_url != null">#{video_url},</if>
<if test="content != null">#{content},</if>
<if tess="status != null">#{status},</if>
<if test="image != null">#{video_image},</if>
</trim>
</script>
获取列表数
select count(*) as result from tablename
四、明天的计划
后台-用户管理
评论