发表于: 2019-12-09 20:40:06

1 1338


一、今天完成的事

今天在改bug中度过

前台影像部

public class WxVideoController {

   private static final Logger log= LogManager.getLogger(WxVideoController.class);

   @Autowired
   WxVideoService wxVideoService;

   /**
    * 获取列表
    * @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 = wxVideoService.selectVideoList(video);
       System.out.println(video.getTeacher_name()+"+++++++++++++++++++++++++++++++++++++++");
       System.out.println(video.getTeacher_id()+"+++++++++++++++++++++++++++++++++++++++");
       System.out.println(video.getTeacher_image()+"+++++++++++++++++++++++++++++++++++++++");
       return new PageInfo<>(videoList);
   }

   /**
    * 视频详情
    * @param id
    * @return
    */
   @GetMapping(value = "/u/video")
   private Video getVideo(Long id){
       return wxVideoService.queryVideoById(id);
   }


   /**
    * 收藏
    * @param vid
    * @param sid
    * @return
    */
   @PutMapping(value = "/u/video/updateCollection")
   private boolean updateCollection(Long vid,Long sid){
       boolean status = wxVideoService.setVideoCollection(vid,sid);
       if(status){
           Video video = wxVideoService.queryVideoById(vid);
           Long collections =  video.getNumber_of_collections()+1L;
           wxVideoService.setCollection(vid,collections);
           return true;
       }
       return false;
   }

   /**
    *
    * 取消收藏
    * @param vid
    * @param sid
    * @return
    */
   @DeleteMapping(value = "/u/video/cancelCollection")
   private boolean deleteCollection(Long vid,Long sid){
       boolean status = wxVideoService.delVideoCollection(vid,sid);
       if(status){
           Video video = wxVideoService.queryVideoById(vid);
           Long collections =  video.getNumber_of_collections()-1L;
           System.out.println("++++++++++++"+collections);
           wxVideoService.setCollection(vid,collections);
           return true;
       }
       return false;
   }

   /**
    * 点赞
    * @param like
    * @return boolen
    */
   @PutMapping(value = "/u/video")
   private boolean setLike(int like,Long id){
       Video video = wxVideoService.queryVideoById(id);
       if(like!=0){
           like = video.getNumber_of_likes()+1;
       }else {
           like = video.getNumber_of_likes()-1;
       }
       return wxVideoService.setLike(like,id);
   }

mapper

package com.jnshu.video.mapper;

import com.jnshu.model.Video;
import com.jnshu.model.VideoCollection;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author Admin
* @PackageName com.jnshu.academyctrlwebclient.mapper
* @ClassName ctrl
* @Description
* @create 2019-11-30 15:57
*/
@Mapper
public interface WxVideoMapper {

   /**
    * 所有视频列表
    * @param video
    * @return
    */
   @Select("<script>select  video.id,video.title, video.grade,video.subject,video.number_of_likes, " +
           "video.number_of_collections,video.classification,video.update_at," +
           "teacher.teacher_id,teacher.teacher_name,teacher.teacher_image from video \n" +
           "left join teacher_video on teacher_video.vid =video.id   \n" +
           "left join teacher on teacher.teacher_id = teacher_video.tid\n" +
           "<where>  1=1 " +
           "<if test= \"grade != null\">and video.grade=#{grade}</if>\n"+
           "<if test= \"subject != null\">and video.subject=#{subject}</if>\n"+
           "<if test= \"classification != null\">and video.classification=#{classification}</if>\n"+
           "</where> order by update_at desc"+
           "</script>\n")
   List<Video> selectVideoList(Video video);


   /**
    * 根据id查询
    * @param id
    * @return
    */
   @Select("select video.id,video.title, video.video_image, video.grade, video.subject , video.video_url, video.content, " +
           "video.introduction,teacher.teacher_id,teacher.teacher_name,teacher.teacher_image," +
           "video.number_of_likes,video.number_of_collections,update_at  from video \n" +
           "left join teacher_video on teacher_video.vid=video.id\n" +
           "left join teacher on teacher.teacher_id=teacher_video.tid\n" +
           "where video.id=#{id}")
   Video queryVideoById(Long id);


   /**
    * 点赞
    * @param like
    * @return
    */
   @Update("update video set number_of_likes=#{like} where id=#{id}")
   boolean setLike(int like,Long id);

   /**
    * 收藏
    * @param vid
    * @param collections
    * @return
    */
   @Update("update video set number_of_collections=#{collections} where id=#{vid}")
   boolean setCollection(Long vid, Long collections);

   /**
    * video_collection表插入
    * @param vid
    * @param sid
    * @return
    */
   @Insert("insert into video_collection(vid,sid) values(#{vid},#{sid}) ")
   boolean setVideoCollection(Long vid, Long sid);

   /**
    * video_collection表查询
    * @param vid
    * @param sid
    * @return
    */
   @Select("select * from video_collection where vid=#{vid} and sid=#{sid}")
   VideoCollection queryVideoCollection(Long vid, Long sid);

   /**
    * 取消收藏
    * @param vid
    * @param sid
    * @return
    */
   @Delete("delete from video_collection where vid=#{vid} and sid=#{sid}")
   boolean delVideoCollection(Long vid, Long sid);


}

二、遇到的问题

三、收获

获取当前时间并转行为long类型

package com.jnshu.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* @author Admin
* @PackageName com.jnshu.utils
* @ClassName academy-ctrl-core
* @Description
* @create 2019-12-09 11:16
*/

public class DateUtil {
   /**
    * 根据格式获取当前格式化时间
    * @param format 格式化方式,基础格式为yyyy-MM-dd HH:mm:ss
    * @return 当前时间
    */
   public static String getCurrentTimeByFormat(String format)
   {
       SimpleDateFormat df = new SimpleDateFormat(format);
       return df.format(new Date());
   }

   /**
    * 格式化时间
    * @param format 格式化格式,基础格式为yyyy-MM-dd HH:mm:ss
    * @return
    */
   public static String formatTime(String format, long time)
   {
       SimpleDateFormat df = new SimpleDateFormat(format);
       return df.format(new Date(time));
   }

   /**
    * 转换为long类型
    * @param time
    * @return
    */
   public static long pare(String time){
       SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
       long s=0;
       try {
           s=sim.parse(time).getTime();
       } catch (ParseException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
       return s;
   }

}

写在core包中

数据空中存放时间戳即可

 Long time = (System.currentTimeMillis());

直接就获取了long时间戳。

四、明天的计划

前台-签到模块



返回列表 返回列表
评论

    分享到