发表于: 2019-12-02 22:02:09
2 1247
一、今天完成的事
package com.jnshu.video.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jnshu.model.Teacher;
import com.jnshu.model.TeacherVideo;
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 java.util.List;
/**
* @author Admin
* @PackageName com.jnshu.academyctrlwebclient.controller
* @ClassName ctrl
* @Description
* @create 2019-11-29 14:05
*/
@RestController
@RequestMapping("/a")
public class WebVideoController {
private static final Logger log= LogManager.getLogger(WebVideoController.class);
@Autowired
WebVideoSerivce webVideoSerivce;
/**
* 获取列表
* @param start
* @param size
* @return
* @throws Exception
*/
@GetMapping(value = "/u/videoList")
private PageInfo<Video> getVideoList(@RequestParam(value = "start", defaultValue = "0") int start,
@RequestParam(value = "size", defaultValue = "10") int size
)throws Exception{
PageHelper.startPage(start,size,"id desc");
List<Video> videoList = webVideoSerivce.selectVideoList();
return new PageInfo<>(videoList);
}
/**
* 修改状态
* @param id
* @param status
* @return
*/
@PutMapping(value = "/u/video/status")
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
* @param teacher
* @return
*/
@PostMapping(value = "/u/video/addVideo")
private boolean addVideo(@RequestParam(value = "video")Video video,
@RequestParam(value = "teacher_id")Teacher teacher){
boolean status = webVideoSerivce.addVideo(video);
if(status){
status = webVideoSerivce.addTeacherVideo(video.getId(),teacher.getId());
return status;
}else {
return false;
}
}
/**
* 增加老师
* @param teacher
* @return
*/
@PostMapping(value = "/u/teacher/addTeacher")
private boolean addTeacher(@RequestParam(value = "teacher")Teacher teacher){
return webVideoSerivce.addTeacher(teacher);
}
}
二、遇到的问题
动态查询
select video.id,video.title, video.grade,video.subject,video.number_of_likes, video.number_of_collections,video.status,video.update_at , teacher.teacher_name from video left join teacher_video on video.id = teacher_video.vid left join teacher on teacher.id = teacher_video.tid<where> <if test= "video.id!=null">video.id=#{video.id}</if><if test= "video.title!=null">and video.title=#{video.title}</if><if test= "video.grade!=null">and video.grade=#{video.grade}</if><if test= "video.subject!=null">and video.subject=#{video.subject}</if><if test="video.number_of_likes!=null">and video.number_of_likes=#{video.number_of_likes}</if><if test= "video.number_of_collections!=null">and video.number_of_collections={video.number_of_collections}</if><if test= "teacher.teacher_name!=null">and teacher.teacher_name=#{teacher.teacher_name}</if> order by update_at desc
淦
三、收获
四、明天的计划
评论