mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-01 11:54:07 +08:00
1. 会员用户,增加 point 积分字段
2. 增加获得优惠劵、收藏数量的 API 接口
This commit is contained in:
@@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
@@ -84,8 +83,15 @@ public class AppFavoriteController {
|
||||
@Operation(summary = "检查是否收藏过商品")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> isFavoriteExists(AppFavoriteReqVO reqVO) {
|
||||
ProductFavoriteDO favoriteDO = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
|
||||
return success(Objects.nonNull(favoriteDO));
|
||||
ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
|
||||
return success(favorite != null);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-count")
|
||||
@Operation(summary = "获得商品收藏数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> getFavoriteCount() {
|
||||
return success(productFavoriteService.getFavoriteCount(getLoginUserId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,4 +21,8 @@ public interface ProductFavoriteMapper extends BaseMapperX<ProductFavoriteDO> {
|
||||
.orderByDesc(ProductFavoriteDO::getId));
|
||||
}
|
||||
|
||||
default Long selectCountByUserId(Long userId) {
|
||||
return selectCount(ProductFavoriteDO::getUserId, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 创建商品收藏
|
||||
*
|
||||
* @param userId 用户 id
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
*/
|
||||
Long createFavorite(Long userId, Long spuId);
|
||||
@@ -24,7 +24,7 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 取消商品收藏
|
||||
*
|
||||
* @param userId 用户 id
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
*/
|
||||
void deleteFavorite(Long userId, Long spuId);
|
||||
@@ -32,7 +32,7 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 分页查询用户收藏列表
|
||||
*
|
||||
* @param userId 用户 id
|
||||
* @param userId 用户编号
|
||||
* @param reqVO 请求 vo
|
||||
*/
|
||||
PageResult<ProductFavoriteDO> getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO);
|
||||
@@ -40,9 +40,17 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 获取收藏过商品
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
*/
|
||||
ProductFavoriteDO getFavorite(Long userId, Long spuId);
|
||||
|
||||
/**
|
||||
* 获取用户收藏数量
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 数量
|
||||
*/
|
||||
Long getFavoriteCount(Long userId);
|
||||
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_EXISTS;
|
||||
@@ -31,7 +30,7 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
||||
@Override
|
||||
public Long createFavorite(Long userId, Long spuId) {
|
||||
ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
if (Objects.nonNull(favorite)) {
|
||||
if (favorite != null) {
|
||||
throw exception(FAVORITE_EXISTS);
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
||||
@Override
|
||||
public void deleteFavorite(Long userId, Long spuId) {
|
||||
ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
if (Objects.isNull(favorite)) {
|
||||
if (favorite == null) {
|
||||
throw exception(FAVORITE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@@ -60,4 +59,9 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
||||
return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFavoriteCount(Long userId) {
|
||||
return productFavoriteMapper.selectCountByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user