newMaster
fjj 2024-01-21 19:02:04 +08:00
parent 72fbfd4649
commit 3702701c0d
5 changed files with 37 additions and 26 deletions

View File

@ -29,8 +29,8 @@ public class VideoController {
}
//购买健康讲堂视频
@PostMapping("/verify/v1/videoBuy")
public HealthR videoBuy(@RequestParam Integer videoId, @RequestParam Integer price){
videoService.videoBuy(videoId,price);
public HealthR videoBuy(@RequestHeader Integer userId,@RequestParam Integer videoId, @RequestParam Integer price){
videoService.videoBuy(userId,videoId,price);
return HealthR.ok();
}

View File

@ -29,12 +29,14 @@ public interface VideoMapper {
UserWalletEntity FindUserWallet(@Param("id") Integer id);
void updateUserWallet(@Param("newblance") int newblance, @Param("id") Integer id);
List<VideoCommentEntity> findVideoCommentList(@Param("videoId") Integer videoId);
void addVideoComment(@Param("userId") Integer userId, @Param("sessionId") String sessionId, @Param("videoId") Integer videoId, @Param("content") String content);
UserEntity FindByUserId(@Param("userId") Integer userId);
// UserWalletEntity FindById(@Param("userId") Integer userId);
}

View File

@ -16,10 +16,12 @@ public interface VideoService {
void addUserVideoCollection(Integer videoId,Integer userId);
void videoBuy(Integer videoId,Integer price);
// void videoBuy(Integer videoId,Integer price);
List<VideoCommentVo> findVideoCommentList(Integer videoId);
void addVideoComment(Integer userId, String sessionId, Integer videoId, String content);
void videoBuy(Integer userId, Integer videoId, Integer price);
}

View File

@ -34,23 +34,23 @@ public class VideoServiceImpl implements VideoService {
videoMapper.updateVideoCount(videoCount);
}
@Override
public void videoBuy(Integer videoId,Integer price) {
//获取用户id
String token = request.getHeader("token");
Integer userId = Integer.valueOf(JwtUtils.getUserId(token));
//查询用户信息
UserEntity user = videoMapper.FindById(userId);
//查询用户钱包
UserWalletEntity userWallet = videoMapper.FindUserWallet(user.getId());
//判断用户钱包是否足够
if (userWallet.getBalance() >= price) {
//更新用户钱包
int newblance = userWallet.getBalance() -price;
//更新用户钱包
videoMapper.updateUserWallet(newblance, userWallet.getId());
}
}
// @Override
// public void videoBuy(Integer videoId,Integer price) {
// //获取用户id
// String token = request.getHeader("token");
// Integer userId = Integer.valueOf(JwtUtils.getUserId(token));
// //查询用户信息
// UserEntity user = videoMapper.FindById(userId);
// //查询用户钱包
// UserWalletEntity userWallet = videoMapper.FindUserWallet(user.getId());
// //判断用户钱包是否足够
// if (userWallet.getBalance() >= price) {
// //更新用户钱包
// int newblance = userWallet.getBalance() -price;
// //更新用户钱包
// videoMapper.updateUserWallet(newblance, userWallet.getId());
// }
// }
@Override
public List<VideoCommentVo> findVideoCommentList(Integer videoId) {
@ -64,5 +64,13 @@ public class VideoServiceImpl implements VideoService {
videoMapper.addVideoComment(userId, sessionId, videoId, content);
}
@Override
public void videoBuy(Integer userId, Integer videoId, Integer price) {
//获取用户id
UserEntity user =videoMapper.FindByUserId(userId);
}
}

View File

@ -31,11 +31,6 @@
set collection_num=collection_num + 1
where id = #{id}
</update>
<update id="updateUserWallet">
update user_wallet
set blance==#{newblance}
where id=#{id}
</update>
<select id="findById" resultType="doctor.domain.entity.VideoEntity">
SELECT user_video_collection.*
@ -63,6 +58,10 @@
<select id="findVideoCommentList" resultType="doctor.domain.entity.VideoCommentEntity">
select * from video_comment where video_id=#{videoId}
</select>
<select id="FindByUserId" resultType="doctor.domain.entity.UserEntity">
select *
from user where user_id=#{userId}
</select>
</mapper>