From b1644608292b8422bf52ccb8de94583c5168faac Mon Sep 17 00:00:00 2001 From: ChenYan <3139166962@qq.com> Date: Sun, 19 Jan 2025 18:12:01 +0800 Subject: [PATCH] feat --- .../resource/MallProductLikeController.java | 68 --------------- .../service/MallProductLikeService.java | 22 ----- .../impl/MallProductLikeServiceImpl.java | 87 ------------------- 3 files changed, 177 deletions(-) delete mode 100644 mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java delete mode 100644 mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java delete mode 100644 mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java deleted file mode 100644 index a769e65..0000000 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.mcwl.web.controller.resource; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.mcwl.common.annotation.RepeatSubmit; -import com.mcwl.common.core.domain.AjaxResult; -import com.mcwl.resource.domain.ModelProduct; -import com.mcwl.resource.domain.vo.MallProductVo; -import com.mcwl.resource.service.MallProductLikeService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -/** - * 点赞商品 - * @author DaiZibo - * @date 2025/1/2 - * @apiNote - */ -@Api(tags = "点赞商品") -@RequestMapping("/like") -@RestController -public class MallProductLikeController { - - @Autowired - private MallProductLikeService mallProductLikeService; - - /** - * 查询用户点赞作品列表 - * @param mallProductVo - * @return - */ - @ApiOperation(value = "查询用户点赞作品列表") - @PostMapping("/selectByUserLike") - public AjaxResult selectByUserLike(@RequestBody MallProductVo mallProductVo){ - - Page mallProductPage = mallProductLikeService.selectByUserLike(mallProductVo); - return AjaxResult.success(mallProductPage); - } - - /** - * 添加/删除点赞商品 - * @param productId - * @return - */ - @ApiOperation(value = "添加/删除点赞商品") - @RepeatSubmit - @GetMapping("/addLike") - public AjaxResult addLike(@RequestParam Long productId){ - - return mallProductLikeService.addLike(productId); - } - - /** - * 查看作品是否点赞 - * @param productId - * @return - */ - @ApiOperation(value = "查看作品是否点赞") - @GetMapping("/selectLike") - public AjaxResult selectLike(@RequestParam Long productId){ - Boolean aBoolean = mallProductLikeService.selectLike(productId); - return AjaxResult.success(aBoolean); - } - - - -} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java deleted file mode 100644 index 4ef48cb..0000000 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/MallProductLikeService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mcwl.resource.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.mcwl.common.core.domain.AjaxResult; -import com.mcwl.resource.domain.ModelProduct; -import com.mcwl.resource.domain.vo.MallProductVo; - -/** - * @author DaiZibo - * @date 2025/1/2 - * @apiNote - */ - -public interface MallProductLikeService { - Page selectByUserLike(MallProductVo mallProductVo); - - AjaxResult addLike(Long productId); - - AjaxResult deleteLike(Long productId); - - Boolean selectLike(Long productId); -} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java deleted file mode 100644 index cae9fd4..0000000 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/MallProductLikeServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.mcwl.resource.service.impl; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.mcwl.common.core.domain.AjaxResult; -import com.mcwl.common.utils.SecurityUtils; -import com.mcwl.resource.domain.MallProductLike; -import com.mcwl.resource.domain.ModelProduct; -import com.mcwl.resource.domain.vo.MallProductVo; -import com.mcwl.resource.mapper.MallProductLikeMapper; -import com.mcwl.resource.service.MallProductLikeService; -import com.mcwl.resource.service.ModelService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * @author DaiZibo - * @date 2025/1/2 - * @apiNote - */ - -@Service -public class MallProductLikeServiceImpl implements MallProductLikeService { - - @Autowired - private MallProductLikeMapper mallProductLikeMapper; - - @Autowired - private ModelService mallProductService; - - @Override - public Page selectByUserLike(MallProductVo mallProductVo) { - - //获取登录人 - Long userId = SecurityUtils.getUserId(); - List list = mallProductLikeMapper.selectByUserId(userId); - //分页查询作品数据 - return mallProductService.pageLike(mallProductVo, list); - } - - @Override - public AjaxResult addLike(Long productId) { - - Boolean aBoolean = selectLike(productId); - if (aBoolean == true){ - //删除点赞记录 - mallProductLikeMapper.deleteByUserIdAndProductId(productId,SecurityUtils.getUserId()); - return AjaxResult.success(false); - } - - MallProductLike mallProductLike = MallProductLike.builder().productId(productId) - .userId(SecurityUtils.getUserId()) - .createName(SecurityUtils.getUsername()) - .createTime(new Date()).build(); - - int insert = mallProductLikeMapper.insert(mallProductLike); - - if (insert<0){ - - return AjaxResult.error("点赞失败",false); - } - return AjaxResult.success(true); - } - - @Override - public AjaxResult deleteLike(Long productId) { - - return AjaxResult.success(); - } - - @Override - public Boolean selectLike(Long productId) { - - MallProductLike mallProductLike1 = mallProductLikeMapper.selectByUserIdAndProductId(SecurityUtils.getUserId(),productId); - - if (mallProductLike1 == null){ - - return false; - } - return true; - } - - - -}