提交 beafcf0c 编写于 作者: 喷火的神灵's avatar 喷火的神灵 🎱

计数模块

上级 99ef7b5d
......@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="mLogo.png">
<title><%= htmlWebpackPlugin.options.title %></title>
<title>YouBili</title>
</head>
<body>
<noscript>
......
......@@ -379,7 +379,7 @@ i {
position: fixed;
top: 0;
left: 0;
background: #fff;
//background: #fff;
height: 60px;
width: 100%;
min-width: 1200px;
......@@ -387,6 +387,7 @@ i {
justify-content: space-between;
align-items: center;
z-index: 99999;
background-image: linear-gradient(#feb692, #ea5455);
}
#left {
......@@ -427,7 +428,7 @@ i {
}
.el-autocomplete {
width: 580px;
width: 680px;
}
.popover {
......
<!--侧边栏-->
<template>
<div>
<div id="mao">
<el-menu
id="sidebar"
class="el-menu-vertical-demo"
:default-active="$router.currentRoute.path"
router
v-show="isShow"
active-text-color="#fe3355"
>
<el-submenu :index="i+''" v-for="(v, i) of themeAll" :key="i">
<template slot="title">
......@@ -64,8 +65,11 @@ export default {
* {
padding: 0;
margin: 0;
color: #fff;
}
#mao {
}
#sidebar {
position: fixed;
top: 60px;
......@@ -74,14 +78,19 @@ export default {
width: 250px;
overflow-y: auto;
border: 0;
background-image: linear-gradient(#fad7a1, #e96d71);
}
#sidebar .el-menu {
border: 0;
}
ul .el-menu .el-menu--inline {
background-color: #000 !important;
}
.el-menu-item.is-active {
background: #aaa !important;
background: #fad7a1 !important;
}
a {
......
......@@ -340,3 +340,30 @@ export function uploadContent(params) {
data: params
})
}
// 获取视频页所有数量
export function LikeCount(params) {
return request({
method: "get",
url: "/video/all/counts",
data: params
})
}
// // 点赞
// export function ForLike(params) {
// return request({
// method: "post",
// url: "/video/handel/like",
// data: params
// })
// }
// 取消点赞
export function ForLike(params) {
return request({
method: "post",
url: "/video/handel/removelike",
data: params
})
}
\ No newline at end of file
......@@ -286,6 +286,7 @@ import Sidebar from "@/components/sidebar.vue";
import MuiPlayer from "mui-player";
import 'mui-player/dist/mui-player.min.css'
import MuiPlayerDesktopPlugin from './mui-player-desktop-plugin.min'
import {ForLike} from "@/utils/option";
......@@ -395,6 +396,7 @@ export default {
likeCount: 1,
dislikeCount: 2,
}
],
},
{
......@@ -578,6 +580,36 @@ export default {
showContentDetail(id) {
this.videoComments.find(item => item.id == id).isShow = true
},
//点赞
// handleLike() {
// ForLike(videoID).then(res => {
// // 如果请求成功,打印响应数据
// console.log(res.data);
// // 显示一个成功的消息
// alert('点赞成功');
// })
// .catch(err => {
// // 如果请求失败,打印错误信息
// console.error(err);
// // 显示一个失败的消息
// alert('点赞失败');
// });
// },
//点赞
// removeLike() {
// deleteLike(likeID).then(res => {
// // 如果请求成功,打印响应数据
// console.log(res.data);
// // 显示一个成功的消息
// alert('点赞成功');
// })
// .catch(err => {
// // 如果请求失败,打印错误信息
// console.error(err);
// // 显示一个失败的消息
// alert('点赞失败');
// });
// },
test() {
// 上传pagenum pagesize 住品论id
......
......@@ -24,7 +24,8 @@ import org.springframework.context.annotation.Configuration;
"cn.tedu.youbiliprojectbackend.modules.user.history.dao.mapper",
"cn.tedu.youbiliprojectbackend.modules.recommend.mahoutCF.mapper",
"cn.tedu.youbiliprojectbackend.common.data.mapper",
"cn.tedu.youbiliprojectbackend.modules.user.account.dao.mapper"
"cn.tedu.youbiliprojectbackend.modules.user.account.dao.mapper",
"cn.tedu.youbiliprojectbackend.modules.social.like.dao.persist.mapper",
})
public class MybatisConfig {
}
......@@ -64,8 +64,10 @@ public class SecurityConfiguration {
// auth.requestMatchers("/alipay/notify");
auth.requestMatchers("/alipay/**").permitAll();
auth.requestMatchers("/orders/details/**").permitAll();
auth.requestMatchers("/video/handle/**").permitAll();
// auth.requestMatchers("/index.html").permitAll();
auth.anyRequest().authenticated();
});
/*来禁用跨站请求伪造防御*/
http.csrf(AbstractHttpConfigurer::disable);
......
......@@ -39,9 +39,9 @@ public class FavoriteController {
*/
@GetMapping("delete")
public RestBean<String> delete(@AuthenticationPrincipal CurrentPrincipal currentPrincipal,
Long favoriteID){
Long favoriteID,Long videoID){
log.debug("开始处理请求: deleteAll");
favoriteService.deleteById(favoriteID, currentPrincipal.getUserID());
favoriteService.deleteById(favoriteID, currentPrincipal.getUserID(),videoID);
return RestBean.success("删除成功!");
}
......@@ -65,10 +65,9 @@ public class FavoriteController {
* @return 返回
*/
@GetMapping("/add-favorite")
public RestBean<String> addFavorite(@AuthenticationPrincipal CurrentPrincipal currentPrincipal,Long videoID){
public RestBean<String> addFavorite(@AuthenticationPrincipal CurrentPrincipal currentPrincipal,Long videoID) {
log.debug("开始处理请求 add-favorite");
favoriteService.insterFavorite(currentPrincipal.getUserID(), videoID);
return RestBean.success("收藏成功");
}
}
package cn.tedu.youbiliprojectbackend.modules.user.favorite.dao.cache;
public interface FavoriteCacheRepoistory {
/**
* 保存
*/
void save();
}
package cn.tedu.youbiliprojectbackend.modules.user.favorite.dao.cache.impl;
import cn.tedu.youbiliprojectbackend.common.cacheUtils.count.video.pojo.VideoCount;
import cn.tedu.youbiliprojectbackend.common.consts.CountConsts;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.dao.cache.FavoriteCacheRepoistory;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.dao.persist.mapper.FavoriteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
@Repository
public class FavoriteCacheRepoistoryImpl implements FavoriteCacheRepoistory {
public class FavoriteCacheRepoistoryImpl implements FavoriteCacheRepoistory, CountConsts {
@Autowired
private FavoriteMapper favoriteMapper;
@Override
public void save() {
public void save() {}
}
}
package cn.tedu.youbiliprojectbackend.modules.user.favorite.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 取消收藏视频的计数
*/
@Data
public class FavoriteParam {
/**
* 用户ID
*/
private Long userID;
/**
* 视频ID
*/
private Long videoID;
/**
* 启用状态
*/
private Integer enable;
/**
* 收藏总数
*/
private Integer favoriteCount;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime gmtModified;
}
package cn.tedu.youbiliprojectbackend.modules.user.favorite.service;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.pojo.vo.FavoriteVO;
import java.util.List;
......@@ -21,7 +22,10 @@ public interface IFavoriteService {
* @param favoriteID
* @param userID
*/
void deleteById(Long favoriteID,Long userID);
void deleteById(Long favoriteID,Long userID,Long videoID);
void insterFavorite(Long userID,Long videoID);
}
......@@ -2,9 +2,12 @@ package cn.tedu.youbiliprojectbackend.modules.user.favorite.service.impl;
import cn.tedu.youbiliprojectbackend.common.ex.ServiceException;
import cn.tedu.youbiliprojectbackend.common.web.response.ServiceCode;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.dao.cache.FavoriteCacheRepoistory;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.dao.persist.repository.IFavoriteRepository;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.pojo.param.FavoriteParam;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.pojo.vo.FavoriteVO;
import cn.tedu.youbiliprojectbackend.modules.user.favorite.service.IFavoriteService;
import cn.tedu.youbiliprojectbackend.modules.video.videocount.dao.cache.VideoCountCacheRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -17,20 +20,22 @@ public class FavoriteService implements IFavoriteService {
@Autowired
IFavoriteRepository favoriteRepository;
@Autowired
private VideoCountCacheRepository videoCountCacheRepository;
@Override
public List<FavoriteVO> list(Long userID) {
List<FavoriteVO> list = null;
try{
try {
list = favoriteRepository.list(userID);
}catch (Throwable e){
} catch (Throwable e) {
e.printStackTrace();
}
if(list == null) {
throw new ServiceException(ServiceCode.ERROR_CONFLICT,"没有查询到响应结果");
if (list == null) {
throw new ServiceException(ServiceCode.ERROR_CONFLICT, "没有查询到响应结果");
}
return list;
......@@ -44,19 +49,21 @@ public class FavoriteService implements IFavoriteService {
* @param userID
*/
@Override
public void deleteById(Long favoriteID, Long userID) {
int i = favoriteRepository.deleteById(userID,favoriteID);
if( i == 0){
throw new ServiceException(ServiceCode.ERROR_CONFLICT,"信息错误!请以正确的形式输入信息");
public void deleteById(Long favoriteID, Long userID,Long videoID) {
int i = favoriteRepository.deleteById(userID, favoriteID);
if (i == 0) {
throw new ServiceException(ServiceCode.ERROR_CONFLICT, "信息错误!请以正确的形式输入信息");
}
videoCountCacheRepository.removeFavoriteCount(videoID);
}
@Override
public void insterFavorite(Long userID, Long videoID) {
int i = favoriteRepository.addFavorite(userID,videoID);
if( i != 1) {
throw new ServiceException(ServiceCode.ERROR_CONFLICT,"信息错误!请以正确的形式输入信息");
int i = favoriteRepository.addFavorite(userID, videoID);
if (i != 1) {
throw new ServiceException(ServiceCode.ERROR_CONFLICT, "信息错误!请以正确的形式输入信息");
}
videoCountCacheRepository.addFavoriteCount(videoID);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.tedu.youbiliprojectbackend.modules.social.like.dao.persist.mapper.LikeMapper">
<insert id="insert">
INSERT INTO likes(likeID,userID,videoID,likeDate,typeEnable,gmtCreate,gmtModified)
VALUES (#{likeID},#{userID},#{videoID},#{likeDate},#{typeEnable},#{gmtCreate},#{gmtModified})
</insert>
<delete id="delete">
DELETE likeID,userID,videoID,likeDate,typeEnable,gmtCreate,gmtModified
FROM youbili_v1.likes
WHERE likeID=#{likeID}
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册